Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd Custom Color Definitions to Output Window in Visual Studio Extension
    text
    copied!<p>It's fairly easy to add a custom color definition to the "Text Editor" category of the Fonts and Colors Dialog using an extension. One usually just defines and exports a new classification type and editor definition and decorates it with a UserVisible(true) attribute. Here's an example.</p> <pre><code>public static class OutputClassificationDefinitions { [Export] [Name("SomeName")] public static readonly ClassificationTypeDefinition BuildHeaderDefinition; [Name("SomeName")] [UserVisible(true)] [Export(typeof(EditorFormatDefinition))] [ClassificationType(ClassificationTypeNames = "SomeName")] public sealed class BuildHeaderFormat : ClassificationFormatDefinition { public BuildHeaderFormat() { ForegroundColor = Properties.Settings.Default.BuildHeaderForerground; BackgroundColor = Properties.Settings.Default.BuildHeaderBackground; } } </code></pre> <p>"SomeName" shows up in the F&amp;C dialog under the "Text Editor" category. If the user changes the color of "SomeName" it's remembered and the editor's format map is updated to use the new color.</p> <p>I want to do a similar thing for the output window. You can write a classifier for the output window and it works just fine. I got the idea form another post here on StackOverflow and it works brilliantly.</p> <p>However, the new color definitions show up in the "Text Editor" category and not the Output Window category, which would be preferred. More annoying is that the user color changes do not update the Output Window's formatMap, meaning the new colors do not take affect.</p> <p>I've tried updating the formatMap myself as follows:</p> <pre><code>[Import] internal IClassificationFormatMapService ClassificationFormatMapService; var formatMap = ClassificationFormatMapService.GetClassificationFormatMap(FontsAndColorsCategory.Outputwindow); var type = ClassificationRegistry.GetClassificationType("SomeName"); formatMap.AddExplicitTextProperties(type, formatMap.GetExplicitTextProperties(type)); </code></pre> <p>This doesn't work. No exceptions or errors are raised, just doesn't do anything.</p> <p>Is there anyway to add my custom definitions to the "Output Window" category of the F&amp;C dialog and, more importantly, have the changes update the Output Window?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload