diff options
author | Shav Kinderlehrer <[email protected]> | 2024-03-07 02:05:03 -0500 |
---|---|---|
committer | Shav Kinderlehrer <[email protected]> | 2024-03-07 02:05:03 -0500 |
commit | fa3e812a301455c7bc7b4d829a7fba01ddaea413 (patch) | |
tree | a7f5c2b3b500c8780b6460f6d1107965680f7148 /src/app.rs | |
parent | c2acb446e7868b67e5743d54cee5c64c469e5a18 (diff) | |
download | molehole-fa3e812a301455c7bc7b4d829a7fba01ddaea413.tar.gz molehole-fa3e812a301455c7bc7b4d829a7fba01ddaea413.zip |
Implement keyboard shortcut popup
Diffstat (limited to 'src/app.rs')
-rw-r--r-- | src/app.rs | 18 |
1 files changed, 7 insertions, 11 deletions
@@ -22,7 +22,7 @@ impl App { pub fn new(tick_rate: Duration) -> Result<Self> { 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<AppAction> = 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()); } })?; |