summaryrefslogtreecommitdiff
path: root/dev
diff options
context:
space:
mode:
Diffstat (limited to 'dev')
-rw-r--r--dev/gui/gui.zig17
-rw-r--r--dev/tui/tui.zig16
2 files changed, 33 insertions, 0 deletions
diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig
index 66b7328d..909c83c6 100644
--- a/dev/gui/gui.zig
+++ b/dev/gui/gui.zig
@@ -1422,6 +1422,23 @@ const Client = struct {
return .{ .drew = cl.shell.presented, .moving = frontendMoving(cl.g) };
}
+ /// What its view asked of this machine (client.zig `asks`): register
+ /// `+` to the desktop's clipboard, the clipboard's text sent as a paste,
+ /// a link opened.
+ pub fn copy(cl: *Client, text: []const u8) void {
+ putClipboard(cl.gpa, text);
+ }
+
+ pub fn paste(_: *Client, l: *ClientLoop) void {
+ const text = takeClipboard() orelse return;
+ defer c.SDL_free(text.ptr);
+ l.input(.{ .paste = text });
+ }
+
+ pub fn open(_: *Client, url: []const u8) void {
+ look.openLink(url);
+ }
+
/// The reader's: a message of the stream, for the loop, which it wakes.
pub fn said(cl: *Client, msg: replica.Said) bool {
cl.lock.lockUncancelable(cl.io);
diff --git a/dev/tui/tui.zig b/dev/tui/tui.zig
index c2f3dbf1..5b5c1e67 100644
--- a/dev/tui/tui.zig
+++ b/dev/tui/tui.zig
@@ -694,6 +694,22 @@ const Tty = struct {
return .{ .drew = t.sh.frames.bytes > 0, .moving = false };
}
+ /// What its view asked of this machine (client.zig `asks`): register
+ /// `+` to the terminal's clipboard (OSC 52), its clipboard asked for
+ /// (the answer comes back as a paste, `Shell.feed`), a link opened.
+ pub fn copy(t: *Tty, text: []const u8) void {
+ const sc = t.screen;
+ if (text.len > 0) sc.vx.copyToSystemClipboard(sc.tty.writer(), text, t.sh.gpa) catch {};
+ }
+
+ pub fn paste(t: *Tty, _: *Client) void {
+ t.screen.vx.requestSystemClipboard(t.screen.tty.writer()) catch {};
+ }
+
+ pub fn open(_: *Tty, url: []const u8) void {
+ look.openLink(url);
+ }
+
/// The session's stream, onto the loop.
pub fn said(t: *Tty, msg: replica.Said) bool {
t.loop.postEvent(.{ .said = msg }) catch return false;