gtkgeditgedit-plugin

Get style of text from Gedit plugin


I'm working on a plugin for the text editor Gedit written in Python where I need to know the formatting (color etc.) of a specific character in the text of a Gtk.Document. I have tried to call get_attibutes() on a Gtk.TextIter object but I cannot get anything out of the resulting Gtk.TextAttributes object. Any ideas?


Solution

  • Gnome text editor uses Gtk.SourceView as a base, and Gtk.SourceView has as one of its features the possibility of applying a predetermined style based on the syntax of the language used in the file (the focus is programming). This is done through Gtk.Tags, to get the tags that apply to a certain Gtk.TextIter you have to use Gtk.TextIter.get_tags().