diff --git a/src/tui/app/machine/input.rs b/src/tui/app/machine/input.rs index 9981777..0494235 100644 --- a/src/tui/app/machine/input.rs +++ b/src/tui/app/machine/input.rs @@ -38,7 +38,7 @@ impl IAppInput for AppInputMode { fn input(mut self, input: InputEvent) -> Self::APP { self.input .0 - .handle_event(&crossterm::event::Event::Key(input)); + .handle_event(&crossterm::event::Event::Key(input.into())); self.app.input_mut().replace(self.input); self.app } @@ -65,10 +65,11 @@ mod tests { use super::*; fn input_event(c: char) -> InputEvent { - InputEvent::new( + crossterm::event::KeyEvent::new( crossterm::event::KeyCode::Char(c), crossterm::event::KeyModifiers::empty(), ) + .into() } #[test] diff --git a/src/tui/app/mod.rs b/src/tui/app/mod.rs index 3506fd5..dd6b3a9 100644 --- a/src/tui/app/mod.rs +++ b/src/tui/app/mod.rs @@ -125,7 +125,20 @@ pub trait IAppInteractMatch { fn abort(self) -> Self::APP; } -type InputEvent = crossterm::event::KeyEvent; +pub struct InputEvent(crossterm::event::KeyEvent); + +impl From for InputEvent { + fn from(value: crossterm::event::KeyEvent) -> Self { + InputEvent(value) + } +} + +impl From for crossterm::event::KeyEvent { + fn from(value: InputEvent) -> Self { + value.0 + } +} + pub trait IAppInput { type APP: IApp; diff --git a/src/tui/handler.rs b/src/tui/handler.rs index 83c4813..9adea18 100644 --- a/src/tui/handler.rs +++ b/src/tui/handler.rs @@ -243,7 +243,7 @@ impl IEventHandlerPrivate for EventHandler { KeyCode::Esc => app.cancel(), KeyCode::Enter => app.confirm(), // Othey keys. - _ => app.input(key_event), + _ => app.input(key_event.into()), } } }