From 3edd2c127c9d1754a487d76de38ec9b2c690ff7c Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 20 Jul 2016 09:41:45 +0100 Subject: Support moving between arbitrary history nodes --- src/buffer.hh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/buffer.hh') diff --git a/src/buffer.hh b/src/buffer.hh index cd136476..be510a79 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -132,8 +132,9 @@ public: void set_fs_timestamp(timespec ts); void commit_undo_group(); - bool undo(); - bool redo(); + bool undo() noexcept; + bool redo() noexcept; + bool move_to(size_t history_id) noexcept; String string(ByteCoord begin, ByteCoord end) const; @@ -245,8 +246,9 @@ private: struct HistoryNode : SafeCountable, UseMemoryDomain { - HistoryNode(HistoryNode* parent); + HistoryNode(size_t id, HistoryNode* parent); + size_t id; SafePtr parent; UndoGroup undo_group; Vector, MemoryDomain::BufferMeta> childs; @@ -254,11 +256,16 @@ private: TimePoint timepoint; }; + size_t m_next_history_id = 0; HistoryNode m_history; SafePtr m_history_cursor; SafePtr m_last_save_history_cursor; UndoGroup m_current_undo_group; + void move_to(HistoryNode* history_node) noexcept; + + template HistoryNode* find_history_node(HistoryNode* node, const Func& func); + Vector m_changes; timespec m_fs_timestamp; -- cgit v1.2.3