mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-20 10:46:07 +03:00
Merge pull request #897 from gpanders/primary-clipboard
clipboard: add Clipboard variant for primary clipboard
This commit is contained in:
@ -2727,6 +2727,7 @@ fn completeClipboardReadOSC52(
|
||||
const kind: u8 = switch (clipboard_type) {
|
||||
.standard => 'c',
|
||||
.selection => 's',
|
||||
.primary => 'p',
|
||||
};
|
||||
|
||||
// Wrap our data with the OSC code
|
||||
|
@ -474,7 +474,7 @@ pub const Surface = struct {
|
||||
) bool {
|
||||
return switch (clipboard_type) {
|
||||
.standard => true,
|
||||
.selection => self.app.opts.supports_selection_clipboard,
|
||||
.selection, .primary => self.app.opts.supports_selection_clipboard,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -658,7 +658,7 @@ pub const Surface = struct {
|
||||
// GLFW can read clipboards immediately so just do that.
|
||||
const str: [:0]const u8 = switch (clipboard_type) {
|
||||
.standard => glfw.getClipboardString() orelse return glfw.mustGetErrorCode(),
|
||||
.selection => selection: {
|
||||
.selection, .primary => selection: {
|
||||
// Not supported except on Linux
|
||||
if (comptime builtin.os.tag != .linux) break :selection "";
|
||||
|
||||
@ -684,7 +684,7 @@ pub const Surface = struct {
|
||||
_ = self;
|
||||
switch (clipboard_type) {
|
||||
.standard => glfw.setClipboardString(val),
|
||||
.selection => {
|
||||
.selection, .primary => {
|
||||
// Not supported except on Linux
|
||||
if (comptime builtin.os.tag != .linux) return;
|
||||
glfwNative.setX11SelectionString(val.ptr);
|
||||
|
@ -589,7 +589,7 @@ fn gtkClipboardRead(
|
||||
fn getClipboard(widget: *c.GtkWidget, clipboard: apprt.Clipboard) ?*c.GdkClipboard {
|
||||
return switch (clipboard) {
|
||||
.standard => c.gtk_widget_get_clipboard(widget),
|
||||
.selection => c.gtk_widget_get_primary_clipboard(widget),
|
||||
.selection, .primary => c.gtk_widget_get_primary_clipboard(widget),
|
||||
};
|
||||
}
|
||||
pub fn getCursorPos(self: *const Surface) !apprt.CursorPos {
|
||||
|
@ -27,9 +27,10 @@ pub const IMEPos = struct {
|
||||
/// The clipboard type.
|
||||
///
|
||||
/// If this is changed, you must also update ghostty.h
|
||||
pub const Clipboard = enum(u1) {
|
||||
pub const Clipboard = enum(u2) {
|
||||
standard = 0, // ctrl+c/v
|
||||
selection = 1, // also known as the "primary" clipboard
|
||||
selection = 1,
|
||||
primary = 2,
|
||||
};
|
||||
|
||||
pub const ClipboardRequestType = enum(u8) {
|
||||
|
@ -2139,6 +2139,7 @@ const StreamHandler = struct {
|
||||
const clipboard_type: apprt.Clipboard = switch (kind) {
|
||||
'c' => .standard,
|
||||
's' => .selection,
|
||||
'p' => .primary,
|
||||
else => .standard,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user