I’m making a Luau text editor in Roblox but I’m having a tough time finding a method that can allow syntax highlighting without allowing the user to see the source formatting. Right now, I’m using an invisible TextBox for the input and a TextLabel with Rich Text for the output.
The problem with the TextLabel is that I can’t figure out how I’m going to let the user highlight stuff and have their cursor be in the right place. Let me know what general approach I can take with this.
I guess you could use .CursorPosition (Letter index position, check api for more info) in the hidden input object to get the highlight, and repeat subtracting cursor position by -1 until you reach a spacebar or empty break, although for positioning the highlight, I’m not sure how you would get the exact x.y’s of the text selected, you can probably do math for that.
Thanks for that. That helped me correctly position the cursor.
No problem, good luck, is that all you need help with?
yeah, I think I’ll find something for the highlighting part.