Search code examples
c#monogtkmonodevelopgtk#

How do you make a Syntax Highlight Text Editor in Gtk Sharp?


I would like to make a custom Text Editor for Gtk# (maybe inherited from Gtk.TextView) which supports Syntax Highlighting , and maybe line numbers at the side. (Something like Scintilla/SciTE?) Anyway, I have tried a few things like putting all the words in an array etc. But so far have not succeeded in making anything that works. Any help, explanation, resource or Sample Code?

NOTE: You may give the answer in another language with a similar syntax for which Gtk has a binding, like Gtkmm or Gtk+.

NOTE2: I am using Gtk 2


Solution

  • Use the Mono.TextEditor assembly from MonoDevelop. It's a source editor widget for GTK# written in C#, and has no dependencies on the rest of MD.

    MonoDevelop used to use GtkSourceView, but switched to Mono.TextEditor about 3 years ago, because it was more portable, and gave us more flexibility to change and improve things.