syntax coloring

zerorex

Registered
Hello,
Ive been working on a text editor, and have finally been able too get 90% of what I want, the problem i have now, is the method by which i am applying my syntax coloring. It works, but is applyed by a loop. As the document being colored gets longer, the longer the loop takes to complete. At this point, it gets intollerable at around 300 lines, which is a problem.

If anyone has any advice, or suggestions, i would be much abliged.

Z
 
how about get it to listen to a keystroke event in the textarea. and if the series of keystroke events match a pattern, colour it!

or something like that...
 
You should probably just check the word you have just typed. Check the previous word when the user types a space, tab etc. or when the user wants to leave the editpoint with a mouse click.
 
Don't waste time checking text that has not changed... As gumse suggested, only check the word that has just been typed or any word that has been modified by something that was just typed.
 
I was actually able to minimze the slow down by only treating the 1000 characters around the edit point. I did some reading, and this seemed to be a common method. Right now, Im looking at the possiblity of handeling the coloring in a slightly different fation, and or placing the coloring in a seperate thread as wiz suggested.

thanks for the suggestions..

Z
 
just look on www.gnustep.org .... and download the projectbuilder for gnustep...it is gpl.... the syntax highlighting there is pretty good ..... you will just need to make somes little modification to have it on your text editor
 
Back
Top