Skip to content

Yank and put use the system clipboard - #76

Merged
tedkulp merged 4 commits into
mainfrom
75-system-clipboard
Oct 20, 2026
Merged

tedkulp merged 4 commits into
mainfrom
75-system-clipboard

Conversation

@tedkulp

@tedkulp tedkulp commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Summary

 store(register, reg)
   regs['"'] = r
   named reg → regs[reg]          ("+ and "* get no slot: they are the clipboard)
+  Clipboard.Write(r.text)        (failure → clipStale, app sends OSC 52)

 paste(reg)
-  r = regs[reg]
+  if reg is ", + or *
+    text = Clipboard.Read()
+    use regs['"'] if read failed, text empty, clipStale, or text == regs['"'].text
+    else paste text: as lines if it ends in "\n", else inline
cmd/pholio/main.go     Deps.Clipboard = seam.NewSystemClipboard(os.Getenv)
internal/seam/         Clipboard interface, SystemClipboard (pbcopy | wl-copy | xclip | xsel), seamtest fake
internal/engine/       Engine.Clipboard, store/paste routed through it
internal/app/          clipboard wrapper: a failed write is sent as OSC 52 (tea.SetClipboard)

Evidence

  • Before: yy in pholio, then paste in another app → nothing. p after copying elsewhere → E353: Nothing in register ".
    After: engine tests with a fake clipboard: yy/dw/vy/block y write it; p pastes outside text as lines or inline; a yanked block pastes back as a block; "ap ignores the clipboard; read/write errors fall back to registers with no message. App test: a missing clipboard tool gives a tea.SetClipboard cmd. go test ./... green, golangci-lint 0 issues.
  • Not yet verified: a manual check in a real terminal (Wayland/X11 round-trip, OSC 52 over SSH, lag when holding x).

Merge Danger

Door: two-way

Revert the branch to restore internal-only registers. No data or config format changes.

Blast Radius: editing

Every yank, delete and x now runs a clipboard tool synchronously (1s timeout), and replaces the user's system clipboard contents. If that causes lag, move the writes into a tea.Cmd.

Closes #75

🤖 Generated with Claude Code

tedkulp and others added 3 commits October 20, 2026 07:11
Every write to the unnamed register also goes to the system clipboard,
and puts from the unnamed register, "+ and "* read it back. Text equal to
the unnamed register is pholio's own, so the register keeps its shape.
seam.SystemClipboard runs wl-copy/xclip/xsel/pbcopy; when writing fails
the app sends the text with OSC 52 instead.

Closes #75

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
When a clipboard write fails but reads work, the clipboard still holds
older text; puts now use the unnamed register until a write succeeds.
Also rename clipReg to isClipboardReg and reuse msgsOf in app tests.

Closes #75

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A herdr or tmux server started outside the desktop gives its panes no
WAYLAND_DISPLAY or DISPLAY, so no clipboard tool was picked: copies went
out over OSC 52 but puts found nothing. With neither set, use the one
wayland-* socket in $XDG_RUNTIME_DIR that accepts a connection. With
none or several, don't guess: a copy sent to a nested compositor would
be lost without an error.

Closes #75

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@tedkulp

tedkulp commented Oct 20, 2026

Copy link
Copy Markdown
Owner Author

Added a display fallback (232807e). In a herdr pane started without WAYLAND_DISPLAY or DISPLAY, pholio now uses the single live wayland-* socket in $XDG_RUNTIME_DIR. When there are zero or several, it keeps the OSC 52 / internal register behaviour, so a nested compositor never gets the copy. Found during the manual check: copy worked inside herdr (OSC 52), but paste said Nothing in register ".

macOS has pbcopy, so it never needs the fallback. The test's sockets now
live in a short temp dir: macOS caps unix socket paths at 104 bytes and
t.TempDir there exceeds it.

Closes #75

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@tedkulp
tedkulp merged commit e40693c into main Oct 20, 2026
3 checks passed
@tedkulp
tedkulp deleted the 75-system-clipboard branch October 20, 2026 12:27
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.

Yank and put use the system clipboard

1 participant