views:

26

answers:

1

I'm developing a Gedit plugin which is built on PyGTK. I'm trying to figure out how to programatically tell the cursor where to go. For example, I'd like to have the cursor automatically go to right before the first "|" (pipe) in the current line.

Any ideas or starting points? I've been using the Gedit API up until now (right here) which is helpful for the most part but doesn't mention anything about manipulating the cursor position.

+1  A: 

Looking at the gedit plugin API, it looks like gedit.Document is a subclass of GtkSourceBuffer which itself subclasses GtkTextBuffer, the last of which has the cursor manipulation API you want. In particular, get_insert() and place_cursor(where) give the basics of moving the cursor around. For other operations (e.g., getting the current line) you'll need to convert to a GtkTextIter using get_iter_at_mark(mark); the cursor is essentially just a special GtkTextMark.

Kai