diff options
Diffstat (limited to 'generic/tkText.c')
-rw-r--r-- | generic/tkText.c | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/generic/tkText.c b/generic/tkText.c index 8be8881..e028a54 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -398,8 +398,8 @@ static int DumpSegment(TkText *textPtr, Tcl_Interp *interp, const char *key, const char *value, Tcl_Obj *command, const TkTextIndex *index, int what); -static int TextEditUndo(TkText *textPtr); -static int TextEditRedo(TkText *textPtr); +static int TextEditUndo(TkText *textPtr, Tcl_Obj *rangesObj); +static int TextEditRedo(TkText *textPtr, Tcl_Obj *rangesObj); static Tcl_Obj * TextGetText(const TkText *textPtr, const TkTextIndex *index1, const TkTextIndex *index2, int visibleOnly); @@ -2784,6 +2784,7 @@ TextPushUndoAction( Tcl_Obj *markSet2InsertObj = NULL; Tcl_Obj *insertCmdObj = Tcl_NewObj(); Tcl_Obj *deleteCmdObj = Tcl_NewObj(); + Tcl_Obj *returnCmdObj = Tcl_NewObj(); /* * Get the index positions. @@ -2833,6 +2834,11 @@ TextPushUndoAction( Tcl_ListObjAppendElement(NULL, deleteCmdObj, index1Obj); Tcl_ListObjAppendElement(NULL, deleteCmdObj, index2Obj); + Tcl_ListObjAppendElement(NULL, returnCmdObj, + Tcl_NewStringObj("list", 4)); + Tcl_ListObjAppendElement(NULL, returnCmdObj, index1Obj); + Tcl_ListObjAppendElement(NULL, returnCmdObj, index2Obj); + /* * Note: we don't wish to use textPtr->widgetCmd in these callbacks * because if we delete the textPtr, but peers still exist, we will then @@ -2850,11 +2856,13 @@ TextPushUndoAction( insertCmdObj, NULL); TkUndoMakeCmdSubAtom(NULL, markSet2InsertObj, iAtom); TkUndoMakeCmdSubAtom(NULL, seeInsertObj, iAtom); + TkUndoMakeCmdSubAtom(NULL, returnCmdObj, iAtom); dAtom = TkUndoMakeSubAtom(&TextUndoRedoCallback, textPtr->sharedTextPtr, deleteCmdObj, NULL); TkUndoMakeCmdSubAtom(NULL, markSet1InsertObj, dAtom); TkUndoMakeCmdSubAtom(NULL, seeInsertObj, dAtom); + TkUndoMakeCmdSubAtom(NULL, returnCmdObj, dAtom); Tcl_DecrRefCount(seeInsertObj); Tcl_DecrRefCount(index1Obj); @@ -5055,7 +5063,7 @@ DumpSegment( * Undo the last change. * * Results: - * None. + * The ranges of text that were changed by the undo operation. * * Side effects: * Apart from manipulating the undo and redo stacks, the state of the @@ -5066,7 +5074,8 @@ DumpSegment( static int TextEditUndo( - TkText *textPtr) /* Overall information about text widget. */ + TkText *textPtr, /* Overall information about text widget. */ + Tcl_Obj *rangesObj) /* Ranges of text that were changed. */ { int status; @@ -5085,7 +5094,7 @@ TextEditUndo( textPtr->sharedTextPtr->dirtyMode = TK_TEXT_DIRTY_UNDO; } - status = TkUndoRevert(textPtr->sharedTextPtr->undoStack); + status = TkUndoRevert(textPtr->sharedTextPtr->undoStack, rangesObj); if (textPtr->sharedTextPtr->dirtyMode != TK_TEXT_DIRTY_FIXED) { textPtr->sharedTextPtr->dirtyMode = TK_TEXT_DIRTY_NORMAL; @@ -5103,7 +5112,7 @@ TextEditUndo( * Redo the last undone change. * * Results: - * None. + * The ranges of text that were changed by the undo operation. * * Side effects: * Apart from manipulating the undo and redo stacks, the state of the @@ -5114,7 +5123,8 @@ TextEditUndo( static int TextEditRedo( - TkText *textPtr) /* Overall information about text widget. */ + TkText *textPtr, /* Overall information about text widget. */ + Tcl_Obj *rangesObj) /* Ranges of text that were changed. */ { int status; @@ -5133,7 +5143,7 @@ TextEditRedo( textPtr->sharedTextPtr->dirtyMode = TK_TEXT_DIRTY_REDO; } - status = TkUndoApply(textPtr->sharedTextPtr->undoStack); + status = TkUndoApply(textPtr->sharedTextPtr->undoStack, rangesObj); if (textPtr->sharedTextPtr->dirtyMode != TK_TEXT_DIRTY_FIXED) { textPtr->sharedTextPtr->dirtyMode = TK_TEXT_DIRTY_NORMAL; @@ -5169,6 +5179,7 @@ TextEditCmd( int index, setModified, oldModified; int canRedo = 0; int canUndo = 0; + Tcl_Obj *rangesObj = Tcl_NewObj(); static const char *const editOptionStrings[] = { "canundo", "canredo", "modified", "redo", "reset", "separator", @@ -5252,11 +5263,13 @@ TextEditCmd( return TCL_ERROR; } canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); - if (TextEditRedo(textPtr)) { + if (TextEditRedo(textPtr, rangesObj)) { Tcl_SetObjResult(interp, Tcl_NewStringObj("nothing to redo", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_REDO", NULL); return TCL_ERROR; - } + } else { + Tcl_SetObjResult(interp, rangesObj); + } canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); if (!canUndo || !canRedo) { GenerateUndoStackEvent(textPtr); @@ -5287,11 +5300,13 @@ TextEditCmd( return TCL_ERROR; } canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); - if (TextEditUndo(textPtr)) { + if (TextEditUndo(textPtr, rangesObj)) { Tcl_SetObjResult(interp, Tcl_NewStringObj("nothing to undo", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_UNDO", NULL); return TCL_ERROR; - } + } else { + Tcl_SetObjResult(interp, rangesObj); + } canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); if (!canRedo || !canUndo) { GenerateUndoStackEvent(textPtr); |