public void SyntaxHighlightBuildFileText(int start, int end, string text) { int startcursorposition = BuildFile.SelectionStart; MatchCollection mc = Regex.Matches(text, @"\/\/(.*)"); foreach (Match m in mc) { BuildFile.Select(start + m.Index - 1, 2); if (BuildFile.SelectedText.Contains(":")) { BuildFile.SelectionLength = startcursorposition; BuildFile.SelectionStart = BuildFile.Text.Length; return; } BuildFile.SelectionLength = startcursorposition; BuildFile.SelectionStart = BuildFile.Text.Length; // Select text that was appended BuildFile.Select(start + m.Index, end - start); BuildFile.SelectionColor = Color.YellowGreen; // Unselect text BuildFile.SelectionLength = startcursorposition; BuildFile.SelectionStart = BuildFile.Text.Length; BuildFile.SelectionColor = Color.Black; } mc = Regex.Matches(text, "\"([^\"]*)\""); foreach (Match m in mc) { // Select text that was appended BuildFile.Select(start + m.Index, m.Value.Length); BuildFile.SelectionColor = Color.CornflowerBlue; // Unselect text BuildFile.SelectionLength = startcursorposition; BuildFile.SelectionStart = BuildFile.Text.Length; BuildFile.SelectionColor = Color.Black; } mc = Regex.Matches(text, "\'([^\"]*)\'"); foreach (Match m in mc) { // Select text that was appended BuildFile.Select(start + m.Index, m.Value.Length); BuildFile.SelectionColor = Color.CornflowerBlue; // Unselect text BuildFile.SelectionLength = startcursorposition; BuildFile.SelectionStart = BuildFile.Text.Length; BuildFile.SelectionColor = Color.Black; } }