diff --git a/espanso-config/src/config/mod.rs b/espanso-config/src/config/mod.rs index 5e0e16a..3510934 100644 --- a/espanso-config/src/config/mod.rs +++ b/espanso-config/src/config/mod.rs @@ -111,6 +111,9 @@ pub trait Config: Send + Sync { // which is used both for the detection and injection process. fn keyboard_layout(&self) -> Option; + // Trigger used to show the Search UI + fn search_trigger(&self) -> Option; + fn is_match<'a>(&self, app: &AppProperties<'a>) -> bool; fn pretty_dump(&self) -> String { diff --git a/espanso-config/src/config/parse/mod.rs b/espanso-config/src/config/parse/mod.rs index 1edcd65..9e049fb 100644 --- a/espanso-config/src/config/parse/mod.rs +++ b/espanso-config/src/config/parse/mod.rs @@ -37,6 +37,7 @@ pub(crate) struct ParsedConfig { pub word_separators: Option>, pub backspace_limit: Option, pub apply_patch: Option, + pub search_trigger: Option, pub pre_paste_delay: Option, pub restore_clipboard_delay: Option, diff --git a/espanso-config/src/config/parse/yaml.rs b/espanso-config/src/config/parse/yaml.rs index f16daff..d45a7e3 100644 --- a/espanso-config/src/config/parse/yaml.rs +++ b/espanso-config/src/config/parse/yaml.rs @@ -82,6 +82,9 @@ pub(crate) struct YAMLConfig { #[serde(default)] pub keyboard_layout: Option, + #[serde(default)] + pub search_trigger: Option, + // Include/Exclude #[serde(default)] pub includes: Option>, @@ -155,6 +158,7 @@ impl TryFrom for ParsedConfig { }) .collect() }), + search_trigger: yaml_config.search_trigger, pre_paste_delay: yaml_config.pre_paste_delay, restore_clipboard_delay: yaml_config.restore_clipboard_delay, @@ -206,6 +210,7 @@ mod tests { layout: test_layout variant: test_variant options: test_options + search_trigger: "search" use_standard_includes: true includes: ["test1"] @@ -249,6 +254,7 @@ mod tests { backspace_limit: Some(10), apply_patch: Some(false), keyboard_layout: Some(keyboard_layout), + search_trigger: Some("search".to_owned()), pre_paste_delay: Some(300), diff --git a/espanso-config/src/config/resolve.rs b/espanso-config/src/config/resolve.rs index 9666e91..5aa7080 100644 --- a/espanso-config/src/config/resolve.rs +++ b/espanso-config/src/config/resolve.rs @@ -274,6 +274,14 @@ impl Config for ResolvedConfig { options: layout.get("options").map(String::from), }) } + + fn search_trigger(&self) -> Option { + match self.parsed.search_trigger.as_deref() { + Some("OFF") | Some("off") => None, + Some(x) => Some(x.to_string()), + None => Some("jkj".to_string()), + } + } } impl ResolvedConfig { @@ -347,6 +355,7 @@ impl ResolvedConfig { word_separators, backspace_limit, keyboard_layout, + search_trigger, includes, excludes, extra_includes, diff --git a/espanso-config/src/legacy/mod.rs b/espanso-config/src/legacy/mod.rs index ffbb48e..45588ab 100644 --- a/espanso-config/src/legacy/mod.rs +++ b/espanso-config/src/legacy/mod.rs @@ -358,6 +358,10 @@ impl Config for LegacyInteropConfig { fn keyboard_layout(&self) -> Option { None } + + fn search_trigger(&self) -> Option { + None + } } struct LegacyMatchGroup {