1 Clipboard
dxtr edited this page 2026-10-14 04:26:09 +02:00

Clipboard

clipboard-text returns the text on the clipboard, or nil, and setf puts text there, for this and other programs to paste:

(setf (win:clipboard-text window-system) "Copied")   ; on Control+C
(win:clipboard-text window-system)                   ; on Control+V
(win:clipboard-text window-system &key (timeout 1)) => string or nil
(setf (win:clipboard-text window-system) text)
  • Lines end with #\Newline, whatever the program that put the text there used.

  • The text may be another program's, which is asked for it. clipboard-text waits up to :timeout seconds, 1 by default, and returns nil if that program does not answer.

  • Do both in answer to the user. On Wayland a program sees the clipboard only while one of its windows has the keyboard focus, and setting it then signals window-system-error otherwise:

    Wayland lets a program put text on the clipboard only while one of its
    windows has the keyboard focus, in answer to the user, as on Control+C.
    

window-system-capabilities includes :clipboard where there is one.

On each platform

  • Wayland: the clipboard is the seat's, through wl_data_device. The text stays on the clipboard until something else is put there or the window system is closed. A compositor without a seat, such as headless Weston, has no clipboard: clipboard-text returns nil, and setting it signals window-system-error.
  • Windows: the text stays on the clipboard until something else is put there. While the session is locked, Windows gives no program the clipboard, and both signal window-system-error.