While we have 100+ lexers to colorize your text in ScintillaControlMBS control, you may sometimes need a custom solution. If none of our existing lexers suits you, you can do it all yourself in Xojo.
You would implement StyleNeeded event to provide coloring for a range of text. You get the position where the action happened, e.g. user typed a few letters. Then you query EndStyled property to know when existing style information ended. Since you are asked usually in chunks, you may start where you finished recently. From there we usually go back to the start of the line, so we query the line with LineFromPosition and the start of the line with PositionFromLine. Then we colorize from that position to the current one.
Here is a sample code to assign style 2 to digits, while keeping everything else untouched:
Your StyleNeeded event needs be quick to perform well. It is called after each key press to color the current line. And it may need to color the visible range, if the user scrolls. To improve performance, we use #pragma BackgroundTasks to speed up a bit.
We also have a Xojo lexer built-in the plugin:
Please try this with the next pre-release version of our plugin (24.0pr7 or later) due to a little bug fix coming in there.