Skip to content

Commit

Permalink
fix(clafrica): replace echap key by pause key
Browse files Browse the repository at this point in the history
- the echap key is used by some input field to cancel the current
  operation (eg. typing)
- the purpose of the pause key can't disturb the working of the clafrica
  • Loading branch information
pythonbrad committed May 10, 2023
1 parent ce5b29c commit 2460d68
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions clafrica/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ pub fn run(config: Config, mut frontend: impl Frontend) -> Result<(), io::Error>

rdev::listen(move |event| {
idle = match event.event_type {
EventType::KeyPress(E_Key::Escape) => true,
EventType::KeyRelease(E_Key::Escape) => false,
EventType::KeyPress(E_Key::Pause) => true,
EventType::KeyRelease(E_Key::Pause) => false,
_ => idle,
};
if !idle {
Expand All @@ -61,7 +61,7 @@ pub fn run(config: Config, mut frontend: impl Frontend) -> Result<(), io::Error>
match event.event_type {
EventType::KeyPress(E_Key::Backspace) => {
if let Some(out) = cursor.undo() {
keyboard.key_down(Key::Escape);
keyboard.key_down(Key::Pause);
keyboard.key_up(Key::Backspace);

let i = out.chars().count();
Expand All @@ -71,7 +71,7 @@ pub fn run(config: Config, mut frontend: impl Frontend) -> Result<(), io::Error>
keyboard.key_sequence(&prev_out);
}

keyboard.key_up(Key::Escape);
keyboard.key_up(Key::Pause);

// Clear the remaining code
while let (None, _i @ 1.., ..) = cursor.state() {
Expand All @@ -94,13 +94,13 @@ pub fn run(config: Config, mut frontend: impl Frontend) -> Result<(), io::Error>
let out = cursor.hit(character);

if let Some(out) = out {
keyboard.key_down(Key::Escape);
keyboard.key_down(Key::Pause);

let i = prev_out.map(|s| s.chars().count()).unwrap_or(prev_code_len) + 1;
(0..i).for_each(|_| keyboard.key_click(Key::Backspace));
keyboard.key_sequence(&out);

keyboard.key_up(Key::Escape);
keyboard.key_up(Key::Pause);
};

frontend.update_text(cursor.to_path());
Expand Down

0 comments on commit 2460d68

Please sign in to comment.