Fix after rebase

This commit is contained in:
Kunal Mohan 2021-05-12 22:27:25 +05:30
parent e203f96d78
commit 41212dc0e8
6 changed files with 41 additions and 15 deletions

View file

@ -17,6 +17,7 @@ use crate::common::{
errors::ContextType,
input::config::Config,
input::handler::input_loop,
input::options::Options,
ipc::{ClientToServerMsg, ServerToClientMsg},
os_input_output::ClientOsApi,
thread_bus::{SenderType, SenderWithContext, SyncChannelWithContext},
@ -62,6 +63,7 @@ fn spawn_server(socket_path: &Path) -> io::Result<()> {
}
pub fn start_client(mut os_input: Box<dyn ClientOsApi>, opts: CliArgs, config: Config) {
let clear_client_terminal_attributes = "\u{1b}[?1l\u{1b}=\u{1b}[r\u{1b}12l\u{1b}[?1000l\u{1b}[?1002l\u{1b}[?1003l\u{1b}[?1005l\u{1b}[?1006l\u{1b}[?12l";
let take_snapshot = "\u{1b}[?1049h";
let bracketed_paste = "\u{1b}[?2004h";
os_input.unset_raw_mode(0);
@ -69,7 +71,10 @@ pub fn start_client(mut os_input: Box<dyn ClientOsApi>, opts: CliArgs, config: C
.get_stdout_writer()
.write(take_snapshot.as_bytes())
.unwrap();
let _ = os_input
.get_stdout_writer()
.write(clear_client_terminal_attributes.as_bytes())
.unwrap();
std::env::set_var(&"ZELLIJ", "0");
#[cfg(not(test))]
@ -81,7 +86,11 @@ pub fn start_client(mut os_input: Box<dyn ClientOsApi>, opts: CliArgs, config: C
let full_screen_ws = os_input.get_terminal_size_using_fd(0);
os_input.connect_to_server(&*ZELLIJ_IPC_PIPE);
os_input.send_to_server(ClientToServerMsg::NewClient(full_screen_ws, opts));
os_input.send_to_server(ClientToServerMsg::NewClient(
full_screen_ws,
opts,
config_options,
));
os_input.set_raw_mode(0);
let _ = os_input
.get_stdout_writer()

View file

@ -3,7 +3,7 @@
use crate::cli::CliArgs;
use crate::common::{
errors::{get_current_ctx, ErrorContext},
input::actions::Action,
input::{actions::Action, options::Options},
};
use crate::panes::PositionAndSize;
use interprocess::local_socket::LocalSocketStream;
@ -47,7 +47,7 @@ pub enum ClientToServerMsg {
DisconnectFromSession,*/
ClientExit,
TerminalResize(PositionAndSize),
NewClient(PositionAndSize, CliArgs),
NewClient(PositionAndSize, CliArgs, Options),
Action(Action),
}

View file

@ -14,7 +14,7 @@ use structopt::StructOpt;
use crate::cli::CliArgs;
use crate::command_is_executing::CommandIsExecuting;
use crate::common::input::config::Config;
use crate::common::input::{config::Config, options::Options};
use crate::os_input_output::{get_client_os_input, get_server_os_input};
use crate::utils::{
consts::{ZELLIJ_TMP_DIR, ZELLIJ_TMP_LOG_DIR},
@ -41,7 +41,7 @@ pub fn main() {
atomic_create_dir(&*ZELLIJ_TMP_LOG_DIR).unwrap();
if let Some(path) = opts.server {
let os_input = get_server_os_input();
start_server(Box::new(os_input), path);
start_server(Box::new(os_input), path, config_options);
} else {
let os_input = get_client_os_input();
start_client(Box::new(os_input), opts, config);

View file

@ -10,6 +10,7 @@ use crate::cli::CliArgs;
use crate::common::thread_bus::{Bus, ThreadSenders};
use crate::common::{
errors::ContextType,
input::options::Options,
ipc::{ClientToServerMsg, ServerToClientMsg},
os_input_output::ServerOsApi,
pty::{pty_thread_main, Pty, PtyInstruction},
@ -27,7 +28,7 @@ use route::route_thread_main;
/// ones sent by client to server
#[derive(Debug, Clone)]
pub enum ServerInstruction {
NewClient(PositionAndSize, CliArgs),
NewClient(PositionAndSize, CliArgs, Options),
Render(Option<String>),
UnblockInputThread,
ClientExit,
@ -38,7 +39,9 @@ impl From<ClientToServerMsg> for ServerInstruction {
fn from(instruction: ClientToServerMsg) -> Self {
match instruction {
ClientToServerMsg::ClientExit => ServerInstruction::ClientExit,
ClientToServerMsg::NewClient(pos, opts) => ServerInstruction::NewClient(pos, opts),
ClientToServerMsg::NewClient(pos, opts, options) => {
ServerInstruction::NewClient(pos, opts, options)
}
_ => unreachable!(),
}
}
@ -62,7 +65,7 @@ impl Drop for SessionMetaData {
}
}
pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf, config_options: Options) {
#[cfg(not(test))]
daemonize::Daemonize::new()
.working_directory(std::env::var("HOME").unwrap())
@ -111,6 +114,9 @@ pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
let sessions = sessions.clone();
let to_server = to_server.clone();
let socket_path = socket_path.clone();
let capabilities = PluginCapabilities {
arrow_fonts: config_options.simplified_ui,
};
move || {
drop(std::fs::remove_file(&socket_path));
let listener = LocalSocketListener::bind(&*socket_path).unwrap();
@ -152,9 +158,14 @@ pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
let (instruction, mut err_ctx) = server_receiver.recv().unwrap();
err_ctx.add_call(ContextType::IPCServer((&instruction).into()));
match instruction {
ServerInstruction::NewClient(full_screen_ws, opts) => {
let session_data =
init_session(os_input.clone(), opts, to_server.clone(), full_screen_ws);
ServerInstruction::NewClient(full_screen_ws, opts, config_options) => {
let session_data = init_session(
os_input.clone(),
opts,
config_options,
to_server.clone(),
full_screen_ws,
);
*sessions.write().unwrap() = Some(session_data);
sessions
.read()

View file

@ -202,7 +202,12 @@ pub fn route_thread_main(
break;
}
ClientToServerMsg::Action(action) => {
route_action(action, rlocked_sessions.as_ref().unwrap(), &*os_input);
route_action(
action,
rlocked_sessions.as_ref().unwrap(),
&*os_input,
capabilities,
);
}
ClientToServerMsg::TerminalResize(new_size) => {
rlocked_sessions

View file

@ -6,7 +6,7 @@ pub mod utils;
use crate::cli::CliArgs;
use crate::client::start_client;
use crate::common::input::config::Config;
use crate::common::input::{config::Config, options::Options};
use crate::os_input_output::{ClientOsApi, ServerOsApi};
use crate::server::start_server;
use std::path::PathBuf;
@ -16,11 +16,12 @@ pub fn start(
opts: CliArgs,
server_os_input: Box<dyn ServerOsApi>,
config: Config,
config_options: Options,
) {
let server_thread = std::thread::Builder::new()
.name("server_thread".into())
.spawn(move || {
start_server(server_os_input, PathBuf::from(""));
start_server(server_os_input, PathBuf::from(""), config_options);
})
.unwrap();
start_client(client_os_input, opts, config);