From 662ba0c904530fff306eaafe5fa347fee71ff67a Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 23 Sep 2011 09:17:19 +0000 Subject: Selection: do not use [begin, end) semantics but [first, last] selections are now defined with inclusive iterators, which means that Selection(cursor, cursor) is a valid selection of the charateter pointed by cursor. On the user interface side, that means that the cursor is now part of the selection, selectors were adapted to this behavior (and word selectors are now much more intuitive) --- src/window.hh | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'src/window.hh') diff --git a/src/window.hh b/src/window.hh index 2506025b..9dafed25 100644 --- a/src/window.hh +++ b/src/window.hh @@ -19,27 +19,20 @@ struct WindowCoord : LineAndColumn struct Selection { - Selection(const BufferIterator& begin, const BufferIterator& end) - : m_begin(begin), m_end(end) {} + Selection(const BufferIterator& first, const BufferIterator& last) + : m_first(first), m_last(last) {} - const BufferIterator& begin() const { return m_begin; } - const BufferIterator& end() const { return m_end; } + BufferIterator begin() const; + BufferIterator end() const; - void canonicalize() - { - if (m_end < m_begin) - std::swap(++m_begin, ++m_end); - } + const BufferIterator& first() const { return m_first; } + const BufferIterator& last() const { return m_last; } - void offset(int offset) - { - m_begin += offset; - m_end += offset; - } + void offset(int offset); private: - BufferIterator m_begin; - BufferIterator m_end; + BufferIterator m_first; + BufferIterator m_last; }; typedef std::vector SelectionList; -- cgit v1.2.3