From 9c5cd0ebb51350c05d3fc3496851f43a209f84ec Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 9 Sep 2022 19:40:19 +0200 Subject: Do not require ctrl for vim keys for manga and matrix --- src/Body.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/Body.cpp') diff --git a/src/Body.cpp b/src/Body.cpp index 5a72165..5de0c56 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -471,23 +471,24 @@ namespace QuickMedia { } } - bool Body::on_event(const mgl::Window &window, const mgl::Event &event, bool keyboard_navigation) { + bool Body::on_event(const mgl::Window &window, const mgl::Event &event, bool keyboard_navigation, bool vim_keys_require_ctrl) { if(keyboard_navigation && event.type == mgl::Event::KeyPressed && !event.key.alt) { const bool rendering_card_view = card_view && card_view_enabled; + const bool vim_keys_valid = (vim_keys_require_ctrl && event.key.control) || !vim_keys_require_ctrl; - if(event.key.code == mgl::Keyboard::Up || (event.key.control && event.key.code == mgl::Keyboard::K)) { + if(event.key.code == mgl::Keyboard::Up || (vim_keys_valid && event.key.code == mgl::Keyboard::K)) { render_selected_item_bg = true; bool top_reached = select_previous_item(true); if(!top_reached && on_top_reached) on_top_reached(); return true; - } else if(event.key.code == mgl::Keyboard::Down || (event.key.control && event.key.code == mgl::Keyboard::J)) { + } else if(event.key.code == mgl::Keyboard::Down || (vim_keys_valid && event.key.code == mgl::Keyboard::J)) { render_selected_item_bg = true; bool bottom_reached = select_next_item(true); if(!bottom_reached && on_bottom_reached) on_bottom_reached(); return true; - } else if(rendering_card_view && selected_column > 0 && ((!event.key.control && event.key.code == mgl::Keyboard::Left) || (event.key.control && event.key.code == mgl::Keyboard::H))) { + } else if(rendering_card_view && selected_column > 0 && ((!event.key.control && event.key.code == mgl::Keyboard::Left) || (vim_keys_valid && event.key.code == mgl::Keyboard::H))) { render_selected_item_bg = true; const int new_selected_item = get_previous_visible_item(selected_item); if(new_selected_item != -1) { @@ -496,7 +497,7 @@ namespace QuickMedia { on_top_reached(); } return true; - } else if(rendering_card_view && selected_column + 1 < num_columns && ((!event.key.control && event.key.code == mgl::Keyboard::Right) || (event.key.control && event.key.code == mgl::Keyboard::L))) { + } else if(rendering_card_view && selected_column + 1 < num_columns && ((!event.key.control && event.key.code == mgl::Keyboard::Right) || (vim_keys_valid && event.key.code == mgl::Keyboard::L))) { render_selected_item_bg = true; const int new_selected_item = get_next_visible_item(selected_item); if(new_selected_item != -1) { -- cgit v1.2.3