diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2011-09-23 09:17:19 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2011-09-23 09:17:19 +0000 |
| commit | 662ba0c904530fff306eaafe5fa347fee71ff67a (patch) | |
| tree | a42843cfe337afe627bbe6c8a22c4c8d6c290870 /src/window.hh | |
| parent | 5ca901644f98f88d9fcfd751d8d6ee580de0147d (diff) | |
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)
Diffstat (limited to 'src/window.hh')
| -rw-r--r-- | src/window.hh | 25 |
1 files changed, 9 insertions, 16 deletions
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<WindowCoord> 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<Selection> SelectionList; |
