aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/UndoHistory.h
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2024-02-01 09:36:08 +1100
committerNeil <nyamatongwe@gmail.com>2024-02-01 09:36:08 +1100
commit252cb0fe25a8cbbce19944033e311203e0fb07dc (patch)
tree49607a3c6cd32981b5ea53598623e706097251ff /src/UndoHistory.h
parentc6b542f84e65083552e52768db7bb4c11dcd7a64 (diff)
downloadscintilla-mirror-252cb0fe25a8cbbce19944033e311203e0fb07dc.tar.gz
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.
Diffstat (limited to 'src/UndoHistory.h')
-rw-r--r--src/UndoHistory.h19
1 files changed, 16 insertions, 3 deletions
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<char[]> 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<Action> actions;
+ std::vector<UndoAction> 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;
};