Recent

Author Topic: External information to highlighter?  (Read 4505 times)

Borneq

  • Full Member
  • ***
  • Posts: 248
External information to highlighter?
« on: December 21, 2019, 11:12:22 pm »
Is possible in any way send external information (for example by event) to highlighter? In C/C++ for example is highlighted to pale region between #ifdef X #endif if not defined X. Also compiler knows but not highlighter if variable is defined.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9864
  • Debugger - SynEdit - and more
    • wiki
Re: External information to highlighter?
« Reply #1 on: December 22, 2019, 01:55:16 am »
Is possible in any way send external information (for example by event) to highlighter?
Depends. In principle: Yes, if the highlighter accepts the info.
- As for the highlighters shipped with Lazarus, none of them does. So for them: No,
- If you write your own HL: Yes
You can even inherit an existing HL, and add such a feature.

Quote
In C/C++ for example is highlighted to pale region between #ifdef X #endif if not defined X. Also compiler knows but not highlighter if variable is defined.

The IDE also high/low-lights ifdef blocks in Pascal. So that is possible.

In the IDE codetool provides the info, and sends it to TSynEditMarkupIfDef (unit SynEditMarkupIfDef). This is only for Pascal code though (and IIRC relies on the PascalHighlighter being used for the file)
"ide\sourcesyneditor.pas" shows how to add it to SynEdit.




SynEdit has a 2 step concept for the Highlight.

First the highlighter is ask to provide the main color info. This is usually according to the content of the file (pascal code, xml, ...)
There can only been one Highlighter per file (well there is SynHighlighterMulti, that allows to split the file, and have a sub-HL for each section)

Then there is Markup.
There is no limit to the amount of Markup modules.
Usually Markup handles dynamic highlight.
Markup acts as an overlay. It can replace or alpha-blend the color from the HL.

However in the end there is no enforcement what goes to HL and what to Markup.

https://forum.lazarus.freepascal.org/index.php/topic,47778.msg342734.html#msg342734

-----------------------
I started https://wiki.lazarus.freepascal.org/SynEdit_Markup
You can study the sources if you like and ask questions to what the sources do.


 

TinyPortal © 2005-2018