From 7c2632a297852e44cc89eb5c10bc115a025a5c2d Mon Sep 17 00:00:00 2001 From: Stanislav Pastushenko Date: Tue, 9 Dec 2025 18:39:01 +0100 Subject: [PATCH] QOL shortcuts --- src/main.rs | 13 ++++++++++++- src/ui/search_panel.rs | 10 +++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index a941bc3..2c1e78e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -199,6 +199,16 @@ impl eframe::App for LogViewerApp { self.handle_close_tab(index); } + // Check for Ctrl+F keyboard shortcut + let ctrl_f_pressed = ctx.input(|i| { + i.modifiers.ctrl && i.key_pressed(egui::Key::F) + }); + + // Check for Ctrl+Enter to execute search globally + let ctrl_enter_pressed = ctx.input(|i| { + i.modifiers.ctrl && i.key_pressed(egui::Key::Enter) + }); + // Render search panel let match_count = self.active_tab().map(|t| t.filtered_lines.len()).unwrap_or(0); let search_actions = render_search_panel( @@ -206,9 +216,10 @@ impl eframe::App for LogViewerApp { &mut self.search_panel_state, &self.search_state, match_count, + ctrl_f_pressed, ); - if search_actions.execute_search { + if search_actions.execute_search || ctrl_enter_pressed { add_to_history( &mut self.search_panel_state.history, &self.search_panel_state.query, diff --git a/src/ui/search_panel.rs b/src/ui/search_panel.rs index 1828e4f..8fa4964 100644 --- a/src/ui/search_panel.rs +++ b/src/ui/search_panel.rs @@ -21,6 +21,7 @@ pub fn render_search_panel( state: &mut SearchPanelState, search_state: &SearchState, match_count: usize, + request_focus: bool, ) -> SearchPanelActions { let mut actions = SearchPanelActions { execute_search: false, @@ -45,14 +46,21 @@ pub fn render_search_panel( ui.add_space(4.0); - // Text input with proper height matching buttons + // Text input with proper height matching buttons and stable ID let text_edit_width = 300.0; + let search_input_id = egui::Id::new("search_input_field"); let text_response = ui.add( egui::TextEdit::singleline(&mut state.query) + .id(search_input_id) .desired_width(text_edit_width) .hint_text("Enter search query...") ); + // Request focus if Ctrl+F was pressed + if request_focus { + text_response.request_focus(); + } + let enter_pressed = text_response.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));