From fa3e812a301455c7bc7b4d829a7fba01ddaea413 Mon Sep 17 00:00:00 2001 From: Shav Kinderlehrer Date: Thu, 7 Mar 2024 02:05:03 -0500 Subject: Implement keyboard shortcut popup --- src/app.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/app.rs') diff --git a/src/app.rs b/src/app.rs index a1fd1e4..03ba04a 100644 --- a/src/app.rs +++ b/src/app.rs @@ -22,7 +22,7 @@ impl App { pub fn new(tick_rate: Duration) -> Result { let tui = tui::init()?; - let mut key_commands = vec![KeyCommand { + let key_commands = vec![KeyCommand { key_code: "q".to_string(), description: "Quit molehole".to_string(), action: Some(AppAction::Quit), @@ -45,7 +45,7 @@ impl App { } pub fn run(&mut self) -> Result<()> { - for component in self.components.iter_mut() { + for component in &mut self.components { component.init()?; } @@ -73,10 +73,9 @@ impl App { if let Some(event) = event { let mut actions: Vec = vec![]; - for component in self.components.iter_mut() { - match component.handle_event(event)? { - Some(action) => actions.push(action), - None => (), + for component in &mut self.components { + if let Some(action) = component.handle_event(event)? { + actions.push(action); } } @@ -90,11 +89,8 @@ impl App { } self.tui.draw(|frame| { - for (_i, component) in self.components.iter_mut().enumerate() { - match component.render(frame, frame.size()) { - Ok(_) => (), - Err(_) => (), - } + for component in &mut self.components { + let _ = component.render(frame, frame.size()); } })?; -- cgit v1.2.3