From 0f361ba6d039a02b835257e28619f0834b3b787f Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Wed, 18 Aug 2021 15:52:19 +0200 Subject: [PATCH] feat(core): add built-in filter in search bar --- espanso/src/cli/modulo/search.rs | 2 +- .../src/cli/worker/engine/process/middleware/match_select.rs | 2 ++ espanso/src/cli/worker/match_cache.rs | 2 ++ espanso/src/gui/mod.rs | 1 + espanso/src/gui/modulo/search.rs | 2 ++ 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/espanso/src/cli/modulo/search.rs b/espanso/src/cli/modulo/search.rs index 9678046..853a934 100644 --- a/espanso/src/cli/modulo/search.rs +++ b/espanso/src/cli/modulo/search.rs @@ -48,7 +48,7 @@ pub fn search_main(matches: &ArgMatches, icon_paths: &IconPaths) -> i32 { // Overwrite the icon config.icon = icon_paths.logo.as_deref().map(|path| path.to_string_lossy().to_string()); - let algorithm = algorithm::get_algorithm(&config.algorithm); + let algorithm = algorithm::get_algorithm(&config.algorithm, true); let search = generator::generate(config); let result = show(search, algorithm); diff --git a/espanso/src/cli/worker/engine/process/middleware/match_select.rs b/espanso/src/cli/worker/engine/process/middleware/match_select.rs index 714527a..f364b7e 100644 --- a/espanso/src/cli/worker/engine/process/middleware/match_select.rs +++ b/espanso/src/cli/worker/engine/process/middleware/match_select.rs @@ -32,6 +32,7 @@ pub struct MatchSummary<'a> { pub id: i32, pub label: &'a str, pub tag: Option<&'a str>, + pub is_builtin: bool, } pub struct MatchSelectorAdapter<'a> { @@ -60,6 +61,7 @@ impl<'a> MatchSelector for MatchSelectorAdapter<'a> { id: m.id.to_string(), label: clipped_label.to_string(), tag: m.tag.map(String::from), + is_builtin: m.is_builtin, } }) .collect(); diff --git a/espanso/src/cli/worker/match_cache.rs b/espanso/src/cli/worker/match_cache.rs index 632dc8a..cef198c 100644 --- a/espanso/src/cli/worker/match_cache.rs +++ b/espanso/src/cli/worker/match_cache.rs @@ -128,11 +128,13 @@ impl<'a> super::engine::process::middleware::match_select::MatchProvider<'a> id: m.id, label: m.description(), tag: m.cause_description(), + is_builtin: false, }, MatchVariant::Builtin(m) => MatchSummary { id: m.id, label: m.label, tag: m.triggers.first().map(String::as_ref), + is_builtin: true, }, }) .collect() diff --git a/espanso/src/gui/mod.rs b/espanso/src/gui/mod.rs index e108b78..e6a434e 100644 --- a/espanso/src/gui/mod.rs +++ b/espanso/src/gui/mod.rs @@ -32,6 +32,7 @@ pub struct SearchItem { pub id: String, pub label: String, pub tag: Option, + pub is_builtin: bool, } pub trait FormUI { diff --git a/espanso/src/gui/modulo/search.rs b/espanso/src/gui/modulo/search.rs index 7c5808f..45c789f 100644 --- a/espanso/src/gui/modulo/search.rs +++ b/espanso/src/gui/modulo/search.rs @@ -75,6 +75,7 @@ struct ModuloSearchItemConfig<'a> { id: &'a str, label: &'a str, trigger: Option<&'a str>, + is_builtin: bool, } // TODO: test @@ -83,5 +84,6 @@ fn convert_items<'a>(items: &'a [SearchItem]) -> Vec> id: &item.id, label: &item.label, trigger: item.tag.as_deref(), + is_builtin: item.is_builtin, }).collect() }