alt-space without numeric parameter now flips selections, inverting first and last char

This commit is contained in:
Maxime Coste 2012-11-19 19:03:56 +01:00
parent 07e5655ac1
commit 3e53ebb5d6
3 changed files with 9 additions and 1 deletions

View File

@ -158,6 +158,13 @@ void Editor::clear_selections()
m_selections.push_back(std::move(sel));
}
void Editor::flip_selections()
{
check_invariant();
for (auto& sel : m_selections)
std::swap(sel.selection.first(), sel.selection.last());
}
void Editor::keep_selection(int index)
{
check_invariant();

View File

@ -59,6 +59,7 @@ public:
void move_selections(CharCount move,
SelectMode mode = SelectMode::Replace);
void clear_selections();
void flip_selections();
void keep_selection(int index);
void remove_selection(int index);
void select(const BufferIterator& iterator);

View File

@ -422,7 +422,7 @@ std::unordered_map<Key, std::function<void (Context& context)>> keymap =
if (count == 0) context.editor().clear_selections();
else context.editor().keep_selection(count-1); } },
{ { Key::Modifiers::Alt, ' ' }, [](Context& context) { int count = context.numeric_param();
if (count == 0) context.editor().clear_selections();
if (count == 0) context.editor().flip_selections();
else context.editor().remove_selection(count-1); } },
{ { Key::Modifiers::None, 'w' }, repeated([](Context& context) { context.editor().select(select_to_next_word<false>); }) },
{ { Key::Modifiers::None, 'e' }, repeated([](Context& context) { context.editor().select(select_to_next_word_end<false>); }) },