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 long long selStart,
long long selEnd)
118 m_activeCell = group;
119 m_activeCellOldText = text;
120 m_activeCellOldSelStart = selStart;
121 m_activeCellOldSelEnd = selEnd;
137 wxASSERT_MSG(m_activeCell == activeCell,
138 _(
"Bug: Cell left but not entered."));
141 if ((m_activeCellOldText.Length() > 1) &&
142 (m_activeCellOldText != currentText) &&
143 (m_activeCellOldText + wxS(
";") != currentText)) {
144 m_undoActions.emplace_front(activeCell, m_activeCellOldText,
145 m_activeCellOldSelStart,
146 m_activeCellOldSelEnd);
175 wxString m_activeCellOldText;
178 long long m_activeCellOldSelStart = -1;
179 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:88
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:157
bool CellLeft(GroupCell *activeCell, const wxString ¤tText)
The cursor is leaving a cell: record a text-change undo action if needed.
Definition: TreeUndoManager.h:134
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:115
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:154
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