View previous topic :: View next topic |
Author |
Message |
tranglos
Joined: 12 Dec 2007 Posts: 12 Location: Poland
|
Posted: Wed Jan 14, 2009 11:50 pm Post subject: Creating user ranges/styles and gutter objects in code |
|
|
I'm trying to use the SyntaxMemo to display a list of log messages. This needs the following functionality:
1. Creating a new range on the fly (in code) for each added line, and assigning a user style to it.
2. Displaying an image in the gutter for each added line to indicate log message severity.
I've seen the demos included with the distribution, but they only showcase setting up these features in the designer. Do you perhaps have any demos that show how to do the above dynamically in code?
Thanks a lot,
Marek (registered user) |
|
Back to top |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
Posted: Wed Jan 28, 2009 7:59 am Post subject: |
|
|
Hello,
1. You may use UserRanges collection. But I suggest to write lexer which will colorize text automatically. For this purpose you may add control char sequence which will identify line type. This control char sequence may be hidden.
2. Use OnGetGutterImage event. For example:
Code: | procedure TFmLogViewer.SyntaxMemo1GetGutterImage(Sender: TObject;
const Line: Integer; List: TList);
var g: TGutterObject;
begin
g := TGutterObject.CreateObj(Line, integer(SyntaxMemo1.Lines.Objects[Line]));
g.Band := 0;
List.Add(g);
end; |
All gutter objects added to List will be destroyed by the Syntax Memo. In gutter object you may define also line colors (fore-, background colors).
Michael. |
|
Back to top |
|
|
|