Menu

#19 idea for highlighter speed optimization

open
nobody
None
5
2009-05-15
2009-05-15
Ron
No

Hi Christophe,

I've been working with the editarea for a lot of time now. It still seems superior to codepress and other highlighters, and I'm also very pleased that there is still development going on. Codepress for example had it's last update in 2007...

The main problem for me at this point is the speed of the editor. When working on files of around 500 lines of code the editor starts to get really slow. This is caused by the highlighter engine for sure (disabling it solves all issues). I was thinking about a new kind of approach for this system. I'm a (javascript) programmer myself, so we could maybe work on this new approach together.

The best solution would be that only the changed parts of the code are re-highlighted. The problem with that approach is multiline strings, how to detect these? Maybe this algorithm is worth a try?
- divide the complete code in one object per line stored in an array (line-objects)
- each object is able to highlight it's line where he's responsible for
- each object is aware of it's position in the main-object-array
- when highlighting the object looks at the object before itself, and if that one is an open string some special code is started
- each object is now capable of highlighting it's own line of code

Now comes the most trickiest part:
- when something is typed the corresponding line-object should be updated and re-highlighted (you cannot type in multiple lines at the same time)
- when enter is pressed a new line-object should be inserted in the main-object-array (easy: http://tinyurl.com/qrmpnl\)
- when backspace is pressed a lline-object deletion should be detected
- when something is pasted these objects should also be inserted in the main-object-array
- when there is an selection and something is typed objects should be deleted
- when tab is typed in an selection some special code should also run to fix this in all line-objects

The highlight-layer should also consist of one div for each line. The line-object has an reference to this DOM object, and so can easily update it's line. Special classnames should be used in the case of an multiline strings etc.

What do you think?

Discussion


Log in to post a comment.