Skip to main content

Module clipboard

Module clipboard 

Source
Expand description

Clipboard and selection access through OSC 52.

§Category

OSC 52 sets, requests, or clears named clipboards/selections. This module provides the common system clipboard (c) and primary selection (p) selector bytes plus writers for each operation.

§OSC framing

The emitted sequences use 7-bit OSC with BEL termination:

ESC ] 52 ; c ; aGk= BEL
──┬── ┬─   ┬   ─┬─  ─┬─
 OSC code  Pc  base64 terminator

Clipboard data is base64-encoded by write_set_clipboard. Request and clear operations use ? or an empty payload in the same field.

§Mode interaction

OSC 52 is not gated by an ANSI/DEC mode. Terminals may still reject clipboard access by policy; this module only encodes the request bytes.

Constants§

PRIMARY_CLIPBOARD
OSC 52 selector byte p for the primary selection.
SYSTEM_CLIPBOARD
OSC 52 selector byte c for the system clipboard.

Functions§

write_clear_clipboard
Clear a clipboard or selection with ESC ] 52 ; <pc> ; BEL.
write_request_clipboard
Request clipboard contents with ESC ] 52 ; <pc> ; ? BEL.
write_set_clipboard
Set a clipboard or selection with ESC ] 52 ; <pc> ; <base64-data> BEL.