diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2012-01-25 14:23:02 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2012-01-25 14:23:02 +0000 |
| commit | d1c29d2b78d22b2c75bf46c6740acb69ab4aad76 (patch) | |
| tree | dc9428e0737e2070fa557ffca1b0034fb7db380e /src/window.cc | |
| parent | 81138b224ff4c119229b9ace0459c7b64e807f5c (diff) | |
moving no longer clears multiple selections
Diffstat (limited to 'src/window.cc')
| -rw-r--r-- | src/window.cc | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/window.cc b/src/window.cc index ff583ea3..2ab34423 100644 --- a/src/window.cc +++ b/src/window.cc @@ -258,16 +258,13 @@ void Window::select(const Selector& selector, bool append) if (not append) { - Selection sel = selector(selections().back().last()); - selections().clear(); - selections().push_back(std::move(sel)); + for (auto& sel : selections()) + sel = selector(sel.last()); } else { for (auto& sel : selections()) - { sel.merge_with(selector(sel.last())); - } } scroll_to_keep_cursor_visible_ifn(); } @@ -303,22 +300,15 @@ BufferString Window::selection_content() const selections().back().end()); } -void Window::move_cursor(const DisplayCoord& offset, bool append) +void Window::move_selections(const DisplayCoord& offset, bool append) { - if (not append) - { - BufferCoord pos = m_buffer.line_and_column_at(cursor_iterator()); - move_cursor_to(m_buffer.iterator_at(pos + BufferCoord(offset))); - } - else + for (auto& sel : selections()) { - for (auto& sel : selections()) - { - BufferCoord pos = m_buffer.line_and_column_at(sel.last()); - sel = Selection(sel.first(), m_buffer.iterator_at(pos + BufferCoord(offset))); - } - scroll_to_keep_cursor_visible_ifn(); + BufferCoord pos = m_buffer.line_and_column_at(sel.last()); + BufferIterator last = m_buffer.iterator_at(pos + BufferCoord(offset)); + sel = Selection(append ? sel.first() : last, last); } + scroll_to_keep_cursor_visible_ifn(); } void Window::move_cursor_to(const BufferIterator& iterator) @@ -461,7 +451,7 @@ IncrementalInserter::IncrementalInserter(Window& window, Mode mode) IncrementalInserter::~IncrementalInserter() { - move_cursor(DisplayCoord(0, -1)); + move_cursors(DisplayCoord(0, -1)); m_window.push_selections(); m_window.hooks_manager().run_hook("InsertEnd", "", Context(m_window)); @@ -505,7 +495,7 @@ void IncrementalInserter::erase() m_window.scroll_to_keep_cursor_visible_ifn(); } -void IncrementalInserter::move_cursor(const DisplayCoord& offset) +void IncrementalInserter::move_cursors(const DisplayCoord& offset) { for (auto& sel : m_window.selections()) { |
