-->
0 Members and 1 Guest are viewing this topic.
//Initiate vars string[] lines = this.Lines; int pos = 0; int cpos = this.SelectionStart; int line = this.GetLineFromCharIndex(cpos); //Let's see if there are even any keywords in the line. //If not, we'll exit bool cont = false; foreach (string kw in rsrvdWrds) if (lines[line].Contains(kw)) cont = true; //If the current line doesn't contain any words, if (!cont) return; //Exit //Get the exact beginning char index of the line for (int i = 0; i < line; i++) //+1 because of \n pos += lines[i].Length + 1; //Now pos is the index of the first char on the current line //Reset line colors (THESE ARE THE FOUR LINES THAT *SHOULD* RESET THE LINE COLOR) this.SelectionStart = pos; //Go to beginning of line this.SelectionLength = lines[line].Length; //Select the line this.SelectionColor = Color.Black; //Turn it black this.SelectionLength = 0; //Deselect the line //For each match of keyword in the current line foreach (Match kw in reservedWords.Matches(lines[line])) { this.SelectionStart = pos + kw.Index; this.SelectionLength = kw.Length; this.SelectionColor = Color.Blue; } //Highlight any strings that might be in the line's string this.HighlightString(line); //Resume current position this.SelectionLength = 0; this.SelectionStart = cpos; this.SelectionColor = Color.Black;