Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Syntax highlighting textbox

Syntax highlighting textbox

Scheduled Pinned Locked Moved C#
databasecomgraphicstoolshelp
3 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Latheesan
    wrote on last edited by
    #1

    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 file 0 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

    L 1 Reply Last reply
    0
    • L Latheesan

      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 file 0 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

      L Offline
      L Offline
      Latheesan
      wrote on last edited by
      #2

      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

      L 1 Reply Last reply
      0
      • L Latheesan

        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

        L Offline
        L Offline
        Latheesan
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups