summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2011-10-05 14:24:52 +0000
committerMaxime Coste <frrrwww@gmail.com>2011-10-05 14:24:52 +0000
commitff730380ed2e093a9cf06ae53a5d3dbba76e5f1e (patch)
tree2b6720919c85db84a71dfb3b604e179c0f592fe2 /src
parent4ce349fa023998c83292eef4cc2f56a385e95721 (diff)
Window: empty_selections -> clear_selections
clear_selections also reset select_mode to Normal, most editing operations now do a clear_selections.
Diffstat (limited to 'src')
-rw-r--r--src/main.cc11
-rw-r--r--src/window.cc3
-rw-r--r--src/window.hh2
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<char, std::function<void (Window& window, int count)>> keymap =
@@ -502,7 +505,7 @@ std::unordered_map<char, std::function<void (Window& window, int count)>> 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;