From 99bb24dd099d37f4db702765802dc1f05bf6ad87 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 11 Apr 2013 21:01:27 +0200 Subject: [PATCH] add z prefixed 'window commands' * zz or zc for centering selection on window (replaces alt-c) * zt and zb for placing the main selection on top/bottom --- src/main.cc | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main.cc b/src/main.cc index 2bc487fc..9c2f8d32 100644 --- a/src/main.cc +++ b/src/main.cc @@ -148,6 +148,29 @@ void do_go(Context& context) }); } +void do_disp_cmd(Context& context) +{ + context.input_handler().on_next_key([](const Key& key, Context& context) { + if (key.modifiers != Key::Modifiers::None or not context.has_window()) + return; + + Window& window = context.window(); + switch (tolower(key.key)) + { + case 'z': + case 'c': + context.window().center_selection(); + break; + case 't': + context.window().display_selection_at(0); + break; + case 'b': + context.window().display_selection_at(window.dimensions().line-1); + break; + } + }); +} + void do_replace_with_char(Context& context) { context.input_handler().on_next_key([](const Key& key, Context& context) { @@ -722,6 +745,8 @@ std::unordered_map> keymap = { { Key::Modifiers::None, 'g' }, do_go }, { { Key::Modifiers::None, 'G' }, do_go }, + { { Key::Modifiers::None, 'z' }, do_disp_cmd }, + { { Key::Modifiers::None, 'y' }, do_yank }, { { Key::Modifiers::None, 'Y' }, do_cat_yank }, { { Key::Modifiers::None, 'p' }, repeated(do_paste) }, @@ -796,8 +821,6 @@ std::unordered_map> keymap = { { Key::Modifiers::None, '<' }, do_deindent }, { { Key::Modifiers::None, '>' }, do_indent }, - { { Key::Modifiers::Alt, 'c' }, [](Context& context) { if (context.has_window()) context.window().center_selection(); } }, - { { Key::Modifiers::None, Key::PageUp }, do_scroll }, { { Key::Modifiers::None, Key::PageDown }, do_scroll },