aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/EditModel.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/EditModel.h')
-rw-r--r--src/EditModel.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/EditModel.h b/src/EditModel.h
index e36d26fb1..716fd5788 100644
--- a/src/EditModel.h
+++ b/src/EditModel.h
@@ -21,6 +21,41 @@ public:
Caret() noexcept;
};
+// Simplified version of selection which won't contain rectangular selection realized
+// into ranges as too much data.
+// Just a type and single range for now.
+
+struct SelectionSimple {
+ std::vector<SelectionRange> ranges;
+ SelectionRange rangeRectangular;
+ size_t mainRange = 0;
+ Selection::SelTypes selType = Selection::SelTypes::stream;
+
+ SelectionSimple() = default;
+ explicit SelectionSimple(const Selection &sel);
+};
+
+enum class UndoRedo { undo, redo };
+
+struct SelectionHistory {
+ int indexCurrent = 0;
+ SelectionSimple ssCurrent;
+ std::map<int, SelectionSimple> stack;
+};
+
+struct ModelState : ViewState {
+ SelectionHistory historyForUndo;
+ SelectionHistory historyForRedo;
+ void RememberSelectionForUndo(int index, const Selection &sel);
+ void ForgetSelectionForUndo() noexcept;
+ void RememberSelectionOntoStack(int index);
+ void RememberSelectionForRedoOntoStack(int index, const Selection &sel);
+ const SelectionSimple *SelectionFromStack(int index, UndoRedo history) const;
+ virtual void TruncateUndo(int index) final;
+};
+
+using ModelStateShared = std::shared_ptr<ModelState>;
+
class EditModel {
public:
bool inOverstrike;
@@ -57,6 +92,10 @@ public:
Document *pdoc;
+ bool rememberingSelectionForUndo = false;
+ bool needRedoRemembered = false;
+ ModelStateShared modelState;
+
EditModel();
// Deleted so EditModel objects can not be copied.
EditModel(const EditModel &) = delete;
@@ -75,6 +114,8 @@ public:
const char *GetFoldDisplayText(Sci::Line lineDoc) const noexcept;
InSelection LineEndInSelection(Sci::Line lineDoc) const;
[[nodiscard]] int GetMark(Sci::Line line) const;
+
+ void EnsureModelState();
};
}