diff options
author | Kunal Mohan <kunalmohan99@gmail.com> | 2021-05-12 23:48:47 +0530 |
---|---|---|
committer | Kunal Mohan <kunalmohan99@gmail.com> | 2021-05-15 22:14:35 +0530 |
commit | 378dd90f8f32d29557bb2437900e318faea460d2 (patch) | |
tree | d0a6605508ba7bd1931cbb0e9c7bd69307808567 /src | |
parent | 41212dc0e8b139fccac443297c06b9478857d5ea (diff) |
Do not pass config_options while spawning server process
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 11 | ||||
-rw-r--r-- | src/server/mod.rs | 26 | ||||
-rw-r--r-- | src/server/route.rs | 21 | ||||
-rw-r--r-- | src/tests/integration/basic.rs | 16 | ||||
-rw-r--r-- | src/tests/integration/close_pane.rs | 15 | ||||
-rw-r--r-- | src/tests/integration/compatibility.rs | 22 | ||||
-rw-r--r-- | src/tests/integration/layouts.rs | 3 | ||||
-rw-r--r-- | src/tests/integration/move_focus_down.rs | 4 | ||||
-rw-r--r-- | src/tests/integration/move_focus_left.rs | 5 | ||||
-rw-r--r-- | src/tests/integration/move_focus_right.rs | 5 | ||||
-rw-r--r-- | src/tests/integration/move_focus_up.rs | 4 | ||||
-rw-r--r-- | src/tests/integration/resize_down.rs | 15 | ||||
-rw-r--r-- | src/tests/integration/resize_left.rs | 15 | ||||
-rw-r--r-- | src/tests/integration/resize_right.rs | 15 | ||||
-rw-r--r-- | src/tests/integration/resize_up.rs | 15 | ||||
-rw-r--r-- | src/tests/integration/tabs.rs | 10 | ||||
-rw-r--r-- | src/tests/integration/terminal_window_resize.rs | 6 | ||||
-rw-r--r-- | src/tests/integration/toggle_fullscreen.rs | 4 | ||||
-rw-r--r-- | src/tests/mod.rs | 5 |
19 files changed, 40 insertions, 177 deletions
diff --git a/src/main.rs b/src/main.rs index 25c363a51..2430d84a7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,7 +14,7 @@ use structopt::StructOpt; use crate::cli::CliArgs; 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}; use crate::utils::{ consts::{ZELLIJ_TMP_DIR, ZELLIJ_TMP_LOG_DIR}, @@ -24,6 +24,13 @@ use std::convert::TryFrom; pub fn main() { let opts = CliArgs::from_args(); + let config = match Config::try_from(&opts) { + Ok(config) => config, + Err(e) => { + eprintln!("There was an error in the config file:\n{}", e); + std::process::exit(1); + } + }; if let Some(crate::cli::ConfigCli::Setup(setup)) = opts.option.clone() { Setup::from_cli(&setup, opts).expect("Failed to print to stdout"); @@ -41,7 +48,7 @@ pub fn main() { atomic_create_dir(&*ZELLIJ_TMP_LOG_DIR).unwrap(); if let Some(path) = opts.server { let os_input = get_server_os_input(); - start_server(Box::new(os_input), path, config_options); + start_server(Box::new(os_input), path); } else { let os_input = get_client_os_input(); start_client(Box::new(os_input), opts, config); diff --git a/src/server/mod.rs b/src/server/mod.rs index afa846e81..b925b4d20 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -49,6 +49,7 @@ impl From<ClientToServerMsg> for ServerInstruction { pub struct SessionMetaData { pub senders: ThreadSenders, + pub capabilities: PluginCapabilities, screen_thread: Option<thread::JoinHandle<()>>, pty_thread: Option<thread::JoinHandle<()>>, wasm_thread: Option<thread::JoinHandle<()>>, @@ -65,7 +66,7 @@ impl Drop for SessionMetaData { } } -pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf, config_options: Options) { +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()) @@ -96,11 +97,8 @@ pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf, config 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))] @@ -114,9 +112,6 @@ pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf, config let sessions = sessions.clone(); let to_server = to_server.clone(); let socket_path = socket_path.clone(); - let capabilities = PluginCapabilities { - arrow_fonts: config_options.simplified_ui, - }; move || { drop(std::fs::remove_file(&socket_path)); let listener = LocalSocketListener::bind(&*socket_path).unwrap(); @@ -135,14 +130,7 @@ pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf, config 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(); } @@ -218,6 +206,10 @@ fn init_session( #[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")); @@ -259,7 +251,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); @@ -290,6 +281,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), diff --git a/src/server/route.rs b/src/server/route.rs index 34db835ff..c435a0e65 100644 --- a/src/server/route.rs +++ b/src/server/route.rs @@ -1,6 +1,6 @@ use std::sync::{Arc, RwLock}; -use zellij_tile::data::{Event, PluginCapabilities}; +use zellij_tile::data::Event; use crate::common::input::actions::{Action, Direction}; use crate::common::input::handler::get_mode_info; @@ -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,7 +185,6 @@ 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, err_ctx) = os_input.recv_from_client(); @@ -202,12 +196,7 @@ pub fn route_thread_main( break; } ClientToServerMsg::Action(action) => { - route_action( - action, - rlocked_sessions.as_ref().unwrap(), - &*os_input, - capabilities, - ); + route_action(action, rlocked_sessions.as_ref().unwrap(), &*os_input); } ClientToServerMsg::TerminalResize(new_size) => { rlocked_sessions diff --git a/src/tests/integration/basic.rs b/src/tests/integration/basic.rs index 83cae2054..bb581eb14 100644 --- a/src/tests/integration/basic.rs +++ b/src/tests/integration/basic.rs @@ -1,7 +1,7 @@ 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::{ @@ -33,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 @@ -62,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 @@ -91,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 @@ -127,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 @@ -156,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 @@ -185,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 @@ -214,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 @@ -251,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 @@ -290,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 @@ -326,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 @@ -365,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 @@ -405,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 @@ -443,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 @@ -484,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 diff --git a/src/tests/integration/close_pane.rs b/src/tests/integration/close_pane.rs index c492591f5..cfb912ee3 100644 --- a/src/tests/integration/close_pane.rs +++ b/src/tests/integration/close_pane.rs @@ -6,7 +6,7 @@ use crate::tests::start; use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}; 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, @@ -46,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 @@ -90,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 @@ -131,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 @@ -173,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 @@ -220,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 @@ -265,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 @@ -312,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 @@ -357,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 @@ -424,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 @@ -487,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 @@ -552,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 @@ -617,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 @@ -655,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 diff --git a/src/tests/integration/compatibility.rs b/src/tests/integration/compatibility.rs index 40c2b9bf5..06222a3aa 100644 --- a/src/tests/integration/compatibility.rs +++ b/src/tests/integration/compatibility.rs @@ -8,7 +8,7 @@ use crate::tests::start; use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}; use crate::CliArgs; -use crate::common::input::{config::Config, options::Options}; +use crate::common::input::config::Config; use crate::tests::utils::commands::QUIT; /* @@ -49,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 @@ -79,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 @@ -114,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 @@ -153,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 @@ -189,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 @@ -224,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 @@ -254,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 @@ -284,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 @@ -314,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 @@ -352,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 @@ -385,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 @@ -415,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 @@ -445,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 @@ -477,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 @@ -509,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 @@ -539,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 @@ -571,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 @@ -601,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 @@ -631,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 @@ -667,7 +648,6 @@ pub fn exa_plus_omf_theme() { CliArgs::default(), Box::new(fake_input_output.clone()), Config::default(), - Options::default(), ); l |