aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/mod.rs
diff options
context:
space:
mode:
authora-kenji <aks.kenji@protonmail.com>2021-03-05 19:23:06 +0100
committera-kenji <aks.kenji@protonmail.com>2021-03-05 19:23:06 +0100
commitc644a1c2437ac439425eaa185d4f69911cf5ee45 (patch)
tree0ca25130d142ba9c26f88a32a7f53daa464a312d /src/common/mod.rs
parentpoke at creating Macros (diff)
downloadsl0ppij-c644a1c2437ac439425eaa185d4f69911cf5ee45.tar.gz
sl0ppij-c644a1c2437ac439425eaa185d4f69911cf5ee45.tar.xz
sl0ppij-c644a1c2437ac439425eaa185d4f69911cf5ee45.zip
poking
Diffstat (limited to 'src/common/mod.rs')
-rw-r--r--src/common/mod.rs20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/common/mod.rs b/src/common/mod.rs
index 5ba2e15d..c8b2ec98 100644
--- a/src/common/mod.rs
+++ b/src/common/mod.rs
@@ -1,5 +1,5 @@
-pub mod config;
pub mod command_is_executing;
+pub mod config;
pub mod errors;
pub mod input;
pub mod install;
@@ -46,10 +46,17 @@ pub enum ApiCommand {
MoveFocus,
}
// FIXME: It would be good to add some more things to this over time
-#[derive(Debug, Clone, Default)]
+#[derive(Debug, Clone)]
pub struct AppState {
pub input_mode: InputMode,
- pub config : Config,
+}
+
+impl Default for AppState {
+ fn default() -> Self {
+ AppState {
+ input_mode: InputMode::default(),
+ }
+ }
}
// FIXME: Make this a method on the big `Communication` struct, so that app_tx can be extracted
@@ -158,8 +165,13 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
.get_stdout_writer()
.write(take_snapshot.as_bytes())
.unwrap();
+
let mut app_state = AppState::default();
+ let config = Config::from_option_or_default(opts.config)
+ .map_err(|e| eprintln!{"Config Error: {}", e})
+ .unwrap();
+
let command_is_executing = CommandIsExecuting::new();
let full_screen_ws = os_input.get_terminal_size_using_fd(0);
@@ -638,9 +650,11 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
let send_pty_instructions = send_pty_instructions.clone();
let send_plugin_instructions = send_plugin_instructions.clone();
let os_input = os_input.clone();
+ let config = config.clone();
move || {
input_loop(
os_input,
+ config,
command_is_executing,
send_screen_instructions,
send_pty_instructions,