diff --git a/src/app.rs b/src/app.rs index 17c8bc3..5e6ab1f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -128,6 +128,12 @@ impl App { fn handle_action(&mut self, action: AppAction) -> Result<()> { match action { AppAction::Quit => Ok(self.quit()?), + _ => { + for component in &mut self.components { + component.handle_action(action.clone()); + } + Ok(()) + } } } } diff --git a/src/app_action.rs b/src/app_action.rs index 8bbe9dd..93131ac 100644 --- a/src/app_action.rs +++ b/src/app_action.rs @@ -1,5 +1,8 @@ -#[derive(Default, Clone, Copy)] +#[derive(Default, Clone)] pub enum AppAction { + StatusBarMessage(String), + StatusBarError(String), + StatusBarInput(String), #[default] Quit, } diff --git a/src/component.rs b/src/component.rs index 8ec7d26..65d865c 100644 --- a/src/component.rs +++ b/src/component.rs @@ -10,6 +10,9 @@ pub trait Component { Ok(()) } + #[allow(unused)] + fn handle_action(&mut self, action: AppAction) {} + #[allow(unused)] fn handle_event(&mut self, event: AppEvent) -> Result> { match event { diff --git a/src/components/global_keys.rs b/src/components/global_keys.rs index 6537339..d0a5800 100644 --- a/src/components/global_keys.rs +++ b/src/components/global_keys.rs @@ -77,7 +77,7 @@ impl Component for GlobalKeys { for key_command in &mut self.key_commands { if key_command.key_code == key_event { - return Ok(key_command.action); + return Ok(key_command.action.clone()); } } } diff --git a/src/main.rs b/src/main.rs index 96ac2f0..ca87db6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,6 @@ use eyre::Result; fn main() -> Result<()> { let mut app = app::App::new(std::time::Duration::from_millis(10))?; - app.run()?; - app.quit() + app.run() }