diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2012-05-29 11:15:43 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2012-05-29 11:15:43 +0000 |
| commit | 2c4bc5582acccae9b41f8ff441ffac82f3731aed (patch) | |
| tree | 2da351a11061046e94d8a12770f276ecb3d2579e /src | |
| parent | 3bfd774f4912c2397734076ec70d298dae1fe51e (diff) | |
Alt-Space permits to remove a selection by index
Diffstat (limited to 'src')
| -rw-r--r-- | src/editor.cc | 8 | ||||
| -rw-r--r-- | src/editor.hh | 1 | ||||
| -rw-r--r-- | src/main.cc | 2 |
3 files changed, 11 insertions, 0 deletions
diff --git a/src/editor.cc b/src/editor.cc index d1253705..c0e9267a 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -136,6 +136,14 @@ void Editor::keep_selection(int index) } } +void Editor::remove_selection(int index) +{ + check_invariant(); + + if (selections().size() > 1 and index < selections().size()) + m_selections.back().erase(m_selections.back().begin() + index); +} + void Editor::select(const BufferIterator& iterator) { m_selections.back().clear(); diff --git a/src/editor.hh b/src/editor.hh index b41e0a81..5b6750d4 100644 --- a/src/editor.hh +++ b/src/editor.hh @@ -43,6 +43,7 @@ public: void move_selections(const BufferCoord& offset, bool append = false); void clear_selections(); void keep_selection(int index); + void remove_selection(int index); void select(const BufferIterator& iterator); void select(const Selector& selector, bool append = false); void multi_select(const MultiSelector& selector); diff --git a/src/main.cc b/src/main.cc index 41e4595d..74d39d9b 100644 --- a/src/main.cc +++ b/src/main.cc @@ -388,6 +388,8 @@ std::unordered_map<Key, std::function<void (Editor& editor, int count)>> keymap { { Key::Modifiers::None, '|' }, do_pipe }, { { Key::Modifiers::None, ' ' }, [](Editor& editor, int count) { if (count == 0) editor.clear_selections(); else editor.keep_selection(count-1); } }, + { { Key::Modifiers::Alt, ' ' }, [](Editor& editor, int count) { if (count == 0) editor.clear_selections(); + else editor.remove_selection(count-1); } }, { { Key::Modifiers::None, 'w' }, [](Editor& editor, int count) { do { editor.select(select_to_next_word<false>); } while(--count > 0); } }, { { Key::Modifiers::None, 'e' }, [](Editor& editor, int count) { do { editor.select(select_to_next_word_end<false>); } while(--count > 0); } }, { { Key::Modifiers::None, 'b' }, [](Editor& editor, int count) { do { editor.select(select_to_previous_word<false>); } while(--count > 0); } }, |
