QOL shortcuts
This commit is contained in:
13
src/main.rs
13
src/main.rs
@@ -199,6 +199,16 @@ impl eframe::App for LogViewerApp {
|
|||||||
self.handle_close_tab(index);
|
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
|
// Render search panel
|
||||||
let match_count = self.active_tab().map(|t| t.filtered_lines.len()).unwrap_or(0);
|
let match_count = self.active_tab().map(|t| t.filtered_lines.len()).unwrap_or(0);
|
||||||
let search_actions = render_search_panel(
|
let search_actions = render_search_panel(
|
||||||
@@ -206,9 +216,10 @@ impl eframe::App for LogViewerApp {
|
|||||||
&mut self.search_panel_state,
|
&mut self.search_panel_state,
|
||||||
&self.search_state,
|
&self.search_state,
|
||||||
match_count,
|
match_count,
|
||||||
|
ctrl_f_pressed,
|
||||||
);
|
);
|
||||||
|
|
||||||
if search_actions.execute_search {
|
if search_actions.execute_search || ctrl_enter_pressed {
|
||||||
add_to_history(
|
add_to_history(
|
||||||
&mut self.search_panel_state.history,
|
&mut self.search_panel_state.history,
|
||||||
&self.search_panel_state.query,
|
&self.search_panel_state.query,
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ pub fn render_search_panel(
|
|||||||
state: &mut SearchPanelState,
|
state: &mut SearchPanelState,
|
||||||
search_state: &SearchState,
|
search_state: &SearchState,
|
||||||
match_count: usize,
|
match_count: usize,
|
||||||
|
request_focus: bool,
|
||||||
) -> SearchPanelActions {
|
) -> SearchPanelActions {
|
||||||
let mut actions = SearchPanelActions {
|
let mut actions = SearchPanelActions {
|
||||||
execute_search: false,
|
execute_search: false,
|
||||||
@@ -45,14 +46,21 @@ pub fn render_search_panel(
|
|||||||
|
|
||||||
ui.add_space(4.0);
|
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 text_edit_width = 300.0;
|
||||||
|
let search_input_id = egui::Id::new("search_input_field");
|
||||||
let text_response = ui.add(
|
let text_response = ui.add(
|
||||||
egui::TextEdit::singleline(&mut state.query)
|
egui::TextEdit::singleline(&mut state.query)
|
||||||
|
.id(search_input_id)
|
||||||
.desired_width(text_edit_width)
|
.desired_width(text_edit_width)
|
||||||
.hint_text("Enter search query...")
|
.hint_text("Enter search query...")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Request focus if Ctrl+F was pressed
|
||||||
|
if request_focus {
|
||||||
|
text_response.request_focus();
|
||||||
|
}
|
||||||
|
|
||||||
let enter_pressed =
|
let enter_pressed =
|
||||||
text_response.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
|
text_response.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user