Improving Syntax Highlighting of PHP in the Delphi IDE
|
I found a great use for the syntax highlighter stuff I was playing with last week. Nothing is better than having a legitimate use for something you did just for the exploration ;-). I have, over the past while been working with quite a bit of PHP pages as a front end to some delphi services. While I have tried out a few editors I am either finding I simply don't like them or more likely I am just too stuck in my editing patterns to want to use something other than Delphi for plain text work. Delphi 7 and Delphi 8 both include a stock PHP highlighter to make your life a bit easier but they are not really great. One of the pet peeves is that variables referenced inside strings are not highlighted :-(. This has caused me grief more than once. | ![]() |
A light bulb turns on (however dim it may be on any given day) and the revelation that I could use the stock PHP highlighter and simply aggregate it to add the extra syntax highlighting :-). It turns out to be pretty easy. I let it do all the work with regarding to parsing, etc. and I just follow up by parsing in the highlight codes looking for string/character markers at which point I then examine the matching characters. If I find a $ or a { then I simply replace the highlight codes with a different highlight code and presto... I am done :-). Should save me a few roundtrips during my PHP development.
The picture on the side shows what the highlighter does (see the variables in the strings). You can control the colors using Delphi's source color options.
I will update the code central entry after I am sure it is working properly.
Labels: Delphi
