pict-copy:   Copy Picts to the Clipboard
pict-copy
9.0

pict-copy: Copy Picts to the Clipboard🔗ℹ

Sam Tobin-Hochstadt

 (require pict-copy) package: pict-copy

This library provides a function for copying picts to the system clipboard.

procedure

(pict-copy p [#:gui? gui?])  void?

  p : pict?
  gui? : boolean? = #f
Copies p to the system clipboard as a bitmap image.

Linux behavior: On Linux, the GUI clipboard requires an event loop to be running to respond to clipboard requests from other applications. This means using the GUI clipboard only works in environments like DrRacket.

By default on Linux, pict-copy uses external tools that work reliably without an event loop:
  • On Wayland: wl-copy from the wl-clipboard package

  • On X11: xclip

If the required tool is not installed, an error is raised with installation instructions.

Set gui? to #t to force using the GUI clipboard (useful in DrRacket where an event loop is running).

Mac and Windows: The GUI clipboard is always used, and the gui? argument is ignored.

Example:
(require pict-copy pict)
 
; Works from REPL or scripts on Linux (uses wl-copy or xclip)
(pict-copy (circle 50))
 
; Use GUI clipboard (only works in DrRacket on Linux)
(pict-copy (circle 50) #:gui? #t)