Add manual input elements to the app an ui #216

Merged
wojtek merged 17 commits from 188---add-option-for-manual-input-during-fetch into main 2024-09-15 15:20:11 +02:00
3 changed files with 18 additions and 4 deletions
Showing only changes of commit 11d3df8f68 - Show all commits

View File

@ -38,7 +38,7 @@ impl IAppInput for AppInputMode {
fn input(mut self, input: InputEvent) -> Self::APP { fn input(mut self, input: InputEvent) -> Self::APP {
self.input self.input
.0 .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.input_mut().replace(self.input);
self.app self.app
} }
@ -65,10 +65,11 @@ mod tests {
use super::*; use super::*;
fn input_event(c: char) -> InputEvent { fn input_event(c: char) -> InputEvent {
InputEvent::new( crossterm::event::KeyEvent::new(
crossterm::event::KeyCode::Char(c), crossterm::event::KeyCode::Char(c),
crossterm::event::KeyModifiers::empty(), crossterm::event::KeyModifiers::empty(),
) )
.into()
} }
#[test] #[test]

View File

@ -125,7 +125,20 @@ pub trait IAppInteractMatch {
fn abort(self) -> Self::APP; 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 { pub trait IAppInput {
type APP: IApp; type APP: IApp;

View File

@ -243,7 +243,7 @@ impl<APP: IApp> IEventHandlerPrivate<APP> for EventHandler {
KeyCode::Esc => app.cancel(), KeyCode::Esc => app.cancel(),
KeyCode::Enter => app.confirm(), KeyCode::Enter => app.confirm(),
// Othey keys. // Othey keys.
_ => app.input(key_event), _ => app.input(key_event.into()),
} }
} }
} }