Posted 19 years ago
by Duncan Woods

Hi,
I am using the highlighter to display log messages. It is proving useful to allow custom higlighting of different message severity and contents.
Could you please advise me on ways to ensure maximum performance since 1000s of messages can be regularly added.
For the actual actipro control traceText, I am calling the following to add x lines every 500ms. The text is halved when it reaches 5000 lines or so to keep memory usage under control:The default higlighting config looks like the following:
Thanks,
Duncan
I am using the highlighter to display log messages. It is proving useful to allow custom higlighting of different message severity and contents.
Could you please advise me on ways to ensure maximum performance since 1000s of messages can be regularly added.
For the actual actipro control traceText, I am calling the following to add x lines every 500ms. The text is halved when it reaches 5000 lines or so to keep memory usage under control:
if (traceText.Document.Lines.Count > maxLines)
{
traceText.Document.Text = traceText.Document.Text.Substring(traceText.Document.Text.Length / 2);
}
traceText.Document.AppendText(s.ToString());
traceText.SelectedView.GoToLine(traceText.Document.Lines.Count - 1);
traceText.Document.UndoRedo.Clear();
<SyntaxLanguage Key="XML" LanguageDefinitionVersion="3.0" Secure="True" xmlns="http://ActiproSoftware/SyntaxEditor/3.0/LanguageDefinition">
<!-- String Properties -->
<Properties>
<Property Key="Creator" Value="Duncan Woods GH" />
<Property Key="Copyright" Value="Copyright (c) Garrad Hassan. All rights reserved." />
</Properties>
<!-- Highlighting Styles -->
<Styles>
<Style Key="ERROR" ForeColor="Red" BackColor="Default" Bold="True" Italic="False" Underline="False" />
<Style Key="WARN" ForeColor="Orange" BackColor="Default" Bold="True" Italic="False" Underline="False" />
<Style Key="INFO" ForeColor="Black" BackColor="Default" Bold="True" Italic="False" Underline="False" />
<Style Key="DEBUG" ForeColor="Gray" BackColor="Default" Bold="True" Italic="False" Underline="False" />
<Style Key="Logger" ForeColor="Blue" BackColor="Default" Bold="False" Italic="False" Underline="False" />
<Style Key="Tag" ForeColor="Blue" BackColor="Default" Bold="False" Italic="False" Underline="False" />
</Styles>
<!-- Macros -->
<Macros>
<!-- Redefine word macros to include hyphens -->
<Macro Key="LoggerMacro" Value="[^:]" />
</Macros>
<!-- States -->
<States>
<State Key="DefaultState">
<!-- Patterns Groups -->
<PatternGroups>
<!-- Whitespace -->
<RegexPatternGroup TokenKey="WhitespaceToken" PatternValue="{WhitespaceMacro}+" IsWhitespace="True" />
<!-- Brackets -->
<ExplicitPatternGroup Key="OpenParenthesisPatternGroup" TokenKey="OpenParenthesisToken" Style="Logger" PatternValue="[" EndBracket="CloseParenthesisPatternGroup" />
<ExplicitPatternGroup Key="CloseParenthesisPatternGroup" TokenKey="CloseParenthesisToken" Style="Logger" PatternValue="]" StartBracket="OpenParenthesisPatternGroup" />
<ExplicitPatternGroup TokenKey="ERROR" Style="ERROR" LookAhead="{NonWordMacro}">
<ExplicitPatterns>ERROR</ExplicitPatterns>
</ExplicitPatternGroup>
<ExplicitPatternGroup TokenKey="WARN" Style="WARN" LookAhead="{NonWordMacro}">
<ExplicitPatterns>WARN</ExplicitPatterns>
</ExplicitPatternGroup>
<ExplicitPatternGroup TokenKey="INFO" Style="INFO" LookAhead="{NonWordMacro}">
<ExplicitPatterns>INFO</ExplicitPatterns>
</ExplicitPatternGroup>
<ExplicitPatternGroup TokenKey="DEBUG" Style="DEBUG" LookAhead="{NonWordMacro}">
<ExplicitPatterns>DEBUG</ExplicitPatterns>
</ExplicitPatternGroup>
</PatternGroups>
<ChildStates>
<ChildState Key="StartTagState" />
</ChildStates>
</State>
<!-- Start Tags -->
<State Key="StartTagState" TokenKey="StartTagDefaultToken" Style="Tag">
<!-- Scopes -->
<Scopes>
<Scope>
<ExplicitPatternGroup Type="StartScope" TokenKey="StartTagStartToken" Style="Tag" PatternValue="[" />
<ExplicitPatternGroup Type="EndScope" TokenKey="StartTagStartToken" Style="Tag" PatternValue="]" />
</Scope>
</Scopes>
</State>
</States>
</SyntaxLanguage>
Duncan