From 252cb0fe25a8cbbce19944033e311203e0fb07dc Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 1 Feb 2024 09:36:08 +1100 Subject: Add UndoAction class as internal type for undo actions and make Action a struct that is used for reporting undo steps to Document. This will allow further minimization of undo memory use. --- src/UndoHistory.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/UndoHistory.h') diff --git a/src/UndoHistory.h b/src/UndoHistory.h index 02b7bd307..423b50a7f 100644 --- a/src/UndoHistory.h +++ b/src/UndoHistory.h @@ -10,11 +10,24 @@ namespace Scintilla::Internal { +class UndoAction { +public: + ActionType at = ActionType::insert; + bool mayCoalesce = false; + Sci::Position position = 0; + std::unique_ptr data; + Sci::Position lenData = 0; + + UndoAction() noexcept; + void Create(ActionType at_, Sci::Position position_ = 0, const char *data_ = nullptr, Sci::Position lenData_ = 0, bool mayCoalesce_ = true); + void Clear() noexcept; +}; + /** * */ class UndoHistory { - std::vector actions; + std::vector actions; int maxAction; int currentAction; int undoSequenceDepth; @@ -53,11 +66,11 @@ public: /// called that many times. Similarly for redo. bool CanUndo() const noexcept; int StartUndo() noexcept; - const Action &GetUndoStep() const noexcept; + const UndoAction &GetUndoStep() const noexcept; void CompletedUndoStep() noexcept; bool CanRedo() const noexcept; int StartRedo() noexcept; - const Action &GetRedoStep() const noexcept; + const UndoAction &GetRedoStep() const noexcept; void CompletedRedoStep() noexcept; }; -- cgit v1.2.3