diff options
| author | Kunal Mohan <kunalmohan99@gmail.com> | 2021-04-29 15:25:55 +0530 |
|---|---|---|
| committer | Kunal Mohan <kunalmohan99@gmail.com> | 2021-05-04 20:48:16 +0530 |
| commit | 9110e444b8ef2f96a0386b7c5e65283a2b5456c0 (patch) | |
| tree | 8ee2bd3e08f0b8a3594a9de6ac942056042e315d /src | |
| parent | Refactor CommandIsExecuting to have a single variant (diff) | |
| download | sl0ppij-9110e444b8ef2f96a0386b7c5e65283a2b5456c0.tar.gz sl0ppij-9110e444b8ef2f96a0386b7c5e65283a2b5456c0.tar.xz sl0ppij-9110e444b8ef2f96a0386b7c5e65283a2b5456c0.zip | |
remove Split, OpenFile and MoveFocus from CliArgs
Diffstat (limited to 'src')
| -rw-r--r-- | src/cli.rs | 12 | ||||
| -rw-r--r-- | src/common/errors.rs | 8 | ||||
| -rw-r--r-- | src/common/input/handler.rs | 2 | ||||
| -rw-r--r-- | src/main.rs | 43 | ||||
| -rw-r--r-- | src/server/mod.rs | 40 |
5 files changed, 7 insertions, 98 deletions
@@ -5,18 +5,6 @@ use structopt::StructOpt; #[derive(StructOpt, Default, Debug, Clone)] #[structopt(name = "zellij")] pub struct CliArgs { - /// Send "split (direction h == horizontal / v == vertical)" to active zellij session - #[structopt(short, long)] - pub split: Option<char>, - - /// Send "move focused pane" to active zellij session - #[structopt(short, long)] - pub move_focus: bool, - - /// Send "open file in new pane" to active zellij session - #[structopt(short, long)] - pub open_file: Option<PathBuf>, - /// Maximum panes on screen, caution: opening more panes will close old ones #[structopt(long)] pub max_panes: Option<usize>, diff --git a/src/common/errors.rs b/src/common/errors.rs index 0b91a09d..411e0225 100644 --- a/src/common/errors.rs +++ b/src/common/errors.rs @@ -341,10 +341,6 @@ impl From<&ClientInstruction> for ClientContext { /// Stack call representations corresponding to the different types of [`ServerInstruction`]s. #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] pub enum ServerContext { - OpenFile, - SplitHorizontally, - SplitVertically, - MoveFocus, NewClient, Action, Render, @@ -356,10 +352,6 @@ pub enum ServerContext { impl From<&ServerInstruction> for ServerContext { fn from(server_instruction: &ServerInstruction) -> Self { match *server_instruction { - ServerInstruction::OpenFile(_) => ServerContext::OpenFile, - ServerInstruction::SplitHorizontally => ServerContext::SplitHorizontally, - ServerInstruction::SplitVertically => ServerContext::SplitVertically, - ServerInstruction::MoveFocus => ServerContext::MoveFocus, ServerInstruction::NewClient(..) => ServerContext::NewClient, ServerInstruction::Action(_) => ServerContext::Action, ServerInstruction::TerminalResize(_) => ServerContext::TerminalResize, diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs index 64e4fbe3..7a4a4e52 100644 --- a/src/common/input/handler.rs +++ b/src/common/input/handler.rs @@ -112,7 +112,7 @@ impl InputHandler { Action::SwitchToMode(mode) => { self.mode = mode; self.os_input - .send_to_server(ServerInstruction::Action(action.clone())); + .send_to_server(ServerInstruction::Action(action)); } Action::CloseFocus | Action::NewPane(_) diff --git a/src/main.rs b/src/main.rs index e8aa39f7..e6edfdfd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,7 @@ mod server; use client::{boundaries, layout, panes, start_client, tab}; use common::{command_is_executing, errors, os_input_output, pty_bus, screen, utils, wasm_vm}; use directories_next::ProjectDirs; -use server::{start_server, ServerInstruction}; +use server::start_server; use structopt::StructOpt; @@ -50,42 +50,11 @@ 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(split_dir) = opts.split { - match split_dir { - 'h' => { - let os_input = get_client_os_input(); - os_input.connect_to_server(); - os_input.send_to_server(ServerInstruction::SplitHorizontally); - } - 'v' => { - let os_input = get_client_os_input(); - os_input.connect_to_server(); - os_input.send_to_server(ServerInstruction::SplitVertically); - } - _ => {} - }; - } else if opts.move_focus { - let os_input = get_client_os_input(); - os_input.connect_to_server(); - os_input.send_to_server(ServerInstruction::MoveFocus); - } else if let Some(file_to_open) = opts.open_file { - let os_input = get_client_os_input(); - os_input.connect_to_server(); - os_input.send_to_server(ServerInstruction::OpenFile(file_to_open)); - } else { - 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)); - } + 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)); } /// Start Zellij with the specified [`ClientOsApi`], [`ServerOsApi`] and command-line arguments. diff --git a/src/server/mod.rs b/src/server/mod.rs index 904093f0..ca34861b 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -35,10 +35,6 @@ use crate::utils::consts::ZELLIJ_IPC_PIPE; /// ones sent by client to server #[derive(Serialize, Deserialize, Debug, Clone)] pub enum ServerInstruction { - OpenFile(PathBuf), - SplitHorizontally, - SplitVertically, - MoveFocus, TerminalResize(PositionAndSize), NewClient(PositionAndSize), Action(Action), @@ -164,42 +160,6 @@ fn handle_client( send_server_instructions.send(instruction).unwrap(); break; } - ServerInstruction::OpenFile(file_name) => { - rlocked_sessions - .as_ref() - .unwrap() - .send_pty_instructions - .send(PtyInstruction::SpawnTerminal(Some(file_name))) - .unwrap(); - break; - } - ServerInstruction::SplitHorizontally => { - rlocked_sessions - .as_ref() - .unwrap() - .send_pty_instructions - .send(PtyInstruction::SpawnTerminalHorizontally(None)) - .unwrap(); - break; - } - ServerInstruction::SplitVertically => { - rlocked_sessions - .as_ref() - .unwrap() - .send_pty_instructions - .send(PtyInstruction::SpawnTerminalVertically(None)) - .unwrap(); - break; - } - ServerInstruction::MoveFocus => { - rlocked_sessions - .as_ref() - .unwrap() - .send_screen_instructions - .send(ScreenInstruction::FocusNextPane) - .unwrap(); - break; - } ServerInstruction::Action(action) => { route_action(action, rlocked_sessions.as_ref().unwrap()); } |
