diff options
| author | Jason Felice <jason.m.felice@gmail.com> | 2018-12-31 12:40:49 -0500 |
|---|---|---|
| committer | Jason Felice <jason.m.felice@gmail.com> | 2020-01-01 19:47:29 -0500 |
| commit | b03b51d27ace58cc17eb8a3aec99fa20dd3209ab (patch) | |
| tree | dc9fa1bcf2d259834f8f31cd4c3c8aac9b816892 /src/buffer.hh | |
| parent | 62b4780e07e152e037e29823bfd7d911b9767f2e (diff) | |
Add 'history' and 'uncommitted_modifications' expansions
Diffstat (limited to 'src/buffer.hh')
| -rw-r--r-- | src/buffer.hh | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/src/buffer.hh b/src/buffer.hh index 0700acb9..73e5b370 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -230,14 +230,40 @@ public: void on_unregistered(); void throw_if_read_only() const; + + // A Modification holds a single atomic modification to Buffer + struct Modification + { + enum Type { Insert, Erase }; + + Type type; + BufferCoord coord; + StringDataPtr content; + + Modification inverse() const; + }; + + using UndoGroup = Vector<Modification, MemoryDomain::BufferMeta>; + + struct HistoryNode : UseMemoryDomain<MemoryDomain::BufferMeta> + { + HistoryNode(HistoryId parent); + + HistoryId parent; + HistoryId redo_child = HistoryId::Invalid; + TimePoint committed; + UndoGroup undo_group; + }; + + const Vector<HistoryNode>& history() const { return m_history; } + const UndoGroup& current_undo_group() const { return m_current_undo_group; } + private: void on_option_changed(const Option& option) override; BufferRange do_insert(BufferCoord pos, StringView content); BufferCoord do_erase(BufferCoord begin, BufferCoord end); - struct Modification; - void apply_modification(const Modification& modification); void revert_modification(const Modification& modification); @@ -264,18 +290,6 @@ private: String m_display_name; Flags m_flags; - using UndoGroup = Vector<Modification, MemoryDomain::BufferMeta>; - - struct HistoryNode : UseMemoryDomain<MemoryDomain::BufferMeta> - { - HistoryNode(HistoryId parent); - - HistoryId parent; - HistoryId redo_child = HistoryId::Invalid; - TimePoint timepoint; - UndoGroup undo_group; - }; - Vector<HistoryNode> m_history; HistoryId m_history_id = HistoryId::Invalid; HistoryId m_last_save_history_id = HistoryId::Invalid; |
