Skip to content

Commit

Permalink
Monitor input only sends key on press now, not on release
Browse files Browse the repository at this point in the history
  • Loading branch information
LelouBil committed Aug 7, 2024
1 parent 2334907 commit ccde9d4
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions espflash/src/cli/monitor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use std::{
time::Duration,
};

use crossterm::event::KeyEventKind;
use crossterm::{
event::{poll, read, Event, KeyCode, KeyEvent, KeyModifiers},
terminal::{disable_raw_mode, enable_raw_mode},
Expand Down Expand Up @@ -116,20 +117,22 @@ pub fn monitor(

if interactive_mode && poll(Duration::from_secs(0)).into_diagnostic()? {
if let Event::Key(key) = read().into_diagnostic()? {
if key.modifiers.contains(KeyModifiers::CONTROL) {
match key.code {
KeyCode::Char('c') => break,
KeyCode::Char('r') => {
reset_after_flash(&mut serial, pid).into_diagnostic()?;
continue;
if key.kind == KeyEventKind::Press {
if key.modifiers.contains(KeyModifiers::CONTROL) {
match key.code {
KeyCode::Char('c') => break,
KeyCode::Char('r') => {
reset_after_flash(&mut serial, pid).into_diagnostic()?;
continue;
}
_ => {}
}
_ => {}
}
}

if let Some(bytes) = handle_key_event(key) {
serial.write_all(&bytes).into_diagnostic()?;
serial.flush().into_diagnostic()?;
if let Some(bytes) = handle_key_event(key) {
serial.write_all(&bytes).into_diagnostic()?;
serial.flush().into_diagnostic()?;
}
}
}
}
Expand Down

0 comments on commit ccde9d4

Please sign in to comment.