feat(config): add search trigger field
This commit is contained in:
parent
db1a3e1247
commit
d569d96dc6
|
@ -111,6 +111,9 @@ pub trait Config: Send + Sync {
|
||||||
// which is used both for the detection and injection process.
|
// which is used both for the detection and injection process.
|
||||||
fn keyboard_layout(&self) -> Option<RMLVOConfig>;
|
fn keyboard_layout(&self) -> Option<RMLVOConfig>;
|
||||||
|
|
||||||
|
// Trigger used to show the Search UI
|
||||||
|
fn search_trigger(&self) -> Option<String>;
|
||||||
|
|
||||||
fn is_match<'a>(&self, app: &AppProperties<'a>) -> bool;
|
fn is_match<'a>(&self, app: &AppProperties<'a>) -> bool;
|
||||||
|
|
||||||
fn pretty_dump(&self) -> String {
|
fn pretty_dump(&self) -> String {
|
||||||
|
|
|
@ -37,6 +37,7 @@ pub(crate) struct ParsedConfig {
|
||||||
pub word_separators: Option<Vec<String>>,
|
pub word_separators: Option<Vec<String>>,
|
||||||
pub backspace_limit: Option<usize>,
|
pub backspace_limit: Option<usize>,
|
||||||
pub apply_patch: Option<bool>,
|
pub apply_patch: Option<bool>,
|
||||||
|
pub search_trigger: Option<String>,
|
||||||
|
|
||||||
pub pre_paste_delay: Option<usize>,
|
pub pre_paste_delay: Option<usize>,
|
||||||
pub restore_clipboard_delay: Option<usize>,
|
pub restore_clipboard_delay: Option<usize>,
|
||||||
|
|
|
@ -82,6 +82,9 @@ pub(crate) struct YAMLConfig {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub keyboard_layout: Option<Mapping>,
|
pub keyboard_layout: Option<Mapping>,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
|
pub search_trigger: Option<String>,
|
||||||
|
|
||||||
// Include/Exclude
|
// Include/Exclude
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub includes: Option<Vec<String>>,
|
pub includes: Option<Vec<String>>,
|
||||||
|
@ -155,6 +158,7 @@ impl TryFrom<YAMLConfig> for ParsedConfig {
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}),
|
}),
|
||||||
|
search_trigger: yaml_config.search_trigger,
|
||||||
|
|
||||||
pre_paste_delay: yaml_config.pre_paste_delay,
|
pre_paste_delay: yaml_config.pre_paste_delay,
|
||||||
restore_clipboard_delay: yaml_config.restore_clipboard_delay,
|
restore_clipboard_delay: yaml_config.restore_clipboard_delay,
|
||||||
|
@ -206,6 +210,7 @@ mod tests {
|
||||||
layout: test_layout
|
layout: test_layout
|
||||||
variant: test_variant
|
variant: test_variant
|
||||||
options: test_options
|
options: test_options
|
||||||
|
search_trigger: "search"
|
||||||
|
|
||||||
use_standard_includes: true
|
use_standard_includes: true
|
||||||
includes: ["test1"]
|
includes: ["test1"]
|
||||||
|
@ -249,6 +254,7 @@ mod tests {
|
||||||
backspace_limit: Some(10),
|
backspace_limit: Some(10),
|
||||||
apply_patch: Some(false),
|
apply_patch: Some(false),
|
||||||
keyboard_layout: Some(keyboard_layout),
|
keyboard_layout: Some(keyboard_layout),
|
||||||
|
search_trigger: Some("search".to_owned()),
|
||||||
|
|
||||||
pre_paste_delay: Some(300),
|
pre_paste_delay: Some(300),
|
||||||
|
|
||||||
|
|
|
@ -274,6 +274,14 @@ impl Config for ResolvedConfig {
|
||||||
options: layout.get("options").map(String::from),
|
options: layout.get("options").map(String::from),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn search_trigger(&self) -> Option<String> {
|
||||||
|
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 {
|
impl ResolvedConfig {
|
||||||
|
@ -347,6 +355,7 @@ impl ResolvedConfig {
|
||||||
word_separators,
|
word_separators,
|
||||||
backspace_limit,
|
backspace_limit,
|
||||||
keyboard_layout,
|
keyboard_layout,
|
||||||
|
search_trigger,
|
||||||
includes,
|
includes,
|
||||||
excludes,
|
excludes,
|
||||||
extra_includes,
|
extra_includes,
|
||||||
|
|
|
@ -358,6 +358,10 @@ impl Config for LegacyInteropConfig {
|
||||||
fn keyboard_layout(&self) -> Option<crate::config::RMLVOConfig> {
|
fn keyboard_layout(&self) -> Option<crate::config::RMLVOConfig> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn search_trigger(&self) -> Option<String> {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct LegacyMatchGroup {
|
struct LegacyMatchGroup {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user