summaryrefslogtreecommitdiffstats
path: root/zellij-server/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'zellij-server/src/lib.rs')
-rw-r--r--zellij-server/src/lib.rs35
1 files changed, 33 insertions, 2 deletions
diff --git a/zellij-server/src/lib.rs b/zellij-server/src/lib.rs
index 437f465bd..008955705 100644
--- a/zellij-server/src/lib.rs
+++ b/zellij-server/src/lib.rs
@@ -44,7 +44,7 @@ use zellij_utils::{
consts::{DEFAULT_SCROLL_BUFFER_SIZE, SCROLL_BUFFER_SIZE},
data::{ConnectToSession, Event, PluginCapabilities},
errors::{prelude::*, ContextType, ErrorInstruction, FatalError, ServerContext},
- home::get_default_data_dir,
+ home::{default_layout_dir, get_default_data_dir},
input::{
command::{RunCommand, TerminalAction},
get_mode_info,
@@ -93,6 +93,7 @@ pub enum ServerInstruction {
pipe_id: String,
client_id: ClientId,
},
+ DisconnectAllClientsExcept(ClientId),
}
impl From<&ServerInstruction> for ServerContext {
@@ -117,6 +118,9 @@ impl From<&ServerInstruction> for ServerContext {
ServerInstruction::AssociatePipeWithClient { .. } => {
ServerContext::AssociatePipeWithClient
},
+ ServerInstruction::DisconnectAllClientsExcept(..) => {
+ ServerContext::DisconnectAllClientsExcept
+ },
}
}
}
@@ -133,6 +137,7 @@ pub(crate) struct SessionMetaData {
pub client_attributes: ClientAttributes,
pub default_shell: Option<TerminalAction>,
pub layout: Box<Layout>,
+ pub config_options: Box<Options>,
screen_thread: Option<thread::JoinHandle<()>>,
pty_thread: Option<thread::JoinHandle<()>>,
plugin_thread: Option<thread::JoinHandle<()>>,
@@ -650,6 +655,21 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
}
break;
},
+ ServerInstruction::DisconnectAllClientsExcept(client_id) => {
+ let client_ids: Vec<ClientId> = session_state
+ .read()
+ .unwrap()
+ .client_ids()
+ .iter()
+ .copied()
+ .filter(|c| c != &client_id)
+ .collect();
+ for client_id in client_ids {
+ let _ = os_input
+ .send_to_client(client_id, ServerToClientMsg::Exit(ExitReason::Normal));
+ remove_client!(client_id, os_input, session_state);
+ }
+ },
ServerInstruction::DetachSession(client_ids) => {
for client_id in client_ids {
let _ = os_input
@@ -749,7 +769,16 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
session_state
);
},
- ServerInstruction::SwitchSession(connect_to_session, client_id) => {
+ ServerInstruction::SwitchSession(mut connect_to_session, client_id) => {
+ let layout_dir = session_data
+ .read()
+ .unwrap()
+ .as_ref()
+ .and_then(|c| c.config_options.layout_dir.clone())
+ .or_else(|| default_layout_dir());
+ if let Some(layout_dir) = layout_dir {
+ connect_to_session.apply_layout_dir(&layout_dir);
+ }
if let Some(min_size) = session_state.read().unwrap().min_client_terminal_size() {
session_data
.write()
@@ -906,6 +935,7 @@ fn init_session(
let client_attributes_clone = client_attributes.clone();
let debug = opts.debug;
let layout = layout.clone();
+ let config_options = config_options.clone();
move || {
screen_thread_main(
screen_bus,
@@ -1006,6 +1036,7 @@ fn init_session(
default_shell,
client_attributes,
layout,
+ config_options: config_options.clone(),
screen_thread: Some(screen_thread),
pty_thread: Some(pty_thread),
plugin_thread: Some(plugin_thread),