2026-01-18 11:02:41 -05:00
|
|
|
use ratatui::crossterm::event::{Event, KeyEvent, MouseEvent};
|
2026-01-17 17:09:42 -05:00
|
|
|
|
|
|
|
|
pub enum Action {
|
|
|
|
|
Noop,
|
|
|
|
|
Quit,
|
2026-01-18 10:09:28 -05:00
|
|
|
Pass, // Pass input to another component.
|
2026-01-17 17:09:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub trait ClideComponent {
|
2026-01-18 11:02:41 -05:00
|
|
|
fn handle_event(&mut self, event: Event) -> Action {
|
|
|
|
|
match event {
|
|
|
|
|
Event::Key(key_event) => self.handle_key_events(key_event),
|
|
|
|
|
_ => Action::Noop,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-18 10:09:28 -05:00
|
|
|
fn handle_key_events(&mut self, _key: KeyEvent) -> Action {
|
|
|
|
|
Action::Noop
|
2026-01-17 17:09:42 -05:00
|
|
|
}
|
|
|
|
|
|
2026-01-18 10:09:28 -05:00
|
|
|
#[allow(dead_code)]
|
|
|
|
|
fn handle_mouse_events(&mut self, _mouse: MouseEvent) -> Action {
|
2026-01-17 17:09:42 -05:00
|
|
|
Action::Noop
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-18 10:09:28 -05:00
|
|
|
#[allow(dead_code)]
|
|
|
|
|
fn update(&mut self, _action: Action) -> Action {
|
2026-01-17 17:09:42 -05:00
|
|
|
Action::Noop
|
|
|
|
|
}
|
|
|
|
|
}
|