Merge branch 'main' of https://github.com/zellij-org/zellij into layout-path-506

This commit is contained in:
a-kenji 2021-05-16 12:44:56 +02:00
commit 197f318756
40 changed files with 461 additions and 425 deletions

3
.gitignore vendored
View File

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

View File

@ -5,7 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
## [Unreleased]
* Remove unused imports (https://github.com/zellij-org/zellij/pull/504)
* More Infrastructure changes for the upcoming session detach feature: run server and client in separate processes (https://github.com/zellij-org/zellij/pull/499)
## [0.11.0] - 2021-05-15
This version is mostly an installation hotfix.
* Add `check` flag to `setup` subcommand, move `generate-completions` subcommand to `setup` flag (https://github.com/zellij-org/zellij/pull/503)
* Change the asset installation from an opt-in to an opt-out (https://github.com/zellij-org/zellij/pull/512)
## [0.10.0] - 2021-05-14
* Change Switch default config loading order of `HOME` and system (https://github.com/zellij-org/zellij/pull/488)

23
Cargo.lock generated
View File

@ -248,6 +248,12 @@ dependencies = [
"once_cell",
]
[[package]]
name = "boxfnonce"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5988cb1d626264ac94100be357308f29ff7cbdd3b36bda27f450a4ee3f713426"
[[package]]
name = "bumpalo"
version = "3.6.1"
@ -467,6 +473,16 @@ dependencies = [
"syn",
]
[[package]]
name = "daemonize"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70c24513e34f53b640819f0ac9f705b673fcf4006d7aab8778bee72ebfc89815"
dependencies = [
"boxfnonce",
"libc",
]
[[package]]
name = "darling"
version = "0.12.3"
@ -2254,13 +2270,14 @@ dependencies = [
[[package]]
name = "zellij"
version = "0.11.0"
version = "0.12.0"
dependencies = [
"ansi_term 0.12.1",
"async-std",
"backtrace",
"bincode",
"colors-transform",
"daemonize",
"directories-next",
"futures",
"insta",
@ -2290,7 +2307,7 @@ dependencies = [
[[package]]
name = "zellij-tile"
version = "0.11.0"
version = "0.12.0"
dependencies = [
"serde",
"serde_json",
@ -2300,7 +2317,7 @@ dependencies = [
[[package]]
name = "zellij-tile-utils"
version = "0.11.0"
version = "0.12.0"
dependencies = [
"ansi_term 0.12.1",
]

View File

@ -1,6 +1,6 @@
[package]
name = "zellij"
version = "0.11.0"
version = "0.12.0"
authors = ["Aram Drevekenin <aram@poor.dev>"]
edition = "2018"
description = "A terminal workspace with batteries included"
@ -15,6 +15,7 @@ include = ["src/**/*", "assets/plugins/*", "assets/layouts/*", "assets/config/*"
ansi_term = "0.12.1"
backtrace = "0.3.55"
bincode = "1.3.1"
daemonize = "0.4.1"
directories-next = "2.0"
futures = "0.3.5"
libc = "0.2"
@ -38,7 +39,7 @@ wasmer-wasi = "1.0.0"
interprocess = "1.1.1"
names = "0.11.0"
colors-transform = "0.2.5"
zellij-tile = { path = "zellij-tile/", version = "0.11.0" }
zellij-tile = { path = "zellij-tile/", version = "0.12.0" }
[dependencies.async-std]
version = "1.3.0"
@ -80,5 +81,4 @@ assets = [
]
[features]
default = [ "enable_automatic_asset_installation", ]
enable_automatic_asset_installation = []
disable_automatic_asset_installation = []

View File

@ -122,9 +122,22 @@ args = ["install", "cross"]
[tasks.publish]
clear = true
workspace = false
dependencies = ["build-plugins-release", "wasm-opt-plugins", "build-release", "publish-zellij-tile", "publish-zellij-tile-utils"]
dependencies = ["build-plugins-release", "wasm-opt-plugins", "release-commit", "build-release", "publish-zellij-tile", "publish-zellij-tile-utils"]
run_task = "publish-zellij"
[tasks.release-commit]
dependencies = ["commit-all", "tag-release"]
command = "git"
args = ["push", "--atomic", "origin", "main", "v${CARGO_MAKE_CRATE_VERSION}"]
[tasks.commit-all]
command = "git"
args = ["commit", "-aem", "chore(release): v${CARGO_MAKE_CRATE_VERSION}"]
[tasks.tag-release]
command = "git"
args = ["tag", "v${CARGO_MAKE_CRATE_VERSION}"]
[tasks.publish-zellij-tile]
ignore_errors = true
cwd = "zellij-tile"

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -13,11 +13,15 @@ pub struct CliArgs {
pub max_panes: Option<usize>,
/// Change where zellij looks for layouts and plugins
#[structopt(long)]
#[structopt(long, parse(from_os_str))]
pub data_dir: Option<PathBuf>,
/// Name of a layout yaml file inside the plugin directory
#[structopt(short, long)]
/// Run server listening at the specified socket path
#[structopt(long, parse(from_os_str))]
pub server: Option<PathBuf>,
/// Path to a layout yaml file
#[structopt(short, long, parse(from_os_str))]
pub layout: Option<PathBuf>,
/// Path to a layout yaml file
@ -25,11 +29,11 @@ pub struct CliArgs {
pub layout_path: Option<PathBuf>,
/// 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>,
/// 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>,
#[structopt(subcommand)]

View File

@ -4,30 +4,62 @@ pub mod pane_resizer;
pub mod panes;
pub mod tab;
use serde::{Deserialize, Serialize};
use std::io::Write;
use std::env::current_exe;
use std::io::{self, Write};
use std::path::Path;
use std::process::Command;
use std::sync::mpsc;
use std::thread;
use crate::cli::CliArgs;
use crate::common::{
command_is_executing::CommandIsExecuting,
errors::{ClientContext, ContextType},
errors::ContextType,
input::config::Config,
input::handler::input_loop,
input::options::Options,
ipc::{ClientToServerMsg, ServerToClientMsg},
os_input_output::ClientOsApi,
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
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Debug, Clone)]
pub enum ClientInstruction {
Error(String),
Render(Option<String>),
UnblockInputThread,
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) {
@ -45,13 +77,16 @@ pub fn start_client(mut os_input: Box<dyn ClientOsApi>, opts: CliArgs, config: C
.unwrap();
std::env::set_var(&"ZELLIJ", "0");
#[cfg(not(test))]
spawn_server(&*ZELLIJ_IPC_PIPE).unwrap();
let mut command_is_executing = CommandIsExecuting::new();
let config_options = Options::from_cli(&config.options, opts.option.clone());
let full_screen_ws = os_input.get_terminal_size_using_fd(0);
os_input.connect_to_server();
os_input.send_to_server(ServerInstruction::NewClient(
os_input.connect_to_server(&*ZELLIJ_IPC_PIPE);
os_input.send_to_server(ClientToServerMsg::NewClient(
full_screen_ws,
opts,
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())
.spawn({
let os_input = os_input.clone();
let send_client_instructions = send_client_instructions.clone();
move || {
os_input.receive_sigwinch(Box::new({
let os_api = os_input.clone();
move || {
os_api.send_to_server(ServerInstruction::TerminalResize(
os_api.get_terminal_size_using_fd(0),
));
}
}));
os_input.handle_signals(
Box::new({
let os_api = os_input.clone();
move || {
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();
@ -114,47 +160,53 @@ pub fn start_client(mut os_input: Box<dyn ClientOsApi>, opts: CliArgs, config: C
.name("router".to_string())
.spawn({
let os_input = os_input.clone();
move || {
loop {
let (instruction, mut err_ctx) = os_input.recv_from_server();
err_ctx.add_call(ContextType::Client(ClientContext::from(&instruction)));
if let ClientInstruction::Exit = instruction {
break;
let mut should_break = false;
move || loop {
let (instruction, err_ctx) = os_input.recv_from_server();
err_ctx.update_thread_ctx();
match instruction {
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();
#[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 {
let (client_instruction, mut err_ctx) = receive_client_instructions
.recv()
.expect("failed to receive app instruction on channel");
err_ctx.add_call(ContextType::Client(ClientContext::from(
&client_instruction,
)));
err_ctx.add_call(ContextType::Client((&client_instruction).into()));
match client_instruction {
ClientInstruction::Exit => break,
ClientInstruction::Error(backtrace) => {
let _ = os_input.send_to_server(ServerInstruction::ClientExit);
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);
let _ = os_input.send_to_server(ClientToServerMsg::ClientExit);
handle_error(backtrace);
}
ClientInstruction::ServerError(backtrace) => {
handle_error(backtrace);
}
ClientInstruction::Render(output) => {
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();
// cleanup();

View File

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

View File

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

View File

@ -1,10 +1,14 @@
//! 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 nix::unistd::dup;
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use std::io::{self, Write};
use std::marker::PhantomData;
use std::os::unix::io::{AsRawFd, FromRawFd};
@ -29,9 +33,9 @@ pub enum ClientType {
}
// Types of messages sent from the client to the server
#[derive(Serialize, Deserialize)]
pub enum _ClientToServerMsg {
// List which sessions are available
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum ClientToServerMsg {
/*// List which sessions are available
ListSessions,
// Create a new session
CreateSession,
@ -40,16 +44,24 @@ pub enum _ClientToServerMsg {
// Force detach
DetachSession(SessionId),
// 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
// @@@ Implement Serialize and Deserialize for this...
pub enum _ServerToClientMsg {
// Info about a particular session
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum ServerToClientMsg {
/*// Info about a particular session
SessionInfo(Session),
// 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`].

View File

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

View File

@ -8,7 +8,7 @@ use std::pin::*;
use std::time::{Duration, Instant};
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::thread_bus::{Bus, ThreadSenders};
use crate::layout::Layout;
@ -87,7 +87,7 @@ pub struct Pty {
pub fn pty_thread_main(mut pty: Pty, maybe_layout: Option<Layout>) {
loop {
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 {
PtyInstruction::SpawnTerminal(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::pty::{PtyInstruction, VteBytes};
use crate::common::thread_bus::Bus;
use crate::errors::{ContextType, ScreenContext};
use crate::errors::ContextType;
use crate::layout::Layout;
use crate::panes::PaneId;
use crate::panes::PositionAndSize;
@ -353,7 +353,7 @@ pub fn screen_thread_main(
.bus
.recv()
.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 {
ScreenInstruction::PtyBytes(pid, vte_bytes) => {
let active_tab = screen.get_active_tab_mut().unwrap();

View File

@ -49,6 +49,6 @@ lazy_static! {
}
pub const FEATURES: &[&str] = &[
#[cfg(feature = "enable_automatic_asset_installation")]
"enable_automatic_asset_installation",
#[cfg(feature = "disable_automatic_asset_installation")]
"disable_automatic_asset_installation",
];

View File

@ -15,7 +15,7 @@ use wasmer::{
use wasmer_wasi::{Pipe, WasiEnv, WasiState};
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::screen::ScreenInstruction;
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();
loop {
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 {
PluginInstruction::Load(pid_tx, path) => {
let plugin_dir = data_dir.join("plugins/");

View File

@ -14,8 +14,8 @@ use structopt::StructOpt;
use crate::cli::CliArgs;
use crate::command_is_executing::CommandIsExecuting;
use crate::common::input::{config::Config, options::Options};
use crate::os_input_output::{get_client_os_input, get_server_os_input, ClientOsApi, ServerOsApi};
use crate::common::input::config::Config;
use crate::os_input_output::{get_client_os_input, get_server_os_input};
use crate::utils::{
consts::{ZELLIJ_TMP_DIR, ZELLIJ_TMP_LOG_DIR},
logging::*,
@ -36,28 +36,14 @@ pub fn main() {
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_LOG_DIR).unwrap();
let server_os_input = get_server_os_input();
let os_input = get_client_os_input();
start(
Box::new(os_input),
opts,
Box::new(server_os_input),
config,
config_options,
);
if let Some(path) = opts.server {
let os_input = get_server_os_input();
start_server(Box::new(os_input), path);
} else {
let os_input = get_client_os_input();
start_client(Box::new(os_input), opts, config);
}
}
}
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;
use interprocess::local_socket::LocalSocketListener;
use serde::{Deserialize, Serialize};
use std::sync::{Arc, RwLock};
use std::thread;
use std::{path::PathBuf, sync::mpsc::channel};
use std::{path::PathBuf, sync::mpsc};
use wasmer::Store;
use zellij_tile::data::PluginCapabilities;
use crate::cli::CliArgs;
use crate::client::ClientInstruction;
use crate::common::thread_bus::{Bus, ThreadSenders};
use crate::common::{
errors::{ContextType, ServerContext},
input::{actions::Action, options::Options},
os_input_output::{set_permissions, ServerOsApi},
errors::ContextType,
input::options::Options,
ipc::{ClientToServerMsg, ServerToClientMsg},
os_input_output::ServerOsApi,
pty::{pty_thread_main, Pty, PtyInstruction},
screen::{screen_thread_main, ScreenInstruction},
setup::{get_default_data_dir, install::populate_data_dir},
thread_bus::{ChannelWithContext, SenderType, SenderWithContext},
utils::consts::{ZELLIJ_IPC_PIPE, ZELLIJ_PROJ_DIR},
thread_bus::{ChannelWithContext, SenderType, SenderWithContext, SyncChannelWithContext},
wasm_vm::{wasm_thread_main, PluginInstruction},
};
use crate::layout::Layout;
@ -28,18 +25,30 @@ use route::route_thread_main;
/// Instructions related to server-side application including the
/// ones sent by client to server
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Debug, Clone)]
pub enum ServerInstruction {
TerminalResize(PositionAndSize),
NewClient(PositionAndSize, CliArgs, Options),
Action(Action),
Render(Option<String>),
UnblockInputThread,
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 senders: ThreadSenders,
pub capabilities: PluginCapabilities,
screen_thread: Option<thread::JoinHandle<()>>,
pty_thread: Option<thread::JoinHandle<()>>,
wasm_thread: Option<thread::JoinHandle<()>>,
@ -56,14 +65,30 @@ impl Drop for SessionMetaData {
}
}
pub fn start_server(
os_input: Box<dyn ServerOsApi>,
config_options: Options,
) -> thread::JoinHandle<()> {
let (to_server, server_receiver): ChannelWithContext<ServerInstruction> = channel();
let to_server = SenderWithContext::new(SenderType::Sender(to_server));
pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
#[cfg(not(test))]
daemonize::Daemonize::new()
.working_directory(std::env::var("HOME").unwrap())
.umask(0o077)
.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));
#[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)]
thread::Builder::new()
.name("server_router".to_string())
@ -71,27 +96,25 @@ pub fn start_server(
let sessions = sessions.clone();
let os_input = os_input.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();
#[cfg(not(test))]
let _ = thread::Builder::new()
.name("server_listener".to_string())
.spawn({
use crate::common::os_input_output::set_permissions;
use interprocess::local_socket::LocalSocketListener;
let os_input = os_input.clone();
let sessions = sessions.clone();
let to_server = to_server.clone();
let capabilities = PluginCapabilities {
arrow_fonts: config_options.simplified_ui,
};
let socket_path = socket_path.clone();
move || {
drop(std::fs::remove_file(&*ZELLIJ_IPC_PIPE));
let listener = LocalSocketListener::bind(&**ZELLIJ_IPC_PIPE).unwrap();
set_permissions(&*ZELLIJ_IPC_PIPE).unwrap();
drop(std::fs::remove_file(&socket_path));
let listener = LocalSocketListener::bind(&*socket_path).unwrap();
set_permissions(&socket_path).unwrap();
for stream in listener.incoming() {
match stream {
Ok(stream) => {
@ -106,14 +129,7 @@ pub fn start_server(
let os_input = os_input.clone();
let to_server = to_server.clone();
move || {
route_thread_main(
sessions,
os_input,
to_server,
capabilities,
)
}
move || route_thread_main(sessions, os_input, to_server)
})
.unwrap();
}
@ -125,48 +141,47 @@ pub fn start_server(
}
});
thread::Builder::new()
.name("server_thread".to_string())
.spawn({
move || loop {
let (instruction, mut err_ctx) = server_receiver.recv().unwrap();
err_ctx.add_call(ContextType::IPCServer(ServerContext::from(&instruction)));
match instruction {
ServerInstruction::NewClient(full_screen_ws, opts, config_options) => {
let session_data = init_session(
os_input.clone(),
opts,
config_options,
to_server.clone(),
full_screen_ws,
);
*sessions.write().unwrap() = Some(session_data);
sessions
.read()
.unwrap()
.as_ref()
.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."),
}
loop {
let (instruction, mut err_ctx) = server_receiver.recv().unwrap();
err_ctx.add_call(ContextType::IPCServer((&instruction).into()));
match instruction {
ServerInstruction::NewClient(full_screen_ws, opts, config_options) => {
let session_data = init_session(
os_input.clone(),
opts,
config_options,
to_server.clone(),
full_screen_ws,
);
*sessions.write().unwrap() = Some(session_data);
sessions
.read()
.unwrap()
.as_ref()
.unwrap()
.senders
.send_to_pty(PtyInstruction::NewTab)
.unwrap();
}
})
.unwrap()
ServerInstruction::UnblockInputThread => {
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(
@ -176,20 +191,24 @@ fn init_session(
to_server: SenderWithContext<ServerInstruction>,
full_screen_ws: PositionAndSize,
) -> 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_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_pty, pty_receiver): ChannelWithContext<PtyInstruction> = channel();
let (to_pty, pty_receiver): ChannelWithContext<PtyInstruction> = mpsc::channel();
let to_pty = SenderWithContext::new(SenderType::Sender(to_pty));
// Determine and initialize the data directory
let data_dir = opts.data_dir.unwrap_or_else(get_default_data_dir);
#[cfg(enable_automatic_assets_installation)]
#[cfg(not(disable_automatic_asset_installation))]
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
#[cfg(not(test))]
let default_layout = Some(PathBuf::from("default"));
@ -234,7 +253,6 @@ fn init_session(
Some(os_input.clone()),
);
let max_panes = opts.max_panes;
let config_options = config_options;
move || {
screen_thread_main(screen_bus, max_panes, full_screen_ws, config_options);
@ -265,6 +283,7 @@ fn init_session(
to_plugin: Some(to_plugin),
to_server: None,
},
capabilities,
screen_thread: Some(screen_thread),
pty_thread: Some(pty_thread),
wasm_thread: Some(wasm_thread),

View File

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

View File

@ -7,11 +7,10 @@ use std::path::PathBuf;
use std::sync::{mpsc, Arc, Condvar, Mutex};
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::errors::ErrorContext;
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::utils::commands::{QUIT, SLEEP};
use crate::utils::shared::default_palette;
@ -77,10 +76,10 @@ pub struct FakeInputOutput {
win_sizes: Arc<Mutex<HashMap<RawFd, PositionAndSize>>>,
possible_tty_inputs: HashMap<u16, Bytes>,
last_snapshot_time: Arc<Mutex<Instant>>,
send_instructions_to_client: SenderWithContext<ClientInstruction>,
receive_instructions_from_server: Arc<Mutex<mpsc::Receiver<(ClientInstruction, ErrorContext)>>>,
send_instructions_to_server: SenderWithContext<ServerInstruction>,
receive_instructions_from_client: Arc<Mutex<mpsc::Receiver<(ServerInstruction, ErrorContext)>>>,
send_instructions_to_client: SenderWithContext<ServerToClientMsg>,
receive_instructions_from_server: Arc<Mutex<mpsc::Receiver<(ServerToClientMsg, ErrorContext)>>>,
send_instructions_to_server: SenderWithContext<ClientToServerMsg>,
receive_instructions_from_client: Arc<Mutex<mpsc::Receiver<(ClientToServerMsg, ErrorContext)>>>,
should_trigger_sigwinch: Arc<(Mutex<bool>, Condvar)>,
sigwinch_event: Option<PositionAndSize>,
}
@ -90,10 +89,10 @@ impl FakeInputOutput {
let mut win_sizes = HashMap::new();
let last_snapshot_time = Arc::new(Mutex::new(Instant::now()));
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();
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();
let send_instructions_to_server = SenderWithContext::new(SenderType::Sender(server_sender));
win_sizes.insert(0, winsize); // 0 is the current terminal
@ -153,7 +152,7 @@ impl ClientOsApi for FakeInputOutput {
.unwrap()
.push(IoEvent::IntoRawMode(pid));
}
fn unset_raw_mode(&mut self, pid: RawFd) {
fn unset_raw_mode(&self, pid: RawFd) {
self.io_events
.lock()
.unwrap()
@ -195,17 +194,17 @@ impl ClientOsApi for FakeInputOutput {
fn get_stdout_writer(&self) -> Box<dyn Write> {
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();
}
fn recv_from_server(&self) -> (ClientInstruction, ErrorContext) {
fn recv_from_server(&self) -> (ServerToClientMsg, ErrorContext) {
self.receive_instructions_from_server
.lock()
.unwrap()
.recv()
.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() {
let (lock, cvar) = &*self.should_trigger_sigwinch;
{
@ -214,10 +213,10 @@ impl ClientOsApi for FakeInputOutput {
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 {
@ -278,14 +277,14 @@ impl ServerOsApi for FakeInputOutput {
self.io_events.lock().unwrap().push(IoEvent::Kill(fd));
Ok(())
}
fn recv_from_client(&self) -> (ServerInstruction, ErrorContext) {
fn recv_from_client(&self) -> (ClientToServerMsg, ErrorContext) {
self.receive_instructions_from_client
.lock()
.unwrap()
.recv()
.unwrap()
}
fn send_to_client(&self, msg: ClientInstruction) {
fn send_to_client(&self, msg: ServerToClientMsg) {
self.send_instructions_to_client.send(msg).unwrap();
}
fn add_client_sender(&mut self) {}

View File

@ -1,8 +1,9 @@
use crate::panes::PositionAndSize;
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::start;
use crate::tests::utils::commands::{
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,
@ -10,7 +11,7 @@ use crate::tests::utils::commands::{
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::{start, CliArgs};
use crate::CliArgs;
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
FakeInputOutput::new(fake_win_size.clone())
@ -32,7 +33,6 @@ pub fn starts_with_one_terminal() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
.stdout_writer
@ -61,7 +61,6 @@ pub fn split_terminals_vertically() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
.stdout_writer
@ -90,7 +89,6 @@ pub fn split_terminals_horizontally() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
.stdout_writer
@ -126,7 +124,6 @@ pub fn split_largest_terminal() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
.stdout_writer
@ -155,7 +152,6 @@ pub fn cannot_split_terminals_vertically_when_active_terminal_is_too_small() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
.stdout_writer
@ -184,7 +180,6 @@ pub fn cannot_split_terminals_horizontally_when_active_terminal_is_too_small() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
.stdout_writer
@ -213,7 +208,6 @@ pub fn cannot_split_largest_terminal_when_there_is_no_room() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
.stdout_writer
@ -250,7 +244,6 @@ pub fn scrolling_up_inside_a_pane() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
.stdout_writer
@ -289,7 +282,6 @@ pub fn scrolling_down_inside_a_pane() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
.stdout_writer
@ -325,7 +317,6 @@ pub fn scrolling_page_up_inside_a_pane() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
.stdout_writer
@ -364,7 +355,6 @@ pub fn scrolling_page_down_inside_a_pane() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
.stdout_writer
@ -404,7 +394,6 @@ pub fn max_panes() {
opts,
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
.stdout_writer
@ -442,7 +431,6 @@ pub fn toggle_focused_pane_fullscreen() {
opts,
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
.stdout_writer
@ -483,7 +471,6 @@ pub fn bracketed_paste() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
.stdout_writer

View File

@ -2,10 +2,11 @@ use crate::panes::PositionAndSize;
use ::insta::assert_snapshot;
use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
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::{
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,
@ -45,7 +46,6 @@ pub fn close_pane_with_another_pane_above_it() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -89,7 +89,6 @@ pub fn close_pane_with_another_pane_below_it() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -130,7 +129,6 @@ pub fn close_pane_with_another_pane_to_the_left() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -172,7 +170,6 @@ pub fn close_pane_with_another_pane_to_the_right() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -219,7 +216,6 @@ pub fn close_pane_with_multiple_panes_above_it() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -264,7 +260,6 @@ pub fn close_pane_with_multiple_panes_below_it() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -311,7 +306,6 @@ pub fn close_pane_with_multiple_panes_to_the_left() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -356,7 +350,6 @@ pub fn close_pane_with_multiple_panes_to_the_right() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -654,7 +643,6 @@ pub fn closing_last_pane_exits_app() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output

View File

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

View File

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

View File

@ -2,10 +2,11 @@ use ::insta::assert_snapshot;
use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
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::{
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,
@ -37,7 +38,6 @@ pub fn move_focus_down() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -75,7 +75,6 @@ pub fn move_focus_down_to_the_most_recently_used_pane() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output

View File

@ -2,10 +2,11 @@ use ::insta::assert_snapshot;
use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
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::{
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,
@ -37,7 +38,6 @@ pub fn move_focus_left() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -76,7 +76,6 @@ pub fn move_focus_left_to_the_most_recently_used_pane() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -115,7 +114,6 @@ pub fn move_focus_left_changes_tab() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output

View File

@ -2,10 +2,11 @@ use ::insta::assert_snapshot;
use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
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::{
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,
@ -38,7 +39,6 @@ pub fn move_focus_right() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -76,7 +76,6 @@ pub fn move_focus_right_to_the_most_recently_used_pane() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -115,7 +114,6 @@ pub fn move_focus_right_changes_tab() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output

View File

@ -2,10 +2,11 @@ use ::insta::assert_snapshot;
use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
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::{
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,
@ -36,7 +37,6 @@ pub fn move_focus_up() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -75,7 +75,6 @@ pub fn move_focus_up_to_the_most_recently_used_pane() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output

View File

@ -2,10 +2,11 @@ use insta::assert_snapshot;
use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
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::{
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,
@ -48,7 +49,6 @@ pub fn resize_down_with_pane_above() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -94,7 +94,6 @@ pub fn resize_down_with_pane_below() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -146,7 +145,6 @@ pub fn resize_down_with_panes_above_and_below() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -197,7 +195,6 @@ pub fn resize_down_with_multiple_panes_above() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -250,7 +247,6 @@ pub fn resize_down_with_panes_above_aligned_left_with_current_pane() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -302,7 +298,6 @@ pub fn resize_down_with_panes_below_aligned_left_with_current_pane() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -352,7 +347,6 @@ pub fn resize_down_with_panes_above_aligned_right_with_current_pane() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -403,7 +397,6 @@ pub fn resize_down_with_panes_below_aligned_right_with_current_pane() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -704,7 +693,6 @@ pub fn cannot_resize_down_when_pane_below_is_at_minimum_height() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output

View File

@ -2,10 +2,11 @@ use ::insta::assert_snapshot;
use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
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::{
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,
@ -44,7 +45,6 @@ pub fn resize_left_with_pane_to_the_left() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -88,7 +88,6 @@ pub fn resize_left_with_pane_to_the_right() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -134,7 +133,6 @@ pub fn resize_left_with_panes_to_the_left_and_right() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -183,7 +181,6 @@ pub fn resize_left_with_multiple_panes_to_the_left() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output

View File

@ -2,10 +2,11 @@ use ::insta::assert_snapshot;
use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
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::{
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,
@ -44,7 +45,6 @@ pub fn resize_right_with_pane_to_the_left() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -88,7 +88,6 @@ pub fn resize_right_with_pane_to_the_right() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -134,7 +133,6 @@ pub fn resize_right_with_panes_to_the_left_and_right() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -183,7 +181,6 @@ pub fn resize_right_with_multiple_panes_to_the_left() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output

View File

@ -2,10 +2,11 @@ use ::insta::assert_snapshot;
use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
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::{
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,
@ -46,7 +47,6 @@ pub fn resize_up_with_pane_above() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -92,7 +92,6 @@ pub fn resize_up_with_pane_below() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -143,7 +142,6 @@ pub fn resize_up_with_panes_above_and_below() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -193,7 +191,6 @@ pub fn resize_up_with_multiple_panes_above() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -244,7 +241,6 @@ pub fn resize_up_with_panes_above_aligned_left_with_current_pane() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -296,7 +292,6 @@ pub fn resize_up_with_panes_below_aligned_left_with_current_pane() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -346,7 +341,6 @@ pub fn resize_up_with_panes_above_aligned_right_with_current_pane() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -397,7 +391,6 @@ pub fn resize_up_with_panes_below_aligned_right_with_current_pane() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
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(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -698,7 +687,6 @@ pub fn cannot_resize_up_when_pane_above_is_at_minimum_height() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output

View File

@ -1,11 +1,12 @@
use insta::assert_snapshot;
use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
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::{start, CliArgs};
use crate::common::input::{config::Config, options::Options};
use crate::common::input::config::Config;
use crate::tests::utils::commands::{
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,
@ -38,7 +39,6 @@ pub fn open_new_tab() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -75,7 +75,6 @@ pub fn switch_to_prev_tab() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -112,7 +111,6 @@ pub fn switch_to_next_tab() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -149,7 +147,6 @@ pub fn close_tab() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -187,7 +184,6 @@ pub fn close_last_pane_in_a_tab() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -227,7 +223,6 @@ pub fn close_the_middle_tab() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -272,7 +267,6 @@ pub fn close_the_tab_that_has_a_pane_in_fullscreen() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -309,7 +303,6 @@ pub fn closing_last_tab_exits_the_app() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output

View File

@ -1,11 +1,12 @@
use crate::panes::PositionAndSize;
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::start;
use crate::tests::utils::commands::QUIT;
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 {
FakeInputOutput::new(fake_win_size.clone())
@ -35,7 +36,6 @@ pub fn window_width_decrease_with_one_pane() {
opts,
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
.stdout_writer
@ -72,7 +72,6 @@ pub fn window_width_increase_with_one_pane() {
opts,
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
.stdout_writer
@ -109,7 +108,6 @@ pub fn window_height_increase_with_one_pane() {
opts,
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
.stdout_writer
@ -146,7 +144,6 @@ pub fn window_width_and_height_decrease_with_one_pane() {
opts,
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
.stdout_writer

View File

@ -2,10 +2,11 @@ use insta::assert_snapshot;
use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
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::{
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,
@ -37,7 +38,6 @@ pub fn adding_new_terminal_in_fullscreen() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output
@ -73,7 +73,6 @@ pub fn move_focus_is_disabled_in_fullscreen() {
CliArgs::default(),
Box::new(fake_input_output.clone()),
Config::default(),
Options::default(),
);
let output_frames = fake_input_output

View File

@ -3,3 +3,26 @@ pub mod integration;
pub mod possible_tty_inputs;
pub mod tty_inputs;
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();
}

View File

@ -1,6 +1,6 @@
[package]
name = "zellij-tile-utils"
version = "0.11.0"
version = "0.12.0"
authors = ["denis <denismaximov98@gmail.com>"]
edition = "2018"
description = "A utility library for Zellij plugins"

View File

@ -1,6 +1,6 @@
[package]
name = "zellij-tile"
version = "0.11.0"
version = "0.12.0"
authors = ["Brooks J Rady <b.j.rady@gmail.com>"]
edition = "2018"
description = "A small client-side library for writing Zellij plugins"