As part of my pretty large scale scene / level editor project, I figured it would look nice as well as ease the writing process to have the engine scripts syntax highlighted.
This did not seem all that easy to do though, mainly due to DBP's speed issues. Therefore, I've spent quite some time trying to wrap Scintilla as well as other highlighting freebies into a plugin form usable by DBP. Unfortunately, that just kept on failing with every single library due to .NET issues.
Anyhow, after experimenting with bleGui's canvas gadgets for a while, I realized that they might just have the speed that was neccessary for something like this (needless to say, the RichEdits do not).
And now, after some rather bothersome work, I have a pretty well working (although not with complete functionality as of yet) totally homemade 2D syntax highlighter control
written in DBPro (! - I've seen a few posts saying how that was probably impossible
).
The complementary screenshot
You can
download a demo application here - try it out and tell me what you think; suggestions, flaws, etc. Also, I have a pretty powerful processor, so I'm rather interrested in hearing whether it runs at a decent framerate for others.
Current features
Type any (I think?) ASCII character into the control.
Completely customisable syntax highlighting (three demo language files are included; DBPro, C++ and the syntax highlighting keyword registration script).
Highlights language constants (scopes, variable types, etc.), keywords (conditional statements, loops, etc.), functions (everything else), comments (lines and blocks), numerics (integer, decimal, binary and hexadecimal notation are supported) and strings (as marked by double quotes; 'c' or <string> are
not highlighted). The font and colour of each one of these can be changed at will through the properties dialog.
Pressing the backspace key will delete the previous character.
Using the left and right arrowkeys you can move the cursor to the next / previous column. Moving past the end / beginning of a line will wrap around to the previous / next line.
A (row, column) can also be directly moved to by clicking the corresponding slot.
The scrollbars can be used to change the starting positions of the displaying area (only the visible part is handled each loop).
Notes
This was written to be used as a script editor within another project of mine. It is
not supposed to be a DBPro editor - hence very few keywords from the DBPro language is included in the corresponding language file; it is just there for demonstrative purposes. You can always open the .sl files and add in your own keywords though, but bear in mind that for every newly added word, there is another one to check against each loop. Perhaps having hundreds of keywords would drop the loop frequency; I haven't tested that. Also, there is currently a maximum of 1024 keywords that can be registered from a single language file.
Speaking of which, the character data is stored as a two dimensional array, consisting of 10000 rows with 1024 columns each. Exceeding this will cause an "Array index out of bounds" error; I will fix that later tonight though.
Seeing as how the highlighter control is entirely written by me, you will find it lacking of much of the standard windows induced functionality, such as marking text, copy and paste, scrolling the view area with the mouse wheel, etc. I'm planning to try to implement such things though.
Well, there then - happy for some c/c
-> Oh, come on...