[pygtk] Undoing apply_tag in gtk.TextBuffer
Samuel Abels
newsgroups at debain.org
Sat Jul 5 22:03:00 WST 2008
On Sat, 2008-07-05 at 01:49 +0200, Samuel Abels wrote:
> Even working around this by trying to find the style that is currently
> applied in a specific region does not seem do work; both, the get_text()
> and get_slice() methods do not seem to include the information in the
> return value.
I found a way to do this; by iterating over each character in the undo
region, each time calling the TextIter.get_tags() method, you can
remember the previous text style in the undo object.
The resulting code is now here:
http://code.google.com/p/spiff-gtkwidgets/source/browse/trunk/src/SpiffGtkWidgets/TextEditor/UndoTag.py
http://code.google.com/p/spiff-gtkwidgets/source/browse/trunk/src/SpiffGtkWidgets/TextEditor/TextBuffer.py
This is a whole lot iterating to do for every single char, so it is
quite slow. (But you won't notice unless you document/undo operation is
very large and uses a lot of tags.) If anybody can point me to a better
way of doing this, please let me know.
-Samuel
More information about the pygtk
mailing list