PavelTorgashov / FastColoredTextBox

Fast Colored TextBox for Syntax Highlighting. The text editor component for .NET.
Other
1.22k stars 465 forks source link

Highlight one character at a time, line by line.? #264

Open Kmicic opened 4 months ago

Kmicic commented 4 months ago

How to set highlighting attributes line by line for each character in a line according to the entered pattern? The picture will explain it better. I enter the pattern into the text field and the highlighting is performed in the appropriate text columns. I can have an array of pattern and lines but I don't know how to set the style for a single character.

toto-highlighter

Kmicic commented 4 months ago

I did it without regular expressions by comparing characters line by line. Even for a large number of lines the result is satisfactory. Thank you. I'm closing the topic unless someone has a better idea. :)

                int k = 0;
                for (int j = 0; j < lineList.Length; j++)
                {

                    if (typeList[k].Contains(lineList[j]))
                    {
                        FastColoredTextBoxNS.Char value = range.tb[i][j];
                        value.style = styleLayer;
                        range.tb[i][j] = value;

                    }
                    if ("1Xx2".Contains(lineList[j])) k++;
                    if (k >= typeList.Count) break;
                }
            }

            range.tb.Invalidate();

screen-highlight