From 31c0931dffbbf100ddcf1f2f2edc0d830fec8f39 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 16 Jul 2012 21:51:37 +0200 Subject: Go back to a generic BufferChangeListener interface for selection update --- src/selection.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/selection.cc') diff --git a/src/selection.cc b/src/selection.cc index 46a38e0f..a892e9fc 100644 --- a/src/selection.cc +++ b/src/selection.cc @@ -54,18 +54,28 @@ void Selection::merge_with(const Selection& selection) m_last = selection.m_last; } +void Selection::on_insert(const BufferIterator& begin, const BufferIterator& end) +{ + m_first.on_insert(begin.coord(), end.coord()); + m_last.on_insert(begin.coord(), end.coord()); +} + +void Selection::on_erase(const BufferIterator& begin, const BufferIterator& end) +{ + m_first.on_erase(begin.coord(), end.coord()); + m_last.on_erase(begin.coord(), end.coord()); +} + void Selection::register_with_buffer() { Buffer& buffer = const_cast(m_first.buffer()); - buffer.add_iterator_to_update(m_first); - buffer.add_iterator_to_update(m_last); + buffer.add_change_listener(*this); } void Selection::unregister_with_buffer() { Buffer& buffer = const_cast(m_first.buffer()); - buffer.remove_iterator_from_update(m_first); - buffer.remove_iterator_from_update(m_last); + buffer.remove_change_listener(*this); } } -- cgit v1.2.3