How to build a undo-redo function for rich text on Gtk4

28 Views Asked by At

I’m looking for a way to have the undo-redo function for formatted text in a Gtk4 Gtk.TextBuffer without having to reimplement the whole gtk_text_history.

I know that, technically, tags and text are totally separate structures but, considering the existence of Gtk.TextBuffer.insert_markup(), it would make perfect sense to save the text on the undo-redo stack in markup format and just use the existing structure of the gtk_text_history to reinsert the text using Gtk.TextBuffer.insert_markup() when needed.

There probably should be a “simple” way to override how gtk_text_history works if you’re a C programmer, but as a python programmer, considering the necessary functions aren’t even exposed to bind, I have no idea the best course of action to take. this problem.

Any suggestion will be highly appreciated.

0

There are 0 best solutions below