diff --git a/config/data/config_sample.toml b/config/data/config_sample.toml index f8114f6..2718779 100644 --- a/config/data/config_sample.toml +++ b/config/data/config_sample.toml @@ -5,6 +5,7 @@ buffer_size = 64 auto_capitalize = false auto_commit = false page_size = 10 +suggestions = false [data] sample = { path = "./data_sample.toml" } diff --git a/config/src/lib.rs b/config/src/lib.rs index 6af4a8b..b0358d0 100644 --- a/config/src/lib.rs +++ b/config/src/lib.rs @@ -178,6 +178,7 @@ pub struct Config { /// auto_capitalize = false /// page_size = 10 /// auto_commit = true +/// suggestions = true /// # "#.to_owned()); /// # /// # // Loads the config file. @@ -193,6 +194,8 @@ pub struct CoreConfig { pub page_size: Option, /// Whether the predicate should be automatically committed. pub auto_commit: Option, + /// Whether we should show suggestions automatically + pub suggestions: Option, } #[derive(Deserialize, Debug, Clone)] @@ -443,6 +446,7 @@ mod tests { assert_eq!(core.buffer_size.unwrap(), 64); assert!(!core.auto_capitalize.unwrap()); assert!(!core.auto_commit.unwrap()); + assert!(!core.suggestions.unwrap()); assert_eq!(core.page_size.unwrap(), 10); true }), diff --git a/service/src/lib.rs b/service/src/lib.rs index 2472cee..6b59bd5 100644 --- a/service/src/lib.rs +++ b/service/src/lib.rs @@ -27,7 +27,7 @@ pub fn run( .map(|(key, value)| vec![key.as_str(), value.as_str()]) .collect(), ); - let (buffer_size, auto_commit, page_size) = config + let (buffer_size, auto_commit, page_size, suggestions) = config .core .as_ref() .map(|core| { @@ -35,9 +35,10 @@ pub fn run( core.buffer_size.unwrap_or(32), core.auto_commit.unwrap_or(false), core.page_size.unwrap_or(10), + core.suggestions.unwrap_or(false), ) }) - .unwrap_or((32, false, 10)); + .unwrap_or((32, false, 10, false)); let mut keyboard = Enigo::new(&Default::default()).unwrap(); let mut preprocessor = Preprocessor::new(Rc::new(memory), buffer_size); #[cfg(not(feature = "rhai"))] @@ -150,7 +151,9 @@ pub fn run( } else if auto_commit && predicate.can_commit { preprocessor.commit(predicate.texts[0].to_owned()); } else { - frontend_tx1.send(GUICmd::Predicate(predicate))?; + if suggestions { + frontend_tx1.send(GUICmd::Predicate(predicate))?; + } } Ok(())