summaryrefslogtreecommitdiffstats
path: root/generic/tkUndo.c
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2016-05-12 20:26:20 (GMT)
committerfvogel <fvogelnew1@free.fr>2016-05-12 20:26:20 (GMT)
commit603eb20ad00d84cd8494a90826c37edc71916e97 (patch)
treee413d0cd22d862dfb2987e44c9a9e1b537b8c3a8 /generic/tkUndo.c
parentfbfb7ab3f964d449a7dd80957998c23fe8c49117 (diff)
downloadtk-603eb20ad00d84cd8494a90826c37edc71916e97.zip
tk-603eb20ad00d84cd8494a90826c37edc71916e97.tar.gz
tk-603eb20ad00d84cd8494a90826c37edc71916e97.tar.bz2
Implementation of TIP #446 - Introspect Undo/Redo Stack
Diffstat (limited to 'generic/tkUndo.c')
-rw-r--r--generic/tkUndo.c72
1 files changed, 69 insertions, 3 deletions
diff --git a/generic/tkUndo.c b/generic/tkUndo.c
index 8359e0a..5934154 100644
--- a/generic/tkUndo.c
+++ b/generic/tkUndo.c
@@ -353,7 +353,7 @@ TkUndoInitStack(
/*
*----------------------------------------------------------------------
*
- * TkUndoSetDepth --
+ * TkUndoSetMaxDepth --
*
* Set the maximum depth of stack.
*
@@ -368,7 +368,7 @@ TkUndoInitStack(
*/
void
-TkUndoSetDepth(
+TkUndoSetMaxDepth(
TkUndoRedoStack *stack, /* An Undo/Redo stack */
int maxdepth) /* The maximum stack depth */
{
@@ -478,6 +478,72 @@ TkUndoFreeStack(
/*
*----------------------------------------------------------------------
*
+ * TkUndoCanRedo --
+ *
+ * Returns true if redo is possible, i.e. if the redo stack is not empty.
+ *
+ * Results:
+ * A boolean.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TkUndoCanRedo(
+ TkUndoRedoStack *stack) /* An Undo/Redo stack */
+{
+ int canRedo = 0;
+ TkUndoAtom *elem = stack->redoStack;
+
+ while (elem != NULL) {
+ if (elem->type != TK_UNDO_SEPARATOR) {
+ canRedo = 1;
+ break;
+ }
+ elem = elem->next;
+ }
+ return canRedo;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkUndoCanUndo --
+ *
+ * Returns true if undo is possible, i.e. if the undo stack is not empty.
+ *
+ * Results:
+ * A boolean.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TkUndoCanUndo(
+ TkUndoRedoStack *stack) /* An Undo/Redo stack */
+{
+ int canUndo = 0;
+ TkUndoAtom *elem = stack->undoStack;
+
+ while (elem != NULL) {
+ if (elem->type != TK_UNDO_SEPARATOR) {
+ canUndo = 1;
+ break;
+ }
+ elem = elem->next;
+ }
+ return canUndo;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkUndoInsertUndoSeparator --
*
* Insert a separator on the undo stack, indicating a border for an
@@ -498,7 +564,7 @@ TkUndoInsertUndoSeparator(
{
if (TkUndoInsertSeparator(&stack->undoStack)) {
stack->depth++;
- TkUndoSetDepth(stack, stack->maxdepth);
+ TkUndoSetMaxDepth(stack, stack->maxdepth);
}
}