mirror of
https://github.com/zellij-org/zellij.git
synced 2024-11-27 14:34:32 +03:00
Merge pull request #549 from a-kenji/default-mode-attach
Add default_mode to attach
This commit is contained in:
commit
80bd53b8f7
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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()))
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user