Merge pull request #499 from zellij-org/multiprocess

Switch to a multiprocess client-sever model
This commit is contained in:
Kunal Mohan 2021-05-15 23:03:38 +05:30 committed by GitHub
commit 4c198b4243
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 427 additions and 411 deletions

3
.gitignore vendored
View file

@ -3,4 +3,5 @@
.vscode .vscode
.vim .vim
.DS_Store .DS_Store
/assets/man/zellij.1 /assets/man/zellij.1
**/target

17
Cargo.lock generated
View file

@ -248,6 +248,12 @@ dependencies = [
"once_cell", "once_cell",
] ]
[[package]]
name = "boxfnonce"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5988cb1d626264ac94100be357308f29ff7cbdd3b36bda27f450a4ee3f713426"
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.6.1" version = "3.6.1"
@ -467,6 +473,16 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "daemonize"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70c24513e34f53b640819f0ac9f705b673fcf4006d7aab8778bee72ebfc89815"
dependencies = [
"boxfnonce",
"libc",
]
[[package]] [[package]]
name = "darling" name = "darling"
version = "0.12.3" version = "0.12.3"
@ -2261,6 +2277,7 @@ dependencies = [
"backtrace", "backtrace",
"bincode", "bincode",
"colors-transform", "colors-transform",
"daemonize",
"directories-next", "directories-next",
"futures", "futures",
"insta", "insta",

View file

@ -15,6 +15,7 @@ include = ["src/**/*", "assets/plugins/*", "assets/layouts/*", "assets/config/*"
ansi_term = "0.12.1" ansi_term = "0.12.1"
backtrace = "0.3.55" backtrace = "0.3.55"
bincode = "1.3.1" bincode = "1.3.1"
daemonize = "0.4.1"
directories-next = "2.0" directories-next = "2.0"
futures = "0.3.5" futures = "0.3.5"
libc = "0.2" libc = "0.2"

View file

@ -13,19 +13,23 @@ pub struct CliArgs {
pub max_panes: Option<usize>, pub max_panes: Option<usize>,
/// Change where zellij looks for layouts and plugins /// Change where zellij looks for layouts and plugins
#[structopt(long)] #[structopt(long, parse(from_os_str))]
pub data_dir: Option<PathBuf>, pub data_dir: Option<PathBuf>,
/// Run server listening at the specified socket path
#[structopt(long, parse(from_os_str))]
pub server: Option<PathBuf>,
/// Path to a layout yaml file /// Path to a layout yaml file
#[structopt(short, long)] #[structopt(short, long, parse(from_os_str))]
pub layout: Option<PathBuf>, pub layout: Option<PathBuf>,
/// Change where zellij looks for the configuration /// Change where zellij looks for the configuration
#[structopt(short, long, env=ZELLIJ_CONFIG_FILE_ENV)] #[structopt(short, long, env=ZELLIJ_CONFIG_FILE_ENV, parse(from_os_str))]
pub config: Option<PathBuf>, pub config: Option<PathBuf>,
/// Change where zellij looks for the configuration /// Change where zellij looks for the configuration
#[structopt(long, env=ZELLIJ_CONFIG_DIR_ENV)] #[structopt(long, env=ZELLIJ_CONFIG_DIR_ENV, parse(from_os_str))]
pub config_dir: Option<PathBuf>, pub config_dir: Option<PathBuf>,
#[structopt(subcommand)] #[structopt(subcommand)]

View file

@ -4,30 +4,62 @@ pub mod pane_resizer;
pub mod panes; pub mod panes;
pub mod tab; pub mod tab;
use serde::{Deserialize, Serialize}; use std::env::current_exe;
use std::io::Write; use std::io::{self, Write};
use std::path::Path;
use std::process::Command;
use std::sync::mpsc; use std::sync::mpsc;
use std::thread; use std::thread;
use crate::cli::CliArgs; use crate::cli::CliArgs;
use crate::common::{ use crate::common::{
command_is_executing::CommandIsExecuting, command_is_executing::CommandIsExecuting,
errors::{ClientContext, ContextType}, errors::ContextType,
input::config::Config, input::config::Config,
input::handler::input_loop, input::handler::input_loop,
input::options::Options, input::options::Options,
ipc::{ClientToServerMsg, ServerToClientMsg},
os_input_output::ClientOsApi, os_input_output::ClientOsApi,
thread_bus::{SenderType, SenderWithContext, SyncChannelWithContext}, thread_bus::{SenderType, SenderWithContext, SyncChannelWithContext},
utils::consts::ZELLIJ_IPC_PIPE,
}; };
use crate::server::ServerInstruction;
/// Instructions related to the client-side application and sent from server to client /// Instructions related to the client-side application and sent from server to client
#[derive(Serialize, Deserialize, Debug, Clone)] #[derive(Debug, Clone)]
pub enum ClientInstruction { pub enum ClientInstruction {
Error(String), Error(String),
Render(Option<String>), Render(Option<String>),
UnblockInputThread, UnblockInputThread,
Exit, Exit,
ServerError(String),
}
impl From<ServerToClientMsg> for ClientInstruction {
fn from(instruction: ServerToClientMsg) -> Self {
match instruction {
ServerToClientMsg::Exit => ClientInstruction::Exit,
ServerToClientMsg::Render(buffer) => ClientInstruction::Render(buffer),
ServerToClientMsg::UnblockInputThread => ClientInstruction::UnblockInputThread,
ServerToClientMsg::ServerError(backtrace) => ClientInstruction::ServerError(backtrace),
}
}
}
fn spawn_server(socket_path: &Path) -> io::Result<()> {
let status = Command::new(current_exe()?)
.arg("--server")
.arg(socket_path)
.status()?;
if status.success() {
Ok(())
} else {
let msg = "Process returned non-zero exit code";
let err_msg = match status.code() {
Some(c) => format!("{}: {}", msg, c),
None => msg.to_string(),
};
Err(io::Error::new(io::ErrorKind::Other, err_msg))
}
} }
pub fn start_client(mut os_input: Box<dyn ClientOsApi>, opts: CliArgs, config: Config) { pub fn start_client(mut os_input: Box<dyn ClientOsApi>, opts: CliArgs, config: Config) {
@ -45,13 +77,16 @@ pub fn start_client(mut os_input: Box<dyn ClientOsApi>, opts: CliArgs, config: C
.unwrap(); .unwrap();
std::env::set_var(&"ZELLIJ", "0"); std::env::set_var(&"ZELLIJ", "0");
#[cfg(not(test))]
spawn_server(&*ZELLIJ_IPC_PIPE).unwrap();
let mut command_is_executing = CommandIsExecuting::new(); let mut command_is_executing = CommandIsExecuting::new();
let config_options = Options::from_cli(&config.options, opts.option.clone()); let config_options = Options::from_cli(&config.options, opts.option.clone());
let full_screen_ws = os_input.get_terminal_size_using_fd(0); let full_screen_ws = os_input.get_terminal_size_using_fd(0);
os_input.connect_to_server(); os_input.connect_to_server(&*ZELLIJ_IPC_PIPE);
os_input.send_to_server(ServerInstruction::NewClient( os_input.send_to_server(ClientToServerMsg::NewClient(
full_screen_ws, full_screen_ws,
opts, opts,
config_options, config_options,
@ -97,15 +132,26 @@ pub fn start_client(mut os_input: Box<dyn ClientOsApi>, opts: CliArgs, config: C
.name("signal_listener".to_string()) .name("signal_listener".to_string())
.spawn({ .spawn({
let os_input = os_input.clone(); let os_input = os_input.clone();
let send_client_instructions = send_client_instructions.clone();
move || { move || {
os_input.receive_sigwinch(Box::new({ os_input.handle_signals(
let os_api = os_input.clone(); Box::new({
move || { let os_api = os_input.clone();
os_api.send_to_server(ServerInstruction::TerminalResize( move || {
os_api.get_terminal_size_using_fd(0), os_api.send_to_server(ClientToServerMsg::TerminalResize(
)); os_api.get_terminal_size_using_fd(0),
} ));
})); }
}),
Box::new({
let send_client_instructions = send_client_instructions.clone();
move || {
send_client_instructions
.send(ClientInstruction::Exit)
.unwrap()
}
}),
);
} }
}) })
.unwrap(); .unwrap();
@ -114,47 +160,53 @@ pub fn start_client(mut os_input: Box<dyn ClientOsApi>, opts: CliArgs, config: C
.name("router".to_string()) .name("router".to_string())
.spawn({ .spawn({
let os_input = os_input.clone(); let os_input = os_input.clone();
move || { let mut should_break = false;
loop { move || loop {
let (instruction, mut err_ctx) = os_input.recv_from_server(); let (instruction, err_ctx) = os_input.recv_from_server();
err_ctx.add_call(ContextType::Client(ClientContext::from(&instruction))); err_ctx.update_thread_ctx();
if let ClientInstruction::Exit = instruction { match instruction {
break; ServerToClientMsg::Exit | ServerToClientMsg::ServerError(_) => {
should_break = true;
} }
send_client_instructions.send(instruction).unwrap(); _ => {}
}
send_client_instructions.send(instruction.into()).unwrap();
if should_break {
break;
} }
send_client_instructions
.send(ClientInstruction::Exit)
.unwrap();
} }
}) })
.unwrap(); .unwrap();
#[warn(clippy::never_loop)] let handle_error = |backtrace: String| {
os_input.unset_raw_mode(0);
let goto_start_of_last_line = format!("\u{1b}[{};{}H", full_screen_ws.rows, 1);
let restore_snapshot = "\u{1b}[?1049l";
let error = format!(
"{}\n{}{}",
goto_start_of_last_line, restore_snapshot, backtrace
);
let _ = os_input
.get_stdout_writer()
.write(error.as_bytes())
.unwrap();
std::process::exit(1);
};
loop { loop {
let (client_instruction, mut err_ctx) = receive_client_instructions let (client_instruction, mut err_ctx) = receive_client_instructions
.recv() .recv()
.expect("failed to receive app instruction on channel"); .expect("failed to receive app instruction on channel");
err_ctx.add_call(ContextType::Client(ClientContext::from( err_ctx.add_call(ContextType::Client((&client_instruction).into()));
&client_instruction,
)));
match client_instruction { match client_instruction {
ClientInstruction::Exit => break, ClientInstruction::Exit => break,
ClientInstruction::Error(backtrace) => { ClientInstruction::Error(backtrace) => {
let _ = os_input.send_to_server(ServerInstruction::ClientExit); let _ = os_input.send_to_server(ClientToServerMsg::ClientExit);
os_input.unset_raw_mode(0); handle_error(backtrace);
let goto_start_of_last_line = format!("\u{1b}[{};{}H", full_screen_ws.rows, 1); }
let restore_snapshot = "\u{1b}[?1049l"; ClientInstruction::ServerError(backtrace) => {
let error = format!( handle_error(backtrace);
"{}\n{}{}",
goto_start_of_last_line, restore_snapshot, backtrace
);
let _ = os_input
.get_stdout_writer()
.write(error.as_bytes())
.unwrap();
std::process::exit(1);
} }
ClientInstruction::Render(output) => { ClientInstruction::Render(output) => {
if output.is_none() { if output.is_none() {
@ -172,7 +224,7 @@ pub fn start_client(mut os_input: Box<dyn ClientOsApi>, opts: CliArgs, config: C
} }
} }
let _ = os_input.send_to_server(ServerInstruction::ClientExit); let _ = os_input.send_to_server(ClientToServerMsg::ClientExit);
router_thread.join().unwrap(); router_thread.join().unwrap();
// cleanup(); // cleanup();

View file

@ -19,12 +19,29 @@ const MAX_THREAD_CALL_STACK: usize = 6;
use super::thread_bus::SenderWithContext; use super::thread_bus::SenderWithContext;
#[cfg(not(test))] #[cfg(not(test))]
use std::panic::PanicInfo; use std::panic::PanicInfo;
pub trait ErrorInstruction {
fn error(err: String) -> Self;
}
impl ErrorInstruction for ClientInstruction {
fn error(err: String) -> Self {
ClientInstruction::Error(err)
}
}
impl ErrorInstruction for ServerInstruction {
fn error(err: String) -> Self {
ServerInstruction::Error(err)
}
}
/// Custom panic handler/hook. Prints the [`ErrorContext`]. /// Custom panic handler/hook. Prints the [`ErrorContext`].
#[cfg(not(test))] #[cfg(not(test))]
pub fn handle_panic( pub fn handle_panic<T>(info: &PanicInfo<'_>, sender: &SenderWithContext<T>)
info: &PanicInfo<'_>, where
send_app_instructions: &SenderWithContext<ClientInstruction>, T: ErrorInstruction + Clone,
) { {
use backtrace::Backtrace; use backtrace::Backtrace;
use std::{process, thread}; use std::{process, thread};
let backtrace = Backtrace::new(); let backtrace = Backtrace::new();
@ -70,7 +87,7 @@ pub fn handle_panic(
println!("{}", backtrace); println!("{}", backtrace);
process::exit(1); process::exit(1);
} else { } else {
let _ = send_app_instructions.send(ClientInstruction::Error(backtrace)); let _ = sender.send(T::error(backtrace));
} }
} }
@ -103,6 +120,11 @@ impl ErrorContext {
break; break;
} }
} }
self.update_thread_ctx()
}
/// Updates the thread local [`ErrorContext`].
pub fn update_thread_ctx(&self) {
ASYNCOPENCALLS ASYNCOPENCALLS
.try_with(|ctx| *ctx.borrow_mut() = *self) .try_with(|ctx| *ctx.borrow_mut() = *self)
.unwrap_or_else(|_| OPENCALLS.with(|ctx| *ctx.borrow_mut() = *self)); .unwrap_or_else(|_| OPENCALLS.with(|ctx| *ctx.borrow_mut() = *self));
@ -333,6 +355,7 @@ pub enum ClientContext {
Error, Error,
UnblockInputThread, UnblockInputThread,
Render, Render,
ServerError,
} }
impl From<&ClientInstruction> for ClientContext { impl From<&ClientInstruction> for ClientContext {
@ -340,6 +363,7 @@ impl From<&ClientInstruction> for ClientContext {
match *client_instruction { match *client_instruction {
ClientInstruction::Exit => ClientContext::Exit, ClientInstruction::Exit => ClientContext::Exit,
ClientInstruction::Error(_) => ClientContext::Error, ClientInstruction::Error(_) => ClientContext::Error,
ClientInstruction::ServerError(_) => ClientContext::ServerError,
ClientInstruction::Render(_) => ClientContext::Render, ClientInstruction::Render(_) => ClientContext::Render,
ClientInstruction::UnblockInputThread => ClientContext::UnblockInputThread, ClientInstruction::UnblockInputThread => ClientContext::UnblockInputThread,
} }
@ -350,22 +374,20 @@ impl From<&ClientInstruction> for ClientContext {
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub enum ServerContext { pub enum ServerContext {
NewClient, NewClient,
Action,
Render, Render,
TerminalResize,
UnblockInputThread, UnblockInputThread,
ClientExit, ClientExit,
Error,
} }
impl From<&ServerInstruction> for ServerContext { impl From<&ServerInstruction> for ServerContext {
fn from(server_instruction: &ServerInstruction) -> Self { fn from(server_instruction: &ServerInstruction) -> Self {
match *server_instruction { match *server_instruction {
ServerInstruction::NewClient(..) => ServerContext::NewClient, ServerInstruction::NewClient(..) => ServerContext::NewClient,
ServerInstruction::Action(_) => ServerContext::Action,
ServerInstruction::TerminalResize(_) => ServerContext::TerminalResize,
ServerInstruction::Render(_) => ServerContext::Render, ServerInstruction::Render(_) => ServerContext::Render,
ServerInstruction::UnblockInputThread => ServerContext::UnblockInputThread, ServerInstruction::UnblockInputThread => ServerContext::UnblockInputThread,
ServerInstruction::ClientExit => ServerContext::ClientExit, ServerInstruction::ClientExit => ServerContext::ClientExit,
ServerInstruction::Error(_) => ServerContext::Error,
} }
} }
} }

View file

@ -4,10 +4,10 @@ use super::actions::Action;
use super::keybinds::Keybinds; use super::keybinds::Keybinds;
use crate::client::ClientInstruction; use crate::client::ClientInstruction;
use crate::common::input::config::Config; use crate::common::input::config::Config;
use crate::common::ipc::ClientToServerMsg;
use crate::common::thread_bus::{SenderWithContext, OPENCALLS}; use crate::common::thread_bus::{SenderWithContext, OPENCALLS};
use crate::errors::ContextType; use crate::errors::ContextType;
use crate::os_input_output::ClientOsApi; use crate::os_input_output::ClientOsApi;
use crate::server::ServerInstruction;
use crate::CommandIsExecuting; use crate::CommandIsExecuting;
use termion::input::{TermRead, TermReadEventsAndRaw}; use termion::input::{TermRead, TermReadEventsAndRaw};
@ -139,7 +139,7 @@ impl InputHandler {
Action::SwitchToMode(mode) => { Action::SwitchToMode(mode) => {
self.mode = mode; self.mode = mode;
self.os_input self.os_input
.send_to_server(ServerInstruction::Action(action)); .send_to_server(ClientToServerMsg::Action(action));
} }
Action::CloseFocus Action::CloseFocus
| Action::NewPane(_) | Action::NewPane(_)
@ -151,13 +151,13 @@ impl InputHandler {
| Action::MoveFocusOrTab(_) => { | Action::MoveFocusOrTab(_) => {
self.command_is_executing.blocking_input_thread(); self.command_is_executing.blocking_input_thread();
self.os_input self.os_input
.send_to_server(ServerInstruction::Action(action)); .send_to_server(ClientToServerMsg::Action(action));
self.command_is_executing self.command_is_executing
.wait_until_input_thread_is_unblocked(); .wait_until_input_thread_is_unblocked();
} }
_ => self _ => self
.os_input .os_input
.send_to_server(ServerInstruction::Action(action)), .send_to_server(ClientToServerMsg::Action(action)),
} }
should_break should_break

View file

@ -1,10 +1,14 @@
//! IPC stuff for starting to split things into a client and server model. //! IPC stuff for starting to split things into a client and server model.
use crate::common::errors::{get_current_ctx, ErrorContext}; use crate::cli::CliArgs;
use crate::common::{
errors::{get_current_ctx, ErrorContext},
input::{actions::Action, options::Options},
};
use crate::panes::PositionAndSize;
use interprocess::local_socket::LocalSocketStream; use interprocess::local_socket::LocalSocketStream;
use nix::unistd::dup; use nix::unistd::dup;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use std::io::{self, Write}; use std::io::{self, Write};
use std::marker::PhantomData; use std::marker::PhantomData;
use std::os::unix::io::{AsRawFd, FromRawFd}; use std::os::unix::io::{AsRawFd, FromRawFd};
@ -29,9 +33,9 @@ pub enum ClientType {
} }
// Types of messages sent from the client to the server // Types of messages sent from the client to the server
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize, Debug, Clone)]
pub enum _ClientToServerMsg { pub enum ClientToServerMsg {
// List which sessions are available /*// List which sessions are available
ListSessions, ListSessions,
// Create a new session // Create a new session
CreateSession, CreateSession,
@ -40,16 +44,24 @@ pub enum _ClientToServerMsg {
// Force detach // Force detach
DetachSession(SessionId), DetachSession(SessionId),
// Disconnect from the session we're connected to // Disconnect from the session we're connected to
DisconnectFromSession, DisconnectFromSession,*/
ClientExit,
TerminalResize(PositionAndSize),
NewClient(PositionAndSize, CliArgs, Options),
Action(Action),
} }
// Types of messages sent from the server to the client // Types of messages sent from the server to the client
// @@@ Implement Serialize and Deserialize for this... #[derive(Serialize, Deserialize, Debug, Clone)]
pub enum _ServerToClientMsg { pub enum ServerToClientMsg {
// Info about a particular session /*// Info about a particular session
SessionInfo(Session), SessionInfo(Session),
// A list of sessions // A list of sessions
SessionList(HashSet<Session>), SessionList(HashSet<Session>),*/
Render(Option<String>),
UnblockInputThread,
Exit,
ServerError(String),
} }
/// Sends messages on a stream socket, along with an [`ErrorContext`]. /// Sends messages on a stream socket, along with an [`ErrorContext`].

View file

@ -1,11 +1,8 @@
use crate::client::ClientInstruction; use crate::common::ipc::{
use crate::common::{ ClientToServerMsg, IpcReceiverWithContext, IpcSenderWithContext, ServerToClientMsg,
ipc::{IpcReceiverWithContext, IpcSenderWithContext},
utils::consts::ZELLIJ_IPC_PIPE,
}; };
use crate::errors::ErrorContext; use crate::errors::ErrorContext;
use crate::panes::PositionAndSize; use crate::panes::PositionAndSize;
use crate::server::ServerInstruction;
use crate::utils::shared::default_palette; use crate::utils::shared::default_palette;
use interprocess::local_socket::LocalSocketStream; use interprocess::local_socket::LocalSocketStream;
use nix::fcntl::{fcntl, FcntlArg, OFlag}; use nix::fcntl::{fcntl, FcntlArg, OFlag};
@ -170,8 +167,8 @@ fn spawn_terminal(file_to_open: Option<PathBuf>, orig_termios: termios::Termios)
#[derive(Clone)] #[derive(Clone)]
pub struct ServerOsInputOutput { pub struct ServerOsInputOutput {
orig_termios: Arc<Mutex<termios::Termios>>, orig_termios: Arc<Mutex<termios::Termios>>,
receive_instructions_from_client: Option<Arc<Mutex<IpcReceiverWithContext<ServerInstruction>>>>, receive_instructions_from_client: Option<Arc<Mutex<IpcReceiverWithContext<ClientToServerMsg>>>>,
send_instructions_to_client: Arc<Mutex<Option<IpcSenderWithContext<ClientInstruction>>>>, send_instructions_to_client: Arc<Mutex<Option<IpcSenderWithContext<ServerToClientMsg>>>>,
} }
/// The `ServerOsApi` trait represents an abstract interface to the features of an operating system that /// The `ServerOsApi` trait represents an abstract interface to the features of an operating system that
@ -195,9 +192,9 @@ pub trait ServerOsApi: Send + Sync {
/// Returns a [`Box`] pointer to this [`ServerOsApi`] struct. /// Returns a [`Box`] pointer to this [`ServerOsApi`] struct.
fn box_clone(&self) -> Box<dyn ServerOsApi>; fn box_clone(&self) -> Box<dyn ServerOsApi>;
/// Receives a message on server-side IPC channel /// Receives a message on server-side IPC channel
fn recv_from_client(&self) -> (ServerInstruction, ErrorContext); fn recv_from_client(&self) -> (ClientToServerMsg, ErrorContext);
/// Sends a message to client /// Sends a message to client
fn send_to_client(&self, msg: ClientInstruction); fn send_to_client(&self, msg: ServerToClientMsg);
/// Adds a sender to client /// Adds a sender to client
fn add_client_sender(&mut self); fn add_client_sender(&mut self);
/// Update the receiver socket for the client /// Update the receiver socket for the client
@ -236,7 +233,7 @@ impl ServerOsApi for ServerOsInputOutput {
waitpid(Pid::from_raw(pid), None).unwrap(); waitpid(Pid::from_raw(pid), None).unwrap();
Ok(()) Ok(())
} }
fn recv_from_client(&self) -> (ServerInstruction, ErrorContext) { fn recv_from_client(&self) -> (ClientToServerMsg, ErrorContext) {
self.receive_instructions_from_client self.receive_instructions_from_client
.as_ref() .as_ref()
.unwrap() .unwrap()
@ -244,7 +241,7 @@ impl ServerOsApi for ServerOsInputOutput {
.unwrap() .unwrap()
.recv() .recv()
} }
fn send_to_client(&self, msg: ClientInstruction) { fn send_to_client(&self, msg: ServerToClientMsg) {
self.send_instructions_to_client self.send_instructions_to_client
.lock() .lock()
.unwrap() .unwrap()
@ -291,8 +288,8 @@ pub fn get_server_os_input() -> ServerOsInputOutput {
#[derive(Clone)] #[derive(Clone)]
pub struct ClientOsInputOutput { pub struct ClientOsInputOutput {
orig_termios: Arc<Mutex<termios::Termios>>, orig_termios: Arc<Mutex<termios::Termios>>,
send_instructions_to_server: Arc<Mutex<Option<IpcSenderWithContext<ServerInstruction>>>>, send_instructions_to_server: Arc<Mutex<Option<IpcSenderWithContext<ClientToServerMsg>>>>,
receive_instructions_from_server: Arc<Mutex<Option<IpcReceiverWithContext<ClientInstruction>>>>, receive_instructions_from_server: Arc<Mutex<Option<IpcReceiverWithContext<ServerToClientMsg>>>>,
} }
/// The `ClientOsApi` trait represents an abstract interface to the features of an operating system that /// The `ClientOsApi` trait represents an abstract interface to the features of an operating system that
@ -305,7 +302,7 @@ pub trait ClientOsApi: Send + Sync {
fn set_raw_mode(&mut self, fd: RawFd); fn set_raw_mode(&mut self, fd: RawFd);
/// Set the terminal associated to file descriptor `fd` to /// Set the terminal associated to file descriptor `fd` to
/// [cooked mode](https://en.wikipedia.org/wiki/Terminal_mode). /// [cooked mode](https://en.wikipedia.org/wiki/Terminal_mode).
fn unset_raw_mode(&mut self, fd: RawFd); fn unset_raw_mode(&self, fd: RawFd);
/// Returns the writer that allows writing to standard output. /// Returns the writer that allows writing to standard output.
fn get_stdout_writer(&self) -> Box<dyn io::Write>; fn get_stdout_writer(&self) -> Box<dyn io::Write>;
/// Returns the raw contents of standard input. /// Returns the raw contents of standard input.
@ -313,13 +310,13 @@ pub trait ClientOsApi: Send + Sync {
/// Returns a [`Box`] pointer to this [`ClientOsApi`] struct. /// Returns a [`Box`] pointer to this [`ClientOsApi`] struct.
fn box_clone(&self) -> Box<dyn ClientOsApi>; fn box_clone(&self) -> Box<dyn ClientOsApi>;
/// Sends a message to the server. /// Sends a message to the server.
fn send_to_server(&self, msg: ServerInstruction); fn send_to_server(&self, msg: ClientToServerMsg);
/// Receives a message on client-side IPC channel /// Receives a message on client-side IPC channel
// This should be called from the client-side router thread only. // This should be called from the client-side router thread only.
fn recv_from_server(&self) -> (ClientInstruction, ErrorContext); fn recv_from_server(&self) -> (ServerToClientMsg, ErrorContext);
fn receive_sigwinch(&self, cb: Box<dyn Fn()>); fn handle_signals(&self, sigwinch_cb: Box<dyn Fn()>, quit_cb: Box<dyn Fn()>);
/// Establish a connection with the server socket. /// Establish a connection with the server socket.
fn connect_to_server(&self); fn connect_to_server(&self, path: &Path);
} }
impl ClientOsApi for ClientOsInputOutput { impl ClientOsApi for ClientOsInputOutput {
@ -329,7 +326,7 @@ impl ClientOsApi for ClientOsInputOutput {
fn set_raw_mode(&mut self, fd: RawFd) { fn set_raw_mode(&mut self, fd: RawFd) {
into_raw_mode(fd); into_raw_mode(fd);
} }
fn unset_raw_mode(&mut self, fd: RawFd) { fn unset_raw_mode(&self, fd: RawFd) {
let orig_termios = self.orig_termios.lock().unwrap(); let orig_termios = self.orig_termios.lock().unwrap();
unset_raw_mode(fd, orig_termios.clone()); unset_raw_mode(fd, orig_termios.clone());
} }
@ -349,7 +346,7 @@ impl ClientOsApi for ClientOsInputOutput {
let stdout = ::std::io::stdout(); let stdout = ::std::io::stdout();
Box::new(stdout) Box::new(stdout)
} }
fn send_to_server(&self, msg: ServerInstruction) { fn send_to_server(&self, msg: ClientToServerMsg) {
self.send_instructions_to_server self.send_instructions_to_server
.lock() .lock()
.unwrap() .unwrap()
@ -357,7 +354,7 @@ impl ClientOsApi for ClientOsInputOutput {
.unwrap() .unwrap()
.send(msg); .send(msg);
} }
fn recv_from_server(&self) -> (ClientInstruction, ErrorContext) { fn recv_from_server(&self) -> (ServerToClientMsg, ErrorContext) {
self.receive_instructions_from_server self.receive_instructions_from_server
.lock() .lock()
.unwrap() .unwrap()
@ -365,28 +362,34 @@ impl ClientOsApi for ClientOsInputOutput {
.unwrap() .unwrap()
.recv() .recv()
} }
fn receive_sigwinch(&self, cb: Box<dyn Fn()>) { fn handle_signals(&self, sigwinch_cb: Box<dyn Fn()>, quit_cb: Box<dyn Fn()>) {
let mut signals = Signals::new(&[SIGWINCH, SIGTERM, SIGINT, SIGQUIT]).unwrap(); let mut signals = Signals::new(&[SIGWINCH, SIGTERM, SIGINT, SIGQUIT, SIGHUP]).unwrap();
for signal in signals.forever() { for signal in signals.forever() {
match signal { match signal {
SIGWINCH => { SIGWINCH => {
cb(); sigwinch_cb();
} }
SIGTERM | SIGINT | SIGQUIT => { SIGTERM | SIGINT | SIGQUIT | SIGHUP => {
quit_cb();
break; break;
} }
_ => unreachable!(), _ => unreachable!(),
} }
} }
} }
fn connect_to_server(&self) { fn connect_to_server(&self, path: &Path) {
let socket = match LocalSocketStream::connect(&**ZELLIJ_IPC_PIPE) { let socket;
Ok(sock) => sock, loop {
Err(_) => { match LocalSocketStream::connect(path) {
std::thread::sleep(std::time::Duration::from_millis(20)); Ok(sock) => {
LocalSocketStream::connect(&**ZELLIJ_IPC_PIPE).unwrap() socket = sock;
break;
}
Err(_) => {
std::thread::sleep(std::time::Duration::from_millis(50));
}
} }
}; }
let sender = IpcSenderWithContext::new(socket); let sender = IpcSenderWithContext::new(socket);
let receiver = sender.get_receiver(); let receiver = sender.get_receiver();
*self.send_instructions_to_server.lock().unwrap() = Some(sender); *self.send_instructions_to_server.lock().unwrap() = Some(sender);

View file

@ -8,7 +8,7 @@ use std::pin::*;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use crate::client::panes::PaneId; use crate::client::panes::PaneId;
use crate::common::errors::{get_current_ctx, ContextType, PtyContext}; use crate::common::errors::{get_current_ctx, ContextType};
use crate::common::screen::ScreenInstruction; use crate::common::screen::ScreenInstruction;
use crate::common::thread_bus::{Bus, ThreadSenders}; use crate::common::thread_bus::{Bus, ThreadSenders};
use crate::layout::Layout; use crate::layout::Layout;
@ -87,7 +87,7 @@ pub struct Pty {
pub fn pty_thread_main(mut pty: Pty, maybe_layout: Option<Layout>) { pub fn pty_thread_main(mut pty: Pty, maybe_layout: Option<Layout>) {
loop { loop {
let (event, mut err_ctx) = pty.bus.recv().expect("failed to receive event on channel"); let (event, mut err_ctx) = pty.bus.recv().expect("failed to receive event on channel");
err_ctx.add_call(ContextType::Pty(PtyContext::from(&event))); err_ctx.add_call(ContextType::Pty((&event).into()));
match event { match event {
PtyInstruction::SpawnTerminal(file_to_open) => { PtyInstruction::SpawnTerminal(file_to_open) => {
let pid = pty.spawn_terminal(file_to_open); let pid = pty.spawn_terminal(file_to_open);

View file

@ -7,7 +7,7 @@ use std::str;
use crate::common::input::options::Options; use crate::common::input::options::Options;
use crate::common::pty::{PtyInstruction, VteBytes}; use crate::common::pty::{PtyInstruction, VteBytes};
use crate::common::thread_bus::Bus; use crate::common::thread_bus::Bus;
use crate::errors::{ContextType, ScreenContext}; use crate::errors::ContextType;
use crate::layout::Layout; use crate::layout::Layout;
use crate::panes::PaneId; use crate::panes::PaneId;
use crate::panes::PositionAndSize; use crate::panes::PositionAndSize;
@ -353,7 +353,7 @@ pub fn screen_thread_main(
.bus .bus
.recv() .recv()
.expect("failed to receive event on channel"); .expect("failed to receive event on channel");
err_ctx.add_call(ContextType::Screen(ScreenContext::from(&event))); err_ctx.add_call(ContextType::Screen((&event).into()));
match event { match event {
ScreenInstruction::PtyBytes(pid, vte_bytes) => { ScreenInstruction::PtyBytes(pid, vte_bytes) => {
let active_tab = screen.get_active_tab_mut().unwrap(); let active_tab = screen.get_active_tab_mut().unwrap();

View file

@ -15,7 +15,7 @@ use wasmer::{
use wasmer_wasi::{Pipe, WasiEnv, WasiState}; use wasmer_wasi::{Pipe, WasiEnv, WasiState};
use zellij_tile::data::{Event, EventType, PluginIds}; use zellij_tile::data::{Event, EventType, PluginIds};
use crate::common::errors::{ContextType, PluginContext}; use crate::common::errors::ContextType;
use crate::common::pty::PtyInstruction; use crate::common::pty::PtyInstruction;
use crate::common::screen::ScreenInstruction; use crate::common::screen::ScreenInstruction;
use crate::common::thread_bus::{Bus, ThreadSenders}; use crate::common::thread_bus::{Bus, ThreadSenders};
@ -44,7 +44,7 @@ pub fn wasm_thread_main(bus: Bus<PluginInstruction>, store: Store, data_dir: Pat
let mut plugin_map = HashMap::new(); let mut plugin_map = HashMap::new();
loop { loop {
let (event, mut err_ctx) = bus.recv().expect("failed to receive event on channel"); let (event, mut err_ctx) = bus.recv().expect("failed to receive event on channel");
err_ctx.add_call(ContextType::Plugin(PluginContext::from(&event))); err_ctx.add_call(ContextType::Plugin((&event).into()));
match event { match event {
PluginInstruction::Load(pid_tx, path) => { PluginInstruction::Load(pid_tx, path) => {
let plugin_dir = data_dir.join("plugins/"); let plugin_dir = data_dir.join("plugins/");

View file

@ -14,8 +14,8 @@ use structopt::StructOpt;
use crate::cli::CliArgs; use crate::cli::CliArgs;
use crate::command_is_executing::CommandIsExecuting; use crate::command_is_executing::CommandIsExecuting;
use crate::common::input::{config::Config, options::Options}; use crate::common::input::config::Config;
use crate::os_input_output::{get_client_os_input, get_server_os_input, ClientOsApi, ServerOsApi}; use crate::os_input_output::{get_client_os_input, get_server_os_input};
use crate::utils::{ use crate::utils::{
consts::{ZELLIJ_TMP_DIR, ZELLIJ_TMP_LOG_DIR}, consts::{ZELLIJ_TMP_DIR, ZELLIJ_TMP_LOG_DIR},
logging::*, logging::*,
@ -36,28 +36,14 @@ pub fn main() {
std::process::exit(1); std::process::exit(1);
} }
}; };
let config_options = Options::from_cli(&config.options, opts.option.clone());
atomic_create_dir(&*ZELLIJ_TMP_DIR).unwrap(); atomic_create_dir(&*ZELLIJ_TMP_DIR).unwrap();
atomic_create_dir(&*ZELLIJ_TMP_LOG_DIR).unwrap(); atomic_create_dir(&*ZELLIJ_TMP_LOG_DIR).unwrap();
let server_os_input = get_server_os_input(); if let Some(path) = opts.server {
let os_input = get_client_os_input(); let os_input = get_server_os_input();
start( start_server(Box::new(os_input), path);
Box::new(os_input), } else {
opts, let os_input = get_client_os_input();
Box::new(server_os_input), start_client(Box::new(os_input), opts, config);
config, }
config_options,
);
} }
} }
pub fn start(
client_os_input: Box<dyn ClientOsApi>,
opts: CliArgs,
server_os_input: Box<dyn ServerOsApi>,
config: Config,
config_options: Options,
) {
let ipc_thread = start_server(server_os_input, config_options);
start_client(client_os_input, opts, config);
drop(ipc_thread.join());
}

View file

@ -1,25 +1,22 @@
pub mod route; pub mod route;
use interprocess::local_socket::LocalSocketListener;
use serde::{Deserialize, Serialize};
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
use std::thread; use std::thread;
use std::{path::PathBuf, sync::mpsc::channel}; use std::{path::PathBuf, sync::mpsc};
use wasmer::Store; use wasmer::Store;
use zellij_tile::data::PluginCapabilities; use zellij_tile::data::PluginCapabilities;
use crate::cli::CliArgs; use crate::cli::CliArgs;
use crate::client::ClientInstruction;
use crate::common::thread_bus::{Bus, ThreadSenders}; use crate::common::thread_bus::{Bus, ThreadSenders};
use crate::common::{ use crate::common::{
errors::{ContextType, ServerContext}, errors::ContextType,
input::{actions::Action, options::Options}, input::options::Options,
os_input_output::{set_permissions, ServerOsApi}, ipc::{ClientToServerMsg, ServerToClientMsg},
os_input_output::ServerOsApi,
pty::{pty_thread_main, Pty, PtyInstruction}, pty::{pty_thread_main, Pty, PtyInstruction},
screen::{screen_thread_main, ScreenInstruction}, screen::{screen_thread_main, ScreenInstruction},
setup::{get_default_data_dir, install::populate_data_dir}, setup::{get_default_data_dir, install::populate_data_dir},
thread_bus::{ChannelWithContext, SenderType, SenderWithContext}, thread_bus::{ChannelWithContext, SenderType, SenderWithContext, SyncChannelWithContext},
utils::consts::ZELLIJ_IPC_PIPE,
wasm_vm::{wasm_thread_main, PluginInstruction}, wasm_vm::{wasm_thread_main, PluginInstruction},
}; };
use crate::layout::Layout; use crate::layout::Layout;
@ -28,18 +25,30 @@ use route::route_thread_main;
/// Instructions related to server-side application including the /// Instructions related to server-side application including the
/// ones sent by client to server /// ones sent by client to server
#[derive(Serialize, Deserialize, Debug, Clone)] #[derive(Debug, Clone)]
pub enum ServerInstruction { pub enum ServerInstruction {
TerminalResize(PositionAndSize),
NewClient(PositionAndSize, CliArgs, Options), NewClient(PositionAndSize, CliArgs, Options),
Action(Action),
Render(Option<String>), Render(Option<String>),
UnblockInputThread, UnblockInputThread,
ClientExit, ClientExit,
Error(String),
}
impl From<ClientToServerMsg> for ServerInstruction {
fn from(instruction: ClientToServerMsg) -> Self {
match instruction {
ClientToServerMsg::ClientExit => ServerInstruction::ClientExit,
ClientToServerMsg::NewClient(pos, opts, options) => {
ServerInstruction::NewClient(pos, opts, options)
}
_ => unreachable!(),
}
}
} }
pub struct SessionMetaData { pub struct SessionMetaData {
pub senders: ThreadSenders, pub senders: ThreadSenders,
pub capabilities: PluginCapabilities,
screen_thread: Option<thread::JoinHandle<()>>, screen_thread: Option<thread::JoinHandle<()>>,
pty_thread: Option<thread::JoinHandle<()>>, pty_thread: Option<thread::JoinHandle<()>>,
wasm_thread: Option<thread::JoinHandle<()>>, wasm_thread: Option<thread::JoinHandle<()>>,
@ -56,14 +65,30 @@ impl Drop for SessionMetaData {
} }
} }
pub fn start_server( pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
os_input: Box<dyn ServerOsApi>, #[cfg(not(test))]
config_options: Options, daemonize::Daemonize::new()
) -> thread::JoinHandle<()> { .working_directory(std::env::var("HOME").unwrap())
let (to_server, server_receiver): ChannelWithContext<ServerInstruction> = channel(); .umask(0o077)
let to_server = SenderWithContext::new(SenderType::Sender(to_server)); .start()
.expect("could not daemonize the server process");
std::env::set_var(&"ZELLIJ", "0");
let (to_server, server_receiver): SyncChannelWithContext<ServerInstruction> =
mpsc::sync_channel(50);
let to_server = SenderWithContext::new(SenderType::SyncSender(to_server));
let sessions: Arc<RwLock<Option<SessionMetaData>>> = Arc::new(RwLock::new(None)); let sessions: Arc<RwLock<Option<SessionMetaData>>> = Arc::new(RwLock::new(None));
#[cfg(not(test))]
std::panic::set_hook({
use crate::errors::handle_panic;
let to_server = to_server.clone();
Box::new(move |info| {
handle_panic(info, &to_server);
})
});
#[cfg(test)] #[cfg(test)]
thread::Builder::new() thread::Builder::new()
.name("server_router".to_string()) .name("server_router".to_string())
@ -71,27 +96,25 @@ pub fn start_server(
let sessions = sessions.clone(); let sessions = sessions.clone();
let os_input = os_input.clone(); let os_input = os_input.clone();
let to_server = to_server.clone(); let to_server = to_server.clone();
let capabilities = PluginCapabilities {
arrow_fonts: !config_options.simplified_ui,
};
move || route_thread_main(sessions, os_input, to_server, capabilities) move || route_thread_main(sessions, os_input, to_server)
}) })
.unwrap(); .unwrap();
#[cfg(not(test))] #[cfg(not(test))]
let _ = thread::Builder::new() let _ = thread::Builder::new()
.name("server_listener".to_string()) .name("server_listener".to_string())
.spawn({ .spawn({
use crate::common::os_input_output::set_permissions;
use interprocess::local_socket::LocalSocketListener;
let os_input = os_input.clone(); let os_input = os_input.clone();
let sessions = sessions.clone(); let sessions = sessions.clone();
let to_server = to_server.clone(); let to_server = to_server.clone();
let capabilities = PluginCapabilities { let socket_path = socket_path.clone();
arrow_fonts: config_options.simplified_ui,
};
move || { move || {
drop(std::fs::remove_file(&*ZELLIJ_IPC_PIPE)); drop(std::fs::remove_file(&socket_path));
let listener = LocalSocketListener::bind(&**ZELLIJ_IPC_PIPE).unwrap(); let listener = LocalSocketListener::bind(&*socket_path).unwrap();
set_permissions(&*ZELLIJ_IPC_PIPE).unwrap(); set_permissions(&socket_path).unwrap();
for stream in listener.incoming() { for stream in listener.incoming() {
match stream { match stream {
Ok(stream) => { Ok(stream) => {
@ -106,14 +129,7 @@ pub fn start_server(
let os_input = os_input.clone(); let os_input = os_input.clone();
let to_server = to_server.clone(); let to_server = to_server.clone();
move || { move || route_thread_main(sessions, os_input, to_server)
route_thread_main(
sessions,
os_input,
to_server,
capabilities,
)
}
}) })
.unwrap(); .unwrap();
} }
@ -125,48 +141,47 @@ pub fn start_server(
} }
}); });
thread::Builder::new() loop {
.name("server_thread".to_string()) let (instruction, mut err_ctx) = server_receiver.recv().unwrap();
.spawn({ err_ctx.add_call(ContextType::IPCServer((&instruction).into()));
move || loop { match instruction {
let (instruction, mut err_ctx) = server_receiver.recv().unwrap(); ServerInstruction::NewClient(full_screen_ws, opts, config_options) => {
err_ctx.add_call(ContextType::IPCServer(ServerContext::from(&instruction))); let session_data = init_session(
match instruction { os_input.clone(),
ServerInstruction::NewClient(full_screen_ws, opts, config_options) => { opts,
let session_data = init_session( config_options,
os_input.clone(), to_server.clone(),
opts, full_screen_ws,
config_options, );
to_server.clone(), *sessions.write().unwrap() = Some(session_data);
full_screen_ws, sessions
); .read()
*sessions.write().unwrap() = Some(session_data); .unwrap()
sessions .as_ref()
.read() .unwrap()
.unwrap() .senders
.as_ref() .send_to_pty(PtyInstruction::NewTab)
.unwrap() .unwrap();
.senders
.send_to_pty(PtyInstruction::NewTab)
.unwrap();
}
ServerInstruction::UnblockInputThread => {
os_input.send_to_client(ClientInstruction::UnblockInputThread);
}
ServerInstruction::ClientExit => {
*sessions.write().unwrap() = None;
os_input.send_to_client(ClientInstruction::Exit);
drop(std::fs::remove_file(&*ZELLIJ_IPC_PIPE));
break;
}
ServerInstruction::Render(output) => {
os_input.send_to_client(ClientInstruction::Render(output))
}
_ => panic!("Received unexpected instruction."),
}
} }
}) ServerInstruction::UnblockInputThread => {
.unwrap() os_input.send_to_client(ServerToClientMsg::UnblockInputThread);
}
ServerInstruction::ClientExit => {
*sessions.write().unwrap() = None;
os_input.send_to_client(ServerToClientMsg::Exit);
break;
}
ServerInstruction::Render(output) => {
os_input.send_to_client(ServerToClientMsg::Render(output))
}
ServerInstruction::Error(backtrace) => {
os_input.send_to_client(ServerToClientMsg::ServerError(backtrace));
break;
}
}
}
#[cfg(not(test))]
drop(std::fs::remove_file(&socket_path));
} }
fn init_session( fn init_session(
@ -176,12 +191,12 @@ fn init_session(
to_server: SenderWithContext<ServerInstruction>, to_server: SenderWithContext<ServerInstruction>,
full_screen_ws: PositionAndSize, full_screen_ws: PositionAndSize,
) -> SessionMetaData { ) -> SessionMetaData {
let (to_screen, screen_receiver): ChannelWithContext<ScreenInstruction> = channel(); let (to_screen, screen_receiver): ChannelWithContext<ScreenInstruction> = mpsc::channel();
let to_screen = SenderWithContext::new(SenderType::Sender(to_screen)); let to_screen = SenderWithContext::new(SenderType::Sender(to_screen));
let (to_plugin, plugin_receiver): ChannelWithContext<PluginInstruction> = channel(); let (to_plugin, plugin_receiver): ChannelWithContext<PluginInstruction> = mpsc::channel();
let to_plugin = SenderWithContext::new(SenderType::Sender(to_plugin)); let to_plugin = SenderWithContext::new(SenderType::Sender(to_plugin));
let (to_pty, pty_receiver): ChannelWithContext<PtyInstruction> = channel(); let (to_pty, pty_receiver): ChannelWithContext<PtyInstruction> = mpsc::channel();
let to_pty = SenderWithContext::new(SenderType::Sender(to_pty)); let to_pty = SenderWithContext::new(SenderType::Sender(to_pty));
// Determine and initialize the data directory // Determine and initialize the data directory
@ -190,6 +205,10 @@ fn init_session(
#[cfg(not(disable_automatic_asset_installation))] #[cfg(not(disable_automatic_asset_installation))]
populate_data_dir(&data_dir); populate_data_dir(&data_dir);
let capabilities = PluginCapabilities {
arrow_fonts: config_options.simplified_ui,
};
// Don't use default layouts in tests, but do everywhere else // Don't use default layouts in tests, but do everywhere else
#[cfg(not(test))] #[cfg(not(test))]
let default_layout = Some(PathBuf::from("default")); let default_layout = Some(PathBuf::from("default"));
@ -231,7 +250,6 @@ fn init_session(
Some(os_input.clone()), Some(os_input.clone()),
); );
let max_panes = opts.max_panes; let max_panes = opts.max_panes;
let config_options = config_options;
move || { move || {
screen_thread_main(screen_bus, max_panes, full_screen_ws, config_options); screen_thread_main(screen_bus, max_panes, full_screen_ws, config_options);
@ -262,6 +280,7 @@ fn init_session(
to_plugin: Some(to_plugin), to_plugin: Some(to_plugin),
to_server: None, to_server: None,
}, },
capabilities,
screen_thread: Some(screen_thread), screen_thread: Some(screen_thread),
pty_thread: Some(pty_thread), pty_thread: Some(pty_thread),
wasm_thread: Some(wasm_thread), wasm_thread: Some(wasm_thread),

View file

@ -1,10 +1,10 @@
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
use zellij_tile::data::{Event, PluginCapabilities}; use zellij_tile::data::Event;
use crate::common::errors::{ContextType, ServerContext};
use crate::common::input::actions::{Action, Direction}; use crate::common::input::actions::{Action, Direction};
use crate::common::input::handler::get_mode_info; use crate::common::input::handler::get_mode_info;
use crate::common::ipc::ClientToServerMsg;
use crate::common::os_input_output::ServerOsApi; use crate::common::os_input_output::ServerOsApi;
use crate::common::pty::PtyInstruction; use crate::common::pty::PtyInstruction;
use crate::common::screen::ScreenInstruction; use crate::common::screen::ScreenInstruction;
@ -12,12 +12,7 @@ use crate::common::thread_bus::SenderWithContext;
use crate::common::wasm_vm::PluginInstruction; use crate::common::wasm_vm::PluginInstruction;
use crate::server::{ServerInstruction, SessionMetaData}; use crate::server::{ServerInstruction, SessionMetaData};
fn route_action( fn route_action(action: Action, session: &SessionMetaData, os_input: &dyn ServerOsApi) {
action: Action,
session: &SessionMetaData,
os_input: &dyn ServerOsApi,
capabilities: PluginCapabilities,
) {
match action { match action {
Action::Write(val) => { Action::Write(val) => {
session session
@ -35,7 +30,7 @@ fn route_action(
.senders .senders
.send_to_plugin(PluginInstruction::Update( .send_to_plugin(PluginInstruction::Update(
None, None,
Event::ModeUpdate(get_mode_info(mode, palette, capabilities)), Event::ModeUpdate(get_mode_info(mode, palette, session.capabilities)),
)) ))
.unwrap(); .unwrap();
session session
@ -43,7 +38,7 @@ fn route_action(
.send_to_screen(ScreenInstruction::ChangeMode(get_mode_info( .send_to_screen(ScreenInstruction::ChangeMode(get_mode_info(
mode, mode,
palette, palette,
capabilities, session.capabilities,
))) )))
.unwrap(); .unwrap();
session session
@ -190,26 +185,20 @@ pub fn route_thread_main(
sessions: Arc<RwLock<Option<SessionMetaData>>>, sessions: Arc<RwLock<Option<SessionMetaData>>>,
mut os_input: Box<dyn ServerOsApi>, mut os_input: Box<dyn ServerOsApi>,
to_server: SenderWithContext<ServerInstruction>, to_server: SenderWithContext<ServerInstruction>,
capabilities: PluginCapabilities,
) { ) {
loop { loop {
let (instruction, mut err_ctx) = os_input.recv_from_client(); let (instruction, err_ctx) = os_input.recv_from_client();
err_ctx.add_call(ContextType::IPCServer(ServerContext::from(&instruction))); err_ctx.update_thread_ctx();
let rlocked_sessions = sessions.read().unwrap(); let rlocked_sessions = sessions.read().unwrap();
match instruction { match instruction {
ServerInstruction::ClientExit => { ClientToServerMsg::ClientExit => {
to_server.send(instruction).unwrap(); to_server.send(instruction.into()).unwrap();
break; break;
} }
ServerInstruction::Action(action) => { ClientToServerMsg::Action(action) => {
route_action( route_action(action, rlocked_sessions.as_ref().unwrap(), &*os_input);
action,
rlocked_sessions.as_ref().unwrap(),
&*os_input,
capabilities,
);
} }
ServerInstruction::TerminalResize(new_size) => { ClientToServerMsg::TerminalResize(new_size) => {
rlocked_sessions rlocked_sessions
.as_ref() .as_ref()
.unwrap() .unwrap()
@ -217,12 +206,9 @@ pub fn route_thread_main(
.send_to_screen(ScreenInstruction::TerminalResize(new_size)) .send_to_screen(ScreenInstruction::TerminalResize(new_size))
.unwrap(); .unwrap();
} }
ServerInstruction::NewClient(..) => { ClientToServerMsg::NewClient(..) => {
os_input.add_client_sender(); os_input.add_client_sender();
to_server.send(instruction).unwrap(); to_server.send(instruction.into()).unwrap();
}
_ => {
to_server.send(instruction).unwrap();
} }
} }
} }

View file

@ -7,11 +7,10 @@ use std::path::PathBuf;
use std::sync::{mpsc, Arc, Condvar, Mutex}; use std::sync::{mpsc, Arc, Condvar, Mutex};
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use crate::client::ClientInstruction; use crate::common::ipc::{ClientToServerMsg, ServerToClientMsg};
use crate::common::thread_bus::{ChannelWithContext, SenderType, SenderWithContext}; use crate::common::thread_bus::{ChannelWithContext, SenderType, SenderWithContext};
use crate::errors::ErrorContext; use crate::errors::ErrorContext;
use crate::os_input_output::{ClientOsApi, ServerOsApi}; use crate::os_input_output::{ClientOsApi, ServerOsApi};
use crate::server::ServerInstruction;
use crate::tests::possible_tty_inputs::{get_possible_tty_inputs, Bytes}; use crate::tests::possible_tty_inputs::{get_possible_tty_inputs, Bytes};
use crate::tests::utils::commands::{QUIT, SLEEP}; use crate::tests::utils::commands::{QUIT, SLEEP};
use crate::utils::shared::default_palette; use crate::utils::shared::default_palette;
@ -77,10 +76,10 @@ pub struct FakeInputOutput {
win_sizes: Arc<Mutex<HashMap<RawFd, PositionAndSize>>>, win_sizes: Arc<Mutex<HashMap<RawFd, PositionAndSize>>>,
possible_tty_inputs: HashMap<u16, Bytes>, possible_tty_inputs: HashMap<u16, Bytes>,
last_snapshot_time: Arc<Mutex<Instant>>, last_snapshot_time: Arc<Mutex<Instant>>,
send_instructions_to_client: SenderWithContext<ClientInstruction>, send_instructions_to_client: SenderWithContext<ServerToClientMsg>,
receive_instructions_from_server: Arc<Mutex<mpsc::Receiver<(ClientInstruction, ErrorContext)>>>, receive_instructions_from_server: Arc<Mutex<mpsc::Receiver<(ServerToClientMsg, ErrorContext)>>>,
send_instructions_to_server: SenderWithContext<ServerInstruction>, send_instructions_to_server: SenderWithContext<ClientToServerMsg>,
receive_instructions_from_client: Arc<Mutex<mpsc::Receiver<(ServerInstruction, ErrorContext)>>>, receive_instructions_from_client: Arc<Mutex<mpsc::Receiver<(ClientToServerMsg, ErrorContext)>>>,
should_trigger_sigwinch: Arc<(Mutex<bool>, Condvar)>, should_trigger_sigwinch: Arc<(Mutex<bool>, Condvar)>,
sigwinch_event: Option<PositionAndSize>, sigwinch_event: Option<PositionAndSize>,
} }
@ -90,10 +89,10 @@ impl FakeInputOutput {
let mut win_sizes = HashMap::new(); let mut win_sizes = HashMap::new();
let last_snapshot_time = Arc::new(Mutex::new(Instant::now())); let last_snapshot_time = Arc::new(Mutex::new(Instant::now()));
let stdout_writer = FakeStdoutWriter::new(last_snapshot_time.clone()); let stdout_writer = FakeStdoutWriter::new(last_snapshot_time.clone());
let (client_sender, client_receiver): ChannelWithContext<ClientInstruction> = let (client_sender, client_receiver): ChannelWithContext<ServerToClientMsg> =
mpsc::channel(); mpsc::channel();
let send_instructions_to_client = SenderWithContext::new(SenderType::Sender(client_sender)); let send_instructions_to_client = SenderWithContext::new(SenderType::Sender(client_sender));
let (server_sender, server_receiver): ChannelWithContext<ServerInstruction> = let (server_sender, server_receiver): ChannelWithContext<ClientToServerMsg> =
mpsc::channel(); mpsc::channel();
let send_instructions_to_server = SenderWithContext::new(SenderType::Sender(server_sender)); let send_instructions_to_server = SenderWithContext::new(SenderType::Sender(server_sender));
win_sizes.insert(0, winsize); // 0 is the current terminal win_sizes.insert(0, winsize); // 0 is the current terminal
@ -153,7 +152,7 @@ impl ClientOsApi for FakeInputOutput {
.unwrap() .unwrap()
.push(IoEvent::IntoRawMode(pid)); .push(IoEvent::IntoRawMode(pid));
} }
fn unset_raw_mode(&mut self, pid: RawFd) { fn unset_raw_mode(&self, pid: RawFd) {
self.io_events self.io_events
.lock() .lock()
.unwrap() .unwrap()
@ -195,17 +194,17 @@ impl ClientOsApi for FakeInputOutput {
fn get_stdout_writer(&self) -> Box<dyn Write> { fn get_stdout_writer(&self) -> Box<dyn Write> {
Box::new(self.stdout_writer.clone()) Box::new(self.stdout_writer.clone())
} }
fn send_to_server(&self, msg: ServerInstruction) { fn send_to_server(&self, msg: ClientToServerMsg) {
self.send_instructions_to_server.send(msg).unwrap(); self.send_instructions_to_server.send(msg).unwrap();
} }
fn recv_from_server(&self) -> (ClientInstruction, ErrorContext) { fn recv_from_server(&self) -> (ServerToClientMsg, ErrorContext) {
self.receive_instructions_from_server self.receive_instructions_from_server
.lock() .lock()
.unwrap() .unwrap()
.recv() .recv()
.unwrap() .unwrap()
} }
fn receive_sigwinch(&self, cb: Box<dyn Fn()>) { fn handle_signals(&self, sigwinch_cb: Box<dyn Fn()>, _quit_cb: Box<dyn Fn()>) {
if self.sigwinch_event.is_some() { if self.sigwinch_event.is_some() {
let (lock, cvar) = &*self.should_trigger_sigwinch; let (lock, cvar) = &*self.should_trigger_sigwinch;
{ {
@ -214,10 +213,10 @@ impl ClientOsApi for FakeInputOutput {
should_trigger_sigwinch = cvar.wait(should_trigger_sigwinch).unwrap(); should_trigger_sigwinch = cvar.wait(should_trigger_sigwinch).unwrap();
} }
} }
cb(); sigwinch_cb();
} }
} }
fn connect_to_server(&self) {} fn connect_to_server(&self, _path: &std::path::Path) {}
} }
impl ServerOsApi for FakeInputOutput { impl ServerOsApi for FakeInputOutput {
@ -278,14 +277,14 @@ impl ServerOsApi for FakeInputOutput {
self.io_events.lock().unwrap().push(IoEvent::Kill(fd)); self.io_events.lock().unwrap().push(IoEvent::Kill(fd));
Ok(()) Ok(())
} }
fn recv_from_client(&self) -> (ServerInstruction, ErrorContext) { fn recv_from_client(&self) -> (ClientToServerMsg, ErrorContext) {
self.receive_instructions_from_client self.receive_instructions_from_client
.lock() .lock()
.unwrap() .unwrap()
.recv() .recv()
.unwrap() .unwrap()
} }
fn send_to_client(&self, msg: ClientInstruction) { fn send_to_client(&self, msg: ServerToClientMsg) {
self.send_instructions_to_client.send(msg).unwrap(); self.send_instructions_to_client.send(msg).unwrap();
} }
fn add_client_sender(&mut self) {} fn add_client_sender(&mut self) {}

View file

@ -1,8 +1,9 @@
use crate::panes::PositionAndSize; use crate::panes::PositionAndSize;
use ::insta::assert_snapshot; use ::insta::assert_snapshot;
use crate::common::input::{config::Config, options::Options}; use crate::common::input::config::Config;
use crate::tests::fakes::FakeInputOutput; use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
use crate::tests::utils::commands::{ use crate::tests::utils::commands::{
BRACKETED_PASTE_END, BRACKETED_PASTE_START, PANE_MODE, QUIT, SCROLL_DOWN_IN_SCROLL_MODE, BRACKETED_PASTE_END, BRACKETED_PASTE_START, PANE_MODE, QUIT, SCROLL_DOWN_IN_SCROLL_MODE,
SCROLL_MODE, SCROLL_PAGE_DOWN_IN_SCROLL_MODE, SCROLL_PAGE_UP_IN_SCROLL_MODE, SCROLL_MODE, SCROLL_PAGE_DOWN_IN_SCROLL_MODE, SCROLL_PAGE_UP_IN_SCROLL_MODE,
@ -10,7 +11,7 @@ use crate::tests::utils::commands::{
SPLIT_RIGHT_IN_PANE_MODE, TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE, TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE,
}; };
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}; use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::{start, CliArgs}; use crate::CliArgs;
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput { fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
FakeInputOutput::new(fake_win_size.clone()) FakeInputOutput::new(fake_win_size.clone())
@ -32,7 +33,6 @@ pub fn starts_with_one_terminal() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -61,7 +61,6 @@ pub fn split_terminals_vertically() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -90,7 +89,6 @@ pub fn split_terminals_horizontally() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -126,7 +124,6 @@ pub fn split_largest_terminal() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -155,7 +152,6 @@ pub fn cannot_split_terminals_vertically_when_active_terminal_is_too_small() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -184,7 +180,6 @@ pub fn cannot_split_terminals_horizontally_when_active_terminal_is_too_small() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -213,7 +208,6 @@ pub fn cannot_split_largest_terminal_when_there_is_no_room() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -250,7 +244,6 @@ pub fn scrolling_up_inside_a_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -289,7 +282,6 @@ pub fn scrolling_down_inside_a_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -325,7 +317,6 @@ pub fn scrolling_page_up_inside_a_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -364,7 +355,6 @@ pub fn scrolling_page_down_inside_a_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -404,7 +394,6 @@ pub fn max_panes() {
opts, opts,
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -442,7 +431,6 @@ pub fn toggle_focused_pane_fullscreen() {
opts, opts,
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -483,7 +471,6 @@ pub fn bracketed_paste() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer

View file

@ -2,10 +2,11 @@ use crate::panes::PositionAndSize;
use ::insta::assert_snapshot; use ::insta::assert_snapshot;
use crate::tests::fakes::FakeInputOutput; use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}; use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::{start, CliArgs}; use crate::CliArgs;
use crate::common::input::{config::Config, options::Options}; use crate::common::input::config::Config;
use crate::tests::utils::commands::{ use crate::tests::utils::commands::{
CLOSE_PANE_IN_PANE_MODE, ESC, MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, CLOSE_PANE_IN_PANE_MODE, ESC, MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT,
RESIZE_DOWN_IN_RESIZE_MODE, RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE, RESIZE_UP_IN_RESIZE_MODE, RESIZE_DOWN_IN_RESIZE_MODE, RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE, RESIZE_UP_IN_RESIZE_MODE,
@ -45,7 +46,6 @@ pub fn close_pane_with_another_pane_above_it() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -89,7 +89,6 @@ pub fn close_pane_with_another_pane_below_it() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -130,7 +129,6 @@ pub fn close_pane_with_another_pane_to_the_left() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -172,7 +170,6 @@ pub fn close_pane_with_another_pane_to_the_right() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -219,7 +216,6 @@ pub fn close_pane_with_multiple_panes_above_it() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -264,7 +260,6 @@ pub fn close_pane_with_multiple_panes_below_it() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -311,7 +306,6 @@ pub fn close_pane_with_multiple_panes_to_the_left() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -356,7 +350,6 @@ pub fn close_pane_with_multiple_panes_to_the_right() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -423,7 +416,6 @@ pub fn close_pane_with_multiple_panes_above_it_away_from_screen_edges() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -486,7 +478,6 @@ pub fn close_pane_with_multiple_panes_below_it_away_from_screen_edges() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -551,7 +542,6 @@ pub fn close_pane_with_multiple_panes_to_the_left_away_from_screen_edges() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -616,7 +606,6 @@ pub fn close_pane_with_multiple_panes_to_the_right_away_from_screen_edges() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -654,7 +643,6 @@ pub fn closing_last_pane_exits_app() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output

View file

@ -4,10 +4,11 @@ use ::std::collections::HashMap;
use crate::panes::PositionAndSize; use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput; use crate::tests::fakes::FakeInputOutput;
use crate::tests::possible_tty_inputs::Bytes; use crate::tests::possible_tty_inputs::Bytes;
use crate::tests::start;
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}; use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::{start, CliArgs}; use crate::CliArgs;
use crate::common::input::{config::Config, options::Options}; use crate::common::input::config::Config;
use crate::tests::utils::commands::QUIT; use crate::tests::utils::commands::QUIT;
/* /*
@ -48,7 +49,6 @@ pub fn run_bandwhich_from_fish_shell() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -78,7 +78,6 @@ pub fn fish_tab_completion_options() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -113,7 +112,6 @@ pub fn fish_select_tab_completion_options() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -152,7 +150,6 @@ pub fn vim_scroll_region_down() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -188,7 +185,6 @@ pub fn vim_ctrl_d() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -223,7 +219,6 @@ pub fn vim_ctrl_u() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -253,7 +248,6 @@ pub fn htop() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -283,7 +277,6 @@ pub fn htop_scrolling() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -313,7 +306,6 @@ pub fn htop_right_scrolling() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -351,7 +343,6 @@ pub fn vim_overwrite() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -384,7 +375,6 @@ pub fn clear_scroll_region() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -414,7 +404,6 @@ pub fn display_tab_characters_properly() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -444,7 +433,6 @@ pub fn neovim_insert_mode() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -476,7 +464,6 @@ pub fn bash_cursor_linewrap() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -508,7 +495,6 @@ pub fn fish_paste_multiline() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -538,7 +524,6 @@ pub fn git_log() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -570,7 +555,6 @@ pub fn git_diff_scrollup() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -600,7 +584,6 @@ pub fn emacs_longbuf() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -630,7 +613,6 @@ pub fn top_and_quit() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -666,7 +648,6 @@ pub fn exa_plus_omf_theme() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer

View file

@ -1,12 +1,13 @@
use insta::assert_snapshot; use insta::assert_snapshot;
use std::path::PathBuf; use std::path::PathBuf;
use crate::common::input::{config::Config, options::Options}; use crate::common::input::config::Config;
use crate::panes::PositionAndSize; use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput; use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
use crate::tests::utils::commands::QUIT; use crate::tests::utils::commands::QUIT;
use crate::tests::utils::get_output_frame_snapshots; use crate::tests::utils::get_output_frame_snapshots;
use crate::{start, CliArgs}; use crate::CliArgs;
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput { fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
FakeInputOutput::new(fake_win_size.clone()) FakeInputOutput::new(fake_win_size.clone())
@ -33,7 +34,6 @@ pub fn accepts_basic_layout() {
opts, opts,
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer

View file

@ -2,10 +2,11 @@ use ::insta::assert_snapshot;
use crate::panes::PositionAndSize; use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput; use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}; use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::{start, CliArgs}; use crate::CliArgs;
use crate::common::input::{config::Config, options::Options}; use crate::common::input::config::Config;
use crate::tests::utils::commands::{ use crate::tests::utils::commands::{
MOVE_FOCUS_DOWN_IN_PANE_MODE, MOVE_FOCUS_UP_IN_PANE_MODE, PANE_MODE, QUIT, MOVE_FOCUS_DOWN_IN_PANE_MODE, MOVE_FOCUS_UP_IN_PANE_MODE, PANE_MODE, QUIT,
SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
@ -37,7 +38,6 @@ pub fn move_focus_down() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -75,7 +75,6 @@ pub fn move_focus_down_to_the_most_recently_used_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output

View file

@ -2,10 +2,11 @@ use ::insta::assert_snapshot;
use crate::panes::PositionAndSize; use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput; use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}; use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::{start, CliArgs}; use crate::CliArgs;
use crate::common::input::{config::Config, options::Options}; use crate::common::input::config::Config;
use crate::tests::utils::commands::{ use crate::tests::utils::commands::{
ENTER, MOVE_FOCUS_LEFT_IN_NORMAL_MODE, MOVE_FOCUS_LEFT_IN_PANE_MODE, ENTER, MOVE_FOCUS_LEFT_IN_NORMAL_MODE, MOVE_FOCUS_LEFT_IN_PANE_MODE,
MOVE_FOCUS_RIGHT_IN_PANE_MODE, NEW_TAB_IN_TAB_MODE, PANE_MODE, QUIT, SPLIT_DOWN_IN_PANE_MODE, MOVE_FOCUS_RIGHT_IN_PANE_MODE, NEW_TAB_IN_TAB_MODE, PANE_MODE, QUIT, SPLIT_DOWN_IN_PANE_MODE,
@ -37,7 +38,6 @@ pub fn move_focus_left() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -76,7 +76,6 @@ pub fn move_focus_left_to_the_most_recently_used_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -115,7 +114,6 @@ pub fn move_focus_left_changes_tab() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output

View file

@ -2,10 +2,11 @@ use ::insta::assert_snapshot;
use crate::panes::PositionAndSize; use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput; use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}; use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::{start, CliArgs}; use crate::CliArgs;
use crate::common::input::{config::Config, options::Options}; use crate::common::input::config::Config;
use crate::tests::utils::commands::{ use crate::tests::utils::commands::{
ENTER, MOVE_FOCUS_LEFT_IN_PANE_MODE, MOVE_FOCUS_RIGHT_IN_NORMAL_MODE, ENTER, MOVE_FOCUS_LEFT_IN_PANE_MODE, MOVE_FOCUS_RIGHT_IN_NORMAL_MODE,
MOVE_FOCUS_RIGHT_IN_PANE_MODE, NEW_TAB_IN_TAB_MODE, PANE_MODE, QUIT, SPLIT_DOWN_IN_PANE_MODE, MOVE_FOCUS_RIGHT_IN_PANE_MODE, NEW_TAB_IN_TAB_MODE, PANE_MODE, QUIT, SPLIT_DOWN_IN_PANE_MODE,
@ -38,7 +39,6 @@ pub fn move_focus_right() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -76,7 +76,6 @@ pub fn move_focus_right_to_the_most_recently_used_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -115,7 +114,6 @@ pub fn move_focus_right_changes_tab() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output

View file

@ -2,10 +2,11 @@ use ::insta::assert_snapshot;
use crate::panes::PositionAndSize; use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput; use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}; use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::{start, CliArgs}; use crate::CliArgs;
use crate::common::input::{config::Config, options::Options}; use crate::common::input::config::Config;
use crate::tests::utils::commands::{ use crate::tests::utils::commands::{
MOVE_FOCUS_DOWN_IN_PANE_MODE, MOVE_FOCUS_UP_IN_PANE_MODE, PANE_MODE, QUIT, MOVE_FOCUS_DOWN_IN_PANE_MODE, MOVE_FOCUS_UP_IN_PANE_MODE, PANE_MODE, QUIT,
SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
@ -36,7 +37,6 @@ pub fn move_focus_up() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -75,7 +75,6 @@ pub fn move_focus_up_to_the_most_recently_used_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output

View file

@ -2,10 +2,11 @@ use insta::assert_snapshot;
use crate::panes::PositionAndSize; use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput; use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}; use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::{start, CliArgs}; use crate::CliArgs;
use crate::common::input::{config::Config, options::Options}; use crate::common::input::config::Config;
use crate::tests::utils::commands::{ use crate::tests::utils::commands::{
MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_DOWN_IN_RESIZE_MODE, MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_DOWN_IN_RESIZE_MODE,
RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE, SLEEP, SPLIT_DOWN_IN_PANE_MODE, RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE, SLEEP, SPLIT_DOWN_IN_PANE_MODE,
@ -48,7 +49,6 @@ pub fn resize_down_with_pane_above() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -94,7 +94,6 @@ pub fn resize_down_with_pane_below() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -146,7 +145,6 @@ pub fn resize_down_with_panes_above_and_below() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -197,7 +195,6 @@ pub fn resize_down_with_multiple_panes_above() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -250,7 +247,6 @@ pub fn resize_down_with_panes_above_aligned_left_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -302,7 +298,6 @@ pub fn resize_down_with_panes_below_aligned_left_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -352,7 +347,6 @@ pub fn resize_down_with_panes_above_aligned_right_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -403,7 +397,6 @@ pub fn resize_down_with_panes_below_aligned_right_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -457,7 +450,6 @@ pub fn resize_down_with_panes_above_aligned_left_and_right_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -513,7 +505,6 @@ pub fn resize_down_with_panes_below_aligned_left_and_right_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -586,7 +577,6 @@ pub fn resize_down_with_panes_above_aligned_left_and_right_with_panes_to_the_lef
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -661,7 +651,6 @@ pub fn resize_down_with_panes_below_aligned_left_and_right_with_to_the_left_and_
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -704,7 +693,6 @@ pub fn cannot_resize_down_when_pane_below_is_at_minimum_height() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output

View file

@ -2,10 +2,11 @@ use ::insta::assert_snapshot;
use crate::panes::PositionAndSize; use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput; use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}; use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::{start, CliArgs}; use crate::CliArgs;
use crate::common::input::{config::Config, options::Options}; use crate::common::input::config::Config;
use crate::tests::utils::commands::{ use crate::tests::utils::commands::{
MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE, MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE,
RESIZE_UP_IN_RESIZE_MODE, SLEEP, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE, RESIZE_UP_IN_RESIZE_MODE, SLEEP, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
@ -44,7 +45,6 @@ pub fn resize_left_with_pane_to_the_left() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -88,7 +88,6 @@ pub fn resize_left_with_pane_to_the_right() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -134,7 +133,6 @@ pub fn resize_left_with_panes_to_the_left_and_right() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -183,7 +181,6 @@ pub fn resize_left_with_multiple_panes_to_the_left() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -234,7 +231,6 @@ pub fn resize_left_with_panes_to_the_left_aligned_top_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -282,7 +278,6 @@ pub fn resize_left_with_panes_to_the_right_aligned_top_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -332,7 +327,6 @@ pub fn resize_left_with_panes_to_the_left_aligned_bottom_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -381,7 +375,6 @@ pub fn resize_left_with_panes_to_the_right_aligned_bottom_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -435,7 +428,6 @@ pub fn resize_left_with_panes_to_the_left_aligned_top_and_bottom_with_current_pa
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -491,7 +483,6 @@ pub fn resize_left_with_panes_to_the_right_aligned_top_and_bottom_with_current_p
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -564,7 +555,6 @@ pub fn resize_left_with_panes_to_the_left_aligned_top_and_bottom_with_panes_abov
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -640,7 +630,6 @@ pub fn resize_left_with_panes_to_the_right_aligned_top_and_bottom_with_panes_abo
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -683,7 +672,6 @@ pub fn cannot_resize_left_when_pane_to_the_left_is_at_minimum_width() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output

View file

@ -2,10 +2,11 @@ use ::insta::assert_snapshot;
use crate::panes::PositionAndSize; use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput; use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}; use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::{start, CliArgs}; use crate::CliArgs;
use crate::common::input::{config::Config, options::Options}; use crate::common::input::config::Config;
use crate::tests::utils::commands::{ use crate::tests::utils::commands::{
MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_MODE, RESIZE_RIGHT_IN_RESIZE_MODE, MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_MODE, RESIZE_RIGHT_IN_RESIZE_MODE,
RESIZE_UP_IN_RESIZE_MODE, SLEEP, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE, RESIZE_UP_IN_RESIZE_MODE, SLEEP, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
@ -44,7 +45,6 @@ pub fn resize_right_with_pane_to_the_left() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -88,7 +88,6 @@ pub fn resize_right_with_pane_to_the_right() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -134,7 +133,6 @@ pub fn resize_right_with_panes_to_the_left_and_right() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -183,7 +181,6 @@ pub fn resize_right_with_multiple_panes_to_the_left() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -234,7 +231,6 @@ pub fn resize_right_with_panes_to_the_left_aligned_top_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -282,7 +278,6 @@ pub fn resize_right_with_panes_to_the_right_aligned_top_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -332,7 +327,6 @@ pub fn resize_right_with_panes_to_the_left_aligned_bottom_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -381,7 +375,6 @@ pub fn resize_right_with_panes_to_the_right_aligned_bottom_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -435,7 +428,6 @@ pub fn resize_right_with_panes_to_the_left_aligned_top_and_bottom_with_current_p
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -491,7 +483,6 @@ pub fn resize_right_with_panes_to_the_right_aligned_top_and_bottom_with_current_
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -564,7 +555,6 @@ pub fn resize_right_with_panes_to_the_left_aligned_top_and_bottom_with_panes_abo
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -639,7 +629,6 @@ pub fn resize_right_with_panes_to_the_right_aligned_top_and_bottom_with_panes_ab
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -682,7 +671,6 @@ pub fn cannot_resize_right_when_pane_to_the_left_is_at_minimum_width() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output

View file

@ -2,10 +2,11 @@ use ::insta::assert_snapshot;
use crate::panes::PositionAndSize; use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput; use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}; use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::{start, CliArgs}; use crate::CliArgs;
use crate::common::input::{config::Config, options::Options}; use crate::common::input::config::Config;
use crate::tests::utils::commands::{ use crate::tests::utils::commands::{
MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE, MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE,
RESIZE_UP_IN_RESIZE_MODE, SLEEP, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE, RESIZE_UP_IN_RESIZE_MODE, SLEEP, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
@ -46,7 +47,6 @@ pub fn resize_up_with_pane_above() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -92,7 +92,6 @@ pub fn resize_up_with_pane_below() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -143,7 +142,6 @@ pub fn resize_up_with_panes_above_and_below() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -193,7 +191,6 @@ pub fn resize_up_with_multiple_panes_above() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -244,7 +241,6 @@ pub fn resize_up_with_panes_above_aligned_left_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -296,7 +292,6 @@ pub fn resize_up_with_panes_below_aligned_left_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -346,7 +341,6 @@ pub fn resize_up_with_panes_above_aligned_right_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -397,7 +391,6 @@ pub fn resize_up_with_panes_below_aligned_right_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -451,7 +444,6 @@ pub fn resize_up_with_panes_above_aligned_left_and_right_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -507,7 +499,6 @@ pub fn resize_up_with_panes_below_aligned_left_and_right_with_current_pane() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -580,7 +571,6 @@ pub fn resize_up_with_panes_above_aligned_left_and_right_with_panes_to_the_left_
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -655,7 +645,6 @@ pub fn resize_up_with_panes_below_aligned_left_and_right_with_to_the_left_and_ri
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -698,7 +687,6 @@ pub fn cannot_resize_up_when_pane_above_is_at_minimum_height() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output

View file

@ -1,11 +1,12 @@
use insta::assert_snapshot; use insta::assert_snapshot;
use crate::tests::fakes::FakeInputOutput; use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}; use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::CliArgs;
use crate::{panes::PositionAndSize, tests::utils::commands::CLOSE_PANE_IN_PANE_MODE}; use crate::{panes::PositionAndSize, tests::utils::commands::CLOSE_PANE_IN_PANE_MODE};
use crate::{start, CliArgs};
use crate::common::input::{config::Config, options::Options}; use crate::common::input::config::Config;
use crate::tests::utils::commands::{ use crate::tests::utils::commands::{
CLOSE_TAB_IN_TAB_MODE, NEW_TAB_IN_TAB_MODE, PANE_MODE, QUIT, SPLIT_DOWN_IN_PANE_MODE, CLOSE_TAB_IN_TAB_MODE, NEW_TAB_IN_TAB_MODE, PANE_MODE, QUIT, SPLIT_DOWN_IN_PANE_MODE,
SWITCH_NEXT_TAB_IN_TAB_MODE, SWITCH_PREV_TAB_IN_TAB_MODE, TAB_MODE, SWITCH_NEXT_TAB_IN_TAB_MODE, SWITCH_PREV_TAB_IN_TAB_MODE, TAB_MODE,
@ -38,7 +39,6 @@ pub fn open_new_tab() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -75,7 +75,6 @@ pub fn switch_to_prev_tab() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -112,7 +111,6 @@ pub fn switch_to_next_tab() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -149,7 +147,6 @@ pub fn close_tab() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -187,7 +184,6 @@ pub fn close_last_pane_in_a_tab() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -227,7 +223,6 @@ pub fn close_the_middle_tab() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -272,7 +267,6 @@ pub fn close_the_tab_that_has_a_pane_in_fullscreen() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -309,7 +303,6 @@ pub fn closing_last_tab_exits_the_app() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output

View file

@ -1,11 +1,12 @@
use crate::panes::PositionAndSize; use crate::panes::PositionAndSize;
use ::insta::assert_snapshot; use ::insta::assert_snapshot;
use crate::common::input::{config::Config, options::Options}; use crate::common::input::config::Config;
use crate::tests::fakes::FakeInputOutput; use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
use crate::tests::utils::commands::QUIT; use crate::tests::utils::commands::QUIT;
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}; use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::{start, CliArgs}; use crate::CliArgs;
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput { fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
FakeInputOutput::new(fake_win_size.clone()) FakeInputOutput::new(fake_win_size.clone())
@ -35,7 +36,6 @@ pub fn window_width_decrease_with_one_pane() {
opts, opts,
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -72,7 +72,6 @@ pub fn window_width_increase_with_one_pane() {
opts, opts,
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -109,7 +108,6 @@ pub fn window_height_increase_with_one_pane() {
opts, opts,
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer
@ -146,7 +144,6 @@ pub fn window_width_and_height_decrease_with_one_pane() {
opts, opts,
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
.stdout_writer .stdout_writer

View file

@ -2,10 +2,11 @@ use insta::assert_snapshot;
use crate::panes::PositionAndSize; use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput; use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}; use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::{start, CliArgs}; use crate::CliArgs;
use crate::common::input::{config::Config, options::Options}; use crate::common::input::config::Config;
use crate::tests::utils::commands::{ use crate::tests::utils::commands::{
MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE, MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE, TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE,
@ -37,7 +38,6 @@ pub fn adding_new_terminal_in_fullscreen() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output
@ -73,7 +73,6 @@ pub fn move_focus_is_disabled_in_fullscreen() {
CliArgs::default(), CliArgs::default(),
Box::new(fake_input_output.clone()), Box::new(fake_input_output.clone()),
Config::default(), Config::default(),
Options::default(),
); );
let output_frames = fake_input_output let output_frames = fake_input_output

View file

@ -3,3 +3,26 @@ pub mod integration;
pub mod possible_tty_inputs; pub mod possible_tty_inputs;
pub mod tty_inputs; pub mod tty_inputs;
pub mod utils; pub mod utils;
use crate::cli::CliArgs;
use crate::client::start_client;
use crate::common::input::config::Config;
use crate::os_input_output::{ClientOsApi, ServerOsApi};
use crate::server::start_server;
use std::path::PathBuf;
pub fn start(
client_os_input: Box<dyn ClientOsApi>,
opts: CliArgs,
server_os_input: Box<dyn ServerOsApi>,
config: Config,
) {
let server_thread = std::thread::Builder::new()
.name("server_thread".into())
.spawn(move || {
start_server(server_os_input, PathBuf::from(""));
})
.unwrap();
start_client(client_os_input, opts, config);
let _ = server_thread.join();
}