aboutsummaryrefslogtreecommitdiff
path: root/src/app.rs
diff options
context:
space:
mode:
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,
})
}