diff --git a/zellij-client/src/input_handler.rs b/zellij-client/src/input_handler.rs index 0f8a60ff2..3c2495c02 100644 --- a/zellij-client/src/input_handler.rs +++ b/zellij-client/src/input_handler.rs @@ -63,7 +63,7 @@ impl InputHandler { let mut err_ctx = OPENCALLS.with(|ctx| *ctx.borrow()); err_ctx.add_call(ContextType::StdinHandler); let alt_left_bracket = vec![27, 91]; - if !self.options.disable_mouse_mode.unwrap_or_default() { + if self.options.mouse_mode.unwrap_or(true) { self.os_input.enable_mouse(); } loop { diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs index 2fa964271..d3af961ae 100644 --- a/zellij-server/src/screen.rs +++ b/zellij-server/src/screen.rs @@ -560,7 +560,7 @@ pub(crate) fn screen_thread_main( config_options: Box, ) { let capabilities = config_options.simplified_ui; - let draw_pane_frames = !config_options.no_pane_frames.unwrap_or_default(); + let draw_pane_frames = config_options.pane_frames.unwrap_or(true); let mut screen = Screen::new( bus, diff --git a/zellij-utils/src/input/options.rs b/zellij-utils/src/input/options.rs index c23267fb6..55036069d 100644 --- a/zellij-utils/src/input/options.rs +++ b/zellij-utils/src/input/options.rs @@ -39,7 +39,7 @@ impl FromStr for OnForceClose { /// into Options and CliOptions, this could be a good canditate for a macro pub struct Options { /// Allow plugins to use a more simplified layout - /// that is compatible with more fonts + /// that is compatible with more fonts (true or false) #[structopt(long)] #[serde(default)] pub simplified_ui: Option, @@ -58,11 +58,13 @@ pub struct Options { pub layout_dir: Option, #[structopt(long)] #[serde(default)] - /// Disable handling of mouse events - pub disable_mouse_mode: Option, + /// Set the handling of mouse events (true or false) + /// Can be temporarily bypassed by the [SHIFT] key + pub mouse_mode: Option, #[structopt(long)] #[serde(default)] - pub no_pane_frames: Option, + /// Set display of the pane frames (true or false) + pub pane_frames: Option, /// Set behaviour on force close (quit or detach) #[structopt(long)] pub on_force_close: Option, @@ -81,8 +83,8 @@ impl Options { /// will supercede a `Some` in `self` // TODO: Maybe a good candidate for a macro? pub fn merge(&self, other: Options) -> Options { - let disable_mouse_mode = other.disable_mouse_mode.or(self.disable_mouse_mode); - let no_pane_frames = other.no_pane_frames.or(self.no_pane_frames); + let mouse_mode = other.mouse_mode.or(self.mouse_mode); + let pane_frames = other.pane_frames.or(self.pane_frames); let simplified_ui = other.simplified_ui.or(self.simplified_ui); let default_mode = other.default_mode.or(self.default_mode); let default_shell = other.default_shell.or_else(|| self.default_shell.clone()); @@ -96,8 +98,8 @@ impl Options { default_mode, default_shell, layout_dir, - disable_mouse_mode, - no_pane_frames, + mouse_mode, + pane_frames, on_force_close, } } @@ -118,8 +120,8 @@ impl Options { }; let simplified_ui = merge_bool(other.simplified_ui, self.simplified_ui); - let disable_mouse_mode = merge_bool(other.disable_mouse_mode, self.disable_mouse_mode); - let no_pane_frames = merge_bool(other.no_pane_frames, self.no_pane_frames); + let mouse_mode = merge_bool(other.mouse_mode, self.mouse_mode); + let pane_frames = merge_bool(other.pane_frames, self.pane_frames); let default_mode = other.default_mode.or(self.default_mode); let default_shell = other.default_shell.or_else(|| self.default_shell.clone()); @@ -133,8 +135,8 @@ impl Options { default_mode, default_shell, layout_dir, - disable_mouse_mode, - no_pane_frames, + mouse_mode, + pane_frames, on_force_close, } } @@ -152,52 +154,36 @@ impl Options { /// Options that can be set through cli flags /// boolean flags end up toggling boolean options in `Options` pub struct CliOptions { - /// Allow plugins to use a more simplified layout - /// that is compatible with more fonts - #[structopt(long)] - pub simplified_ui: bool, - /// Set the default theme - #[structopt(long)] - pub theme: Option, - /// Set the default mode - #[structopt(long)] - pub default_mode: Option, - /// Set the default shell - #[structopt(long, parse(from_os_str))] - pub default_shell: Option, - /// Set the layout_dir, defaults to - /// subdirectory of config dir - #[structopt(long, parse(from_os_str))] - pub layout_dir: Option, - #[structopt(long)] /// Disable handling of mouse events + #[structopt(long, conflicts_with("mouse-mode"))] pub disable_mouse_mode: bool, - #[structopt(long)] + /// Disable display of pane frames + #[structopt(long, conflicts_with("pane-frames"))] pub no_pane_frames: bool, - /// Set behaviour on force close (quit or detach) - #[structopt(long)] - pub on_force_close: Option, + #[structopt(flatten)] + options: Options, } impl From for Options { fn from(cli_options: CliOptions) -> Self { - let handle_bool = |bool| { - if bool { - Some(true) - } else { - None - } - }; + let mut opts = cli_options.options; + + if cli_options.no_pane_frames { + opts.pane_frames = Some(false); + } + if cli_options.disable_mouse_mode { + opts.mouse_mode = Some(false); + } Self { - simplified_ui: handle_bool(cli_options.simplified_ui), - theme: cli_options.theme, - default_mode: cli_options.default_mode, - default_shell: cli_options.default_shell, - layout_dir: cli_options.layout_dir, - disable_mouse_mode: handle_bool(cli_options.disable_mouse_mode), - no_pane_frames: handle_bool(cli_options.no_pane_frames), - on_force_close: cli_options.on_force_close, + simplified_ui: opts.simplified_ui, + theme: opts.theme, + default_mode: opts.default_mode, + default_shell: opts.default_shell, + layout_dir: opts.layout_dir, + mouse_mode: opts.mouse_mode, + pane_frames: opts.pane_frames, + on_force_close: opts.on_force_close, } } } diff --git a/zellij-utils/src/setup.rs b/zellij-utils/src/setup.rs index 1ca596ffc..fcd90d1c3 100644 --- a/zellij-utils/src/setup.rs +++ b/zellij-utils/src/setup.rs @@ -270,7 +270,7 @@ impl Setup { // https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda let hyperlink_start = "\u{1b}]8;;"; let hyperlink_mid = "\u{1b}\\"; - let hyperlink_end = "\u{1b}]8;;\u{1b}\\\n'"; + let hyperlink_end = "\u{1b}]8;;\u{1b}\\"; let mut message = String::new(); @@ -315,7 +315,7 @@ impl Setup { message.push_str(&format!("[ARROW SEPARATOR]: {}\n", ARROW_SEPARATOR)); message.push_str(" Is the [ARROW_SEPARATOR] displayed correctly?\n"); - message.push_str(" If not you may want to either start zellij with a compatible mode 'zellij options --simplified-ui'\n"); + message.push_str(" If not you may want to either start zellij with a compatible mode: 'zellij options --simplified-ui true'\n"); let mut hyperlink_compat = String::new(); hyperlink_compat.push_str(hyperlink_start); hyperlink_compat.push_str("https://zellij.dev/documentation/compatibility.html#the-status-bar-fonts-dont-render-correctly"); @@ -326,6 +326,9 @@ impl Setup { " Or check the font that is in use:\n {}\n", hyperlink_compat )); + message.push_str("[MOUSE INTERACTION]: \n"); + message.push_str(" Can be temporarily disabled through pressing the [SHIFT] key.\n"); + message.push_str(" If that doesn't fix any issues consider to disable the mouse handling of zellij: 'zellij options --disable-mouse-mode'\n"); message.push_str(&format!("[FEATURES]: {:?}\n", FEATURES)); let mut hyperlink = String::new(); @@ -334,7 +337,7 @@ impl Setup { hyperlink.push_str(hyperlink_mid); hyperlink.push_str("zellij.dev/documentation"); hyperlink.push_str(hyperlink_end); - message.push_str(&format!("[DOCUMENTATION]: {}", hyperlink)); + message.push_str(&format!("[DOCUMENTATION]: {}\n", hyperlink)); //printf '\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n' std::io::stdout().write_all(message.as_bytes())?;