<space> with a count argument replaces current selections with the counth selection.

This commit is contained in:
Maxime Coste 2012-01-09 14:28:01 +00:00
parent e02cb4e5bd
commit 9557167f26
3 changed files with 15 additions and 1 deletions

View File

@ -775,7 +775,8 @@ std::unordered_map<Key, std::function<void (Window& window, int count)>> keymap
{ { Key::Modifiers::None, ':' }, [](Window& window, int count) { do_command(); } }, { { Key::Modifiers::None, ':' }, [](Window& window, int count) { do_command(); } },
{ { Key::Modifiers::None, '|' }, do_pipe }, { { Key::Modifiers::None, '|' }, do_pipe },
{ { Key::Modifiers::None, ' ' }, [](Window& window, int count) { window.clear_selections(); } }, { { Key::Modifiers::None, ' ' }, [](Window& window, int count) { if (count == 0) window.clear_selections();
else window.keep_selection(count-1); } },
{ { Key::Modifiers::None, 'w' }, [](Window& window, int count) { do { window.select(select_to_next_word); } while(--count > 0); } }, { { Key::Modifiers::None, 'w' }, [](Window& window, int count) { do { window.select(select_to_next_word); } while(--count > 0); } },
{ { Key::Modifiers::None, 'e' }, [](Window& window, int count) { do { window.select(select_to_next_word_end); } while(--count > 0); } }, { { Key::Modifiers::None, 'e' }, [](Window& window, int count) { do { window.select(select_to_next_word_end); } while(--count > 0); } },
{ { Key::Modifiers::None, 'b' }, [](Window& window, int count) { do { window.select(select_to_previous_word); } while(--count > 0); } }, { { Key::Modifiers::None, 'b' }, [](Window& window, int count) { do { window.select(select_to_previous_word); } while(--count > 0); } },

View File

@ -239,6 +239,18 @@ void Window::clear_selections()
selections().push_back(std::move(sel)); selections().push_back(std::move(sel));
} }
void Window::keep_selection(int index)
{
check_invariant();
if (index < selections().size())
{
Selection sel = selections()[index];
selections().clear();
selections().push_back(std::move(sel));
}
}
void Window::select(const Selector& selector, bool append) void Window::select(const Selector& selector, bool append)
{ {
check_invariant(); check_invariant();

View File

@ -73,6 +73,7 @@ public:
void move_cursor_to(const BufferIterator& iterator); void move_cursor_to(const BufferIterator& iterator);
void clear_selections(); void clear_selections();
void keep_selection(int index);
void select(const Selector& selector, bool append = false); void select(const Selector& selector, bool append = false);
void multi_select(const MultiSelector& selector); void multi_select(const MultiSelector& selector);
BufferString selection_content() const; BufferString selection_content() const;