summaryrefslogtreecommitdiff
path: root/src/dynamic_buffer_iterator.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2011-10-24 14:26:21 +0000
committerMaxime Coste <frrrwww@gmail.com>2011-10-24 14:26:21 +0000
commitd2c6ceb47b532d125c3cafffdca79fada54ee21f (patch)
treee13757428f023d134cf0ba51bfab880a60c8ae40 /src/dynamic_buffer_iterator.hh
parentbace526fa31f1ce9fbc89a1c468f2dc91bee8845 (diff)
DynamicBufferIterator: add and use in Selections
DynamicBufferIterator are a new type of BufferIterators that automatically update themselves when their buffer is modified. Selections now uses this type of iterators instead of plain ones
Diffstat (limited to 'src/dynamic_buffer_iterator.hh')
-rw-r--r--src/dynamic_buffer_iterator.hh35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/dynamic_buffer_iterator.hh b/src/dynamic_buffer_iterator.hh
new file mode 100644
index 00000000..17e74485
--- /dev/null
+++ b/src/dynamic_buffer_iterator.hh
@@ -0,0 +1,35 @@
+#ifndef dynamic_buffer_iterator_hh_INCLUDED
+#define dynamic_buffer_iterator_hh_INCLUDED
+
+#include "buffer.hh"
+
+namespace Kakoune
+{
+
+class DynamicBufferIterator : public BufferIterator,
+ public BufferModificationListener
+{
+public:
+ DynamicBufferIterator() : BufferIterator() {}
+ DynamicBufferIterator(const Buffer& buffer, BufferPos position);
+ DynamicBufferIterator(const BufferIterator& other);
+ DynamicBufferIterator(const DynamicBufferIterator& other)
+ : BufferIterator(other) { register_ifp(); }
+
+ DynamicBufferIterator(DynamicBufferIterator&& other);
+ DynamicBufferIterator& operator=(const BufferIterator& other);
+ DynamicBufferIterator& operator=(const DynamicBufferIterator& other)
+ { return this->operator= (static_cast<const BufferIterator&>(other)); }
+ ~DynamicBufferIterator();
+
+ void on_modification(const BufferModification& modification);
+
+private:
+ void register_ifp();
+ void unregister_ifn();
+};
+
+
+}
+
+#endif // dynamic_buffer_iterator_hh_INCLUDED