diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-09-09 19:40:19 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-09-09 19:40:19 +0200 |
commit | 9c5cd0ebb51350c05d3fc3496851f43a209f84ec (patch) | |
tree | 64b09af13842ed36efefd78f71e77b6ef8e26aba | |
parent | 6d9a07369a9ae20f73cf0d70cdf8b3e0cc06e87d (diff) |
Do not require ctrl for vim keys for manga and matrix
-rw-r--r-- | README.md | 14 | ||||
-rw-r--r-- | TODO | 3 | ||||
-rw-r--r-- | include/Body.hpp | 2 | ||||
-rw-r--r-- | src/Body.cpp | 11 | ||||
-rw-r--r-- | src/ImageViewer.cpp | 4 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 14 |
6 files changed, 28 insertions, 20 deletions
@@ -83,8 +83,8 @@ Type text and then wait and QuickMedia will automatically search.\ ### Local anime search page controls `Ctrl+R`: Mark the anime as watched/unwatched. ### Manga page view controls -`Arrow up`/`Ctrl+K`: Go to the previous page (or chapter if the current page is the last one).\ -`Arrow down`/`Ctrl+J`: Go to the next page (or chapter if the current page is the first one).\ +`Arrow up`/`K`: Go to the previous page (or chapter if the current page is the last one).\ +`Arrow down`/`J`: Go to the next page (or chapter if the current page is the first one).\ `Page up`: Go back 10 pages.\ `Page down`: Go forward 10 pages.\ `Home`: Go to the first page.\ @@ -92,8 +92,8 @@ Type text and then wait and QuickMedia will automatically search.\ `F`: Toggle between scaling the image to the window size or only down scaling if the image is too large.\ `I`: Switch to scroll view. ### Manga scroll view controls -`Arrow up`/`Ctrl+K`: Move up.\ -`Arrow down`/`Ctrl+J`: Move down.\ +`Arrow up`/`K`: Move up.\ +`Arrow down`/`J`: Move down.\ `Mouse scroll`/`Middle mouse click+Move mouse`: Scroll smoothly.\ `Home`: Go to the first page.\ `End`: Go to the last page.\ @@ -115,6 +115,8 @@ Type text and then wait and QuickMedia will automatically search.\ `Ctrl+S`: Save the selected file.\ `Ctrl+V`: Uploads the file specified in the clipboard.\ `U`: Bring up the file manager and select a file to upload to the room, `Esc` to cancel.\ +`Arrow up`/`K`: Move up.\ +`Arrow down`/`J`: Move down.\ `Alt+Up`/`Ctrl+Alt+K`: Select the room above the currently selected room.\ `Alt+Down`/`Ctrl+Alt+J`: Select the room below the currently selected room.\ `Alt+Home`: Select the first room in the room list.\ @@ -136,7 +138,9 @@ Type text and then wait and QuickMedia will automatically search.\ `Ctrl+Right`: Go to the next word.\ `Ctrl+V`: Paste clipboard content into the message input.\ `Ctrl+D`: Clear the input text.\ -`@`: Start searching for a user to mention. +`@`: Start searching for a user to mention.\ +`Arrow up`/`Ctrl+K`: Move up in mentions.\ +`Arrow down`/`Ctrl+J`: Move down in mentions.\ ### 4chan thread controls `Enter`: Show the posts that the selected post replies to and the posts the replied to the selected post.\ `Backspace`: Go back to the previously selected item after selecting it with `Enter`.\ @@ -233,4 +233,5 @@ Support proper emoji, maybe a different emoji per image. Consider adding an option to use external sxiv, imv etc instead of mpv/quickmedia image viewer. Fallback to playing videos/etc from origin homeserver in matrix if the file is larger than the users homeserver allows. This wont work with pantalaimon + encrypted rooms, so it should be delayed until quickmedia supports matrix encryption. Fix 4chan posting! cloudflare broke shit. Then create external captcha solver program that solves captcha from captcha image. -Add option to use invidious, and the invidious front page.
\ No newline at end of file +Add option to use invidious, and the invidious front page. +Add proper vim modal mode. Maybe switch focused part with tab? then also need to show which part is focused.
\ No newline at end of file diff --git a/include/Body.hpp b/include/Body.hpp index 373c6b4..ced5f4e 100644 --- a/include/Body.hpp +++ b/include/Body.hpp @@ -105,7 +105,7 @@ namespace QuickMedia { void clamp_selection(); // Returns true if the event was handled - bool on_event(const mgl::Window &window, const mgl::Event &event, bool keyboard_navigation = true); + bool on_event(const mgl::Window &window, const mgl::Event &event, bool keyboard_navigation = true, bool vim_keys_require_ctrl = true); // Returns the the body total height double draw(mgl::Window &window, mgl::vec2f pos, mgl::vec2f size); // Returns the the body total height 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) { diff --git a/src/ImageViewer.cpp b/src/ImageViewer.cpp index 179669d..e670d66 100644 --- a/src/ImageViewer.cpp +++ b/src/ImageViewer.cpp @@ -217,11 +217,11 @@ namespace QuickMedia { } static bool is_key_scroll_up(const mgl::Event::KeyEvent &key) { - return (!key.control && key.code == mgl::Keyboard::Up) || (!key.alt && key.control && key.code == mgl::Keyboard::K); + return (!key.control && key.code == mgl::Keyboard::Up) || (!key.alt && key.code == mgl::Keyboard::K); } static bool is_key_scroll_down(const mgl::Event::KeyEvent &key) { - return (!key.control && key.code == mgl::Keyboard::Down) || (!key.alt && key.control && key.code == mgl::Keyboard::J); + return (!key.control && key.code == mgl::Keyboard::Down) || (!key.alt && key.code == mgl::Keyboard::J); } void ImageViewer::scroll_to_page(int page) { diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 9f233da..95938c5 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -4138,7 +4138,7 @@ namespace QuickMedia { } else if(event.type == mgl::Event::GainedFocus) { redraw = true; } else if(event.type == mgl::Event::KeyPressed) { - if((!event.key.control && event.key.code == mgl::Keyboard::Up) || (!event.key.alt && event.key.control && event.key.code == mgl::Keyboard::K)) { + if((!event.key.control && event.key.code == mgl::Keyboard::Up) || (!event.key.alt && event.key.code == mgl::Keyboard::K)) { if(image_index > 0) { --image_index; goto end_of_images_page; @@ -4146,7 +4146,7 @@ namespace QuickMedia { page_navigation = -1; goto end_of_images_page; } - } else if((!event.key.control && event.key.code == mgl::Keyboard::Down) || (!event.key.alt && event.key.control && event.key.code == mgl::Keyboard::J)) { + } else if((!event.key.control && event.key.code == mgl::Keyboard::Down) || (!event.key.alt && event.key.code == mgl::Keyboard::J)) { if(image_index < num_manga_pages) { ++image_index; goto end_of_images_page; @@ -6626,24 +6626,26 @@ namespace QuickMedia { ui_tabs.on_event(event); if(chat_state == ChatState::URL_SELECTION) { - if(url_selection_body.on_event(window, event)) + if(url_selection_body.on_event(window, event, true, false)) idle_active_handler(); } else { - if(tabs[selected_tab].body->on_event(window, event, chat_state == ChatState::NAVIGATING)) + if(tabs[selected_tab].body->on_event(window, event, chat_state == ChatState::NAVIGATING, false)) idle_active_handler(); } base_event_handler(event, PageType::EXIT, tabs[selected_tab].body.get(), nullptr, false, false); event_idle_handler(event); if(!frame_skip_text_entry) { - if(!mention.visible || event.type != mgl::Event::KeyPressed || (event.key.code != mgl::Keyboard::Up && event.key.code != mgl::Keyboard::Down && event.key.code != mgl::Keyboard::Left && event.key.code != mgl::Keyboard::Right)) + const bool move_arrows = (event.key.code == mgl::Keyboard::Up || event.key.code == mgl::Keyboard::Down || event.key.code == mgl::Keyboard::Left || event.key.code == mgl::Keyboard::Right); + const bool move_vim_keys = (event.key.control && (event.key.code == mgl::Keyboard::J || event.key.code != mgl::Keyboard::K)); + if(!mention.visible || event.type != mgl::Event::KeyPressed || (!move_arrows && !move_vim_keys)) chat_input.process_event(window, event); if(chat_input.is_editable()) mention.handle_event(event); } if(draw_room_list) { - if(matrix_chat_page->rooms_page->body->on_event(window, event, false)) + if(matrix_chat_page->rooms_page->body->on_event(window, event, false, false)) idle_active_handler(); } |