34#ifndef TREEUNDOMANAGER_H
35#define TREEUNDOMANAGER_H
69 if (actionList->empty())
72 actionList->pop_back();
73 }
while (!actionList->empty() && actionList->back().m_partOfAtomicAction);
79 if (!actionList->empty())
80 actionList->front().m_partOfAtomicAction =
true;
89 while (!m_redoActions.empty())
96 while (!m_undoActions.empty())
105 m_activeCell =
nullptr;
116 while (
static_cast<long>(m_undoActions.size()) > undoLimit)
128 long long selStart,
long long selEnd)
130 m_activeCell = group;
131 m_activeCellOldText = text;
132 m_activeCellOldSelStart = selStart;
133 m_activeCellOldSelEnd = selEnd;
152 wxASSERT_MSG(m_activeCell == activeCell,
153 _(
"Bug: Cell left but not entered."));
156 if ((m_activeCellOldText.Length() > 1) &&
157 (m_activeCellOldText != currentText) &&
158 (m_activeCellOldText + wxS(
";") != currentText)) {
159 m_undoActions.emplace_front(activeCell, m_activeCellOldText,
160 m_activeCellOldSelStart,
161 m_activeCellOldSelEnd);
191 wxString m_activeCellOldText;
194 long long m_activeCellOldSelStart = -1;
195 long long m_activeCellOldSelEnd = -1;
Declares TreeUndoAction, the immutable record of one cell-tree undo/redo step, and the UndoActions li...
std::list< TreeUndoAction > UndoActions
The type of the list of tree actions that can be undone.
Definition: TreeUndoAction.h:120
A weak non-owning pointer that becomes null whenever the observed object is destroyed.
Definition: CellPtr.h:511
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:87
Owns the cell-tree undo/redo stacks and the active-cell snapshot.
Definition: TreeUndoManager.h:51
GroupCell * ActiveCell() const
The cell the cursor is in, as recorded by CellEntered().
Definition: TreeUndoManager.h:173
bool CellLeft(GroupCell *activeCell, const wxString ¤tText, long undoLimit)
The cursor is leaving a cell: record a text-change undo action if needed.
Definition: TreeUndoManager.h:148
void CellEntered(GroupCell *group, const wxString &text, long long selStart, long long selEnd)
The cursor has entered a cell: snapshot its contents.
Definition: TreeUndoManager.h:127
void ClearUndoActionList()
Clear the list of actions that can be undone.
Definition: TreeUndoManager.h:94
void ClearBuffers()
Clear both action lists and forget the active-cell snapshot.
Definition: TreeUndoManager.h:101
UndoActions & UndoStack()
The list of tree actions that can be undone.
Definition: TreeUndoManager.h:54
void ForgetActiveCell()
Forget the active-cell snapshot (e.g. the next change must not be undoable).
Definition: TreeUndoManager.h:170
void LimitUndoBuffer(long undoLimit)
Drop actions from the back of the undo list until it is within the limit.
Definition: TreeUndoManager.h:112
static void DiscardAction(UndoActions *actionList)
Remove one action from an action list.
Definition: TreeUndoManager.h:67
UndoActions & RedoStack()
The list of undone tree actions that can be redone.
Definition: TreeUndoManager.h:58
void ClearRedoActionList()
Clear the list of actions that can be redone.
Definition: TreeUndoManager.h:87
void AppendAction()
Mark the newest undo action as part of the following atomic action.
Definition: TreeUndoManager.h:84
static void AppendAction(UndoActions *actionList)
Mark the newest action of the list as part of the following atomic action.
Definition: TreeUndoManager.h:77