diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2011-09-23 14:06:10 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2011-09-23 14:06:10 +0000 |
| commit | 52ad372adbef14f0acec0e69edc3678284abafdd (patch) | |
| tree | b14bc42516297351cae7faad89c6c1d9134d42e1 /src | |
| parent | 662ba0c904530fff306eaafe5fa347fee71ff67a (diff) | |
Selectors: support inclusive mode in select_to (bound to f key)
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cc | 3 | ||||
| -rw-r--r-- | src/selectors.cc | 4 | ||||
| -rw-r--r-- | src/selectors.hh | 2 |
3 files changed, 5 insertions, 4 deletions
diff --git a/src/main.cc b/src/main.cc index dc69b056..ea976a45 100644 --- a/src/main.cc +++ b/src/main.cc @@ -368,7 +368,8 @@ std::unordered_map<char, std::function<void (Window& window, int count)>> keymap { 'L', [](Window& window, int count) { window.select(true, std::bind(move_select, std::ref(window), std::placeholders::_1, WindowCoord(0, std::max(count,1)))); } }, - { 't', [](Window& window, int count) { window.select(false, std::bind(select_to, std::placeholders::_1, getch())); } }, + { 't', [](Window& window, int count) { window.select(false, std::bind(select_to, std::placeholders::_1, getch(), false)); } }, + { 'f', [](Window& window, int count) { window.select(false, std::bind(select_to, std::placeholders::_1, getch(), true)); } }, { 'd', [](Window& window, int count) { window.erase(); window.empty_selections(); } }, { 'c', [](Window& window, int count) { window.erase(); do_insert(window); } }, diff --git a/src/selectors.cc b/src/selectors.cc index 2b73d370..155d7be6 100644 --- a/src/selectors.cc +++ b/src/selectors.cc @@ -191,12 +191,12 @@ Selection select_matching(const BufferIterator& cursor) return Selection(cursor, cursor); } -Selection select_to(const BufferIterator& cursor, char c) +Selection select_to(const BufferIterator& cursor, char c, bool inclusive) { BufferIterator end = cursor + 1; skip_while(end, [c](char cur) { return not is_eol(cur) and cur != c; }); if (not is_eol(*end)) - return Selection(cursor, end-1); + return Selection(cursor, inclusive ? end : end-1); return Selection(cursor, cursor); } diff --git a/src/selectors.hh b/src/selectors.hh index 0d9adc64..0fe6136b 100644 --- a/src/selectors.hh +++ b/src/selectors.hh @@ -12,7 +12,7 @@ Selection select_to_previous_word(const BufferIterator& cursor); Selection select_line(const BufferIterator& cursor); Selection move_select(Window& window, const BufferIterator& cursor, const WindowCoord& offset); Selection select_matching(const BufferIterator& cursor); -Selection select_to(const BufferIterator& cursor, char c); +Selection select_to(const BufferIterator& cursor, char c, bool inclusive); } |
