clide/src/tui/component.rs

31 lines
697 B
Rust

use ratatui::crossterm::event::{Event, KeyEvent, MouseEvent};
pub enum Action {
Noop,
Quit,
Pass, // Pass input to another component.
}
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
}
#[allow(dead_code)]
fn handle_mouse_events(&mut self, _mouse: MouseEvent) -> Action {
Action::Noop
}
#[allow(dead_code)]
fn update(&mut self, _action: Action) -> Action {
Action::Noop
}
}