diff options
| author | a-kenji <aks.kenji@protonmail.com> | 2021-05-14 23:28:30 +0200 |
|---|---|---|
| committer | a-kenji <aks.kenji@protonmail.com> | 2021-05-24 23:06:50 +0200 |
| commit | 80fe803ffd49c0aa05c3883d04c0239e5dd5bae1 (patch) | |
| tree | bec4de7a2e53060f78744bd7a0341c2a9d7deb8c /src | |
| parent | feat(build): incorporate git committing and tagging into the publish process (diff) | |
| download | sl0ppij-80fe803ffd49c0aa05c3883d04c0239e5dd5bae1.tar.gz sl0ppij-80fe803ffd49c0aa05c3883d04c0239e5dd5bae1.tar.xz sl0ppij-80fe803ffd49c0aa05c3883d04c0239e5dd5bae1.zip | |
Default mode 368
* Parsing Implemented
* Adds option to specify a default mode
either through a flag `--options default-mode [MODE]`,
or a configuration option `default_mode: [MODE]`
closes #368
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/mod.rs | 5 | ||||
| -rw-r--r-- | src/common/input/handler.rs | 5 | ||||
| -rw-r--r-- | src/common/input/options.rs | 14 | ||||
| -rw-r--r-- | src/common/screen.rs | 4 |
4 files changed, 24 insertions, 4 deletions
diff --git a/src/client/mod.rs b/src/client/mod.rs index 6f298615..8d83b626 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -20,6 +20,7 @@ use crate::common::{ thread_bus::{SenderType, SenderWithContext, SyncChannelWithContext}, }; use crate::server::ServerInstruction; +use zellij_tile::data::InputMode; /// Instructions related to the client-side application and sent from server to client #[derive(Serialize, Deserialize, Debug, Clone)] @@ -54,7 +55,7 @@ pub fn start_client(mut os_input: Box<dyn ClientOsApi>, opts: CliArgs, config: C os_input.send_to_server(ServerInstruction::NewClient( full_screen_ws, opts, - config_options, + config_options.clone(), )); os_input.set_raw_mode(0); let _ = os_input @@ -83,12 +84,14 @@ pub fn start_client(mut os_input: Box<dyn ClientOsApi>, opts: CliArgs, config: C let send_client_instructions = send_client_instructions.clone(); let command_is_executing = command_is_executing.clone(); let os_input = os_input.clone(); + let default_mode = config_options.default_mode.unwrap_or(InputMode::Normal); move || { input_loop( os_input, config, command_is_executing, send_client_instructions, + default_mode, ) } }); diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs index b2f4d0a3..7dabc71e 100644 --- a/src/common/input/handler.rs +++ b/src/common/input/handler.rs @@ -33,9 +33,10 @@ impl InputHandler { command_is_executing: CommandIsExecuting, config: Config, send_client_instructions: SenderWithContext<ClientInstruction>, + mode: InputMode, ) -> Self { InputHandler { - mode: InputMode::Normal, + mode, os_input, config, command_is_executing, @@ -225,12 +226,14 @@ pub fn input_loop( config: Config, command_is_executing: CommandIsExecuting, send_client_instructions: SenderWithContext<ClientInstruction>, + default_mode: InputMode, ) { let _handler = InputHandler::new( os_input, command_is_executing, config, send_client_instructions, + default_mode, ) .handle_input(); } diff --git a/src/common/input/options.rs b/src/common/input/options.rs index 33625b65..0c5909d0 100644 --- a/src/common/input/options.rs +++ b/src/common/input/options.rs @@ -2,6 +2,7 @@ use crate::cli::ConfigCli; use serde::{Deserialize, Serialize}; use structopt::StructOpt; +use zellij_tile::data::InputMode; #[derive(Clone, Default, Debug, PartialEq, Deserialize, Serialize, StructOpt)] /// Options that can be set either through the config file, @@ -11,6 +12,9 @@ pub struct Options { /// that is compatible with more fonts #[structopt(long)] pub simplified_ui: bool, + /// Allows to specify the default mode + #[structopt(long)] + pub default_mode: Option<InputMode>, } impl Options { @@ -32,7 +36,15 @@ impl Options { self.simplified_ui }; - Options { simplified_ui } + let default_mode = match other.default_mode { + None => self.default_mode, + other => other, + }; + + Options { + simplified_ui, + default_mode, + } } pub fn from_cli(&self, other: Option<ConfigCli>) -> Options { diff --git a/src/common/screen.rs b/src/common/screen.rs index bc99f953..dbdccb86 100644 --- a/src/common/screen.rs +++ b/src/common/screen.rs @@ -333,6 +333,7 @@ pub fn screen_thread_main( ) { let colors = bus.os_input.as_ref().unwrap().load_palette(); let capabilities = config_options.simplified_ui; + let default_mode = config_options.default_mode.unwrap_or_default(); let mut screen = Screen::new( bus, @@ -343,9 +344,10 @@ pub fn screen_thread_main( capabilities: PluginCapabilities { arrow_fonts: capabilities, }, + mode: default_mode, ..ModeInfo::default() }, - InputMode::Normal, + default_mode, colors, ); loop { |
