diff options
author | a-kenji <aks.kenji@protonmail.com> | 2021-05-29 19:08:36 +0200 |
---|---|---|
committer | a-kenji <aks.kenji@protonmail.com> | 2021-05-29 19:08:36 +0200 |
commit | 70d9d2cf4f49a35f8ac5a4dd1b3e8c88da3981a6 (patch) | |
tree | f3bff85328dc62d87728977faaa7a08dd3f6de0c | |
parent | 154ed3d41cc863e0e4446309db38f8b3aa4479a6 (diff) |
Add default_mode to attach
* Attaching a new session now also respects the
default_mode setting of the client
-rw-r--r-- | src/main.rs | 6 | ||||
-rw-r--r-- | zellij-client/src/lib.rs | 6 | ||||
-rw-r--r-- | zellij-server/src/lib.rs | 13 | ||||
-rw-r--r-- | zellij-server/src/route.rs | 2 | ||||
-rw-r--r-- | zellij-utils/src/ipc.rs | 2 |
5 files changed, 17 insertions, 12 deletions
diff --git a/src/main.rs b/src/main.rs index b9147fab2..97ad3deee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,7 @@ use zellij_utils::{ cli::{CliArgs, Command, Sessions}, consts::{ZELLIJ_TMP_DIR, ZELLIJ_TMP_LOG_DIR}, input::config::Config, + input::options::Options, logging::*, setup::{get_default_data_dir, Setup}, structopt::StructOpt, @@ -63,11 +64,14 @@ pub fn main() { } else { session_name = Some(get_active_session()); } + + let config_options = Options::from_cli(&config.options, opts.command.clone()); + start_client( Box::new(os_input), opts, config, - ClientInfo::Attach(session_name.unwrap(), force), + ClientInfo::Attach(session_name.unwrap(), force, config_options), ); } else { let session_name = opts diff --git a/zellij-client/src/lib.rs b/zellij-client/src/lib.rs index 701047842..bd46c90b7 100644 --- a/zellij-client/src/lib.rs +++ b/zellij-client/src/lib.rs @@ -77,7 +77,7 @@ fn spawn_server(socket_path: &Path) -> io::Result<()> { #[derive(Debug, Clone)] pub enum ClientInfo { - Attach(String, bool), + Attach(String, bool, Options), New(String), } @@ -112,11 +112,11 @@ pub fn start_client( #[cfg(not(any(feature = "test", test)))] let first_msg = match info { - ClientInfo::Attach(name, force) => { + ClientInfo::Attach(name, force, config_options) => { SESSION_NAME.set(name).unwrap(); std::env::set_var(&"ZELLIJ_SESSION_NAME", SESSION_NAME.get().unwrap()); - ClientToServerMsg::AttachClient(client_attributes, force) + ClientToServerMsg::AttachClient(client_attributes, force, config_options) } ClientInfo::New(name) => { SESSION_NAME.set(name).unwrap(); diff --git a/zellij-server/src/lib.rs b/zellij-server/src/lib.rs index b40362001..76b4b7b18 100644 --- a/zellij-server/src/lib.rs +++ b/zellij-server/src/lib.rs @@ -15,7 +15,7 @@ use std::path::PathBuf; use std::sync::{Arc, Mutex, RwLock}; use std::thread; use wasmer::Store; -use zellij_tile::data::{Event, InputMode, PluginCapabilities}; +use zellij_tile::data::{Event, PluginCapabilities}; use crate::{ os_input_output::ServerOsApi, @@ -44,7 +44,7 @@ pub(crate) enum ServerInstruction { ClientExit, Error(String), DetachSession, - AttachClient(ClientAttributes, bool), + AttachClient(ClientAttributes, bool, Options), } impl From<ClientToServerMsg> for ServerInstruction { @@ -53,8 +53,8 @@ impl From<ClientToServerMsg> for ServerInstruction { ClientToServerMsg::NewClient(attrs, opts, options) => { ServerInstruction::NewClient(attrs, opts, options) } - ClientToServerMsg::AttachClient(attrs, force) => { - ServerInstruction::AttachClient(attrs, force) + ClientToServerMsg::AttachClient(attrs, force, options) => { + ServerInstruction::AttachClient(attrs, force, options) } _ => unreachable!(), } @@ -225,7 +225,7 @@ pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) { .send_to_pty(PtyInstruction::NewTab) .unwrap(); } - ServerInstruction::AttachClient(attrs, _) => { + ServerInstruction::AttachClient(attrs, _, options) => { *session_state.write().unwrap() = SessionState::Attached; let rlock = session_data.read().unwrap(); let session_data = rlock.as_ref().unwrap(); @@ -233,8 +233,9 @@ pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) { .senders .send_to_screen(ScreenInstruction::TerminalResize(attrs.position_and_size)) .unwrap(); + let default_mode = options.default_mode.unwrap_or_default(); let mode_info = - get_mode_info(InputMode::Normal, attrs.palette, session_data.capabilities); + get_mode_info(default_mode, attrs.palette, session_data.capabilities); session_data .senders .send_to_screen(ScreenInstruction::ChangeMode(mode_info.clone())) diff --git a/zellij-server/src/route.rs b/zellij-server/src/route.rs index 8dcd98ffa..673f563a5 100644 --- a/zellij-server/src/route.rs +++ b/zellij-server/src/route.rs @@ -238,7 +238,7 @@ pub(crate) fn route_thread_main( to_server.send(instruction.into()).unwrap(); } } - ClientToServerMsg::AttachClient(_, force) => { + ClientToServerMsg::AttachClient(_, force, _) => { if *session_state.read().unwrap() == SessionState::Attached && !force { os_input.send_to_temp_client(ServerToClientMsg::Exit(ExitReason::CannotAttach)); } else { diff --git a/zellij-utils/src/ipc.rs b/zellij-utils/src/ipc.rs index a160b782f..3d75f8a72 100644 --- a/zellij-utils/src/ipc.rs +++ b/zellij-utils/src/ipc.rs @@ -57,7 +57,7 @@ pub enum ClientToServerMsg { DisconnectFromSession,*/ TerminalResize(PositionAndSize), NewClient(ClientAttributes, Box<CliArgs>, Box<Options>), - AttachClient(ClientAttributes, bool), + AttachClient(ClientAttributes, bool, Options), Action(Action), ClientExited, } |