Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/Surface.zig
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ const DerivedConfig = struct {
clipboard_paste_bracketed_safe: bool,
clipboard_codepoint_map: configpkg.Config.RepeatableClipboardCodepointMap,
copy_on_select: configpkg.CopyOnSelect,
middle_click_paste: configpkg.MiddleClickPaste,
right_click_action: configpkg.RightClickAction,
confirm_close_surface: configpkg.ConfirmCloseSurface,
cursor_click_to_move: bool,
Expand Down Expand Up @@ -388,6 +389,7 @@ const DerivedConfig = struct {
.clipboard_paste_bracketed_safe = config.@"clipboard-paste-bracketed-safe",
.clipboard_codepoint_map = try config.@"clipboard-codepoint-map".clone(alloc),
.copy_on_select = config.@"copy-on-select",
.middle_click_paste = config.@"middle-click-paste",
.right_click_action = config.@"right-click-action",
.confirm_close_surface = config.@"confirm-close-surface",
.cursor_click_to_move = config.@"cursor-click-to-move",
Expand Down Expand Up @@ -4008,11 +4010,17 @@ pub fn mouseButtonCallback(
}

// Middle-click pastes from our selection clipboard
if (button == .middle and action == .press) {
const clipboard: apprt.Clipboard = if (self.rt_surface.supportsClipboard(.selection))
.selection
else
.standard;
if (button == .middle and action == .press and
self.config.middle_click_paste != .false)
{
const clipboard: apprt.Clipboard = switch (self.config.middle_click_paste) {
.false => unreachable,
.selection => if (self.rt_surface.supportsClipboard(.selection))
.selection
else
.standard,
.clipboard => .standard,
};
_ = try self.startClipboardRequest(clipboard, .{ .paste = {} });
}

Expand Down
1 change: 1 addition & 0 deletions src/config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub const ClipboardAccess = Config.ClipboardAccess;
pub const Command = Config.Command;
pub const ConfirmCloseSurface = Config.ConfirmCloseSurface;
pub const CopyOnSelect = Config.CopyOnSelect;
pub const MiddleClickPaste = Config.MiddleClickPaste;
pub const RightClickAction = Config.RightClickAction;
pub const CustomShaderAnimation = Config.CustomShaderAnimation;
pub const FontSyntheticStyle = Config.FontSyntheticStyle;
Expand Down
29 changes: 27 additions & 2 deletions src/config/Config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2404,8 +2404,8 @@ keybind: Keybinds = .{},
/// The value `clipboard` will always copy text to the selection clipboard
/// as well as the system clipboard.
///
/// Middle-click paste will always use the selection clipboard. Middle-click
/// paste is always enabled even if this is `false`.
/// Middle-click paste behavior can be configured with `middle-click-paste`,
/// including disabling it entirely.
///
/// The default value is true on Linux and macOS.
@"copy-on-select": CopyOnSelect = switch (builtin.os.tag) {
Expand All @@ -2414,6 +2414,18 @@ keybind: Keybinds = .{},
else => .false,
},

/// The clipboard to use when pasting with the middle mouse button.
///
/// Valid values:
/// * `selection` - Paste from the selection clipboard. Falls back to
/// the system clipboard if the selection clipboard is not supported by
/// the platform.
/// * `clipboard` - Paste from the system clipboard.
/// * `false` - Disable middle-click paste entirely.
///
/// The default value is `selection`.
@"middle-click-paste": MiddleClickPaste = .selection,

/// The action to take when the user right-clicks on the terminal surface.
///
/// Valid values:
Expand Down Expand Up @@ -8601,6 +8613,19 @@ pub const CopyOnSelect = enum {
clipboard,
};

/// Options for middle-click paste clipboard selection.
pub const MiddleClickPaste = enum {
/// Disables middle-click paste entirely.
false,

/// Paste from the selection clipboard. Falls back to the system clipboard
/// if the selection clipboard is not supported by the platform.
selection,

/// Paste from the system clipboard.
clipboard,
};

/// Options for right-click actions.
pub const RightClickAction = enum {
/// No action is taken on right-click.
Expand Down