[tui] Move default input logic into ClideComponent.
This commit is contained in:
@@ -42,21 +42,10 @@ impl<'a> App<'a> {
|
||||
self.editor
|
||||
.event_handler
|
||||
.on_event(event.clone(), &mut self.editor.state);
|
||||
|
||||
match event {
|
||||
Event::FocusGained => {}
|
||||
Event::FocusLost => {}
|
||||
Event::Key(key_event) => {
|
||||
// Handle main application key events.
|
||||
match self.handle_key_events(key_event) {
|
||||
Action::Noop => {}
|
||||
Action::Quit => break,
|
||||
Action::Pass => {}
|
||||
}
|
||||
}
|
||||
Event::Mouse(_) => {}
|
||||
Event::Paste(_) => {}
|
||||
Event::Resize(_, _) => {}
|
||||
match self.handle_event(event) {
|
||||
Action::Noop => {}
|
||||
Action::Quit => break,
|
||||
Action::Pass => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use ratatui::crossterm::event::{KeyEvent, MouseEvent};
|
||||
use ratatui::crossterm::event::{Event, KeyEvent, MouseEvent};
|
||||
|
||||
pub enum Action {
|
||||
Noop,
|
||||
@@ -7,6 +7,13 @@ pub enum Action {
|
||||
}
|
||||
|
||||
pub trait ClideComponent {
|
||||
fn handle_event(&mut self, event: Event) -> Action {
|
||||
match event {
|
||||
Event::Key(key_event) => self.handle_key_events(key_event),
|
||||
_ => Action::Noop,
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_key_events(&mut self, _key: KeyEvent) -> Action {
|
||||
Action::Noop
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user