diff options
author | Christophe Verbinnen <christophe@verbinnen.org> | 2022-01-15 06:38:45 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-15 12:38:45 +0100 |
commit | 9cc2645db024df0a95efda42aed34bd3def19b28 (patch) | |
tree | d2345ca39dba0d5a2bf2cd7527799859147d6d69 /default-plugins | |
parent | 6af419528f019ad603bedb8d0f564a569ba3e77a (diff) |
Add a copy command option (#996)
Usage: zellij options --copy-command "xclip -sel clip"
Co-authored-by: Christophe Verbinnen <christophev@knowbe4.com>
Diffstat (limited to 'default-plugins')
-rw-r--r-- | default-plugins/status-bar/src/main.rs | 19 | ||||
-rw-r--r-- | default-plugins/status-bar/src/second_line.rs | 12 |
2 files changed, 30 insertions, 1 deletions
diff --git a/default-plugins/status-bar/src/main.rs b/default-plugins/status-bar/src/main.rs index bc322e6a8..1a26ca14f 100644 --- a/default-plugins/status-bar/src/main.rs +++ b/default-plugins/status-bar/src/main.rs @@ -10,7 +10,8 @@ use zellij_tile_utils::style; use first_line::{ctrl_keys, superkey}; use second_line::{ - fullscreen_panes_to_hide, keybinds, locked_fullscreen_panes_to_hide, text_copied_hint, + fullscreen_panes_to_hide, keybinds, locked_fullscreen_panes_to_hide, system_clipboard_error, + text_copied_hint, }; use tip::utils::get_cached_tip_name; @@ -24,6 +25,7 @@ struct State { tip_name: String, mode_info: ModeInfo, diplay_text_copied_hint: bool, + display_system_clipboard_failure: bool, } register_plugin!(State); @@ -142,6 +144,7 @@ impl ZellijPlugin for State { EventType::TabUpdate, EventType::CopyToClipboard, EventType::InputReceived, + EventType::SystemClipboardFailure, ]); } @@ -156,8 +159,12 @@ impl ZellijPlugin for State { Event::CopyToClipboard => { self.diplay_text_copied_hint = true; } + Event::SystemClipboardFailure => { + self.display_system_clipboard_failure = true; + } Event::InputReceived => { self.diplay_text_copied_hint = false; + self.display_system_clipboard_failure = false; } _ => {} } @@ -188,12 +195,16 @@ impl ZellijPlugin for State { if t.is_fullscreen_active { second_line = if self.diplay_text_copied_hint { text_copied_hint(&self.mode_info.palette) + } else if self.display_system_clipboard_failure { + system_clipboard_error(&self.mode_info.palette) } else { fullscreen_panes_to_hide(&self.mode_info.palette, t.panes_to_hide) } } else { second_line = if self.diplay_text_copied_hint { text_copied_hint(&self.mode_info.palette) + } else if self.display_system_clipboard_failure { + system_clipboard_error(&self.mode_info.palette) } else { keybinds(&self.mode_info, &self.tip_name, cols) } @@ -203,6 +214,8 @@ impl ZellijPlugin for State { if t.is_fullscreen_active { second_line = if self.diplay_text_copied_hint { text_copied_hint(&self.mode_info.palette) + } else if self.display_system_clipboard_failure { + system_clipboard_error(&self.mode_info.palette) } else { locked_fullscreen_panes_to_hide( &self.mode_info.palette, @@ -212,6 +225,8 @@ impl ZellijPlugin for State { } else { second_line = if self.diplay_text_copied_hint { text_copied_hint(&self.mode_info.palette) + } else if self.display_system_clipboard_failure { + system_clipboard_error(&self.mode_info.palette) } else { keybinds(&self.mode_info, &self.tip_name, cols) } @@ -220,6 +235,8 @@ impl ZellijPlugin for State { _ => { second_line = if self.diplay_text_copied_hint { text_copied_hint(&self.mode_info.palette) + } else if self.display_system_clipboard_failure { + system_clipboard_error(&self.mode_info.palette) } else { keybinds(&self.mode_info, &self.tip_name, cols) } diff --git a/default-plugins/status-bar/src/second_line.rs b/default-plugins/status-bar/src/second_line.rs index 6f3c6461f..32a444255 100644 --- a/default-plugins/status-bar/src/second_line.rs +++ b/default-plugins/status-bar/src/second_line.rs @@ -241,6 +241,18 @@ pub fn text_copied_hint(palette: &Palette) -> LinePart { } } +pub fn system_clipboard_error(palette: &Palette) -> LinePart { + let hint = " Error using the system clipboard."; + let red_color = match palette.red { + PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), + PaletteColor::EightBit(color) => Fixed(color), + }; + LinePart { + part: Style::new().fg(red_color).bold().paint(hint).to_string(), + len: hint.len(), + } +} + pub fn fullscreen_panes_to_hide(palette: &Palette, panes_to_hide: usize) -> LinePart { let white_color = match palette.white { PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), |