diff options
| author | Thomas Linford <tlinford@users.noreply.github.com> | 2022-04-16 09:04:06 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-16 09:04:06 +0200 |
| commit | 198625b055af7d4dce103abceb256c60a7b4184a (patch) | |
| tree | cba9b017955160d82d78cc99bc481f20facd7964 /zellij-utils/src/input/options.rs | |
| parent | docs(changelog): SIGHUP change (diff) | |
| download | sl0ppij-198625b055af7d4dce103abceb256c60a7b4184a.tar.gz sl0ppij-198625b055af7d4dce103abceb256c60a7b4184a.tar.xz sl0ppij-198625b055af7d4dce103abceb256c60a7b4184a.zip | |
feat(copy): add copy_on_select option (#1298)
* feat(copy): add copy_on_select option
with default value of true, keep current behavior of automatically
copying selection to clipboard when done selecting.
with copy_on_select = false, on mouse release the selection remains, and
can be copied with the `Copy` action.
* add example to default.yaml
* add copy action example to default.yaml, cleanup
* fix updated tab tests
* fix selection changing while scrolling after release
* fix clippy warnings
Diffstat (limited to 'zellij-utils/src/input/options.rs')
| -rw-r--r-- | zellij-utils/src/input/options.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/zellij-utils/src/input/options.rs b/zellij-utils/src/input/options.rs index 34b4dc88..861e4877 100644 --- a/zellij-utils/src/input/options.rs +++ b/zellij-utils/src/input/options.rs @@ -84,9 +84,14 @@ pub struct Options { #[clap(long, arg_enum, ignore_case = true, conflicts_with = "copy-command")] #[serde(default)] pub copy_clipboard: Option<Clipboard>, + + /// Automatically copy when selecting text (true or false) + #[clap(long)] + #[serde(default)] + pub copy_on_select: Option<bool>, } -#[derive(ArgEnum, Deserialize, Serialize, Debug, Clone, PartialEq)] +#[derive(ArgEnum, Deserialize, Serialize, Debug, Clone, Copy, PartialEq)] pub enum Clipboard { #[serde(alias = "system")] System, @@ -124,7 +129,8 @@ impl Options { let on_force_close = other.on_force_close.or(self.on_force_close); let scroll_buffer_size = other.scroll_buffer_size.or(self.scroll_buffer_size); let copy_command = other.copy_command.or_else(|| self.copy_command.clone()); - let copy_clipboard = other.copy_clipboard.or_else(|| self.copy_clipboard.clone()); + let copy_clipboard = other.copy_clipboard.or(self.copy_clipboard); + let copy_on_select = other.copy_on_select.or(self.copy_on_select); Options { simplified_ui, @@ -139,6 +145,7 @@ impl Options { scroll_buffer_size, copy_command, copy_clipboard, + copy_on_select, } } @@ -169,7 +176,8 @@ impl Options { let on_force_close = other.on_force_close.or(self.on_force_close); let scroll_buffer_size = other.scroll_buffer_size.or(self.scroll_buffer_size); let copy_command = other.copy_command.or_else(|| self.copy_command.clone()); - let copy_clipboard = other.copy_clipboard.or_else(|| self.copy_clipboard.clone()); + let copy_clipboard = other.copy_clipboard.or(self.copy_clipboard); + let copy_on_select = other.copy_on_select.or(self.copy_on_select); Options { simplified_ui, @@ -184,6 +192,7 @@ impl Options { scroll_buffer_size, copy_command, copy_clipboard, + copy_on_select, } } @@ -234,6 +243,7 @@ impl From<CliOptions> for Options { scroll_buffer_size: opts.scroll_buffer_size, copy_command: opts.copy_command, copy_clipboard: opts.copy_clipboard, + copy_on_select: opts.copy_on_select, } } } |
