wxMaxima
Loading...
Searching...
No Matches
TreeUndoAction.h
Go to the documentation of this file.
1// -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2//
3// Copyright (C) 2004-2015 Andrej Vodopivec <andrej.vodopivec@gmail.com>
4// (C) 2014-2018 Gunter Königsmann <wxMaxima@physikbuch.de>
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 2 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16//
17// You should have received a copy of the GNU General Public License
18// along with this program; if not, write to the Free Software
19// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20//
21// SPDX-License-Identifier: GPL-2.0+
22
31#ifndef TREEUNDOACTION_H
32#define TREEUNDOACTION_H
33
34#include "cells/CellPtr.h"
35#include "cells/GroupCell.h"
36#include <wx/string.h>
37#include <list>
38#include <memory>
39
44{
45public:
46 TreeUndoAction(GroupCell *start, const wxString &oldText,
47 long long oldSelStart = -1, long long oldSelEnd = -1) :
48 m_start(start), m_oldText(oldText),
49 m_oldSelStart(oldSelStart), m_oldSelEnd(oldSelEnd)
50 {
51 wxASSERT_MSG(start, _("Bug: Trying to record a cell contents change for undo without a cell."));
52 }
53 TreeUndoAction(GroupCell *start, GroupCell *end) :
54 m_start(start), m_newCellsEnd(end)
55 {
56 wxASSERT_MSG(start, _("Bug: Trying to record a cell contents change for undo without a cell."));
57 }
58 TreeUndoAction(GroupCell *start, GroupCell *end, GroupCell *oldCells) :
59 m_start(start), m_newCellsEnd(end), m_oldCells(oldCells)
60 {
61 }
62
69
81
87 const wxString m_oldText;
88
95 const long long m_oldSelStart = -1;
96 const long long m_oldSelEnd = -1;
97
108
116 std::unique_ptr<GroupCell> m_oldCells;
117};
118
120using UndoActions = std::list<TreeUndoAction>;
121
122#endif // TREEUNDOACTION_H
Implementation of an observing weak Cell pointer.
This file defines the class GroupCell that bundles input and output in the worksheet.
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
The description of one action for the undo (or redo) command.
Definition: TreeUndoAction.h:44
const wxString m_oldText
The old contents of the cell start.
Definition: TreeUndoAction.h:87
const long long m_oldSelStart
The old cursor/selection range in the EditorCell pointed to by m_start.
Definition: TreeUndoAction.h:95
CellPtr< GroupCell > m_start
The position this action started at.
Definition: TreeUndoAction.h:80
std::unique_ptr< GroupCell > m_oldCells
Cells that were deleted in this action.
Definition: TreeUndoAction.h:116
CellPtr< GroupCell > m_newCellsEnd
This action inserted all cells from start to newCellsEnd.
Definition: TreeUndoAction.h:107
bool m_partOfAtomicAction
True = This undo action is only part of an atomic undo action.
Definition: TreeUndoAction.h:68