Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void richTextBox1_TextChanged(object sender, EventArgs e) {
- int ln = 0;
- int sel = richTextBox1.SelectionStart;
- foreach (string s in richTextBox1.Lines) {
- int index = commentOut(richTextBox1.Lines[ln]);
- if(richTextBox1.Lines.Length > 0
- && richTextBox1.Lines[ln].Contains("#")) {
- richTextBox1.Select(index, richTextBox1.Lines[ln].Length);
- richTextBox1.SelectionColor = Color.Green;
- richTextBox1.Select(0, richTextBox1.Lines[ln].Length - index);
- richTextBox1.SelectionColor = Color.Black;
- //richTextBox1.Select(sel, 0);
- richTextBox1.Select(sel, 0);
- return;
- }
- ln++;
- }
- this.CheckKeyword("while", Color.Purple, 0);
- this.CheckKeyword("if", Color.Green, 0);
- }
- private int commentOut(String line) {
- char[] ar = line.ToCharArray();
- int ln = 0;
- foreach(char s in ar) {
- if(s.ToString().Equals("#")) {
- break;
- }
- ln++;
- }
- return ln;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement