summaryrefslogtreecommitdiff
path: root/fluid/undo.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2024-08-31 20:36:34 +0200
committerMatthias Melcher <github@matthiasm.com>2024-08-31 20:36:34 +0200
commitd51046cdeaf1dceac91e70fe6be358502280a431 (patch)
treefccd991be47f4b69935bb378d737a0f9de242f2e /fluid/undo.cxx
parente01c9ff6a03f3775e0d93a56d671a8c2f8cf96a2 (diff)
FLUID: Add Synchronized Resize. #1055
Diffstat (limited to 'fluid/undo.cxx')
-rw-r--r--fluid/undo.cxx16
1 files changed, 15 insertions, 1 deletions
diff --git a/fluid/undo.cxx b/fluid/undo.cxx
index 0d5cb4d9b..31b412878 100644
--- a/fluid/undo.cxx
+++ b/fluid/undo.cxx
@@ -1,7 +1,7 @@
//
// FLUID undo support for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2021 by Bill Spitzak and others.
+// Copyright 1998-2024 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@@ -53,6 +53,7 @@ int undo_last = 0; // Last undo level in buffer
int undo_max = 0; // Maximum undo level used
int undo_save = -1; // Last undo level that was saved
static int undo_paused = 0; // Undo checkpointing paused?
+int undo_once_type = 0; // Suspend further undos of the same type
// Return the undo filename.
@@ -80,6 +81,7 @@ static char *undo_filename(int level) {
void redo_cb(Fl_Widget *, void *) {
// int undo_item = main_menubar->find_index(undo_cb);
// int redo_item = main_menubar->find_index(redo_cb);
+ undo_once_type = 0;
if (undo_current >= undo_last) {
fl_beep();
@@ -120,6 +122,7 @@ void redo_cb(Fl_Widget *, void *) {
void undo_cb(Fl_Widget *, void *) {
// int undo_item = main_menubar->find_index(undo_cb);
// int redo_item = main_menubar->find_index(redo_cb);
+ undo_once_type = 0;
if (undo_current <= 0) {
fl_beep();
@@ -165,6 +168,16 @@ void undo_cb(Fl_Widget *, void *) {
undo_resume();
}
+void undo_checkpoint_once(int type) {
+ if (undo_paused) return;
+ if (undo_once_type != type) {
+ undo_checkpoint();
+ undo_once_type = type;
+ } else {
+ // do not add more checkpoints for the same undo typw
+ }
+}
+
// Save current file to undo buffer
void undo_checkpoint() {
// printf("undo_checkpoint(): undo_current=%d, undo_paused=%d, modflag=%d\n",
@@ -175,6 +188,7 @@ void undo_checkpoint() {
// int undo_item = main_menubar->find_index(undo_cb);
// int redo_item = main_menubar->find_index(redo_cb);
+ undo_once_type = 0;
// Save the current UI to a checkpoint file...
const char *filename = undo_filename(undo_current);