From fd2336a0c3826bddb85ebf7f4bc2bd93328c36fe Mon Sep 17 00:00:00 2001 From: Fomegne Brady Date: Mon, 10 Jul 2023 09:29:30 +0100 Subject: [PATCH] fix(clafrica): whitespaces as allowed chacracters (#63) Now, the user is able to use code who contains spaces --- CHANGELOG.md | 1 + clafrica/data/test.toml | 1 + clafrica/src/lib.rs | 8 ++++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8640f79..09c966e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Implement the auto capitalization. [(#56)](https://github.com/pythonbrad/clafrica/pull/56) ### Fixed +- Allowed whitespaces usage. [(#63)](https://github.com/pythonbrad/clafrica/pull/63) - Improve the pause/resume way via double pressing of CTRL key. [(#54)](https://github.com/pythonbrad/clafrica/pull/54) - Drop function key F1-12 which was reserved for special purposes. [(#62)](https://github.com/pythonbrad/clafrica/pull/62) diff --git a/clafrica/data/test.toml b/clafrica/data/test.toml index 379894d..8af94eb 100644 --- a/clafrica/data/test.toml +++ b/clafrica/data/test.toml @@ -18,3 +18,4 @@ cc = { value = "ç", alias = ["ccced"]} uu = "ʉ" uu3 = "ʉ̄" uuaf3 = "ʉ̄ɑ̄" +"a\t" = "ɑ" diff --git a/clafrica/src/lib.rs b/clafrica/src/lib.rs index b05db18..91ed3ff 100644 --- a/clafrica/src/lib.rs +++ b/clafrica/src/lib.rs @@ -61,8 +61,8 @@ pub fn run(config: config::Config, mut frontend: impl Frontend) -> Result<(), io for event in rx.iter() { let character = event.name.and_then(|s| s.chars().next()); let is_valid = character - .map(|c| c.is_alphanumeric() || c.is_ascii_punctuation()) - .unwrap_or_default(); + .map(|c| c.is_alphanumeric() || c.is_ascii_punctuation() || c.is_whitespace()) + .unwrap_or(false); match event.event_type { EventType::KeyPress(E_Key::Backspace) => { @@ -257,6 +257,10 @@ mod tests { input!(CapsLock Num5 CapsLock KeyU, typing_speed_ms); output!(textfield, format!("{LIMIT}αÛû")); + // We verify that the usage of white works as expected + input!(KeyA Tab, typing_speed_ms); + output!(textfield, format!("{LIMIT}αÛûɑ")); + rstk::end_wish(); } }