Forum > SynEdit
Highlighter for SynEdit
paulee32:
Hello,
for TSynEdit, I would like to implement a custom Highlighter, but I fail.
I have compile the helper tool SynGen, that output, I have modified a little bit:
I would like highlight comments, and block of:
@mainpage and
@end
The strings in TSynEdit dont be colored. when the @ sign is moved, then they will be colored.
So, How can I use @mainpage ?
here is the grammar.msg file:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TSynHelpNdocSyntkIdentStart '@','_', 'a'..'z', 'A'..'Z':: '_', '0'..'9', 'a'..'z', 'A'..'Z':: TOKENTYPESIdentifierComment Style=[fsItalic]|Foreground=clGreenKey Style=[]|Foreground=clBlue |><| KEYS'@mainpage''@end' |><| CHARS'A'..'Z', 'a'..'z', '_':: Ident BeginProc fTokenID := IdentKind((fLine + Run)); inc(Run, fStringLen);EndProc|><| ENCLOSEDBYComment,CStyleComment,/*,*/,MultiLine|><|
Edson:
Hi.
I haven't hear about "SynGen". Maybe it's only for Delphi Synedit. :-\
Lazarus SynEdit is incompatible with Delphi SynEdit since a long time ago.
I recommend to use SynFacilSyn for Lazarus SynEdit: https://github.com/t-edson/SynFacilSyn . It has a detailed documentation.
Moreover if you want to add completion code, you can use SynFacilCompletion: https://github.com/t-edson/SynFacilCompletion. It's 100% compatible with SynFacilSyn.
paulee32:
Hello,
I search the Internet via Google, and found a hint, to use SynGeneralHighlighter.
This component is indeed under the Palette of SynEdit's Highlighters.
I can put keywords into a StringList, and I have the possibility, to set the FG/BG color of the keywords.
But the Problem is, that the Sign "@" will not be recognize.
So, the keyword "@mainpage" will not be parsed or colored.
Only "mainpage" as keyword is accepted.
Has someone an Idea, how to use the @ with keyword(s) ?
Martin_fr:
There is a tutorial: https://wiki.lazarus.freepascal.org/SynEdit_Highlighter
paulee32:
Thank You @all,
I get it done.
The simplest thing was to rename the classname of TSynGeneral to my highlighter,
and do little bit modifications.
Here a picture:
https://imgur.com/Yrtv5Ks
Navigation
[0] Message Index
[#] Next page