Skip to content

darwin: adopt custom clipboard formats via raw pasteboard types (#17)#129

Merged
changkun merged 1 commit into
mainfrom
feat/custom-formats-darwin
Jun 6, 2026
Merged

darwin: adopt custom clipboard formats via raw pasteboard types (#17)#129
changkun merged 1 commit into
mainfrom
feat/custom-formats-darwin

Conversation

@changkun

@changkun changkun commented Jun 6, 2026

Copy link
Copy Markdown
Member

Backend PR of the custom clipboard formats design (spec). Builds on #128. Refs #17, #40.

Scope (macOS backend)

  • read/write default case resolves a custom Format token to its MIME string via formatMIME, then stores/reads the bytes verbatim under that string as an NSPasteboardType — raw passthrough, no encoding/conversion (contrast FmtImage's PNG↔TIFF transcode).
  • New helpers: nsString (Go string → autoreleased NSString pasteboard type), clipboard_read_custom, clipboard_write_custom.
  • Watch of a custom format works for free (it polls Read).
  • Built-in FmtText/FmtImage paths untouched.

Tests

  • clipboard_custom_test.go: platform-agnostic customRoundTrip helper (round-trips raw bytes incl. NUL + non-UTF-8 through a registered format and ReadAs; verifies an unwritten format reads nil).
  • clipboard_custom_darwin_test.go: TestCustomFormatRoundTrip runs it on macOS.

Subsequent PRs wire the same helper into X11/Linux+BSD, Wayland, Windows, and the mobile/nocgo degrade paths.

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.
@changkun changkun merged commit 062fecc into main Jun 6, 2026
7 checks passed
@changkun changkun deleted the feat/custom-formats-darwin branch June 6, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant