[Gtk-sharp-list] need help with TextBuffers and TextIters

Patrik Olterman patrik@olterman.se
Sat, 22 Nov 2003 12:12:17 +0100


Ok so I got the gtksourceview working but to actually get syntax
highlighting in that is kinda magical heres the last version of the code

full code at http://www.olterman.se:8080/repos/mono/ezsharp/ezsharp.cs

  class Hilite 
  {

        public SourceBuffer buf;
	public SourceView main_text;
	public SourceTagTable tt;

	public Hilite()
	{
	SourceLanguagesManager lm = new SourceLanguagesManager();
	SourceLanguage lang = lm.GetLanguageFromMimeType("text/c-sharp");
	tt = new SourceTagTable();
	if (lang != null) {
      	buf = new SourceBuffer (lang);
	} else {
	buf = new SourceBuffer (tt);
	Console.WriteLine("using tagtable");
	}
      	
	main_text = new SourceView (buf);
	main_text.ShowLineNumbers=true;
	


	}

	public void hilite_all()
	{
		buf.Highlight=true;
	}
	
	public void hilite_last_word()
	{
	
	}

	public void hilite_remove()
	{
		TextIter first = new TextIter();
		first = App.hilite.buf.StartIter;
		TextIter last = new TextIter();
		last = App.hilite.buf.EndIter;

		App.hilite.buf.RemoveAllTags(first, last);
	}
  }