|
wxMaxima
|
The view-independent state and commands of an edited worksheet document. More...
#include <WorksheetDocument.h>
Public Types | |
| enum class | TextUndoResult { CellGone , NoOpSkipped , Applied } |
| What UndoTextChange() did with the action it was given. More... | |
Public Member Functions | |
| EvaluationQueue & | GetEvaluationQueue () |
| The list of cells scheduled to be sent to Maxima for evaluation. | |
| const EvaluationQueue & | GetEvaluationQueue () const |
| The list of cells scheduled for evaluation (read-only view). | |
| TreeUndoManager & | GetTreeUndo () |
| The document's undo/redo history of tree-structure edits. | |
| const TreeUndoManager & | GetTreeUndo () const |
| The document's tree-edit undo/redo history (read-only view). | |
| WorksheetCursor & | GetCursor () |
| The between-cells cursor (the h-caret) and its group-level selection. | |
| const WorksheetCursor & | GetCursor () const |
| The between-cells cursor (read-only view). | |
| GroupCell * | GetTree () const |
| The first GroupCell of the document (null when the document is empty). | |
| std::unique_ptr< GroupCell > & | TreeOwner () |
| Mutable access to the owning pointer of the cell tree. | |
| CellPtr< GroupCell > & | LastCache () const |
| The cached pointer to the document's last GroupCell (<0 = unknown). | |
| void | SetDocumentView (WorksheetDocumentView *view) |
| Register the view the document notifies when it edits its own structure. | |
| bool | CanApplyTreeAction (const UndoActions &actions) const |
| Can the tree-undo/redo at the front of the given stack be applied now? | |
| TextUndoResult | UndoTextChange (const TreeUndoAction &action, UndoActions *undoForThisOperation) |
Apply a pending text-change undo/redo action. | |
| GroupCell * | GetLastCell () const |
| The document's last GroupCell, memoised in m_last (null if empty). | |
| void | NumberSections () const |
| Renumber all sectioning cells (titles, sections, ...) from the top. | |
| GroupCell * | Fold (GroupCell *which) |
Fold which; see GroupCell::Fold(). | |
| GroupCell * | Unfold (GroupCell *which) |
Unfold which; see GroupCell::Unfold(). Mirrors Fold(). | |
| GroupCell * | ToggleFold (GroupCell *which) |
Fold or unfold which, whichever it currently isn't; see GroupCell::Fold()/Unfold(). | |
| GroupCell * | ToggleFoldAll (GroupCell *which) |
Like ToggleFold(), but folds/unfolds which's whole subtree. | |
| void | FoldAll () |
| Recursively folds every foldable cell in the document. | |
| void | UnfoldAll () |
| Recursively unfolds every folded cell in the document. | |
| bool | CanEdit () const |
| Is exactly one cell selected, and does it directly follow Maxima's own input prompt (as opposed to being e.g. a text or section cell)? | |
| bool | CanDeleteSelection () const |
| Can the current selection be deleted right now (see CanRemoveCells())? | |
| bool | CanMergeSelection () const |
| Can the current selection (of more than one cell) be merged into one? | |
| bool | IsSelected (CellType type) const |
| Is the selection exactly one cell of the given type? | |
| bool | IsSelectionInWorkingGroup () const |
| Is the selection start inside the group Maxima is currently evaluating? | |
| bool | CanUndoInsideCell () const |
| Can the active cell's own (intra-cell) undo be invoked right now? | |
| bool | CanRedoInsideCell () const |
| Can the active cell's own (intra-cell) redo be invoked right now? | |
| GroupCell * | InsertCells (std::unique_ptr< GroupCell > &&cells, GroupCell *where) |
Insert a list of group cells into the document after where. | |
| bool | CanRemoveCells (GroupCell *start, const GroupCell *end) const |
| Can the range [start,end] (inclusive) be safely removed from the tree? | |
| std::unique_ptr< GroupCell > | RemoveCells (GroupCell *start, GroupCell *end) |
| Remove the range [start,end] (inclusive) from the tree. | |
| const wxString & | GetCurrentFile () const |
| The file this document was last loaded from / saved to (empty if none). | |
| void | SetCurrentFile (const wxString &file) |
| Record the file this document is associated with. | |
| const wxString & | GetLastQuestion () const |
| The text of the Maxima question the user is currently being asked. | |
| void | SetLastQuestion (const wxString &lastQuestion) |
| Remember the text of the question Maxima is currently asking. | |
| bool | QuestionPending () const |
| Is Maxima currently waiting for an answer to a question? | |
| void | SetQuestionPending (bool pending) |
| Record whether Maxima is waiting for an answer to a question. | |
| DocumentCellPointers & | GetCellPointers () |
| The document-model half of the cell-pointer registry (selection, the active/answer/current-text cell, working group and error list). | |
| const DocumentCellPointers & | GetCellPointers () const |
| The document-model half of the cell-pointer registry (read-only view). | |
| bool | IsSaved () const |
| True while the document has no unsaved changes. | |
| void | SetSaved (bool saved) |
| Record whether the document is in its saved state. | |
| void | OutputChanged () |
| Note that a cell's output changed. | |
The view-independent state and commands of an edited worksheet document.
Currently a small aggregate that Worksheet delegates to; it grows as further document state is migrated off Worksheet. Held by value by Worksheet.
|
strong |
What UndoTextChange() did with the action it was given.
Can the range [start,end] (inclusive) be safely removed from the tree?
Refuses if either end is null, or if the range contains the cell Maxima is currently evaluating.
Fold which; see GroupCell::Fold().
Returns the cell if it was actually folded, null if which is null, not foldable, or already folded. Records an undo action (GH #266) and clears the redo list; the caller still has to schedule a recalculation - every existing caller already does.
| GroupCell * WorksheetDocument::InsertCells | ( | std::unique_ptr< GroupCell > && | cells, |
| GroupCell * | where | ||
| ) |
Insert a list of group cells into the document after where.
where == null inserts at the very top. Splices the cells into the tree, renumbers sections if needed and notifies the view (recalc/redraw/adjust size/modified) through the registered WorksheetDocumentView. Returns the last inserted cell. The caller (Worksheet) records the undo action, which needs a Configuration and so stays on the view side.
The cached pointer to the document's last GroupCell (<0 = unknown).
Mutable so the const "find the last cell" lookup can memoise its result; the surgery code also updates it directly when it reseats the tail.
|
inline |
Note that a cell's output changed.
For a .wxmx (which caches output on disk) changed output means the file is no longer saved. Sets the flag directly, without a control refresh, to match the historical behaviour: this is called often during evaluation and must stay cheap.
Remove the range [start,end] (inclusive) from the tree.
Pure structural surgery plus the document-side bookkeeping it implies: dequeues the removed cells from the evaluation queue, clears their cached output bitmaps, splices them out of the tree, renumbers sections if a foldable or image cell left, and notifies the view (recalc/redraw/ modified) through the registered WorksheetDocumentView. Returns the removed cells (still linked to each other) so the caller can push them onto its undo buffer, or null if start / end don't form a removable range (see CanRemoveCells()). The caller (Worksheet) still handles the cursor/selection housekeeping around the deletion (moving the cursor to a sane place before cells vanish out from under it) and the layout-position refresh, both view concerns.
| void WorksheetDocument::SetSaved | ( | bool | saved | ) |
Record whether the document is in its saved state.
On an actual change of the flag the view is told via WorksheetDocumentView::NotifySavedStateChanged() so it can refresh the controls that depend on the saved-state. Defined in the .cpp because it needs the complete WorksheetDocumentView type.
Fold or unfold which, whichever it currently isn't; see GroupCell::Fold()/Unfold().
Returns the cell if something actually changed, null if which is null or not foldable. The caller still has to schedule a recalculation - every existing caller already does.
|
inline |
Mutable access to the owning pointer of the cell tree.
Transitional: while the tree-editing surgery still lives in Worksheet, it reseats the head of the list (moves a new tree in, resets it, splices), so it needs the unique_ptr itself, not just GetTree(). Moves onto WorksheetDocument with the tree-surgery methods in a later increment.
| WorksheetDocument::TextUndoResult WorksheetDocument::UndoTextChange | ( | const TreeUndoAction & | action, |
| UndoActions * | undoForThisOperation | ||
| ) |
Apply a pending text-change undo/redo action.
Pure part of Worksheet::TreeUndoTextChange(): checks the target cell is still part of the tree, detects a no-op (the text to restore is already there), records the cell's CURRENT state into undoForThisOperation (so this undo can itself be redone) and reverts the cell's text/selection to the recorded old state. The caller still has to move the cursor to the affected cell and schedule its recalculation/redraw on Applied, or retry the next action on NoOpSkipped - both view/cursor concerns.