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,
}
-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();
//LYXERR0("undo.array: " << *undo.array);
LBUFERR(undo.array);
dit.cell().swap(*undo.array);
+ dit.inset().setBuffer(buffer_);
delete undo.array;
undo.array = 0;
} else {
}
-bool Undo::Private::textUndoOrRedo(CursorData & cur, bool isUndoOperation)
+bool Undo::Private::undoRedoAction(CursorData & cur, bool isUndoOperation)
{
undo_finished_ = true;
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;
}
}
-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);
}
}
+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);