Hi there,

I am working on a small project (mainly just because I am bored of playing Serious Sam 2 and RTCW all the day :grin: ) in which I need some Syntax Highlighting.

I looked at ICZ's Tut 35 (Syntax Highlighting <- Who would have thought? ) and my problem is that I don't really know, how to adapt this function into my program.

In ICZ's case he looks for the first letter, if this letter exists in his ARRAY he checks the whole word and the length, so he knows, what how to highlight.

My stuff is slightly different. In my text there are not complete words I want to highlight, but phrases starting and ending with some specific code (similar to HTML for example <TAG>.....</TAG>).
So how would I go and highlight from the beginning of the TAG until to the end? Should I just throw the beginnigs in one array, the endings in another and after finding a location where this TAG occurs, just keep highlight enabled until I reach the TAG a second time?

Any other suggestions?

YaWNS aka Stefan K.
Posted on 2002-03-08 15:40:49 by YaWNS
Use a stack:

each time you find a start TAG push tag code and position of tag in file/text buffer on stack, when you find the end TAG pop the code (check for same and emit error or take action if different) then if all OK pop the position in file and highilite from THERE until HERE ...

neddles to say that you do that only for the curent text displayed on screen +/- some extra buffer
Posted on 2002-03-08 17:46:34 by BogdanOntanu

never thought of this solution. Let me recall what you say (just in case I missed smth.):

I adapt the highlight routines (esp. the search part) and make it, so that, after finding a TAG, I get its position and save the TAG and the POSITION into buffer, after finding the CLOSING TAG I get its position as well and save the positions into a temporary file (I assume it should be temporary only, since highlighting text changes when reading other files or when file has become updated) and then I do highlighting between these two positions? Sounds somehow complicated but like some chance for experiences :grin:

I will try that next week.

Thanks Bogdan.
Greets YaWNS aka Stefan K.
Posted on 2002-03-09 04:22:18 by YaWNS