Hi I just started a little hobby project.
The goal is to write a very simple dev environment including an editor with simple syntax highlighting. I did tackle this years before as a rookie VB coder with little understanding what I was acutally doing. So I found my old project (batch file editor) and went through the code. What I did back then was looping trough the RTB Text and looking for keywords. When I had found one I set the cursor poistion to the word select it and use the SelectionColor property to change the color then reset the cursor to its previous location.
This solution seemed pretty messy to me at first. And it obviously is. For example if you want to be able to process files and not limit the size you need to relieve stress and the algorithm which searches through the text. Doing this by using another thread may cause the cursor to jump to unwanted locations while the user is typing which could cause a definitely unwanted effect... So I went online searching for other solutions but as it seems there are pretty much no other approaches out.
So I thought before starting to rewrite a complete own TextBox supporting this I might ask here if anyone knows a good solution to this. Preferably without using any libraries not included into .Net but I'm starting to take this into consideration.