diff --git a/README.md b/README.md index 538f9f99..635a64df 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,7 @@ value as shown below: "history_limit": 100, "clipboard_limit": 20, "preserve_command": false, + "clear_query_after_run": false, "follow_mouse": true, "static_location_enabled": false, "static_pos": [0, 0], @@ -158,6 +159,7 @@ Example: typing `test` will only list entries containing `test`. If an alias mat `history_limit` defines how many entries the history plugin keeps. `clipboard_limit` sets how many clipboard entries are persisted for the clipboard plugin. `preserve_command` keeps the typed command prefix (like `bm add` or `f add`) in the search field after running an action. +`clear_query_after_run` removes the search text after a successful action whenever you prefer starting with a blank box. `enabled_capabilities` maps plugin names to capability identifiers so features can be toggled individually. The folders plugin, for example, exposes `show_full_path`. `screenshot_dir` sets the directory used when saving screenshots. If omitted, screenshots are stored in a `MultiLauncher_Screenshots` folder in the current working directory. `screenshot_save_file` determines whether screenshots copied to the clipboard are also written to disk. The default is `true`. diff --git a/settings.json b/settings.json index 372a3c21..7164bea0 100644 --- a/settings.json +++ b/settings.json @@ -8,7 +8,10 @@ "enabled_capabilities": null, "debug_logging": false, "log_file": null, - "offscreen_pos": null, + "offscreen_pos": [ + 2000, + 2000 + ], "window_size": [ 718, 777 @@ -34,19 +37,64 @@ "clipboard_limit": 20, "follow_mouse": true, "static_location_enabled": false, - "static_pos": null, - "static_size": null, - "hide_after_run": false, + "static_pos": [ + 0, + 0 + ], + "static_size": [ + 400, + 220 + ], + "hide_after_run": true, "always_on_top": true, "timer_refresh": 1.0, "disable_timer_updates": false, "preserve_command": false, + "clear_query_after_run": true, "net_refresh": 1.0, "net_unit": "auto", "screenshot_dir": null, "screenshot_save_file": false, "screenshot_auto_save": true, "screenshot_use_editor": true, - "plugin_settings": {}, + "plugin_settings": { + "network": { + "refresh_rate": 1.0, + "unit": "auto" + }, + "history": { + "max_entries": 100 + }, + "color_picker": { + "color": [ + 255, + 0, + 0, + 255 + ] + }, + "browser_tabs": { + "recalc_each_query": false + }, + "stopwatch": { + "precision": 2, + "refresh_rate": 1.0 + }, + "screenshot": { + "screenshot_auto_save": true, + "screenshot_dir": "", + "screenshot_save_file": false, + "screenshot_use_editor": true + }, + "shell": { + "open_in_wezterm": false + }, + "calculator": { + "save_on_enter": false + }, + "clipboard": { + "max_entries": 20 + } + }, "pinned_panels": [] } \ No newline at end of file diff --git a/src/gui/mod.rs b/src/gui/mod.rs index e4a2a1fa..cc7de288 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -36,11 +36,7 @@ pub use fav_dialog::FavDialog; pub use image_panel::ImagePanel; pub use macro_dialog::MacroDialog; pub use note_panel::{ - build_nvim_command, - build_wezterm_command, - extract_links, - show_wiki_link, - spawn_external, + build_nvim_command, build_wezterm_command, extract_links, show_wiki_link, spawn_external, NotePanel, }; pub use notes_dialog::NotesDialog; @@ -385,6 +381,7 @@ pub struct LauncherApp { pub timer_refresh: f32, pub disable_timer_updates: bool, pub preserve_command: bool, + pub clear_query_after_run: bool, pub query_autocomplete: bool, pub net_refresh: f32, pub net_unit: crate::settings::NetUnit, @@ -501,6 +498,7 @@ impl LauncherApp { static_pos: Option<(i32, i32)>, static_size: Option<(i32, i32)>, hide_after_run: Option, + clear_query_after_run: Option, timer_refresh: Option, disable_timer_updates: Option, preserve_command: Option, @@ -556,6 +554,9 @@ impl LauncherApp { if let Some(v) = hide_after_run { self.hide_after_run = v; } + if let Some(v) = clear_query_after_run { + self.clear_query_after_run = v; + } if let Some(v) = timer_refresh { self.timer_refresh = v; } @@ -884,6 +885,7 @@ impl LauncherApp { timer_refresh: settings.timer_refresh, disable_timer_updates: settings.disable_timer_updates, preserve_command: settings.preserve_command, + clear_query_after_run: settings.clear_query_after_run, query_autocomplete: settings.query_autocomplete, net_refresh: settings.net_refresh, net_unit: settings.net_unit, @@ -2207,6 +2209,7 @@ impl eframe::App for LauncherApp { let current = self.query.clone(); let mut refresh = false; let mut set_focus = false; + let mut command_changed_query = false; if let Some(new_q) = a.action.strip_prefix("query:") { tracing::debug!("query action via Enter: {new_q}"); self.query = new_q.to_string(); @@ -2397,6 +2400,7 @@ impl eframe::App for LauncherApp { } else { self.query.clear(); } + command_changed_query = true; refresh = true; set_focus = true; } else if a.action.starts_with("bookmark:remove:") { @@ -2408,6 +2412,7 @@ impl eframe::App for LauncherApp { } else { self.query.clear(); } + command_changed_query = true; refresh = true; set_focus = true; } else if a.action.starts_with("folder:remove:") { @@ -2425,6 +2430,7 @@ impl eframe::App for LauncherApp { } else { self.query.clear(); } + command_changed_query = true; refresh = true; set_focus = true; if self.enable_toasts { @@ -2445,6 +2451,7 @@ impl eframe::App for LauncherApp { set_focus = true; if current.starts_with("note list") { self.pending_query = Some(current.clone()); + command_changed_query = true; } if self.enable_toasts { let label = @@ -2461,6 +2468,7 @@ impl eframe::App for LauncherApp { // Re-run the current query so the todo list reflects the // updated completion state immediately. self.pending_query = Some(current.clone()); + command_changed_query = true; if self.enable_toasts { let label = a .label @@ -2526,6 +2534,7 @@ impl eframe::App for LauncherApp { } else { self.query.clear(); } + command_changed_query = true; set_focus = true; } else if a.action.starts_with("timer:cancel:") && current.starts_with("timer rm") @@ -2550,6 +2559,12 @@ impl eframe::App for LauncherApp { } else { self.query.clear(); } + command_changed_query = true; + set_focus = true; + } + if self.clear_query_after_run && !command_changed_query { + self.query.clear(); + refresh = true; set_focus = true; } if self.hide_after_run @@ -2973,9 +2988,11 @@ impl eframe::App for LauncherApp { } if resp.clicked() { let current = self.query.clone(); + let mut command_changed_query = false; if let Some(new_q) = a.action.strip_prefix("query:") { tracing::debug!("query action via click: {new_q}"); clicked_query = Some(new_q.to_string()); + command_changed_query = true; set_focus = true; tracing::debug!("move_cursor_end set via mouse click"); self.move_cursor_end = true; @@ -3119,6 +3136,7 @@ impl eframe::App for LauncherApp { } else { self.query.clear(); } + command_changed_query = true; refresh = true; set_focus = true; } else if a.action.starts_with("bookmark:remove:") { @@ -3130,6 +3148,7 @@ impl eframe::App for LauncherApp { } else { self.query.clear(); } + command_changed_query = true; refresh = true; set_focus = true; } else if a.action.starts_with("folder:remove:") { @@ -3147,6 +3166,7 @@ impl eframe::App for LauncherApp { } else { self.query.clear(); } + command_changed_query = true; refresh = true; set_focus = true; if self.enable_toasts { @@ -3167,6 +3187,7 @@ impl eframe::App for LauncherApp { set_focus = true; if current.starts_with("note list") { clicked_query = Some(current.clone()); + command_changed_query = true; } if self.enable_toasts { let label = a @@ -3186,6 +3207,7 @@ impl eframe::App for LauncherApp { // Re-run the current query so the visible list refreshes // with the toggled completion state. clicked_query = Some(current.clone()); + command_changed_query = true; if self.enable_toasts { let label = a .label @@ -3254,6 +3276,12 @@ impl eframe::App for LauncherApp { } else { self.query.clear(); } + command_changed_query = true; + set_focus = true; + } + if self.clear_query_after_run && !command_changed_query { + self.query.clear(); + refresh = true; set_focus = true; } if self.hide_after_run diff --git a/src/plugin_editor.rs b/src/plugin_editor.rs index 943c1028..ba35f149 100644 --- a/src/plugin_editor.rs +++ b/src/plugin_editor.rs @@ -116,6 +116,7 @@ impl PluginEditor { s.static_pos, s.static_size, Some(s.hide_after_run), + Some(s.clear_query_after_run), Some(s.timer_refresh), Some(s.disable_timer_updates), Some(s.preserve_command), diff --git a/src/settings.rs b/src/settings.rs index 462df665..d888bc1f 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -149,6 +149,9 @@ pub struct Settings { /// Keep the command prefix in the query after running an action. #[serde(default)] pub preserve_command: bool, + /// Clear the search query after successfully running an action. + #[serde(default)] + pub clear_query_after_run: bool, #[serde(default = "default_net_refresh")] pub net_refresh: f32, #[serde(default)] @@ -294,6 +297,7 @@ impl Default for Settings { net_unit: NetUnit::Auto, disable_timer_updates: false, preserve_command: false, + clear_query_after_run: false, show_examples: false, screenshot_dir: Some( std::env::current_dir() diff --git a/src/settings_editor.rs b/src/settings_editor.rs index cb84fee1..e5e72088 100644 --- a/src/settings_editor.rs +++ b/src/settings_editor.rs @@ -51,6 +51,7 @@ pub struct SettingsEditor { timer_refresh: f32, disable_timer_updates: bool, preserve_command: bool, + clear_query_after_run: bool, query_autocomplete: bool, net_refresh: f32, net_unit: crate::settings::NetUnit, @@ -140,6 +141,7 @@ impl SettingsEditor { timer_refresh: settings.timer_refresh, disable_timer_updates: settings.disable_timer_updates, preserve_command: settings.preserve_command, + clear_query_after_run: settings.clear_query_after_run, query_autocomplete: settings.query_autocomplete, net_refresh: settings.net_refresh, net_unit: settings.net_unit, @@ -252,6 +254,7 @@ impl SettingsEditor { timer_refresh: self.timer_refresh, disable_timer_updates: self.disable_timer_updates, preserve_command: self.preserve_command, + clear_query_after_run: self.clear_query_after_run, query_autocomplete: self.query_autocomplete, net_refresh: self.net_refresh, net_unit: self.net_unit, @@ -357,9 +360,15 @@ impl SettingsEditor { ); }); } - ui.checkbox(&mut self.hide_after_run, "Hide window after running action"); + ui.horizontal_wrapped(|ui| { + ui.checkbox( + &mut self.hide_after_run, + "Hide window after running action", + ); + ui.checkbox(&mut self.preserve_command, "Preserve command after run"); + ui.checkbox(&mut self.clear_query_after_run, "Clear query after run"); + }); ui.checkbox(&mut self.always_on_top, "Always on top"); - ui.checkbox(&mut self.preserve_command, "Preserve command after run"); ui.checkbox(&mut self.query_autocomplete, "Enable query autocomplete"); ui.checkbox( &mut self.disable_timer_updates, @@ -642,6 +651,7 @@ impl SettingsEditor { new_settings.static_pos, new_settings.static_size, Some(new_settings.hide_after_run), + Some(new_settings.clear_query_after_run), Some(new_settings.timer_refresh), Some(new_settings.disable_timer_updates), Some(new_settings.preserve_command), @@ -680,6 +690,8 @@ impl SettingsEditor { app.clipboard_limit = new_settings.clipboard_limit; app.page_jump = new_settings.page_jump; app.preserve_command = new_settings.preserve_command; + app.clear_query_after_run = + new_settings.clear_query_after_run; app.query_autocomplete = new_settings.query_autocomplete; app.net_refresh = new_settings.net_refresh; diff --git a/tests/hide_after_run.rs b/tests/hide_after_run.rs index 8aec2335..d9af9333 100644 --- a/tests/hide_after_run.rs +++ b/tests/hide_after_run.rs @@ -78,6 +78,7 @@ fn run_action(action: &str) -> bool { None, None, None, + None, ); flag.store(true, Ordering::SeqCst); let a = app.results[0].clone();