diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2016-07-20 09:41:45 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2016-07-24 21:25:05 +0100 |
| commit | 3edd2c127c9d1754a487d76de38ec9b2c690ff7c (patch) | |
| tree | 8c292c3cc062b896a766468931ac60936505e5a6 /src/buffer.hh | |
| parent | b9c77e2f09f34985aec83b6f5e5e9dc4b942af2f (diff) | |
Support moving between arbitrary history nodes
Diffstat (limited to 'src/buffer.hh')
| -rw-r--r-- | src/buffer.hh | 13 |
1 files changed, 10 insertions, 3 deletions
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<MemoryDomain::BufferMeta> { - HistoryNode(HistoryNode* parent); + HistoryNode(size_t id, HistoryNode* parent); + size_t id; SafePtr<HistoryNode> parent; UndoGroup undo_group; Vector<std::unique_ptr<HistoryNode>, MemoryDomain::BufferMeta> childs; @@ -254,11 +256,16 @@ private: TimePoint timepoint; }; + size_t m_next_history_id = 0; HistoryNode m_history; SafePtr<HistoryNode> m_history_cursor; SafePtr<HistoryNode> m_last_save_history_cursor; UndoGroup m_current_undo_group; + void move_to(HistoryNode* history_node) noexcept; + + template<typename Func> HistoryNode* find_history_node(HistoryNode* node, const Func& func); + Vector<Change, MemoryDomain::BufferMeta> m_changes; timespec m_fs_timestamp; |
