alt-space without numeric parameter now flips selections, inverting first and last char
This commit is contained in:
parent
07e5655ac1
commit
3e53ebb5d6
|
@ -158,6 +158,13 @@ void Editor::clear_selections()
|
||||||
m_selections.push_back(std::move(sel));
|
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)
|
void Editor::keep_selection(int index)
|
||||||
{
|
{
|
||||||
check_invariant();
|
check_invariant();
|
||||||
|
|
|
@ -59,6 +59,7 @@ public:
|
||||||
void move_selections(CharCount move,
|
void move_selections(CharCount move,
|
||||||
SelectMode mode = SelectMode::Replace);
|
SelectMode mode = SelectMode::Replace);
|
||||||
void clear_selections();
|
void clear_selections();
|
||||||
|
void flip_selections();
|
||||||
void keep_selection(int index);
|
void keep_selection(int index);
|
||||||
void remove_selection(int index);
|
void remove_selection(int index);
|
||||||
void select(const BufferIterator& iterator);
|
void select(const BufferIterator& iterator);
|
||||||
|
|
|
@ -422,7 +422,7 @@ std::unordered_map<Key, std::function<void (Context& context)>> keymap =
|
||||||
if (count == 0) context.editor().clear_selections();
|
if (count == 0) context.editor().clear_selections();
|
||||||
else context.editor().keep_selection(count-1); } },
|
else context.editor().keep_selection(count-1); } },
|
||||||
{ { Key::Modifiers::Alt, ' ' }, [](Context& context) { int count = context.numeric_param();
|
{ { 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); } },
|
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, '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>); }) },
|
{ { Key::Modifiers::None, 'e' }, repeated([](Context& context) { context.editor().select(select_to_next_word_end<false>); }) },
|
||||||
|
|
Loading…
Reference in New Issue
Block a user