summaryrefslogtreecommitdiffstats
path: root/generic/tkText.c
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2016-05-17 20:00:20 (GMT)
committerfvogel <fvogelnew1@free.fr>2016-05-17 20:00:20 (GMT)
commitd1ed9566df0379d64ce1bcbeb9cf4d6ce5054dc1 (patch)
treedab7dc3f799b4a2692b2be6c74da6f4eed2dc2f3 /generic/tkText.c
parent8d4c26fbadf5ae5ecc09a1290cb03fbe6be2cc09 (diff)
downloadtk-d1ed9566df0379d64ce1bcbeb9cf4d6ce5054dc1.zip
tk-d1ed9566df0379d64ce1bcbeb9cf4d6ce5054dc1.tar.gz
tk-d1ed9566df0379d64ce1bcbeb9cf4d6ce5054dc1.tar.bz2
Took comments from Koen Danckaert into account (with my thanks) to simplify the implementation of TkUndoCanUndo() and TkUndoCanRedo() in tkUndo.c, and in tkText.c to remove direct calls to internals of the undo or redo stacktip_446
Diffstat (limited to 'generic/tkText.c')
-rw-r--r--generic/tkText.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/generic/tkText.c b/generic/tkText.c
index a9b7527..b610844 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -2770,7 +2770,7 @@ TextPushUndoAction(
/* Index describing second location. */
{
TkUndoSubAtom *iAtom, *dAtom;
- TkUndoAtom *redoElem, *undoElem;
+ int canUndo, canRedo;
/*
* Create the helpers.
@@ -2857,8 +2857,8 @@ TextPushUndoAction(
Tcl_DecrRefCount(index1Obj);
Tcl_DecrRefCount(index2Obj);
- undoElem = textPtr->sharedTextPtr->undoStack->undoStack;
- redoElem = textPtr->sharedTextPtr->undoStack->redoStack;
+ canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack);
+ canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack);
/*
* Depending whether the action is to insert or delete, we provide the
@@ -2872,7 +2872,7 @@ TextPushUndoAction(
TkUndoPushAction(textPtr->sharedTextPtr->undoStack, dAtom, iAtom);
}
- if (undoElem == NULL || redoElem != NULL) {
+ if (!canUndo || canRedo) {
GenerateUndoStackEvent(textPtr);
}
}
@@ -5166,7 +5166,6 @@ TextEditCmd(
int index, setModified, oldModified;
int canRedo = 0;
int canUndo = 0;
- TkUndoAtom *redoElem, *undoElem;
static const char *const editOptionStrings[] = {
"canundo", "canredo", "modified", "redo", "reset", "separator",
@@ -5249,14 +5248,14 @@ TextEditCmd(
Tcl_WrongNumArgs(interp, 3, objv, NULL);
return TCL_ERROR;
}
- undoElem = textPtr->sharedTextPtr->undoStack->undoStack;
+ canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack);
if (TextEditRedo(textPtr)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("nothing to redo", -1));
Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_REDO", NULL);
return TCL_ERROR;
}
- redoElem = textPtr->sharedTextPtr->undoStack->redoStack;
- if (undoElem == NULL || redoElem == NULL) {
+ canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack);
+ if (!canUndo || !canRedo) {
GenerateUndoStackEvent(textPtr);
}
break;
@@ -5265,10 +5264,10 @@ TextEditCmd(
Tcl_WrongNumArgs(interp, 3, objv, NULL);
return TCL_ERROR;
}
- undoElem = textPtr->sharedTextPtr->undoStack->undoStack;
- redoElem = textPtr->sharedTextPtr->undoStack->redoStack;
+ canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack);
+ canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack);
TkUndoClearStacks(textPtr->sharedTextPtr->undoStack);
- if (undoElem != NULL || redoElem != NULL) {
+ if (canUndo || canRedo) {
GenerateUndoStackEvent(textPtr);
}
break;
@@ -5284,14 +5283,14 @@ TextEditCmd(
Tcl_WrongNumArgs(interp, 3, objv, NULL);
return TCL_ERROR;
}
- redoElem = textPtr->sharedTextPtr->undoStack->redoStack;
+ canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack);
if (TextEditUndo(textPtr)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("nothing to undo", -1));
Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_UNDO", NULL);
return TCL_ERROR;
}
- undoElem = textPtr->sharedTextPtr->undoStack->undoStack;
- if (redoElem == NULL || undoElem == NULL) {
+ canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack);
+ if (!canRedo || !canUndo) {
GenerateUndoStackEvent(textPtr);
}
break;