Crate afrim_preprocessor
source ·Expand description
Preprocessor of keyboard events for an input method.
Example
use afrim_preprocessor::{utils, Command, Preprocessor};
use keyboard_types::{
webdriver::{self, Event},
Key::*,
};
use std::collections::VecDeque;
// We build initiate our preprocessor
let data = utils::load_data("cc ç");
let map = utils::build_map(data);
let mut preprocessor = Preprocessor::new(map, 8);
// We trigger a sequence
webdriver::send_keys("cc")
.into_iter()
.for_each(|e| {
match e {
Event::Keyboard(e) => preprocessor.process(e),
_ => unimplemented!(),
};
});
// We got the generated command
let mut expecteds = VecDeque::from(vec![
Command::Pause,
Command::KeyClick(Backspace),
#[cfg(feature = "inhibit")]
Command::Resume,
#[cfg(feature = "inhibit")]
Command::Pause,
Command::KeyClick(Backspace),
Command::CommitText("ç".to_owned()),
Command::Resume,
]);
while let Some(command) = preprocessor.pop_stack() {
assert_eq!(command, expecteds.pop_front().unwrap());
}Modules
- Module providing a set of tools to facilitate the loading of a data in the memory.
Structs
- Keyboard events are issued for all pressed and released keys.
- The main structure of the preprocessor.
Enums
- Possible commands that can be generated.
- Key represents the meaning of a keypress.
- Describes the state the key is in.