summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/Fl_Input_.H6
-rw-r--r--src/Fl_Input_.cxx24
2 files changed, 30 insertions, 0 deletions
diff --git a/FL/Fl_Input_.H b/FL/Fl_Input_.H
index a7062f5a0..6eacc27ae 100644
--- a/FL/Fl_Input_.H
+++ b/FL/Fl_Input_.H
@@ -384,9 +384,15 @@ public:
/* Undo previous changes to the text buffer. */
int undo();
+ /* Return true if the last operation can be undone. */
+ bool can_undo();
+
/* Redo previous undo operations. */
int redo();
+ /* Return true if there is a redo action in the list. */
+ bool can_redo();
+
/* Copy the yank buffer to the clipboard. */
int copy_cuts();
diff --git a/src/Fl_Input_.cxx b/src/Fl_Input_.cxx
index 7842c9fca..16b2f4aae 100644
--- a/src/Fl_Input_.cxx
+++ b/src/Fl_Input_.cxx
@@ -88,6 +88,10 @@ public:
clear();
}
+ int size() const {
+ return list_size_;
+ }
+
void push(Fl_Input_Undo_Action* action) {
if (list_size_ == list_capacity_) {
list_capacity_ += 25;
@@ -1067,6 +1071,15 @@ int Fl_Input_::undo() {
}
/**
+ Check if the last operation can be undone.
+
+ \return true if the widget can unod the last change
+ */
+bool Fl_Input_::can_undo() {
+ return (undo_->undocut || undo_->undoinsert);
+}
+
+/**
Redo previous undo operation.
This call reapplies previously executed undo operations.
@@ -1080,6 +1093,8 @@ int Fl_Input_::redo() {
if (undo_->undocut || undo_->undoinsert)
undo_list_->push(undo_);
+ else
+ delete undo_;
undo_ = redo_action;
int ret = apply_undo();
@@ -1089,6 +1104,15 @@ int Fl_Input_::redo() {
}
/**
+ Check if there is a redo action available.
+
+ \return true if the widget can redo the last undo action
+ */
+bool Fl_Input_::can_redo() {
+ return (redo_list_->size() > 0);
+}
+
+/**
Copies the \e yank buffer to the clipboard.
This method copies all the previous contiguous cuts from the undo