Saturday, March 21, 2009

Finally ported CodeMirror syntax engine to bespin

I have written before about my attempt to port the CodeMirror syntax highlight engine to bespin. I got it mostly working now (for Javascript, HTML, CSS, PHP and even all these languags mixed together as in PHP) and have submitted an initial patch for review.

The port required quite a few structural changes of the code because, on bespin the syntax engine is running in a background thread if webworkers are available (FF 3.1beta, Safari 4beta, Webkit nightly) or gears is installed, otherwise it is still running asynchronous, triggered by a Javascript setTimeout() with value 0. This all has only been possible thanks to the groundbreaking work of Malte Ubl.

So if you wanna try that patch out today, you need of course a local installation of bespin, then apply the patch and use the command-line to enable / disable the syntax engine:

set syntax2 on / set syntax2 off

And don't expect it to be not even near as fast as the default engine. It is just an initial port, caching and other tricks to make it fast are not enabled or implemented yet.

2 comments:

Malte said...

Thanks for the flowers :) Did you merge this yet with my work that went into tip?

By the way: My local changes now allow to use includeScripts inside the worker to load more source (Even in Safari 4 which does not support this feature nor does it support XMLHttpRequest inside workers).

PS: My last name has an L at the end.

Roberto Saccon said...

Malte, yes I do use your latest work from tip. And sorry for that typo, it's corrected now.