From ff730380ed2e093a9cf06ae53a5d3dbba76e5f1e Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 5 Oct 2011 14:24:52 +0000 Subject: [PATCH] Window: empty_selections -> clear_selections clear_selections also reset select_mode to Normal, most editing operations now do a clear_selections. --- src/main.cc | 11 +++++++---- src/window.cc | 3 ++- src/window.hh | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main.cc b/src/main.cc index 99965f7e..12513d0e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -314,6 +314,7 @@ void do_insert(Window& window, IncrementalInserter::Mode mode) } draw_window(window); } + window.clear_selections(); } void do_go(Window& window, int count) @@ -447,18 +448,19 @@ void do_search_next(Window& window) void do_yank(Window& window, int count) { RegisterManager::instance()['"'] = window.selection_content(); + window.clear_selections(); } void do_erase(Window& window, int count) { - do_yank(window, 0); + RegisterManager::instance()['"'] = window.selection_content(); window.erase(); - window.empty_selections(); + window.clear_selections(); } void do_change(Window& window, int count) { - do_yank(window, 0); + RegisterManager::instance()['"'] = window.selection_content(); do_insert(window, IncrementalInserter::Mode::Change); } @@ -469,6 +471,7 @@ void do_paste(Window& window, int count) window.append(RegisterManager::instance()['"']); else window.insert(RegisterManager::instance()['"']); + window.clear_selections(); } std::unordered_map> keymap = @@ -502,7 +505,7 @@ std::unordered_map> keymap { return Selection(cursor.buffer().begin(), cursor.buffer().end()-1); }); } }, { ':', [](Window& window, int count) { do_command(); } }, - { ' ', [](Window& window, int count) { window.empty_selections(); } }, + { ' ', [](Window& window, int count) { window.clear_selections(); } }, { 'w', [](Window& window, int count) { do { window.select(select_to_next_word); } while(--count > 0); } }, { 'e', [](Window& window, int count) { do { window.select(select_to_next_word_end); } while(--count > 0); } }, { 'b', [](Window& window, int count) { do { window.select(select_to_previous_word); } while(--count > 0); } }, diff --git a/src/window.cc b/src/window.cc index 34baaee6..21666dd2 100644 --- a/src/window.cc +++ b/src/window.cc @@ -222,13 +222,14 @@ WindowCoord Window::line_and_column_at(const BufferIterator& iterator) const return buffer_to_window(m_buffer.line_and_column_at(iterator)); } -void Window::empty_selections() +void Window::clear_selections() { check_invariant(); Selection sel = Selection(m_selections.back().last(), m_selections.back().last()); m_selections.clear(); m_selections.push_back(std::move(sel)); + m_select_mode = SelectMode::Normal; } void Window::select(const Selector& selector) diff --git a/src/window.hh b/src/window.hh index a5ea7a08..8b8eb3fe 100644 --- a/src/window.hh +++ b/src/window.hh @@ -70,7 +70,7 @@ public: void move_cursor(const WindowCoord& offset); void move_cursor_to(const WindowCoord& new_pos); - void empty_selections(); + void clear_selections(); void select(const Selector& selector); BufferString selection_content() const;