mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-11 03:39:36 +00:00
libghostty-vt was already parsing OSC 52 into the clipboard_contents action but the stream handler dropped, so there was no way to observe clipboard writes (in this case, a program using go-libghostty). This adds a clipboard_set effect following the existing bell/title_changed pattern and expose it through the C API as `GHOSTTY_TERMINAL_OPT_CLIPBOARD_SET`. The callback receives the OSC 52 kind byte and the base64 payload exactly as received; decoding and kind interpretation are left to the embedder, matching how decoding is typically deferred. Note this intentionally does not deal with clipboard read requests given the security implications. AI disclosure: Fable (via Claude Code) did the majority of the work here, I validated it on the client side and fully understand the pattern we're fitting into.
Examples
Standalone projects demonstrating the Ghostty library APIs.
The directories starting with c- use the C API and the directories
starting with zig- use the Zig API.
Every example can be built and run using zig build and zig build run
from within the respective example directory.
Even the C API examples use the Zig build system (not the language) to
build the project.
Running an Example
cd example/<dir>
zig build run