From b03b51d27ace58cc17eb8a3aec99fa20dd3209ab Mon Sep 17 00:00:00 2001 From: Jason Felice Date: Mon, 31 Dec 2018 12:40:49 -0500 Subject: Add 'history' and 'uncommitted_modifications' expansions --- src/buffer.hh | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'src/buffer.hh') 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; + + struct HistoryNode : UseMemoryDomain + { + HistoryNode(HistoryId parent); + + HistoryId parent; + HistoryId redo_child = HistoryId::Invalid; + TimePoint committed; + UndoGroup undo_group; + }; + + const Vector& 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; - - struct HistoryNode : UseMemoryDomain - { - HistoryNode(HistoryId parent); - - HistoryId parent; - HistoryId redo_child = HistoryId::Invalid; - TimePoint timepoint; - UndoGroup undo_group; - }; - Vector m_history; HistoryId m_history_id = HistoryId::Invalid; HistoryId m_last_save_history_id = HistoryId::Invalid; -- cgit v1.2.3