aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/CellBuffer.h
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2024-02-01 08:56:45 +1100
committerNeil <nyamatongwe@gmail.com>2024-02-01 08:56:45 +1100
commitc6b542f84e65083552e52768db7bb4c11dcd7a64 (patch)
treee97a615381f422e67df985b18b3a50a56cb5590b /src/CellBuffer.h
parent1345bb5b0e10e213fb1943fe491679d6fe45e9b0 (diff)
downloadscintilla-mirror-c6b542f84e65083552e52768db7bb4c11dcd7a64.tar.gz
Move UndoHistory into its own module that is accessible from CellBuffer and
tests but hidden from most of Scintilla. Access through std::unique_ptr.
Diffstat (limited to 'src/CellBuffer.h')
-rw-r--r--src/CellBuffer.h55
1 files changed, 3 insertions, 52 deletions
diff --git a/src/CellBuffer.h b/src/CellBuffer.h
index 701472f4f..d71287d1b 100644
--- a/src/CellBuffer.h
+++ b/src/CellBuffer.h
@@ -20,7 +20,9 @@ public:
virtual void RemoveLine(Sci::Line line)=0;
};
+class UndoHistory;
class ChangeHistory;
+
/**
* The line vector contains information about each of the lines in a cell buffer.
*/
@@ -44,57 +46,6 @@ public:
void Clear() noexcept;
};
-/**
- *
- */
-class UndoHistory {
- std::vector<Action> actions;
- int maxAction;
- int currentAction;
- int undoSequenceDepth;
- int savePoint;
- int tentativePoint;
- std::optional<int> detach;
-
- void EnsureUndoRoom();
-
-public:
- UndoHistory();
-
- const char *AppendAction(ActionType at, Sci::Position position, const char *data, Sci::Position lengthData, bool &startSequence, bool mayCoalesce=true);
-
- void BeginUndoAction();
- void EndUndoAction();
- void DropUndoSequence() noexcept;
- void DeleteUndoHistory();
-
- /// The save point is a marker in the undo stack where the container has stated that
- /// the buffer was saved. Undo and redo can move over the save point.
- void SetSavePoint() noexcept;
- bool IsSavePoint() const noexcept;
- bool BeforeSavePoint() const noexcept;
- bool BeforeReachableSavePoint() const noexcept;
- bool AfterSavePoint() const noexcept;
- bool AfterDetachPoint() const noexcept;
-
- // Tentative actions are used for input composition so that it can be undone cleanly
- void TentativeStart() noexcept;
- void TentativeCommit() noexcept;
- bool TentativeActive() const noexcept;
- int TentativeSteps() noexcept;
-
- /// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
- /// called that many times. Similarly for redo.
- bool CanUndo() const noexcept;
- int StartUndo() noexcept;
- const Action &GetUndoStep() const noexcept;
- void CompletedUndoStep() noexcept;
- bool CanRedo() const noexcept;
- int StartRedo() noexcept;
- const Action &GetRedoStep() const noexcept;
- void CompletedRedoStep() noexcept;
-};
-
struct SplitView {
const char *segment1 = nullptr;
size_t length1 = 0;
@@ -137,7 +88,7 @@ private:
Scintilla::LineEndType utf8LineEnds;
bool collectingUndo;
- UndoHistory uh;
+ std::unique_ptr<UndoHistory> uh;
std::unique_ptr<ChangeHistory> changeHistory;