private void CrearSintaxisColorAllText(string s) { Poblamiento = true; int CurrentSelectionStart = richTextBox1.SelectionStart; int CurrentSelectionLength = richTextBox1.SelectionLength; int count = ParseLine(s); string previousWord = ""; for (int i = 0; i < count; i++) { WordAndPosition wp = TheBuffer[i]; if (wp.Word == "/" && previousWord == "/") { int posCommentStart = wp.Position - 1; int posCommentEnd = i; while (wp.Word != "\n" && i < count) { wp = TheBuffer[i]; i++; } i--; posCommentEnd = wp.Position; richTextBox1.Select(posCommentStart, posCommentEnd - posCommentStart); richTextBox1.SelectionColor = this.kCommentarioColor; } else { Color c = MostrarColor(wp.Word); richTextBox1.Select(wp.Position, wp.Length); richTextBox1.SelectionColor = c; } previousWord = wp.Word; } if (CurrentSelectionStart >= 0) { richTextBox1.Select(CurrentSelectionStart, CurrentSelectionLength); } Poblamiento = false; }
private void CrearSintaxisPorCadaLinea() { int Start = richTextBox1.SelectionStart; int Length = richTextBox1.SelectionLength; int pos = Start; while ((pos > 0) && (richTextBox1.Text[pos - 1] != '\n')) { pos--; } int pos2 = Start; while ((pos2 < richTextBox1.Text.Length) && (richTextBox1.Text[pos2] != '\n')) { pos2++; } string s = richTextBox1.Text.Substring(pos, pos2 - pos); if (TestComment(s) == true) { richTextBox1.Select(pos, pos2 - pos); richTextBox1.SelectionColor = kCommentarioColor; } else { string previousWord = ""; int count = ParseLine(s); for (int i = 0; i < count; i++) { WordAndPosition wp = TheBuffer[i]; if (wp.Word == "/" && previousWord == "/") { int posCommentStart = wp.Position - 1; int posCommentEnd = pos2; while (wp.Word != "\n" && i < count) { wp = TheBuffer[i]; i++; } i--; posCommentEnd = pos2; richTextBox1.Select(posCommentStart + pos, posCommentEnd - (posCommentStart + pos)); richTextBox1.SelectionColor = this.kCommentarioColor; } else { Color c = MostrarColor(wp.Word); richTextBox1.Select(wp.Position + pos, wp.Length); richTextBox1.SelectionColor = c; } previousWord = wp.Word; } } if (Start >= 0) { richTextBox1.Select(Start, Length); } }