summaryrefslogtreecommitdiff
path: root/src/macos.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/macos.zig')
-rw-r--r--src/macos.zig15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/macos.zig b/src/macos.zig
index ef68d7e7..dce136f4 100644
--- a/src/macos.zig
+++ b/src/macos.zig
@@ -122,14 +122,15 @@ pub const Image = extern struct {
rgba: [*]const u8,
};
-/// Sync with: pardes_runtime_s. Two callbacks, because everything else the
+/// Sync with: pardes_runtime_s. Three callbacks, because everything else the
/// core asks for it already does itself — it owns the ptys, and look.openLink
-/// hands URLs to /usr/bin/open. Both are optional at the ABI level: a host that
+/// hands URLs to /usr/bin/open. All optional at the ABI level: a host that
/// passes null simply does without, rather than trapping inside the library.
pub const Runtime = extern struct {
userdata: ?*anyopaque = null,
wakeup: ?*const fn (?*anyopaque) callconv(.c) void = null,
set_clipboard: ?*const fn (?*anyopaque, [*]const u8, usize) callconv(.c) void = null,
+ read_clipboard: ?*const fn (?*anyopaque) callconv(.c) void = null,
};
const color_default: u32 = 0x01000000;
@@ -1127,6 +1128,16 @@ fn drainEffects(st: *State, threads_ok: bool) bool {
const y = core.yank orelse continue;
cb(st.runtime.userdata, y.ptr, y.len);
},
+ // The host answers with pardes_paste, which the AppDelegate calls
+ // straight back inside this call: NSPasteboard reads are
+ // synchronous, so the paste event lands here, mid-drain. That is
+ // safe and deliberate — pardes_paste only feeds core.update, and
+ // whatever that queues is picked up by this same loop rather than
+ // waiting a tick. A host with a null callback simply never pastes.
+ .read_clipboard => {
+ const cb = st.runtime.read_clipboard orelse continue;
+ cb(st.runtime.userdata);
+ },
// An empty answer, immediately: the honest reply from a shell with
// no worker, and the only safe one. Tab after a `.` DIVERTS to the
// backend instead of indenting and indents late, when the answer