Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonbrad committed Aug 28, 2023
1 parent 3946c3d commit 0e456eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions clafrica/data/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ uu3 = { value = "ʉ̄", alias = ["uu\""] }
uuaf3 = { value = "ʉ̄ɑ̄", alias = ["uuqf\""] }

[translation]
hi = "hello"
hello = "hi"
heli = "helicopter"
hea = "health"
22 changes: 12 additions & 10 deletions clafrica/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ pub fn run(
EventType::KeyRelease(E_Key::ControlLeft | E_Key::ControlRight) => {
is_special_pressed = false;
}
EventType::KeyRelease(E_Key::Alt) if is_special_pressed => frontend.next_predicate(),
EventType::KeyRelease(E_Key::ShiftLeft | E_Key::ShiftRight) if is_special_pressed => {
frontend.next_predicate()
}
EventType::KeyRelease(E_Key::Unknown(151)) if is_special_pressed => {
frontend.previous_predicate()
}
EventType::KeyRelease(E_Key::Space) if is_special_pressed => {
EventType::KeyRelease(E_Key::Alt) if is_special_pressed => {
if let Some(predicate) = frontend.get_selected_predicate() {
is_special_pressed = false;
processor.commit(&predicate.0, &predicate.1, &predicate.2);
Expand Down Expand Up @@ -244,26 +246,26 @@ mod tests {
});

// We verify that the translation work as expected
input!(KeyH KeyE KeyL KeyL KeyO, typing_speed_ms);
output!(textfield, format!("{LIMIT}hi"));
input!(KeyH KeyI, typing_speed_ms);
output!(textfield, format!("{LIMIT}hello"));

(0..2).for_each(|_| {
(0..5).for_each(|_| {
input!(Backspace, typing_speed_ms);
});

// We verify that the predicate selection work as expected
input!(KeyH KeyE, typing_speed_ms);
rdev::simulate(&KeyPress(ControlLeft)).unwrap();
input!(Unknown(151), typing_speed_ms);
input!(Alt, typing_speed_ms);
input!(ShiftLeft ShiftRight, typing_speed_ms);
rdev::simulate(&KeyRelease(ControlLeft)).unwrap();

input!(KeyL KeyL, typing_speed_ms);
rdev::simulate(&KeyPress(ControlLeft)).unwrap();
input!(Space, typing_speed_ms);
rdev::simulate(&KeyRelease(ControlLeft)).unwrap();
rdev::simulate(&KeyPress(ControlRight)).unwrap();
input!(Alt Alt, typing_speed_ms);
rdev::simulate(&KeyRelease(ControlRight)).unwrap();
output!(textfield, format!("{LIMIT}hi"));

rstk::end_wish();
rstk::tell_wish("bind . <Leave> {destroy .}");
}
}

0 comments on commit 0e456eb

Please sign in to comment.