aboutsummaryrefslogtreecommitdiff
path: root/src/app.rs
diff options
context:
space:
mode:
authorShav Kinderlehrer <[email protected]>2024-03-06 14:14:07 -0500
committerShav Kinderlehrer <[email protected]>2024-03-06 14:14:07 -0500
commitc2acb446e7868b67e5743d54cee5c64c469e5a18 (patch)
tree0a0243b2d064fe2d1d6acf2a21ea93a40ad9a02a /src/app.rs
parenta5dbccee4f22de991e33449ae1d1835269c6075d (diff)
downloadmolehole-c2acb446e7868b67e5743d54cee5c64c469e5a18.tar.gz
molehole-c2acb446e7868b67e5743d54cee5c64c469e5a18.zip
Add keyboard commands
Diffstat (limited to 'src/app.rs')
-rw-r--r--src/app.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/app.rs b/src/app.rs
index 22a8c40..a1fd1e4 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -6,12 +6,14 @@ use crate::app_action::AppAction;
use crate::app_event::AppEvent;
use crate::component::Component;
use crate::components;
+use crate::keys::key_commands::KeyCommand;
use crate::tui;
pub struct App {
pub tui: tui::Tui,
pub tick_rate: Duration,
pub components: Vec<Box<dyn Component>>,
+ pub key_commands: Vec<KeyCommand>,
should_quit: bool,
}
@@ -20,13 +22,24 @@ impl App {
pub fn new(tick_rate: Duration) -> Result<Self> {
let tui = tui::init()?;
- let global_keys = components::global_keys::GlobalKeys::default();
+ let mut key_commands = vec![KeyCommand {
+ key_code: "q".to_string(),
+ description: "Quit molehole".to_string(),
+ action: Some(AppAction::Quit),
+ }];
+
+ let global_keys = components::global_keys::GlobalKeys {
+ key_commands: key_commands.clone(),
+ ..Default::default()
+ };
let hello_world = components::hello_world::HelloWorld::default();
Ok(Self {
tui,
tick_rate,
components: vec![Box::new(hello_world), Box::new(global_keys)],
+ key_commands,
+
should_quit: false,
})
}