Code editors in Mozilla apps
The main problem when designing a Mozilla-based development tool is the lack of a decent code editor. Here’s a quick overview of the existing solutions.
SeaMonkey Composer uses a plaintext editor to edit HTML source (editortype="text").
Plain and simple, reliable, gets the job done… as long as you don’t want any syntax highlighting, line numbers, code folding, auto-completion, etc.: it’s a Notepad, no more, no less.
Nvu used an html editor to edit HTML source (editortype="html"):
- a colored source view of the current page is generated, modified to add line numbers and sent to the html editor
- after this html view of the html source has been edited in wysiwyg, it’s exported to text and the HTML document is rebuilt from that text.
I think this isn’t an acceptable solution:
- all these successive conversions are too tricky: this “Source tab” was very buggy in Nvu’s and has caused most of the crashes and data losses
- this pseudo syntax highlighting can’t be updated as you modify the code, so what’s the point?
- the html editor is a poor text editor: it’s slow, the caret gets stuck sometimes, requiring to use the mouse.
I guess it’s better than nothing but as far as I’m concerned, I prefer a Notepad.
Firebug uses a browser to display and edit the HTML source. This brings a decent syntax highlighting and a good code folding, and it’s very handy for small modifications.
However, it’s nowhere near a text editor either: it’s slow, it’s impossible to use without a mouse, and it’s very specific to HTML and CSS. It makes a lot of sense in Firebug and might be interesting in a web editor like KompoZer, but it doesn’t claim to be a code editor.
Komodo relies on SciMoz, i.e. a Scintilla binding. I think it’s the best possible editor component for Mozilla apps: it’s very fast and lightweight, it has the best lexer I know (better than Vim’s imho) and a good code completion. Its code folding feature works well with all languages… except with HTML, unfortunately.
The main drawback is that SciMoz is very difficult to embed into a non-Komodo app. I believe ActiveState would like to share the effort on SciMoz with Mozilla, and an <editor editortype="scintilla"> element would sure rock… but unfortunately this doesn’t seem to be a priority for Mozilla. I sure wish it was!
Speaking of KompoZer, the solution would be to build KompoZer on OpenKomodo: KompoZer would become quite heavy-weight but it would remain acceptable compared to Expression Web or DreamWeaver.
We’ve also been asked whether we’d like to make it easy for folks to embed Bespin’s canvas editor in their own non-Bespin projects. Absolutely we do. Bespin will eventually spin out three projects:
1. The Bespin project: an on-line code editor (i.e., the project we’ve currently announced)
2. Thunderhead: a canvas/JS GUI toolkit
3. (To Be Named Editor): a stand-alone canvas editor that you can embed
I still doubt Bespin can come close to Scintilla in terms of performances and features; but having an embeddable, standalone editor that could easily be used in any Mozilla project would be a great improvement, despite all other limitations.
So far I intended to use SciMoz in KompoZer 0.9, but Bespin might bring a very interesting alternative — especially if KompoZer merges with SeaMonkey Composer. I’ll keep a close eye on this standalone canvas editor project!