diff --git a/src/buffer.cc b/src/buffer.cc index 4e7c2606..56a4350d 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -68,16 +68,10 @@ Buffer::~Buffer() m_options.unregister_watcher(*this); BufferManager::instance().unregister_buffer(*this); m_values.clear(); - kak_assert(m_change_listeners.empty()); } void Buffer::reload(std::vector lines, time_t fs_timestamp) { - // use back coord to simulate the persistance of the last end of line - // as buffers are expected to never be empty. - for (auto listener : m_change_listeners) - listener->on_erase(*this, {0,0}, back_coord(), true); - m_changes.push_back({ Change::Erase, {0,0}, back_coord(), true }); m_history.clear(); @@ -100,9 +94,6 @@ void Buffer::reload(std::vector lines, time_t fs_timestamp) m_fs_timestamp = fs_timestamp; m_changes.push_back({ Change::Insert, {0,0}, back_coord(), true }); - - for (auto listener : m_change_listeners) - listener->on_insert(*this, {0,0}, back_coord(), true); } String Buffer::display_name() const @@ -522,8 +513,6 @@ ByteCoord Buffer::do_insert(ByteCoord pos, const String& content) } m_changes.push_back({ Change::Insert, begin, end, at_end }); - for (auto listener : m_change_listeners) - listener->on_insert(*this, begin, end, at_end); return begin; } @@ -553,8 +542,6 @@ ByteCoord Buffer::do_erase(ByteCoord begin, ByteCoord end) m_lines[i].start -= length; m_changes.push_back({ Change::Erase, begin, end, is_end(begin) }); - for (auto listener : m_change_listeners) - listener->on_erase(*this, begin, end, is_end(begin)); return next; } diff --git a/src/buffer.hh b/src/buffer.hh index f817eef0..3a9b0426 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -63,15 +63,6 @@ private: ByteCoord m_coord; }; -class BufferChangeListener -{ -public: - virtual void on_insert(const Buffer& buffer, - ByteCoord begin, ByteCoord end, bool at_end) = 0; - virtual void on_erase(const Buffer& buffer, - ByteCoord begin, ByteCoord end, bool at_end) = 0; -}; - // A Buffer is a in-memory representation of a file // // The Buffer class permits to read and mutate this file @@ -170,8 +161,6 @@ public: void run_hook_in_own_context(const String& hook_name, const String& param); - std::unordered_set& change_listeners() const { return m_change_listeners; } - void reload(std::vector lines, time_t fs_timestamp = InvalidTime); void check_invariant() const; @@ -230,10 +219,6 @@ private: time_t m_fs_timestamp; - // this is mutable as adding or removing listeners is not muting the - // buffer observable state. - mutable std::unordered_set m_change_listeners; - OptionManager m_options; HookManager m_hooks; KeymapManager m_keymaps; @@ -270,30 +255,6 @@ private: } }; -struct BufferListenerRegisterFuncs -{ - static void insert(const Buffer& buffer, BufferChangeListener& listener) - { - buffer.change_listeners().insert(&listener); - } - static void remove(const Buffer& buffer, BufferChangeListener& listener) - { - buffer.change_listeners().erase(&listener); - } -}; - -class BufferChangeListener_AutoRegister - : public BufferChangeListener, - public AutoRegister -{ -public: - BufferChangeListener_AutoRegister(Buffer& buffer) - : AutoRegister(buffer) {} - - Buffer& buffer() const { return registry(); } -}; - } #include "buffer.inl.hh"