darwin: adopt custom clipboard formats via raw pasteboard types (#17)#129
Merged
Conversation
Wire the custom-format seam into the macOS backend: read/write's default case resolves a custom Format token to its MIME string (formatMIME) and stores/reads the bytes verbatim under that string as an NSPasteboardType, with no conversion (raw passthrough). Watch picks up custom formats for free since it polls Read. Built-in FmtText/FmtImage are unchanged. Adds a platform-agnostic customRoundTrip test helper and a darwin test that round-trips raw bytes (including NUL and non-UTF-8) through a registered format and ReadAs.
This was referenced Jun 6, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backend PR of the custom clipboard formats design (spec). Builds on #128. Refs #17, #40.
Scope (macOS backend)
read/writedefaultcase resolves a customFormattoken to its MIME string viaformatMIME, then stores/reads the bytes verbatim under that string as anNSPasteboardType— raw passthrough, no encoding/conversion (contrastFmtImage's PNG↔TIFF transcode).nsString(Go string → autoreleasedNSStringpasteboard type),clipboard_read_custom,clipboard_write_custom.Watchof a custom format works for free (it pollsRead).FmtText/FmtImagepaths untouched.Tests
clipboard_custom_test.go: platform-agnosticcustomRoundTriphelper (round-trips raw bytes incl. NUL + non-UTF-8 through a registered format andReadAs; verifies an unwritten format reads nil).clipboard_custom_darwin_test.go:TestCustomFormatRoundTripruns it on macOS.Subsequent PRs wire the same helper into X11/Linux+BSD, Wayland, Windows, and the mobile/nocgo degrade paths.