mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
apprt: clipboard
This commit is contained in:
@ -543,7 +543,7 @@ fn clipboardRead(self: *const Window, kind: u8) !void {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = glfw.getClipboardString() catch |err| {
|
const data = self.windowing_system.getClipboardString() catch |err| {
|
||||||
log.warn("error reading clipboard: {}", .{err});
|
log.warn("error reading clipboard: {}", .{err});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@ -591,7 +591,7 @@ fn clipboardWrite(self: *const Window, data: []const u8) !void {
|
|||||||
try dec.decode(buf, data);
|
try dec.decode(buf, data);
|
||||||
assert(buf[buf.len] == 0);
|
assert(buf[buf.len] == 0);
|
||||||
|
|
||||||
glfw.setClipboardString(buf) catch |err| {
|
self.windowing_system.setClipboardString(buf) catch |err| {
|
||||||
log.err("error setting clipboard string err={}", .{err});
|
log.err("error setting clipboard string err={}", .{err});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@ -821,7 +821,7 @@ pub fn keyCallback(
|
|||||||
};
|
};
|
||||||
defer self.alloc.free(buf);
|
defer self.alloc.free(buf);
|
||||||
|
|
||||||
glfw.setClipboardString(buf) catch |err| {
|
self.windowing_system.setClipboardString(buf) catch |err| {
|
||||||
log.err("error setting clipboard string err={}", .{err});
|
log.err("error setting clipboard string err={}", .{err});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@ -829,7 +829,7 @@ pub fn keyCallback(
|
|||||||
},
|
},
|
||||||
|
|
||||||
.paste_from_clipboard => {
|
.paste_from_clipboard => {
|
||||||
const data = glfw.getClipboardString() catch |err| {
|
const data = self.windowing_system.getClipboardString() catch |err| {
|
||||||
log.warn("error reading clipboard: {}", .{err});
|
log.warn("error reading clipboard: {}", .{err});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
@ -194,6 +194,20 @@ pub const Window = struct {
|
|||||||
try self.window.setTitle(slice.ptr);
|
try self.window.setTitle(slice.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Read the clipboard. The windowing system is responsible for allocating
|
||||||
|
/// a buffer as necessary. This should be a stable pointer until the next
|
||||||
|
/// time getClipboardString is called.
|
||||||
|
pub fn getClipboardString(self: *const Window) ![:0]const u8 {
|
||||||
|
_ = self;
|
||||||
|
return try glfw.getClipboardString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set the clipboard.
|
||||||
|
pub fn setClipboardString(self: *const Window, val: [:0]const u8) !void {
|
||||||
|
_ = self;
|
||||||
|
try glfw.setClipboardString(val);
|
||||||
|
}
|
||||||
|
|
||||||
/// The cursor position from glfw directly is in screen coordinates but
|
/// The cursor position from glfw directly is in screen coordinates but
|
||||||
/// all our interface works in pixels.
|
/// all our interface works in pixels.
|
||||||
fn cursorPosToPixels(self: *const Window, pos: glfw.Window.CursorPos) !glfw.Window.CursorPos {
|
fn cursorPosToPixels(self: *const Window, pos: glfw.Window.CursorPos) !glfw.Window.CursorPos {
|
||||||
|
Reference in New Issue
Block a user