From 15b3c0f563d73787c574d1d03d627fbc46db59c4 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 1 Nov 2019 11:12:21 -0700 Subject: textview: add undo/redo support to GtkTextView This builds upon the GtkTextHistory helper to provide undo and redo support for the GtkTextView widget and GtkTextBuffer object. You can undo/redo using familiar shortcuts such as Primary+Z, Primary+Shift+Z, ad Primary+Y. Developers that wish to disable undo, should set the GtkTextBuffer:enable-undo property to FALSE. You can wrap irreversible actions gtk_text_buffer_begin_irreversible_action() and gtk_text_buffer_end_irreversible_action(). This will cause the undo stack to drop all undo/redo actions and the changes made between them will be the "initial state" of the buffer. Calling gtk_text_buffer_set_text() will do this automatically for you. --- gtk/gtktextprivate.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gtk/gtktextprivate.h') diff --git a/gtk/gtktextprivate.h b/gtk/gtktextprivate.h index daeed71bce..500389824d 100644 --- a/gtk/gtktextprivate.h +++ b/gtk/gtktextprivate.h @@ -85,6 +85,8 @@ struct _GtkTextClass void (* paste_clipboard) (GtkText *self); void (* toggle_overwrite) (GtkText *self); void (* insert_emoji) (GtkText *self); + void (* undo) (GtkText *self); + void (* redo) (GtkText *self); }; char * gtk_text_get_display_text (GtkText *entry, -- cgit v1.2.1