X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FUndo.cpp;h=5d613f2e0db4f6c84ac4502690c11a11c3b80db8;hb=05e2621a1782504d995f961f77edc604329ab1ee;hp=eb7722839c2d9ca27b7134b15b73652ca7954a47;hpb=cd9e42dc3529980257d2b0fe6fd623fd2b99a1e6;p=lyx.git diff --git a/src/Undo.cpp b/src/Undo.cpp index eb7722839c..5d613f2e0d 100644 --- a/src/Undo.cpp +++ b/src/Undo.cpp @@ -203,10 +203,10 @@ struct Undo::Private group_id_(0), group_level_(0) {} // Do one undo/redo step - void doTextUndoOrRedo(CursorData & cur, UndoElementStack & stack, + void doUndoRedoAction(CursorData & cur, UndoElementStack & stack, UndoElementStack & otherStack); // Apply one undo/redo group. Returns false if no undo possible. - bool textUndoOrRedo(CursorData & cur, bool isUndoOperation); + bool undoRedoAction(CursorData & cur, bool isUndoOperation); /// void doRecordUndo(UndoKind kind, @@ -430,7 +430,7 @@ void Undo::Private::recordUndoBufferParams(CursorData const & cur) } -void Undo::Private::doTextUndoOrRedo(CursorData & cur, UndoElementStack & stack, UndoElementStack & otherstack) +void Undo::Private::doUndoRedoAction(CursorData & cur, UndoElementStack & stack, UndoElementStack & otherstack) { // Adjust undo stack and get hold of current undo data. UndoElement & undo = stack.top(); @@ -472,6 +472,7 @@ void Undo::Private::doTextUndoOrRedo(CursorData & cur, UndoElementStack & stack, //LYXERR0("undo.array: " << *undo.array); LBUFERR(undo.array); dit.cell().swap(*undo.array); + dit.inset().setBuffer(buffer_); delete undo.array; undo.array = 0; } else { @@ -527,7 +528,7 @@ void Undo::Private::doTextUndoOrRedo(CursorData & cur, UndoElementStack & stack, } -bool Undo::Private::textUndoOrRedo(CursorData & cur, bool isUndoOperation) +bool Undo::Private::undoRedoAction(CursorData & cur, bool isUndoOperation) { undo_finished_ = true; @@ -541,7 +542,7 @@ bool Undo::Private::textUndoOrRedo(CursorData & cur, bool isUndoOperation) const size_t gid = stack.top().group_id; while (!stack.empty() && stack.top().group_id == gid) - doTextUndoOrRedo(cur, stack, otherstack); + doUndoRedoAction(cur, stack, otherstack); return true; } @@ -553,15 +554,15 @@ void Undo::finishUndo() } -bool Undo::textUndo(CursorData & cur) +bool Undo::undoAction(CursorData & cur) { - return d->textUndoOrRedo(cur, true); + return d->undoRedoAction(cur, true); } -bool Undo::textRedo(CursorData & cur) +bool Undo::redoAction(CursorData & cur) { - return d->textUndoOrRedo(cur, false); + return d->undoRedoAction(cur, false); } @@ -609,6 +610,14 @@ void Undo::endUndoGroup(CursorData const & cur_after) } +bool Undo::activeUndoGroup() const +{ + return d->group_level_ > 0 + && !d->undostack_.empty() + && d->undostack_.top().group_id == d->group_id_; +} + + void Undo::recordUndo(CursorData const & cur, UndoKind kind) { d->recordUndo(kind, cur, cur.pit(), cur.pit(), cur);