diff --git a/config/src/keyassignment.rs b/config/src/keyassignment.rs index b2dc644d9..9be715716 100644 --- a/config/src/keyassignment.rs +++ b/config/src/keyassignment.rs @@ -189,8 +189,8 @@ pub enum KeyAssignment { SelectTextAtMouseCursor(SelectionMode), ExtendSelectionToMouseCursor(Option), OpenLinkAtMouseCursor, - CompleteSelection, - CompleteSelectionOrOpenLinkAtMouseCursor, + CompleteSelection(ClipboardCopyDestination), + CompleteSelectionOrOpenLinkAtMouseCursor(ClipboardCopyDestination), AdjustPaneSize(PaneDirection, usize), ActivatePaneDirection(PaneDirection), @@ -243,12 +243,36 @@ impl InputMap { // a given entry then that will take precedence. k!( // Clipboard - [Modifiers::SHIFT, KeyCode::Insert, Paste], - [Modifiers::CTRL, KeyCode::Insert, Copy], - [Modifiers::SUPER, KeyCode::Char('c'), Copy], - [Modifiers::SUPER, KeyCode::Char('v'), Paste], - [Modifiers::CTRL, KeyCode::Char('C'), Copy], - [Modifiers::CTRL, KeyCode::Char('V'), Paste], + [ + Modifiers::SHIFT, + KeyCode::Insert, + PasteFrom(ClipboardPasteSource::PrimarySelection) + ], + [ + Modifiers::CTRL, + KeyCode::Insert, + CopyTo(ClipboardCopyDestination::PrimarySelection) + ], + [ + Modifiers::SUPER, + KeyCode::Char('c'), + CopyTo(ClipboardCopyDestination::Clipboard) + ], + [ + Modifiers::SUPER, + KeyCode::Char('v'), + PasteFrom(ClipboardPasteSource::Clipboard) + ], + [ + Modifiers::CTRL, + KeyCode::Char('C'), + CopyTo(ClipboardCopyDestination::Clipboard) + ], + [ + Modifiers::CTRL, + KeyCode::Char('V'), + PasteFrom(ClipboardPasteSource::Clipboard) + ], // Window management [Modifiers::ALT, KeyCode::Char('\n'), ToggleFullScreen], [Modifiers::ALT, KeyCode::Char('\r'), ToggleFullScreen], @@ -458,7 +482,9 @@ impl InputMap { streak: 1, button: MouseButton::Left }, - CompleteSelectionOrOpenLinkAtMouseCursor + CompleteSelectionOrOpenLinkAtMouseCursor( + ClipboardCopyDestination::PrimarySelection + ) ], [ Modifiers::NONE, @@ -466,7 +492,7 @@ impl InputMap { streak: 2, button: MouseButton::Left }, - CompleteSelection + CompleteSelection(ClipboardCopyDestination::PrimarySelection) ], [ Modifiers::NONE, @@ -474,7 +500,7 @@ impl InputMap { streak: 3, button: MouseButton::Left }, - CompleteSelection + CompleteSelection(ClipboardCopyDestination::PrimarySelection) ], [ Modifiers::NONE, @@ -506,7 +532,7 @@ impl InputMap { streak: 1, button: MouseButton::Middle }, - Paste + PasteFrom(ClipboardPasteSource::PrimarySelection) ], ); } diff --git a/config/src/lib.rs b/config/src/lib.rs index b27911562..41e54d17f 100644 --- a/config/src/lib.rs +++ b/config/src/lib.rs @@ -1,8 +1,6 @@ //! Configuration for the gui portion of the terminal -use crate::keyassignment::{ - ClipboardCopyDestination, ClipboardPasteSource, KeyAssignment, MouseEventTrigger, SpawnCommand, -}; +use crate::keyassignment::{KeyAssignment, MouseEventTrigger, SpawnCommand}; use anyhow::{anyhow, bail, Context, Error}; use lazy_static::lazy_static; use luahelper::impl_lua_conversion; @@ -856,12 +854,6 @@ pub struct Config { #[serde(default = "default_true")] pub adjust_window_size_when_changing_font_size: bool, - #[serde(default = "default_copy_destination")] - pub default_clipboard_copy_destination: ClipboardCopyDestination, - - #[serde(default = "default_paste_source")] - pub default_clipboard_paste_source: ClipboardPasteSource, - #[serde(default = "default_alternate_buffer_wheel_scroll_speed")] pub alternate_buffer_wheel_scroll_speed: u8, } @@ -1281,18 +1273,6 @@ impl Config { } } -fn default_copy_destination() -> ClipboardCopyDestination { - if cfg!(any(target_os = "macos", windows)) { - ClipboardCopyDestination::Clipboard - } else { - ClipboardCopyDestination::ClipboardAndPrimarySelection - } -} - -fn default_paste_source() -> ClipboardPasteSource { - ClipboardPasteSource::Clipboard -} - fn default_ratelimit_line_prefetches_per_second() -> u32 { 10 } diff --git a/docs/changelog.md b/docs/changelog.md index c01cac160..5c6fa5b4e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -49,8 +49,10 @@ brief notes about them may accumulate here. * Windows: when pasting text, ensure that the text has CRLF line endings unless bracketed paste is enabled. This imperfect heuristic helps to keep multi-line pastes on multiple lines when using Windows console applications and to avoid interleaved blank lines when using unix applications. [#411](https://github.com/wez/wezterm/issues/411) * New: [ClearScrollback](config/lua/keyassignment/ClearScrollback.html) now accepts a parameter to control whether the viewport is cleared along with the scrollback. Thanks to [@dfrankland](https://github.com/dfrankland)! * New: [default_cwd](config/lua/config/default_cwd.html) to specify an alternative current working directory. Thanks to [@dfrankland](https://github.com/dfrankland)! -* New: [default_clipboard_copy_destination](config/lua/config/default_clipboard_copy_destination.md) and [default_clipboard_paste_source](config/lua/config/default_clipboard_paste_source.md) config options for X11, along with [CopyTo](config/lua/keyassignment/CopyTo.md) and [PasteFrom](config/lua/keyassignment/PasteFrom.md) actions. [PastePrimarySelection](config/lua/keyassignment/PastePrimarySelection.md) is now deprecated in favor of these new options. -* New: Added a new default `CTRL-Insert` key assignment bound to `Copy` +* New: [CopyTo](config/lua/keyassignment/CopyTo.md) and [PasteFrom](config/lua/keyassignment/PasteFrom.md) actions. [Copy](config/lua/keyassignment/Copy.md), [Paste](config/lua/keyassignment/Paste.md) and [PastePrimarySelection](config/lua/keyassignment/PastePrimarySelection.md) are now deprecated in favor of these new options. +* X11: Mouse-based selection now copies-to and pastes-from the `PrimarySelection` by default. The [CompleteSelection](config/lua/keyassignment/CompleteSelection.md) and [CompleteSelectionOrOpenLinkAtMouseCursor](config/lua/keyassignment/CompleteSelectionOrOpenLinkAtMouseCursor.md) actions now require a parameter to specify the clipboard. +* X11: `SHIFT-CTRL-C` and `SHIFT-CTRL-V` now copy-to and paste from the `Clipboard` by default. `SHIFT-Insert` pastes from the `PrimarySelection` by default. +* New: Added a new default `CTRL-Insert` key assignment bound to `CopyTo(PrimarySelection)` * macOS: Windows now have drop-shadows when they are opaque. These were disabled due transparency support was added. Thanks to [Rice](https://github.com/fanzeyi)! [#445](https://github.com/wez/wezterm/pull/445) * Unix: adjust font-config patterns to also match "dual spacing" fonts such as [Iosevka Term](https://typeof.net/Iosevka/). Thanks to [Leiser](https://github.com/leiserfg)! [#446](https://github.com/wez/wezterm/pull/446) * New: Added [alternate_buffer_wheel_scroll_speed](config/lua/config/alternate_buffer_wheel_scroll_speed.md) option to control how many cursor key presses are generated by the mouse wheel when the alternate screen is active. The new default for this is a faster-than-previous-releases 3 lines per wheel tick. [#432](https://github.com/wez/wezterm/issues/432) diff --git a/docs/config/keys.md b/docs/config/keys.md index e410301eb..ea379b5d0 100644 --- a/docs/config/keys.md +++ b/docs/config/keys.md @@ -104,12 +104,12 @@ The default key bindings are: | Modifiers | Key | Action | | --------- | --- | ------ | -| `SUPER` | `c` | `Copy` | -| `SUPER` | `v` | `Paste` | -| `CTRL+SHIFT` | `c` | `Copy` | -| `CTRL+SHIFT` | `v` | `Paste` | -| `CTRL` | `Insert` | `Copy` (*since: nightly builds*) | -| `SHIFT` | `Insert` | `Paste` | +| `SUPER` | `c` | `CopyTo="Clipboard"` | +| `SUPER` | `v` | `PasteFrom="Clipboard"` | +| `CTRL+SHIFT` | `c` | `CopyTo="Clipboard"` | +| `CTRL+SHIFT` | `v` | `PasteFrom="Clipboard"` | +| `CTRL` | `Insert` | `CopyTo="PrimarySelection"` (*since: nightly builds*) | +| `SHIFT` | `Insert` | `PasteFrom="PrimarySelection"` | | `SUPER` | `m` | `Hide` | | `SUPER` | `n` | `SpawnWindow` | | `CTRL+SHIFT` | `n` | `SpawnWindow` | @@ -195,13 +195,13 @@ that order. | Double Left Down | `NONE` | `SelectTextAtMouseCursor="Word"` | | Single Left Down | `NONE` | `SelectTextAtMouseCursor="Cell"` | | Single Left Down | `SHIFT` | `ExtendSelectionToMouseCursor={}` | -| Single Left Up | `NONE` | `CompleteSelectionOrOpenLinkAtMouseCursor` | -| Double Left Up | `NONE` | `CompleteSelection` | -| Triple Left Up | `NONE` | `CompleteSelection` | +| Single Left Up | `NONE` | `CompleteSelectionOrOpenLinkAtMouseCursor="PrimarySelection"` | +| Double Left Up | `NONE` | `CompleteSelection="PrimarySelection"` | +| Triple Left Up | `NONE` | `CompleteSelection="PrimarySelection"` | | Single Left Drag | `NONE` | `ExtendSelectionToMouseCursor="Cell"` | | Double Left Drag | `NONE` | `ExtendSelectionToMouseCursor="Word"` | | Triple Left Drag | `NONE` | `ExtendSelectionToMouseCursor="Line"` | -| Single Middle Down | `NONE` | `Paste` | +| Single Middle Down | `NONE` | `PasteFrom="PrimarySelection"` | If you don't want the default assignments to be registered, you can disable all of them with this configuration; if you chose to do this, @@ -236,7 +236,7 @@ return { { event={Up={streak=1, button="Left"}}, mods="NONE", - action="CompleteSelection", + action=wezterm.action{CompleteSelection="PrimarySelection"}, }, -- and make CTRL-Click open hyperlinks diff --git a/docs/config/lua/config/default_clipboard_copy_destination.md b/docs/config/lua/config/default_clipboard_copy_destination.md deleted file mode 100644 index 9894a38c7..000000000 --- a/docs/config/lua/config/default_clipboard_copy_destination.md +++ /dev/null @@ -1,16 +0,0 @@ -# `default_clipboard_copy_destination` - -*Since: nightly builds only* - -Specifies which clipboard buffer should be populated by the [Copy](../keyassignment/Copy.md), [CompleteSelection](../keyassignment/CompleteSelection.md) and [CompleteSelectionOrOpenLinkAtMouseCursor](../keyassignment/CompleteSelectionOrOpenLinkAtMouseCursor.md) actions. - -Possible values are: - -* `Clipboard` - copy the text to the system clipboard. -* `PrimarySelection` - Copy the test to the primary selection buffer (applicable to X11 systems only) -* `ClipboardAndPrimarySelection` - Copy to both the clipboard and the primary selection. - -The default value is `ClipboardAndPrimarySelection`. - -Prior to the introduction of this option, the behavior was not configurable, -but had the same behavior as the default. diff --git a/docs/config/lua/config/default_clipboard_paste_source.md b/docs/config/lua/config/default_clipboard_paste_source.md deleted file mode 100644 index 346736aeb..000000000 --- a/docs/config/lua/config/default_clipboard_paste_source.md +++ /dev/null @@ -1,16 +0,0 @@ -# `default_clipboard_paste_source` - -*Since: nightly builds only* - -Specifies which clipboard buffer should be read by the -[Paste](../keyassignment/Paste.md) action. - -Possible values are: - -* `Clipboard` - paste from the system clipboard -* `PrimarySelection` - paste from the primary selection buffer (applicable to X11 systems only) - -The default value is `Clipboard`. - -Prior to the introduction of this option, the behavior was not configurable, -but had the same behavior as the default. diff --git a/docs/config/lua/keyassignment/CompleteSelection.md b/docs/config/lua/keyassignment/CompleteSelection.md index 5c000402a..19b0e5083 100644 --- a/docs/config/lua/keyassignment/CompleteSelection.md +++ b/docs/config/lua/keyassignment/CompleteSelection.md @@ -4,4 +4,27 @@ Completes an active text selection process; the selection range is marked closed and then the selected text is copied as though the `Copy` action was executed. +*since: nightly* +`CompleteSelection` now requires a destination parameter to specify +which clipboard buffer the selection will populate; the copy action +is now equivalent to [CopyTo](CopyTo.md). + +```lua +local wezterm = require 'wezterm'; + +return { + mouse_bindings = { + -- Change the default click behavior so that it only selects + -- text and doesn't open hyperlinks, and that it populates + -- the Clipboard rather the PrimarySelection which is part + -- of the default assignment for a left mouse click. + { + event={Up={streak=1, button="Left"}}, + mods="NONE", + action=wezterm.action{CompleteSelection="Clipboard"}, + }, + }, +} + +``` diff --git a/docs/config/lua/keyassignment/CompleteSelectionOrOpenLinkAtMouseCursor.md b/docs/config/lua/keyassignment/CompleteSelectionOrOpenLinkAtMouseCursor.md index aaccc8109..82e2d7feb 100644 --- a/docs/config/lua/keyassignment/CompleteSelectionOrOpenLinkAtMouseCursor.md +++ b/docs/config/lua/keyassignment/CompleteSelectionOrOpenLinkAtMouseCursor.md @@ -5,3 +5,25 @@ triggered. Otherwise acts as though `OpenLinkAtMouseCursor` was triggered. +*since: nightly* + +`CompleteSelectionOrOpenLinkAtMouseCursor` now requires a destination parameter to specify +which clipboard buffer the selection will populate. The copy action +is now equivalent to [CopyTo](CopyTo.md). + +```lua +local wezterm = require 'wezterm'; + +return { + mouse_bindings = { + -- Change the default click behavior so that it populates + -- the Clipboard rather the PrimarySelection. + { + event={Up={streak=1, button="Left"}}, + mods="NONE", + action=wezterm.action{CompleteSelectionOrOpenLinkAtMouseCursor="Clipboard"}, + }, + }, +} + +``` diff --git a/docs/config/lua/keyassignment/Copy.md b/docs/config/lua/keyassignment/Copy.md index d71d70938..13a70a227 100644 --- a/docs/config/lua/keyassignment/Copy.md +++ b/docs/config/lua/keyassignment/Copy.md @@ -2,7 +2,12 @@ Copy the selection to the clipboard. -The value of the [default_clipboard_copy_destination](../config/default_clipboard_copy_destination.md) configuration option specifies which clipboard buffer is populated. +*since: nightly* + +This action is considered to be deprecated and will be removed in +a future release; please use [CopyTo](CopyTo.md) instead. + +## Example ```lua diff --git a/docs/config/lua/keyassignment/Paste.md b/docs/config/lua/keyassignment/Paste.md index 66db85256..2b1926b1d 100644 --- a/docs/config/lua/keyassignment/Paste.md +++ b/docs/config/lua/keyassignment/Paste.md @@ -2,11 +2,12 @@ Paste the clipboard to the current pane. -On X11 systems that have multiple clipboards, the -[default_clipboard_paste_source](../config/default_clipboard_paste_source.md) -option specifies which source to use. +*since: nightly* -See also [PastePrimarySelection](PastePrimarySelection.md) and [PasteFrom](PasteFrom.md). +This action is considered to be deprecated and will be removed in +a future release; please use [PasteFrom](PasteFrom.md) instead. + +## Example ```lua local wezterm = require 'wezterm'; diff --git a/docs/config/lua/keyassignment/PastePrimarySelection.md b/docs/config/lua/keyassignment/PastePrimarySelection.md index 0e8a19a43..6555b7bb0 100644 --- a/docs/config/lua/keyassignment/PastePrimarySelection.md +++ b/docs/config/lua/keyassignment/PastePrimarySelection.md @@ -5,9 +5,8 @@ On other systems, this behaves identically to [Paste](Paste.md). *since: nightly* -This action is considered to be deprecated; please consider -using either [PasteFrom](PasteFrom.md) or just [Paste](Paste.md) -and adjusting the new [default_clipboard_paste_source](../config/default_clipboard_paste_source.md) configuration option. +This action is considered to be deprecated and will be removed in +a future release; please use [PasteFrom](PasteFrom.md) instead. ## Example diff --git a/wezterm-gui/src/gui/termwindow.rs b/wezterm-gui/src/gui/termwindow.rs index 28f27c81d..2e54e66a6 100644 --- a/wezterm-gui/src/gui/termwindow.rs +++ b/wezterm-gui/src/gui/termwindow.rs @@ -1939,14 +1939,17 @@ impl TermWindow { } Copy => { let text = self.selection_text(pane); - self.copy_to_clipboard(configuration().default_clipboard_copy_destination, text); + self.copy_to_clipboard( + ClipboardCopyDestination::ClipboardAndPrimarySelection, + text, + ); } CopyTo(dest) => { let text = self.selection_text(pane); self.copy_to_clipboard(*dest, text); } Paste => { - self.paste_from_clipboard(pane, configuration().default_clipboard_paste_source); + self.paste_from_clipboard(pane, ClipboardPasteSource::Clipboard); } PastePrimarySelection => { self.paste_from_clipboard(pane, ClipboardPasteSource::PrimarySelection); @@ -2088,13 +2091,10 @@ impl TermWindow { })) .detach(); } - CompleteSelectionOrOpenLinkAtMouseCursor => { + CompleteSelectionOrOpenLinkAtMouseCursor(dest) => { let text = self.selection_text(pane); if !text.is_empty() { - self.copy_to_clipboard( - configuration().default_clipboard_copy_destination, - text, - ); + self.copy_to_clipboard(*dest, text); let window = self.window.as_ref().unwrap(); window.invalidate(); } else { @@ -2102,13 +2102,10 @@ impl TermWindow { .perform_key_assignment(pane, &KeyAssignment::OpenLinkAtMouseCursor); } } - CompleteSelection => { + CompleteSelection(dest) => { let text = self.selection_text(pane); if !text.is_empty() { - self.copy_to_clipboard( - configuration().default_clipboard_copy_destination, - text, - ); + self.copy_to_clipboard(*dest, text); let window = self.window.as_ref().unwrap(); window.invalidate(); }