diff options
Diffstat (limited to 'test/macos_e2e.swift')
| -rw-r--r-- | test/macos_e2e.swift | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/test/macos_e2e.swift b/test/macos_e2e.swift index 42bc8229..16992271 100644 --- a/test/macos_e2e.swift +++ b/test/macos_e2e.swift @@ -47,7 +47,7 @@ private struct ScriptError: Error { let message: String } -/// What the two C callbacks reach through `userdata`. A class, because a C +/// What the three C callbacks reach through `userdata`. A class, because a C /// function pointer cannot capture: a pointer the runtime struct carries is the /// only way back into Swift state. private final class Host { @@ -177,6 +177,18 @@ private final class Driver: PardesViewDelegate { yank = String(decoding: bytes, as: UTF8.self) } host.clipboard = yank + }, + read_clipboard: { ud in + // Main thread, inside pardes_tick, and answered on the spot: + // the core asked for the clipboard and pardes_paste hands it + // back before this returns. `host.clipboard`, never + // NSPasteboard, for the same reason as set_clipboard above. + // No pump — the tick that emitted this effect is still + // draining and will pick up whatever the paste queued. + guard let ud else { return } + let host = Unmanaged<Host>.fromOpaque(ud).takeUnretainedValue() + let text = host.clipboard ?? "" + text.withCString { pardes_paste($0, text.utf8.count) } }) let rc = pardes_init(&runtime, got.cols, got.rows) |
