I don’t think I’ve ever seen anyone do this before (but could be wrong), so decided to try it out myself. It’s capable of creating a syntax-highlighted version of a textbox as the player types on-the-fly. It uses the Penlight lexer. Since I had a lexer at hand, it only took about an hour to get this fully working. Still a couple issues: Comments are formatted weird; no way to scroll.
The end goal is to overlay the textbox with the highlighted version and simply hide the text of the textbox. The issue though is that doing so will also hide the caret. Let me know if you have any ideas with that.
I did this one in a script builder, cuz SB OP.
(granted, it wasn’t live, but that was just because I was too lazy)
(granted, it didn’t check for errors, but that was just because I didn’t know exactly how)
(I did write the lexer/highlighter myself, hence the absence of error checking)
(Mine just loaded a corescript from github, as it was solely a show-off of my boredness)
It’s usually easier to just rewrite it entirely. For example, the ‘lexer’ I wrote just waits until you input a whitespace character and then looks at the current ‘word’ and highlights it accordingly, using the normal syntax highlighting colours.
I use a pure Lua lexer in the Penlight library. I couldn’t tell you much about how it works though. My goal wasn’t to understand the lexer, but to simply implement it to make syntax highlighting quickly.