diff options
| author | a-kenji <aks.kenji@protonmail.com> | 2021-03-05 22:40:42 +0100 |
|---|---|---|
| committer | a-kenji <aks.kenji@protonmail.com> | 2021-03-09 19:16:15 +0100 |
| commit | c97c553870380956904ab7d2daa36e5ce0aef010 (patch) | |
| tree | f84ac83057df1a5da72af1733ffc048555ad8b40 /src/common/input/handler.rs | |
| parent | poking (diff) | |
| download | sl0ppij-c97c553870380956904ab7d2daa36e5ce0aef010.tar.gz sl0ppij-c97c553870380956904ab7d2daa36e5ce0aef010.tar.xz sl0ppij-c97c553870380956904ab7d2daa36e5ce0aef010.zip | |
feature(input): add config file
* use a simple platform dependent config location `ProjectDir`
* deserialise from yaml
iterate more on config format, maybe be more verbose?
* make keybinds a tuple struct
same size as newtype, but makes impls easier to add
* merge optionally multiple keys for one keybinding
easier configuration
Diffstat (limited to 'src/common/input/handler.rs')
| -rw-r--r-- | src/common/input/handler.rs | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs index 9d8b2cf2..9b08491b 100644 --- a/src/common/input/handler.rs +++ b/src/common/input/handler.rs @@ -1,7 +1,7 @@ //! Main input logic. use super::actions::Action; -use super::keybinds::get_default_keybinds; +use super::keybinds::Keybinds; use crate::common::config::Config; use crate::common::{update_state, AppInstruction, AppState, SenderWithContext, OPENCALLS}; use crate::errors::ContextType; @@ -15,8 +15,6 @@ use serde::{Deserialize, Serialize}; use strum_macros::EnumIter; use termion::input::TermReadEventsAndRaw; -use super::keybinds::key_to_actions; - /// Handles the dispatching of [`Action`]s according to the current /// [`InputMode`], and keep tracks of the current [`InputMode`]. struct InputHandler { @@ -62,9 +60,8 @@ impl InputHandler { self.send_pty_instructions.update(err_ctx); 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()); + if let Ok(_keybinds) = Keybinds::get_default_keybinds() { + let keybinds = self.config.keybinds.clone(); 'input_loop: loop { //@@@ I think this should actually just iterate over stdin directly let stdin_buffer = self.os_input.read_from_stdin(); @@ -84,11 +81,8 @@ impl InputHandler { let mut should_break = false; // 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, + for action in Keybinds::key_to_actions( + &key, raw_bytes, &self.mode, &keybinds, ) { should_break |= self.dispatch_action(action); } |
