• (2 Pages)
  • +
  • 1
  • 2

Syntax Highlight in C# How to implement syntax highlighting in a WinForms application.

#16 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1363
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Posted 21 January 2012 - 09:01 AM

That question was asked at the beginning of September last year. I would think they have figured it out by now.
Was This Post Helpful? 0
  • +
  • -

#17 blogwhodle  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 49
  • Joined: 18-January 12

Posted 01 February 2012 - 05:02 PM

Good point.
Was This Post Helpful? 0
  • +
  • -

#18 blogwhodle  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 49
  • Joined: 18-January 12

Posted 01 February 2012 - 05:17 PM

By the way I had a syntax highlighter for my batch editor program that works kind of like this:
[DllImport("user32.dll")] 
public static extern bool LockWindowUpdate (IntPtr hWndLock);

                private void work(string str, Color clr)
		{
                        LockWindowUpdate(richTextBox1.Handle);
			int startie = 0;
			do
			{
				startie = richTextBox1.Find(str, startie, richTextBox1.Text.Length, RichTextBoxFinds.None);
				if (startie > -1)
				{
					richTextBox1.Select(startie, str.Length);
					richTextBox1.SelectionColor = clr;
					richTextBox1.SelectedText = str;
					startie++;
				}
			} while (startie > -1);
			richTextBox1.DeselectAll();
			richTextBox1.Select(richTextBox1.Text.Length, 0);
                        LockWindowUpdate(IntPtr.Zero);
		}



                public void Highlight(Dictionary<string, Color> words)
		{
			foreach (string item in words.Keys)
			{
				Color key;
				words.TryGetValue(item, key);
				if (!key == null)
				{
					work(item, key);
				}
			}
		}
/*
Sorry about the terrible indentation. I had this for my batch editor before I saw this but I added the lockwindowupdate thing because I thought it might help keep my window from higlighting randomized words out of nowhere.
PS: The method Highlight is called on richTextBox1_TextChanged with a dictionary of batch keywords and colors.
*/


Which syntax highlighter is better?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2