Syntax highlighting textbox
-
Hello, I am using this library in one of my project : http://www.codeproject.com/cs/miscctrl/SyntaxHighlighting.asp[^] This is how i used it in my editor i've been working on:
/* Create a new SyntaxHighlightingTextBox */ shtb = new SyntaxHighlightingTextBox(); shtb.Name = "shtb"; shtb.Location = new Point(0, 0); shtb.Dock = DockStyle.Fill; shtb.WordWrap = false; shtb.ScrollBars = RichTextBoxScrollBars.Both; shtb.FilterAutoComplete = false; shtb.AcceptsTab = true; shtb.DetectUrls = false; shtb.Font = new System.Drawing.Font("Verdana", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); /* Separaters */ shtb.Seperators.Add(' '); shtb.Seperators.Add('\r'); shtb.Seperators.Add('\n'); shtb.Seperators.Add('\t'); shtb.Seperators.Add(','); shtb.Seperators.Add('.'); shtb.Seperators.Add('-'); shtb.Seperators.Add('+'); /* Controls */ shtb.ContextMenuStrip = EditorContextMenu; Controls.Add(shtb); this.Controls.Add(this.MainMenu); /* Syntax Highlighting Keywords [ BLUE ] */ try { TextReader syntax_blue = new StreamReader("synHighLib_DB/blue.txt"); string line = syntax_blue.ReadLine(); while (line != null) { shtb.HighlightDescriptors.Add(new HighlightDescriptor(line, Color.Blue, null, DescriptorType.Word, DescriptorRecognition.WholeWord, true)); line = syntax_blue.ReadLine(); } syntax_blue.Close(); } catch (Exception e) { MessageBox.Show("Exception Error : " + e.Message, "eAthena Script Editor"); }
This is the contents of my blue.txt db file0 1 2 3 4 5 6 7 8 9
As you can see, i want to turn all interger that the user types in the editor into blue color. When i tried this in the compiled app, this is how it looks like: http://img254.imageshack.us/img254/989 -
Hello, I am using this library in one of my project : http://www.codeproject.com/cs/miscctrl/SyntaxHighlighting.asp[^] This is how i used it in my editor i've been working on:
/* Create a new SyntaxHighlightingTextBox */ shtb = new SyntaxHighlightingTextBox(); shtb.Name = "shtb"; shtb.Location = new Point(0, 0); shtb.Dock = DockStyle.Fill; shtb.WordWrap = false; shtb.ScrollBars = RichTextBoxScrollBars.Both; shtb.FilterAutoComplete = false; shtb.AcceptsTab = true; shtb.DetectUrls = false; shtb.Font = new System.Drawing.Font("Verdana", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); /* Separaters */ shtb.Seperators.Add(' '); shtb.Seperators.Add('\r'); shtb.Seperators.Add('\n'); shtb.Seperators.Add('\t'); shtb.Seperators.Add(','); shtb.Seperators.Add('.'); shtb.Seperators.Add('-'); shtb.Seperators.Add('+'); /* Controls */ shtb.ContextMenuStrip = EditorContextMenu; Controls.Add(shtb); this.Controls.Add(this.MainMenu); /* Syntax Highlighting Keywords [ BLUE ] */ try { TextReader syntax_blue = new StreamReader("synHighLib_DB/blue.txt"); string line = syntax_blue.ReadLine(); while (line != null) { shtb.HighlightDescriptors.Add(new HighlightDescriptor(line, Color.Blue, null, DescriptorType.Word, DescriptorRecognition.WholeWord, true)); line = syntax_blue.ReadLine(); } syntax_blue.Close(); } catch (Exception e) { MessageBox.Show("Exception Error : " + e.Message, "eAthena Script Editor"); }
This is the contents of my blue.txt db file0 1 2 3 4 5 6 7 8 9
As you can see, i want to turn all interger that the user types in the editor into blue color. When i tried this in the compiled app, this is how it looks like: http://img254.imageshack.us/img254/989Same with having everything inside " and " brown, i did this: shtb.HighlightDescriptors.Add(new HighlightDescriptor("\"", "\"", Color.Brown, null, DescriptorType.ToCloseToken, DescriptorRecognition.StartsWith, false)); I compiled the app and tried to type like this "hello" and only once the first double quote became brown and then as soon as i typed the h, it stopped being brown. Where im i going wrong? how can i get this right? Thanks in advance for any help you can offer
-
Same with having everything inside " and " brown, i did this: shtb.HighlightDescriptors.Add(new HighlightDescriptor("\"", "\"", Color.Brown, null, DescriptorType.ToCloseToken, DescriptorRecognition.StartsWith, false)); I compiled the app and tried to type like this "hello" and only once the first double quote became brown and then as soon as i typed the h, it stopped being brown. Where im i going wrong? how can i get this right? Thanks in advance for any help you can offer
Okay, i did some searching and using this code, i fixed this second problem - http://www.codeproject.com/cs/miscctrl/SyntaxHighlighting.asp?msg=1194287#xx1194287xx[^] However, i still have the first problem... does anyone have any idea how to solve this?