Re: on-the-fly syntax highlighter

From: Date: Sun, 12 Jan 2003 20:28:32 +0000
Subject: Re: on-the-fly syntax highlighter
References: 1 2 3 4  Groups: php.doc.chm 
Request: Send a blank email to php-doc-chm+get-604@lists.php.net to get a copy of this message
"Gabor Hojtsy" <gabor@hojtsy.hu> wrote in message news:005f01c2ba58$713fcc10$34db4d3e@emergency... > > echo "$key = $val\n"; > > > > In the current php syntax highlighter that is in chm file, the $key would > > not be blue, however in echo statements a lot of things are colored other > > colors. (check it out.. open your chm file and take a look) > > > > It would be very possible to make this happen but not without a noticeable > > drop in rendering time. The syntax highlighter works by finding a start > and > > end point of strings, and then highlighting them. Because just about > > anything can come after a var, e.g. <>!@#$%^&*()-=+;'[]\:"{}|?, one search > > would have to take place for each of these characters. That is a lot of > > searches! > > Maybe another search to find the endpoint with specifying what is valid > before the endpoint. It is quite easier to specify what is a valid > varname char... If we were to implement a feature like the colored vars, this would probably be the way I would do it. However it would require a new function and would still incur medium rendering time. I personally don't think the rendering time it would take to accomplish the task of highlighting vars is worth it. > > BTW have you looked at JS regular expression support? It may also help > in such cases (and maybe in others too) to speed up the parsing. I used a method to search a text range. if I were to use regular expressions, I would have to copy the text range into a string and search over it. from there I would have to remember the position of the "hit" and jump to that position in the text range before I could color it.... I think searching the text range would be much faster. I used regular expressions at one point to find a string of characters but I found a faster way to do the same thing. Good idea, but JS does not provide any regular expression support with text ranges. Brendan > > Goba >

« previous php.doc.chm (#604) next »