[tui] Move default input logic into ClideComponent.

This commit is contained in:
2026-01-18 11:02:41 -05:00
parent fe6390c1cd
commit ce6c12f068
4 changed files with 16 additions and 60 deletions

View File

@@ -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 => {}
}
}
}

View File

@@ -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
}