[fpc-pascal]OT: Syntax Highlighting

James_Wilson at i2.com James_Wilson at i2.com
Thu Nov 8 14:28:44 CET 2001

Sorry for the off topic...

I have a text-mode file viewer that I wrote for Win32 and Go32. I'm trying 
 to add a new feature; syntax highlighting. I think it would be fairly 
unique to have a viewer that understands a languages syntax (I know any 
editor of even reasonable power has done this for years -- which I find to 
be totally indispensable now -- but I thought I could derive a similar 
benefit from a viewer that had the same ability).

Every implementation that I've coded thus far has either had some type of 
rendering problem and/or been horribly slow. The one I thought would have 
the most promise was loading a bunch of keywords in memory and then 
scanning each line of the display everytime a movement command 
(pgup/pgdn/arrows etc) was issued for words that matched the ones loaded 
in memory. But unfortunately pos() has proven to be way too slow for this, 
seeing as how the list of potential words to be highlighted could be a few 
hundred, so when I run the program on anything less then a screaming-fast 
PC it redraws the screen terribly slow and uneven. Sigh...

I've looked at shedit in the FCL, but I'm afraid I don't understand 
objects enough to be able to make much sense of the syntax highlighting 
code in their. So, my question is this; does anyone know of another method 
for syntax highlighting other then using pos() on each line? Is there a 
way to make pos() faster? Is there something better then pos() to check if 
a string resides within another string?

Any concepts on how to do this --  or even better, some example code -- 
would be greatly appreciated. TIA...

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20011108/62db51d7/attachment.html>

More information about the fpc-pascal mailing list