From dc100ce6e06666fa2494ed3de31f91f20b4dedb9 Mon Sep 17 00:00:00 2001 From: pm100 Date: Tue, 9 May 2023 12:15:00 +0200 Subject: [PATCH] fix double input on windows --- Cargo.toml | 1 + src/input.rs | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e543e5c..fd67e94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,6 +42,7 @@ tui = { version = "0.19", default-features = false, optional = true } arbitrary = { version = "1", features = ["derive"], optional = true } crossterm-026 = { package = "crossterm", version = "0.26", optional = true } ratatui = { version = "0.20.1", default-features = false, optional = true } +log = "0.4.17" [[example]] name = "minimal" diff --git a/src/input.rs b/src/input.rs index aa099e3..4128a0e 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1,10 +1,12 @@ #[cfg(any(feature = "crossterm", feature = "ratatui-crossterm"))] use crate::crossterm::event::{ - Event as CrosstermEvent, KeyCode, KeyEvent, KeyModifiers, MouseEvent as CrosstermMouseEvent, - MouseEventKind as CrosstermMouseEventKind, + Event as CrosstermEvent, KeyCode, KeyEvent, KeyEventKind, KeyModifiers, + MouseEvent as CrosstermMouseEvent, MouseEventKind as CrosstermMouseEventKind, }; #[cfg(feature = "arbitrary")] use arbitrary::Arbitrary; +#[cfg(any(feature = "crossterm", feature = "ratatui-crossterm"))] +use log::trace; #[cfg(any(feature = "termion", feature = "ratatui-termion"))] use termion::event::{Event as TermionEvent, Key as TermionKey, MouseEvent as TermionMouseEvent}; @@ -99,8 +101,9 @@ impl Default for Input { impl From for Input { /// Convert [`crossterm::event::Event`] to [`Input`]. fn from(event: CrosstermEvent) -> Self { + trace!("Cross Event:{:?}", event); match event { - CrosstermEvent::Key(key) => Self::from(key), + CrosstermEvent::Key(key) if key.kind == KeyEventKind::Press => Self::from(key), CrosstermEvent::Mouse(mouse) => Self::from(mouse), _ => Self::default(), }