user defined markup and token type (string/comment) lazarus / 9-Editor ---------------------------------------------------------------------- Martin_fr · 2015-04-08 11:22 Follow up to http://forum.lazarus.freepascal.org/index.php/topic,27985 .msg173857.html#msg173857 Quote from: Artie on April 08, 2015, 12:46:36 pmQuote from: Martin_fr on April 08, 2015, 12:15:48 pmYes you are right, I did not check before I posted. The base colors do not have a priority. You can add a feature request, but it will be awhile before I get to it. It doesn't have to be a feature request. The syntax highlighting engine would only need to switch into string mode once it encounters an opening quote (as it does for the color), disabling any keyword checking until the closing quote. Well even this kind of "disabling" would need to bi implemented. So it is a feature request. But it is not at all that easy. The markup, and the highlight are done in 2 independent modules. That is because the markup works with any highlighter, and even without highlighter. The markup would need to enquire with the highlighter (if any highlighter is used), what token type is present at a certain location. Strings can start with different chars in different languages. In some languages string may be multi line) And (example for pascal) this would include handling search terms like Code: [Select]:= 'abcwhich are part string (so it is not enough to check at the begin of the token) In the IDE the search engine does not provide reg ex for this, but some of the related classes can be used with reg-ex. So matching part string would not always be that obvious. It also needs to detect, if text changes between string, and none string (multiline string / change of hl). Or (in pascal) with comments, that could be at any line in the text (string becomes comment and vice versa), since there are multi line comments. The fact that strings can change over many lines, of which only the first was edited, means that the current concept of finding the correct range to rescan for matches must be changed too. IIRC Currently only edited lines are re-searched (if they are visible on the screen) All in all, it is not a simple as it sounds. I would probably first work on providing this via priorities (not hand to do, but I still need to find the time, there are other things I want to finish first). Priorities will solve many cases. Priorities do not have the issues with what needs to be searched. The found results do not change. priorities simply decide, at the time of actual painting the text to the canvas, if a color is applied or not. Adding dedicated search in/outside string options would probably be much later. ---------------------------------------------------------------------- munair · 2015-04-08 11:45 OK, I understand. Thanks for your explanation Martin. ---------------------------------------------------------------------- Martin_fr · 2015-04-08 11:50 I suggest you make she change to the highlighter Quote from: Martin_fr on April 08, 2015, 12:26:03 pmTry in components\synedit\synhighlighterpas.pp line 2345 Code: [Select]  fStringAttri := TSynHighlighterAttributesModifier.Create(@SYNS_AttrString, SYNS_XML_AttrString); instead of TSynHighlighterAttributes.Create And the same for comments. Then you can set their priority. User defined colors also have a priority (edit on the user defined page). That will get you immediately what you need. When I have time, I probably merge the 2 classes (assuming all checks pass / e.g. need to check, if alpha works in that case). ---------------------------------------------------------------------- munair · 2015-04-08 12:33 Still doesn't work. But it is only an annoyance not worth all the effort right now. I tested 1.4RC2 extensively while porting a realstudio project to freepascal. It worked great. Now I test 1.4RC3... ---------------------------------------------------------------------- Martin_fr · 2015-04-08 12:56 It did work for me when I tested. What exactly do you highlight? Though it can only do color. Underline and italics do have prioritise, but they are not available in the IDE options dialog. I have highlights for "debugln" and "assert" (font color) The user defined font color has a priority of 3500 (afaik default) Assuming that string does have a color assigned for its font/foreground color, if I set the string font color priority to 3501, then that worked. ---------------------------------------------------------------------- munair · 2015-04-08 15:20 I still do not get priority settings next to the colour settings when I select string or comment. In synhighlighterpas.pp fIDEDirectiveAttri and fCaseLabelAttri are also instantiated from Attribu]"]>Blockeddifier.Create but both can only change alpha settings in IDE Options (with AND without a selected foreground colour). ---------------------------------------------------------------------- Martin_fr · 2015-04-08 15:30 After I replaced, and recompiled. IF you mark your string with say a background color, then you must set the foreground color to the same value as default text, and set the checkbox. If the checkbox is not set. then the priority is not listed. If you want do keep he backcolor, then you must set the backcolors checkbox (and ensure priority is less than selection) The image is, before I increased the priority ---------------------------------------------------------------------- munair · 2015-04-08 18:26 Thanks Martin, yes I got it working. I only need to uncheck BOLD for custom words (and consequently for reserved words), otherwise they would still raise to bold in string texts. But you mentioned this before, so this was to be expected. Thanks again! ---------------------------------------------------------------------- munair · 2016-11-11 10:32 With version 1.6 this hack no longer seems to work. I changed synhighlighterpas.pp as suggested: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i // fCommentAttri := TSynHighlighterAttributes.Create(@SYNS_AttrComment, SYNS_XML_AttrComment);fCommentAttri := TSynHighlighterAttributesModifier.Create(@SYNS_AttrComment, SYNS_XML_AttrComment);fCommentAttri.Style:= [fsItalic];AddAttribute(fCommentAttri);FCurCommentAttri := TSynSelectedColorMergeResult.Create(@SYNS_AttrComment, SYNS_XML_AttrComment);Did the same for fStringAttri. I recompiled the IDE with and without the FCur<>Attri line but it makes no difference. With the foreground color selected alpha and priority settings do not show up. Is there another hack I should be aware of?