diff options
author | fvogel <fvogelnew1@free.fr> | 2016-05-12 20:26:20 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2016-05-12 20:26:20 (GMT) |
commit | 6edae2839102dc6916273780f7b1c6109c6296dd (patch) | |
tree | e413d0cd22d862dfb2987e44c9a9e1b537b8c3a8 /generic/tkText.c | |
parent | 8dac2dbee4250de1b447068357077a7a2c5649ab (diff) | |
download | tk-6edae2839102dc6916273780f7b1c6109c6296dd.zip tk-6edae2839102dc6916273780f7b1c6109c6296dd.tar.gz tk-6edae2839102dc6916273780f7b1c6109c6296dd.tar.bz2 |
Implementation of TIP #446 - Introspect Undo/Redo Stack
Diffstat (limited to 'generic/tkText.c')
-rw-r--r-- | generic/tkText.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/generic/tkText.c b/generic/tkText.c index 3e8d625..4a352b2 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2093,7 +2093,7 @@ ConfigureText( textPtr->sharedTextPtr->maxUndo = textPtr->maxUndo; textPtr->sharedTextPtr->autoSeparators = textPtr->autoSeparators; - TkUndoSetDepth(textPtr->sharedTextPtr->undoStack, + TkUndoSetMaxDepth(textPtr->sharedTextPtr->undoStack, textPtr->sharedTextPtr->maxUndo); /* @@ -5156,10 +5156,12 @@ TextEditCmd( { int index, setModified, oldModified; static const char *const editOptionStrings[] = { - "modified", "redo", "reset", "separator", "undo", NULL + "canundo", "canredo", "modified", "redo", "reset", "separator", + "undo", NULL }; enum editOptions { - EDIT_MODIFIED, EDIT_REDO, EDIT_RESET, EDIT_SEPARATOR, EDIT_UNDO + EDIT_CANUNDO, EDIT_CANREDO, EDIT_MODIFIED, EDIT_REDO, EDIT_RESET, + EDIT_SEPARATOR, EDIT_UNDO }; if (objc < 3) { @@ -5173,6 +5175,32 @@ TextEditCmd( } switch ((enum editOptions) index) { + case EDIT_CANREDO: { + int canRedo = 0; + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 3, objv, NULL); + return TCL_ERROR; + } + if (textPtr->sharedTextPtr->undo) { + canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); + } + Tcl_SetObjResult(interp, Tcl_NewBooleanObj(canRedo)); + break; + } + case EDIT_CANUNDO: { + int canUndo = 0; + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 3, objv, NULL); + return TCL_ERROR; + } + if (textPtr->sharedTextPtr->undo) { + canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); + } + Tcl_SetObjResult(interp, Tcl_NewBooleanObj(canUndo)); + break; + } case EDIT_MODIFIED: if (objc == 3) { Tcl_SetObjResult(interp, |