Updates to Syntax Editor
I made a few changes to the syntax highlighting editor I introduced in yesterday’s post:
- Added simple line numbering
- Added a workable (but not bulletproof) CSS sub-grammar to the HTML grammar.
Check out the updated demo. IE6 has a fair number of bugs - for one, undo will probably never work in IE6 because it oh-so-intelligently clobbers the undo buffer whenever there is a change to the DOM tree. I’m not sure if IE7 has this bug or not. It also has some more easy-to-fix bugs, such as all the line numbers being the same (wtf?) and broken CRLFs inside selections.
Safari tab width is an issue - this will only really get solved when the browser itself is fixed. As an aside, Opera used to have the same problem - I noticed it when I was working on the proof-of-concept about a year ago. At the time, I complained about it on their newsgroup and it’s since been fixed. I’m not saying it was because of me that they fixed this, but huzzah in any case! Maybe Apple will follow suit if I complain to them!
The biggest issue is still optimization. This thing is becoming a useful tool, but only if you have a really fast machine and really short documents to edit. The key is going to be removing previously highlighted nodes only as they are discovered to be “dirty”, and figuring out when to stop parsing. I still don’t really know how I’m going to solve that, but once I do I expect I’ll release this thing under some kind of public license.
Note: This component pairs nicely with the Tabinta Mozilla Extension, which lets you place tabs in textarea fields without tabbing out of the field.