41#ifndef WORKSHEETDOCUMENT_H
42#define WORKSHEETDOCUMENT_H
44#include "CellPointers.h"
87 std::unique_ptr<GroupCell> &
TreeOwner() {
return m_tree; }
211 m_lastQuestion = lastQuestion;
242 if (m_currentFile.EndsWith(wxS(
".wxmx")))
251 void RecordFoldUndo(
const std::vector<GroupCell *> &affected,
262 std::unique_ptr<GroupCell> m_tree;
268 wxString m_currentFile;
270 wxString m_lastQuestion;
272 bool m_questionPrompt =
false;
Implementation of an observing weak Cell pointer.
CellType
The supported types of math cells.
Definition: Cell.h:64
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:141
Declares TreeUndoManager: the owner of the cell-tree undo/redo state.
The worksheet's "between the cells" cursor (the horizontally drawn caret).
A weak non-owning pointer that becomes null whenever the observed object is destroyed.
Definition: CellPtr.h:539
The document-model half of the cell-pointer registry.
Definition: CellPointers.h:50
A simple FIFO queue with manual removal of elements.
Definition: EvaluationQueue.h:43
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:88
The description of one action for the undo (or redo) command.
Definition: TreeUndoAction.h:45
FoldDirection
Which way a fold/unfold undo action (see m_fold) goes.
Definition: TreeUndoAction.h:65
Owns the cell-tree undo/redo stacks and the active-cell snapshot.
Definition: TreeUndoManager.h:51
The between-the-cells cursor: active flag, position, selection anchors.
Definition: WorksheetCursor.h:49
The view notifications a WorksheetDocument emits when it edits itself.
Definition: WorksheetDocumentView.h:50
The view-independent state and commands of an edited worksheet document.
Definition: WorksheetDocument.h:61
bool CanMergeSelection() const
Can the current selection (of more than one cell) be merged into one?
Definition: WorksheetDocument.cpp:361
CellPtr< GroupCell > & LastCache() const
The cached pointer to the document's last GroupCell (<0 = unknown).
Definition: WorksheetDocument.h:93
bool CanRedoInsideCell() const
Can the active cell's own (intra-cell) redo be invoked right now?
Definition: WorksheetDocument.cpp:390
const WorksheetCursor & GetCursor() const
The between-cells cursor (read-only view).
Definition: WorksheetDocument.h:76
void SetSaved(bool saved)
Record whether the document is in its saved state.
Definition: WorksheetDocument.cpp:34
void FoldAll()
Recursively folds every foldable cell in the document.
Definition: WorksheetDocument.cpp:317
bool CanApplyTreeAction(const UndoActions &actions) const
Can the tree-undo/redo at the front of the given stack be applied now?
Definition: WorksheetDocument.cpp:195
void UnfoldAll()
Recursively unfolds every folded cell in the document.
Definition: WorksheetDocument.cpp:326
bool QuestionPending() const
Is Maxima currently waiting for an answer to a question?
Definition: WorksheetDocument.h:215
bool CanUndoInsideCell() const
Can the active cell's own (intra-cell) undo be invoked right now?
Definition: WorksheetDocument.cpp:386
GroupCell * GetLastCell() const
The document's last GroupCell, memoised in m_last (null if empty).
Definition: WorksheetDocument.cpp:42
bool IsSaved() const
True while the document has no unsaved changes.
Definition: WorksheetDocument.h:226
void SetCurrentFile(const wxString &file)
Record the file this document is associated with.
Definition: WorksheetDocument.h:205
EvaluationQueue & GetEvaluationQueue()
The list of cells scheduled to be sent to Maxima for evaluation.
Definition: WorksheetDocument.h:64
GroupCell * Unfold(GroupCell *which)
Unfold which; see GroupCell::Unfold(). Mirrors Fold().
Definition: WorksheetDocument.cpp:277
bool IsSelectionInWorkingGroup() const
Is the selection start inside the group Maxima is currently evaluating?
Definition: WorksheetDocument.cpp:381
DocumentCellPointers & GetCellPointers()
The document-model half of the cell-pointer registry (selection, the active/answer/current-text cell,...
Definition: WorksheetDocument.h:221
bool IsSelected(CellType type) const
Is the selection exactly one cell of the given type?
Definition: WorksheetDocument.cpp:374
TextUndoResult
What UndoTextChange() did with the action it was given.
Definition: WorksheetDocument.h:102
@ CellGone
The cell no longer exists; the caller should drop the action.
@ Applied
The cell's text/selection were reverted to the recorded old state.
@ NoOpSkipped
The cell's text already matched the target state (a later, since reverted edit reproduced it); nothin...
GroupCell * InsertCells(std::unique_ptr< GroupCell > &&cells, GroupCell *where)
Insert a list of group cells into the document after where.
Definition: WorksheetDocument.cpp:59
GroupCell * ToggleFold(GroupCell *which)
Fold or unfold which, whichever it currently isn't; see GroupCell::Fold()/Unfold().
Definition: WorksheetDocument.cpp:292
const TreeUndoManager & GetTreeUndo() const
The document's tree-edit undo/redo history (read-only view).
Definition: WorksheetDocument.h:71
void NumberSections() const
Renumber all sectioning cells (titles, sections, ...) from the top.
Definition: WorksheetDocument.cpp:52
TreeUndoManager & GetTreeUndo()
The document's undo/redo history of tree-structure edits.
Definition: WorksheetDocument.h:69
const EvaluationQueue & GetEvaluationQueue() const
The list of cells scheduled for evaluation (read-only view).
Definition: WorksheetDocument.h:66
const wxString & GetCurrentFile() const
The file this document was last loaded from / saved to (empty if none).
Definition: WorksheetDocument.h:203
void SetDocumentView(WorksheetDocumentView *view)
Register the view the document notifies when it edits its own structure.
Definition: WorksheetDocument.h:96
std::unique_ptr< GroupCell > & TreeOwner()
Mutable access to the owning pointer of the cell tree.
Definition: WorksheetDocument.h:87
bool CanRemoveCells(GroupCell *start, const GroupCell *end) const
Can the range [start,end] (inclusive) be safely removed from the tree?
Definition: WorksheetDocument.cpp:127
std::unique_ptr< GroupCell > RemoveCells(GroupCell *start, GroupCell *end)
Remove the range [start,end] (inclusive) from the tree.
Definition: WorksheetDocument.cpp:145
const wxString & GetLastQuestion() const
The text of the Maxima question the user is currently being asked.
Definition: WorksheetDocument.h:208
bool CanDeleteSelection() const
Can the current selection be deleted right now (see CanRemoveCells())?
Definition: WorksheetDocument.cpp:353
bool CanEdit() const
Is exactly one cell selected, and does it directly follow Maxima's own input prompt (as opposed to be...
Definition: WorksheetDocument.cpp:335
void SetQuestionPending(bool pending)
Record whether Maxima is waiting for an answer to a question.
Definition: WorksheetDocument.h:217
WorksheetCursor & GetCursor()
The between-cells cursor (the h-caret) and its group-level selection.
Definition: WorksheetDocument.h:74
GroupCell * GetTree() const
The first GroupCell of the document (null when the document is empty).
Definition: WorksheetDocument.h:79
void SetLastQuestion(const wxString &lastQuestion)
Remember the text of the question Maxima is currently asking.
Definition: WorksheetDocument.h:210
GroupCell * ToggleFoldAll(GroupCell *which)
Like ToggleFold(), but folds/unfolds which's whole subtree.
Definition: WorksheetDocument.cpp:299
void OutputChanged()
Note that a cell's output changed.
Definition: WorksheetDocument.h:241
GroupCell * Fold(GroupCell *which)
Fold which; see GroupCell::Fold().
Definition: WorksheetDocument.cpp:262
TextUndoResult UndoTextChange(const TreeUndoAction &action, UndoActions *undoForThisOperation)
Apply a pending text-change undo/redo action.
Definition: WorksheetDocument.cpp:206
const DocumentCellPointers & GetCellPointers() const
The document-model half of the cell-pointer registry (read-only view).
Definition: WorksheetDocument.h:223