Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix windows double character #17

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -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"
Expand Down
9 changes: 6 additions & 3 deletions 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};

Expand Down Expand Up @@ -99,8 +101,9 @@ impl Default for Input {
impl From<CrosstermEvent> 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(),
}
Expand Down