Don't use crossterm type directly
This commit is contained in:
parent
b597edc86f
commit
11d3df8f68
@ -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]
|
||||
|
@ -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<crossterm::event::KeyEvent> for InputEvent {
|
||||
fn from(value: crossterm::event::KeyEvent) -> Self {
|
||||
InputEvent(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<InputEvent> for crossterm::event::KeyEvent {
|
||||
fn from(value: InputEvent) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
|
||||
pub trait IAppInput {
|
||||
type APP: IApp;
|
||||
|
||||
|
@ -243,7 +243,7 @@ impl<APP: IApp> IEventHandlerPrivate<APP> for EventHandler {
|
||||
KeyCode::Esc => app.cancel(),
|
||||
KeyCode::Enter => app.confirm(),
|
||||
// Othey keys.
|
||||
_ => app.input(key_event),
|
||||
_ => app.input(key_event.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user