From 8275fe30f9d4534578040464766e2119874d4370 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 28 Feb 2012 20:50:47 +0000 Subject: [PATCH] support appending with search --- src/main.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.cc b/src/main.cc index 1d848f43..bde3aa47 100644 --- a/src/main.cc +++ b/src/main.cc @@ -596,6 +596,7 @@ void do_pipe(Editor& editor, int count) catch (prompt_aborted&) {} } +template void do_search(Editor& editor) { try @@ -606,16 +607,17 @@ void do_search(Editor& editor) else RegisterManager::instance()['/'] = ex; - editor.select(std::bind(select_next_match, _1, ex)); + editor.select(std::bind(select_next_match, _1, ex), append); } catch (prompt_aborted&) {} } +template void do_search_next(Editor& editor) { const std::string& ex = RegisterManager::instance()['/'].get(); if (not ex.empty()) - editor.select(std::bind(select_next_match, _1, ex)); + editor.select(std::bind(select_next_match, _1, ex), append); else NCurses::print_status("no search pattern"); } @@ -766,8 +768,12 @@ std::unordered_map> keymap { { Key::Modifiers::None, 'X' }, [](Editor& editor, int count) { do { editor.select(select_line, true); } while(--count > 0); } }, { { Key::Modifiers::None, 'm' }, [](Editor& editor, int count) { editor.select(select_matching); } }, { { Key::Modifiers::None, 'M' }, [](Editor& editor, int count) { editor.select(select_matching, true); } }, - { { Key::Modifiers::None, '/' }, [](Editor& editor, int count) { do_search(editor); } }, - { { Key::Modifiers::None, 'n' }, [](Editor& editor, int count) { do_search_next(editor); } }, + + { { Key::Modifiers::None, '/' }, [](Editor& editor, int count) { do_search(editor); } }, + { { Key::Modifiers::None, '?' }, [](Editor& editor, int count) { do_search(editor); } }, + { { Key::Modifiers::None, 'n' }, [](Editor& editor, int count) { do_search_next(editor); } }, + { { Key::Modifiers::None, 'N' }, [](Editor& editor, int count) { do_search_next(editor); } }, + { { Key::Modifiers::None, 'u' }, [](Editor& editor, int count) { do { if (not editor.undo()) { NCurses::print_status("nothing left to undo"); break; } } while(--count > 0); } }, { { Key::Modifiers::None, 'U' }, [](Editor& editor, int count) { do { if (not editor.redo()) { NCurses::print_status("nothing left to redo"); break; } } while(--count > 0); } },