Dynamically load symbols into syntax highlighter

rhkramer at gmail.com rhkramer at gmail.com
Wed May 22 16:09:03 BST 2019


On Wednesday, May 22, 2019 10:30:11 AM Bradley Dufresne wrote:
> Hello.  I have a kTextEditor integrated into my application.  I would like
> to support syntax highlighting with the standard highlighting files, but
> additionally I would like to dynamically introduce my own symbols to be
> highlighted as well.  Does anyone know if there is public interface
> available on kTextEditor to do this (I haven't been able to find one in
> the documentation or source)?  If that's not built-in functionality, is
> there public interface to access a QTextDocument or similar in order to
> additionally apply my own QSyntaxHighlight?

I may be premature in suggesting this (I mean, someone else may have a better 
answer), but I'm wondering how dynamic you want these to be, or, to elaborate, 
is there any chance they could all be recognized by a regular expression?

The highlighting (and folding) in kwrite / kate is controlled by .xml (iirc), 
which people have written for various languages / purposes.

If you have a standard file that you highlight, presumably there is a .xml file 
which controls that highlighting, which you could consider modifying.

Presumably, you could also modify that .xml with the actual symbols (i.e., 
without a regular expression to recognize them), but I don't remember if I had 
to re-open kate after each attempt that I made to get a working .xml file (back 
in the day).  If so, I suspect it would be rather inconvenient to reload 
kwrite each time you modified the appropriate .xml file to dynamically add a 
symbol.

Aside: It is nice to see a user question on this list -- most of the time all 
I see are developers posting messages, and even if a user posts a message, I 
rarely see a response.

Good luck!



More information about the KWrite-Devel mailing list