mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
"copy-on-select" configuation to disable
This commit is contained in:
@ -144,6 +144,7 @@ const DerivedConfig = struct {
|
|||||||
clipboard_read: bool,
|
clipboard_read: bool,
|
||||||
clipboard_write: bool,
|
clipboard_write: bool,
|
||||||
clipboard_trim_trailing_spaces: bool,
|
clipboard_trim_trailing_spaces: bool,
|
||||||
|
copy_on_select: configpkg.CopyOnSelect,
|
||||||
confirm_close_surface: bool,
|
confirm_close_surface: bool,
|
||||||
mouse_interval: u64,
|
mouse_interval: u64,
|
||||||
macos_non_native_fullscreen: bool,
|
macos_non_native_fullscreen: bool,
|
||||||
@ -159,6 +160,7 @@ const DerivedConfig = struct {
|
|||||||
.clipboard_read = config.@"clipboard-read",
|
.clipboard_read = config.@"clipboard-read",
|
||||||
.clipboard_write = config.@"clipboard-write",
|
.clipboard_write = config.@"clipboard-write",
|
||||||
.clipboard_trim_trailing_spaces = config.@"clipboard-trim-trailing-spaces",
|
.clipboard_trim_trailing_spaces = config.@"clipboard-trim-trailing-spaces",
|
||||||
|
.copy_on_select = config.@"copy-on-select",
|
||||||
.confirm_close_surface = config.@"confirm-close-surface",
|
.confirm_close_surface = config.@"confirm-close-surface",
|
||||||
.mouse_interval = config.@"click-repeat-interval" * 1_000_000, // 500ms
|
.mouse_interval = config.@"click-repeat-interval" * 1_000_000, // 500ms
|
||||||
.macos_non_native_fullscreen = config.@"macos-non-native-fullscreen",
|
.macos_non_native_fullscreen = config.@"macos-non-native-fullscreen",
|
||||||
@ -833,6 +835,13 @@ fn setSelection(self: *Surface, sel_: ?terminal.Selection) void {
|
|||||||
const prev_ = self.io.terminal.screen.selection;
|
const prev_ = self.io.terminal.screen.selection;
|
||||||
self.io.terminal.screen.selection = sel_;
|
self.io.terminal.screen.selection = sel_;
|
||||||
|
|
||||||
|
// Determine the clipboard we want to copy selection to, if it is enabled.
|
||||||
|
const clipboard: apprt.Clipboard = switch (self.config.copy_on_select) {
|
||||||
|
.false => return,
|
||||||
|
.true => .selection,
|
||||||
|
.clipboard => .standard,
|
||||||
|
};
|
||||||
|
|
||||||
// Set our selection clipboard. If the selection is cleared we do not
|
// Set our selection clipboard. If the selection is cleared we do not
|
||||||
// clear the clipboard. If the selection is set, we only set the clipboard
|
// clear the clipboard. If the selection is set, we only set the clipboard
|
||||||
// again if it changed, since setting the clipboard can be an expensive
|
// again if it changed, since setting the clipboard can be an expensive
|
||||||
@ -850,7 +859,7 @@ fn setSelection(self: *Surface, sel_: ?terminal.Selection) void {
|
|||||||
};
|
};
|
||||||
defer self.alloc.free(buf);
|
defer self.alloc.free(buf);
|
||||||
|
|
||||||
self.rt_surface.setClipboardString(buf, .selection) catch |err| {
|
self.rt_surface.setClipboardString(buf, clipboard) catch |err| {
|
||||||
log.err("error setting clipboard string err={}", .{err});
|
log.err("error setting clipboard string err={}", .{err});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@ -1697,7 +1706,14 @@ pub fn mouseButtonCallback(
|
|||||||
|
|
||||||
// Middle-click pastes from our selection clipboard
|
// Middle-click pastes from our selection clipboard
|
||||||
if (button == .middle and action == .press) {
|
if (button == .middle and action == .press) {
|
||||||
try self.clipboardPaste(.selection, false);
|
if (self.config.copy_on_select != .false) {
|
||||||
|
const clipboard: apprt.Clipboard = switch (self.config.copy_on_select) {
|
||||||
|
.true => .selection,
|
||||||
|
.clipboard => .standard,
|
||||||
|
.false => unreachable,
|
||||||
|
};
|
||||||
|
try self.clipboardPaste(clipboard, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,6 +186,17 @@ pub const Config = struct {
|
|||||||
/// This does not affect data sent to the clipboard via "clipboard-write".
|
/// This does not affect data sent to the clipboard via "clipboard-write".
|
||||||
@"clipboard-trim-trailing-spaces": bool = true,
|
@"clipboard-trim-trailing-spaces": bool = true,
|
||||||
|
|
||||||
|
/// Whether to automatically copy selected text to the clipboard. "true"
|
||||||
|
/// will only copy on systems that support a selection clipboard.
|
||||||
|
///
|
||||||
|
/// The value "clipboard" will copy to the system clipboard, making this
|
||||||
|
/// work on macOS. Note that middle-click will also paste from the system
|
||||||
|
/// clipboard in this case.
|
||||||
|
///
|
||||||
|
/// Note that if this is disabled, middle-click paste will also be
|
||||||
|
/// disabled.
|
||||||
|
@"copy-on-select": CopyOnSelect = .true,
|
||||||
|
|
||||||
/// The time in milliseconds between clicks to consider a click a repeat
|
/// The time in milliseconds between clicks to consider a click a repeat
|
||||||
/// (double, triple, etc.) or an entirely new single click. A value of
|
/// (double, triple, etc.) or an entirely new single click. A value of
|
||||||
/// zero will use a platform-specific default. The default on macOS
|
/// zero will use a platform-specific default. The default on macOS
|
||||||
@ -1375,6 +1386,20 @@ pub const Keybinds = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Options for copy on select behavior.
|
||||||
|
pub const CopyOnSelect = enum {
|
||||||
|
/// Disables copy on select entirely.
|
||||||
|
false,
|
||||||
|
|
||||||
|
/// Copy on select is enabled, but goes to the selection clipboard.
|
||||||
|
/// This is not supported on platforms such as macOS. This is the default.
|
||||||
|
true,
|
||||||
|
|
||||||
|
/// Copy on select is enabled and goes to the system clipboard.
|
||||||
|
clipboard,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Shell integration values
|
||||||
pub const ShellIntegration = enum {
|
pub const ShellIntegration = enum {
|
||||||
none,
|
none,
|
||||||
detect,
|
detect,
|
||||||
|
Reference in New Issue
Block a user