Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undo with GTK TextView

I'm trying to keep dependencies to a minimum for a program I contribute to, it's a small text editor.

GTK Textview doesn't seem to come with a built-in undo function. Is there any reference implementation I've been missing on so far? Is everyone writing their own undo function for their TextView widgets?

I'll be happy about any sample code - most happy about python sample code, as our project is in python.

like image 331
Florian Heinle Avatar asked Sep 16 '08 19:09

Florian Heinle


2 Answers

as a follwow-up: I ported gtksourceview's undo mechanism to python: http://bitbucket.org/tiax/gtk-textbuffer-with-undo/

serves as a drop-in replacement for gtksourceview's undo

(OP here, but launchpad open-id doesn't work anymore)

like image 148
Florian Heinle Avatar answered Nov 13 '22 16:11

Florian Heinle


As far as I know, GTK TextView doesn't include an undo function. So while I am not familiar with Python's GTK library, I would think it doesn't have one.

The Ruby-GNOME2 project has a sample text editor that has undo/redo functionality. Basically they are connecting to the insert_text and delete_range signals of the TextView widget and recording the events and associated data in a list.

like image 4
mlibby Avatar answered Nov 13 '22 15:11

mlibby