use crate::{BreakingAction, Component, SharedState};
use crossterm::event::{Event, KeyCode, KeyEvent};
pub struct QuitterComponent;
impl<S> Component<S> for QuitterComponent {
fn on_event(
&mut self,
event: Event,
shared_state: &mut SharedState<S>,
) -> Option<BreakingAction> {
if matches!(
event,
Event::Key(KeyEvent {
code: KeyCode::Char('q' | 'Q'),
..
})
) {
Some(BreakingAction::Quit)
} else {
None
}
}
}