diff options
Diffstat (limited to 'src/selection.hh')
| -rw-r--r-- | src/selection.hh | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/src/selection.hh b/src/selection.hh index 8ea0fa97..83246a9c 100644 --- a/src/selection.hh +++ b/src/selection.hh @@ -21,11 +21,17 @@ public: const BufferIterator& first() const { return m_first; } const BufferIterator& last() const { return m_last; } + bool operator== (const Range& other) const + { + return m_first == other.m_first and m_last == other.m_last; + } + // returns min(first, last) BufferIterator begin() const; // returns max(first, last) + 1 BufferIterator end() const; + void check_invariant() const; private: BufferIterator m_first; BufferIterator m_last; @@ -40,33 +46,19 @@ inline bool overlaps(const Range& lhs, const Range& rhs) using CaptureList = std::vector<String>; // A selection is a Range, associated with a CaptureList -// that updates itself when the buffer it points to gets modified. -struct Selection : public Range, public BufferChangeListener +struct Selection : public Range { Selection(const BufferIterator& first, const BufferIterator& last, - CaptureList captures = {}); - Selection(Selection&& other); - Selection(const Selection& other); - ~Selection(); - - Selection& operator=(const Selection& other); - Selection& operator=(Selection&& other); + CaptureList captures = {}) + : Range(first, last), m_captures(std::move(captures)) {} void avoid_eol(); CaptureList& captures() { return m_captures; } const CaptureList& captures() const { return m_captures; } + const Buffer& buffer() const { return first().buffer(); } private: - void on_insert(const BufferIterator& begin, - const BufferIterator& end) override; - void on_erase(const BufferIterator& begin, - const BufferIterator& end) override; - - void check_invariant() const; - - void register_with_buffer(); - void unregister_with_buffer(); CaptureList m_captures; }; @@ -75,4 +67,3 @@ using SelectionList = std::vector<Selection>; } #endif // selection_hh_INCLUDED - |
