diff options
author | Aram Drevekenin <aram@poor.dev> | 2022-10-10 16:02:27 +0200 |
---|---|---|
committer | Aram Drevekenin <aram@poor.dev> | 2022-10-10 16:02:27 +0200 |
commit | 3e75510b09c77b59595f8b075625ad1965a95638 (patch) | |
tree | 157e6244f43a1bb6a124a914920979660692ff11 | |
parent | 82bca6dbb7e75864c7f4aa26b6570b723bb2392c (diff) |
bool floating flag
-rw-r--r-- | zellij-server/src/route.rs | 26 | ||||
-rw-r--r-- | zellij-utils/src/cli.rs | 18 | ||||
-rw-r--r-- | zellij-utils/src/input/actions.rs | 18 |
3 files changed, 30 insertions, 32 deletions
diff --git a/zellij-server/src/route.rs b/zellij-server/src/route.rs index 75230488d..eea7d8366 100644 --- a/zellij-server/src/route.rs +++ b/zellij-server/src/route.rs @@ -250,24 +250,20 @@ pub(crate) fn route_action( session.senders.send_to_pty(pty_instr).unwrap(); }, Action::EditFile(path_to_file, line_number, split_direction, should_float) => { - match should_float { - Some(true) => { - session - .senders - .send_to_screen(ScreenInstruction::ShowFloatingPanes(client_id)) - .unwrap(); - }, - Some(false) => { - session - .senders - .send_to_screen(ScreenInstruction::HideFloatingPanes(client_id)) - .unwrap(); - }, - None => {}, + if should_float { + session + .senders + .send_to_screen(ScreenInstruction::ShowFloatingPanes(client_id)) + .unwrap(); + } else { + session + .senders + .send_to_screen(ScreenInstruction::HideFloatingPanes(client_id)) + .unwrap(); }; let open_file = TerminalAction::OpenFile(path_to_file, line_number); - let pty_instr = match (split_direction, should_float.unwrap_or(false)) { + let pty_instr = match (split_direction, should_float) { (Some(Direction::Left), false) => { PtyInstruction::SpawnTerminalVertically(Some(open_file), client_id) }, diff --git a/zellij-utils/src/cli.rs b/zellij-utils/src/cli.rs index 24616bd17..cc7009cd7 100644 --- a/zellij-utils/src/cli.rs +++ b/zellij-utils/src/cli.rs @@ -124,7 +124,7 @@ pub enum Sessions { #[clap(visible_alias = "ac")] #[clap(subcommand)] Action(CliAction), - /// Send actions to a specific session + /// Send a command to a specific session #[clap(visible_alias = "c")] Command { command: Option<String>, @@ -132,8 +132,8 @@ pub enum Sessions { direction: Option<Direction>, #[clap(long, value_parser)] cwd: Option<PathBuf>, - #[clap(short, long, value_parser, default_missing_value("true"))] - floating: Option<bool>, + #[clap(short, long, value_parser, default_value("false"), takes_value(false))] + floating: bool, }, /// Edit file with default $EDITOR / $VISUAL in a specific session #[clap(visible_alias = "e")] @@ -143,8 +143,8 @@ pub enum Sessions { line_number: Option<usize>, #[clap(short, long, value_parser, conflicts_with("floating"))] direction: Option<Direction>, - #[clap(short, long, value_parser, default_missing_value("true"))] - floating: Option<bool>, + #[clap(short, long, value_parser, default_value("false"), takes_value(false))] + floating: bool, }, ConvertConfig { old_config_file: PathBuf, @@ -210,8 +210,8 @@ pub enum CliAction { command: Option<String>, #[clap(long, value_parser)] cwd: Option<PathBuf>, - #[clap(short, long, value_parser, default_missing_value("true"))] - floating: Option<bool>, + #[clap(short, long, value_parser, default_value("false"), takes_value(false))] + floating: bool, }, /// Open the specified file in a new zellij pane with your default EDITOR Edit { @@ -220,8 +220,8 @@ pub enum CliAction { direction: Option<Direction>, #[clap(short, long, value_parser)] line_number: Option<usize>, - #[clap(short, long, value_parser, default_missing_value("true"))] - floating: Option<bool>, + #[clap(short, long, value_parser, default_value("false"), takes_value(false))] + floating: bool, }, /// Switch input mode of all connected clients [locked|pane|tab|resize|move|search|session] SwitchMode { input_mode: InputMode }, diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs index d9fd9514e..36ad19de4 100644 --- a/zellij-utils/src/input/actions.rs +++ b/zellij-utils/src/input/actions.rs @@ -200,7 +200,7 @@ pub enum Action { /// If no direction is specified, will try to use the biggest available space. NewPane(Option<Direction>), /// Open the file in a new pane using the default editor - EditFile(PathBuf, Option<usize>, Option<Direction>, Option<bool>), // usize is an optional line number, bool is floating true/false + EditFile(PathBuf, Option<usize>, Option<Direction>, bool), // usize is an optional line number, bool is floating true/false /// Open a new floating pane NewFloatingPane(Option<RunCommandAction>), /// Open a new tiled (embedded, non-floating) pane @@ -296,17 +296,19 @@ impl Action { direction, hold_on_close: true, }; - match floating { - Some(true) => Ok(vec![Action::NewFloatingPane(Some(run_command_action))]), - _ => Ok(vec![Action::NewTiledPane( + if floating { + Ok(vec![Action::NewFloatingPane(Some(run_command_action))]) + } else { + Ok(vec![Action::NewTiledPane( direction, Some(run_command_action), - )]), + )]) } }, - None => match floating { - Some(true) => Ok(vec![Action::NewFloatingPane(None)]), - _ => Ok(vec![Action::NewTiledPane(direction, None)]), + None => if floating { + Ok(vec![Action::NewFloatingPane(None)]) + } else { + Ok(vec![Action::NewTiledPane(direction, None)]) }, }, CliAction::Edit { |