diff options
| author | a-kenji <aks.kenji@protonmail.com> | 2021-03-05 19:23:06 +0100 |
|---|---|---|
| committer | a-kenji <aks.kenji@protonmail.com> | 2021-03-05 19:23:06 +0100 |
| commit | c644a1c2437ac439425eaa185d4f69911cf5ee45 (patch) | |
| tree | 0ca25130d142ba9c26f88a32a7f53daa464a312d /src/common/input | |
| parent | poke at creating Macros (diff) | |
| download | sl0ppij-c644a1c2437ac439425eaa185d4f69911cf5ee45.tar.gz sl0ppij-c644a1c2437ac439425eaa185d4f69911cf5ee45.tar.xz sl0ppij-c644a1c2437ac439425eaa185d4f69911cf5ee45.zip | |
poking
Diffstat (limited to 'src/common/input')
| -rw-r--r-- | src/common/input/handler.rs | 19 | ||||
| -rw-r--r-- | src/common/input/keybinds.rs | 2 | ||||
| -rw-r--r-- | src/common/input/macros.rs | 4 |
3 files changed, 19 insertions, 6 deletions
diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs index 5c4f1971..9d8b2cf2 100644 --- a/src/common/input/handler.rs +++ b/src/common/input/handler.rs @@ -2,6 +2,7 @@ use super::actions::Action; use super::keybinds::get_default_keybinds; +use crate::common::config::Config; use crate::common::{update_state, AppInstruction, AppState, SenderWithContext, OPENCALLS}; use crate::errors::ContextType; use crate::os_input_output::OsApi; @@ -22,6 +23,7 @@ struct InputHandler { /// The current input mode mode: InputMode, os_input: Box<dyn OsApi>, + config: Config, command_is_executing: CommandIsExecuting, send_screen_instructions: SenderWithContext<ScreenInstruction>, send_pty_instructions: SenderWithContext<PtyInstruction>, @@ -34,6 +36,7 @@ impl InputHandler { fn new( os_input: Box<dyn OsApi>, command_is_executing: CommandIsExecuting, + config: Config, send_screen_instructions: SenderWithContext<ScreenInstruction>, send_pty_instructions: SenderWithContext<PtyInstruction>, send_plugin_instructions: SenderWithContext<PluginInstruction>, @@ -42,6 +45,7 @@ impl InputHandler { InputHandler { mode: InputMode::Normal, os_input, + config, command_is_executing, send_screen_instructions, send_pty_instructions, @@ -59,6 +63,8 @@ impl InputHandler { self.send_app_instructions.update(err_ctx); self.send_screen_instructions.update(err_ctx); if let Ok(keybinds) = get_default_keybinds() { + let mut merged_keybinds = keybinds; + merged_keybinds.extend(self.config.keybinds.clone().into_iter()); 'input_loop: loop { //@@@ I think this should actually just iterate over stdin directly let stdin_buffer = self.os_input.read_from_stdin(); @@ -76,9 +82,14 @@ impl InputHandler { // been revised. Sorry about this (@categorille) if { let mut should_break = false; - for action in - key_to_actions(&key, raw_bytes, &self.mode, &keybinds) - { + // Hacked on way to have a means of testing Macros, needs to + // get properly integrated + for action in key_to_actions( + &key, + raw_bytes, + &self.mode, + &merged_keybinds, + ) { should_break |= self.dispatch_action(action); } should_break @@ -324,6 +335,7 @@ pub fn get_help(mode: InputMode) -> Help { /// its [`InputHandler::handle_input()`] loop. pub fn input_loop( os_input: Box<dyn OsApi>, + config: Config, command_is_executing: CommandIsExecuting, send_screen_instructions: SenderWithContext<ScreenInstruction>, send_pty_instructions: SenderWithContext<PtyInstruction>, @@ -333,6 +345,7 @@ pub fn input_loop( let _handler = InputHandler::new( os_input, command_is_executing, + config, send_screen_instructions, send_pty_instructions, send_plugin_instructions, diff --git a/src/common/input/keybinds.rs b/src/common/input/keybinds.rs index 0ea0695f..8799649d 100644 --- a/src/common/input/keybinds.rs +++ b/src/common/input/keybinds.rs @@ -23,7 +23,7 @@ pub fn get_default_keybinds() -> Result<Keybinds, String> { Ok(defaults) } -/// Returns the default keybinds for a givent [`InputMode`]. +/// Returns the default keybinds for a given [`InputMode`]. fn get_defaults_for_mode(mode: &InputMode) -> Result<ModeKeybinds, String> { let mut defaults = ModeKeybinds::new(); diff --git a/src/common/input/macros.rs b/src/common/input/macros.rs index cbd14332..4b7c6df1 100644 --- a/src/common/input/macros.rs +++ b/src/common/input/macros.rs @@ -2,11 +2,11 @@ //! defined predictable order. use super::actions::Action; - + use serde::Deserialize; #[derive(Debug, Clone, Deserialize)] pub struct Macro { name: Option<String>, - sequence: Vec<Action> + sequence: Vec<Action>, } |
