diff options
| author | Johannes Altmanninger <aclopte@gmail.com> | 2022-12-03 16:50:29 +0100 |
|---|---|---|
| committer | Johannes Altmanninger <aclopte@gmail.com> | 2022-12-27 18:24:55 +0100 |
| commit | a50cb5f6e7969183c69b56578ad63cb61fe06227 (patch) | |
| tree | f12f9e568eca2c4d786f8a12037b8dc525dd6991 /src/context.hh | |
| parent | 938be7a7b0fb0753329bc74735e4d9d2132ea28c (diff) | |
Share logic for undo/redo selection changes
I will suggest a few changes to this code.
No functional change.
Diffstat (limited to 'src/context.hh')
| -rw-r--r-- | src/context.hh | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/context.hh b/src/context.hh index 5ef3c42c..cf7b7a67 100644 --- a/src/context.hh +++ b/src/context.hh @@ -19,6 +19,8 @@ class DisplayLine; class KeymapManager; class AliasRegistry; +enum Direction { Backward = -1, Forward = 1 }; + struct JumpList { void push(SelectionList jump, Optional<size_t> index = {}); @@ -91,8 +93,8 @@ public: SelectionList& selections_write_only(); void end_selection_edition() { m_selection_history.end_edition(); } + template<Direction direction> void undo_selection_change(); - void redo_selection_change(); void change_buffer(Buffer& buffer, Optional<FunctionRef<void()>> set_selection = {}); void forget_buffer(Buffer& buffer); @@ -170,8 +172,8 @@ private: void end_edition(); bool in_edition() const { return m_in_edition; } + template<Direction direction> void undo(); - void redo(); void forget_buffer(Buffer& buffer); private: enum class HistoryId : size_t { First = 0, Invalid = (size_t)-1 }; |
