Hi, I have a question about highlighting.
I'm using a SyntaxEditor control to write log messages in the following example format:
error: File not found 'gunship.asd'
debug: Loading module '/lua/levels/currentlevel.lua'
info: Loaded file: ui/energy_icon.asd
-size: 23425 bytes
-scope: local
info: Initialization time: 0.84 seconds.
(Individual messages may span multiple lines).
The goal is to have each message (including prefix) be a different highlight. For example error messages are read, debug messages are blue, etc.
I have already achieved this in the following way.However, I have recently received feedback from my users saying that the prefixes (error:, warning:, etc) being written over and over are annoying, and that they already know what type of message it is based on the color.
My question is, is there a way I could remove these prefixes from being shown, and still maintain color-codedness across the different message types?
Any help would be appreciated.
Thanks! :)
I'm using a SyntaxEditor control to write log messages in the following example format:
error: File not found 'gunship.asd'
debug: Loading module '/lua/levels/currentlevel.lua'
info: Loaded file: ui/energy_icon.asd
-size: 23425 bytes
-scope: local
info: Initialization time: 0.84 seconds.
(Individual messages may span multiple lines).
The goal is to have each message (including prefix) be a different highlight. For example error messages are read, debug messages are blue, etc.
I have already achieved this in the following way.
// Construct a sample language that shows many highlighting style features
DynamicSyntaxLanguage language = new DynamicSyntaxLanguage("Sample", false);
language.IsUpdating = true;
string[] prefixes = new string[] { "Debug", "Info", "Warning", "Error" };
Dictionary<string, Color> colors = new Dictionary<string, Color>();
colors["Debug"] = Color.Turquoise;
colors["Info"] = Color.SaddleBrown;
colors["Warning"] = Color.Salmon;
colors["Error"] = Color.Olive;
string allPrefixes = "Debug:|Info:|Warning:|Error:";
foreach (string prefix in prefixes)
{
HighlightingStyle contentStyle = new HighlightingStyle(prefix + "StyleC", null, colors[prefix], Color.Empty, DefaultableBoolean.False, DefaultableBoolean.Default, HighlightingStyleLineStyle.Default);
HighlightingStyle titleStyle = new HighlightingStyle(prefix + "StyleT", null, colors[prefix], Color.Empty, DefaultableBoolean.True, DefaultableBoolean.Default, HighlightingStyleLineStyle.Default);
language.HighlightingStyles.Add(contentStyle);
language.HighlightingStyles.Add(titleStyle);
// Create an message state
DynamicLexicalState messageState = new DynamicLexicalState(0, prefix + "MessageState");
messageState.DefaultTokenKey = prefix + "MessageDefaultToken";
messageState.DefaultHighlightingStyle = contentStyle;
language.LexicalStates.Add(messageState);
language.DefaultLexicalState.ChildLexicalStates.Add(messageState);
DynamicLexicalScope lexicalScope = new DynamicLexicalScope();
lexicalScope.StartLexicalPatternGroup = new LexicalPatternGroup(LexicalPatternType.Regex, prefix + "MessageStartToken", titleStyle, string.Format("^{0}:", prefix));
lexicalScope.EndLexicalPatternGroup = new LexicalPatternGroup(LexicalPatternType.Regex, prefix + "MessageEndToken", titleStyle, @"{LineTerminatorMacro}", allPrefixes);
messageState.LexicalScopes.Add(lexicalScope);
}
language.IsUpdating = false;
this.syntaxEditor1.Document.Language = language;
My question is, is there a way I could remove these prefixes from being shown, and still maintain color-codedness across the different message types?
Any help would be appreciated.
Thanks! :)