From 53e45fa23203f98423a3744b12a47a2417a885ef Mon Sep 17 00:00:00 2001 From: Javier Feliz Date: Thu, 4 Sep 2025 00:35:06 -0400 Subject: [PATCH] Stub out file search plugin --- src/main.rs | 1 + src/plugins/file_search.rs | 53 ++++++++++++++++++++++++++++++++++++++ src/plugins/mod.rs | 1 + src/ui/mod.rs | 1 + 4 files changed, 56 insertions(+) create mode 100644 src/plugins/file_search.rs diff --git a/src/main.rs b/src/main.rs index a804294..e51c886 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,6 +11,7 @@ fn main() { app.connect_activate(|app| { let launcher = WaycastLauncher::new() .add_plugin(plugins::drun::DrunPlugin {}) + .add_plugin(plugins::file_search::FileSearchPlugin {}) .initialize(app); launcher.borrow().show(); diff --git a/src/plugins/file_search.rs b/src/plugins/file_search.rs new file mode 100644 index 0000000..1780bfc --- /dev/null +++ b/src/plugins/file_search.rs @@ -0,0 +1,53 @@ +use crate::{LaunchError, LauncherListItem, LauncherPlugin}; + +struct FileEntry { + title: String, +} + +impl LauncherListItem for ExampleEntry { + fn title(&self) -> String { + return self.title.to_string(); + } + fn description(&self) -> Option { + return None; + } + + fn execute(&self) -> Result<(), LaunchError> { + println!("Sample item clicked: {}", self.title); + Ok(()) + } + fn icon(&self) -> String { + return String::from("vscode"); + } +} + +pub struct FileSearchPlugin {} +impl LauncherPlugin for FileSearchPlugin { + fn name(&self) -> String { + return String::from("File search"); + } + + fn priority(&self) -> i32 { + return 900; + } + + fn description(&self) -> Option { + None + } + + fn prefix(&self) -> Option { + Some(String::from("f")) + } + + fn by_prefix_only(&self) -> bool { + false + } + + fn default_list(&self) -> Vec> { + Vec::new() + } + + fn filter(&self, query: &str) -> Vec> { + self.default_list() + } +} diff --git a/src/plugins/mod.rs b/src/plugins/mod.rs index f7dc79b..61b1cd6 100644 --- a/src/plugins/mod.rs +++ b/src/plugins/mod.rs @@ -1 +1,2 @@ pub mod drun; +pub mod file_search; diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 89a752d..a8e5777 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -128,6 +128,7 @@ impl WaycastLauncher { for p in init_plugins { plugins.push(Arc::from(p)); } + plugins.sort_by(|a, b| b.priority().cmp(&a.priority())); // Organize plugins for faster querying let mut plugins_show_always: Vec> = Vec::new(); for p in &plugins {