Skip to content
Myr

clipboard.go

This file

Path

clipboard.go

72 lines · 2.2 KiB · Go

Last changed by

fix: skip capability queries when input is disabled (#1801)draw me an elephantbefore adoption8b10e22

History of this file

Take it

Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97

lines 1–40why, one step back
1package tea
23// ClipboardMsg is a clipboard read message event. This message is emitted when4// a terminal receives an OSC52 clipboard read message event.5type ClipboardMsg struct {6 Content string7 Selection byte8}910// Clipboard returns the clipboard selection type. This will be one of the11// following values:12//13// - c: System clipboard.14// - p: Primary clipboard (X11/Wayland only).15func (e ClipboardMsg) Clipboard() byte {16 return e.Selection17}1819// String returns the string representation of the clipboard message.20func (e ClipboardMsg) String() string {21 return e.Content22}2324// setClipboardMsg is an internal message used to set the system clipboard25// using OSC52.26type setClipboardMsg string2728// SetClipboard produces a command that sets the system clipboard using OSC52.29// Note that OSC52 is not supported in all terminals.30func SetClipboard(s string) Cmd {31 return func() Msg {32 return setClipboardMsg(s)33 }34}3536// readClipboardMsg is an internal message used to read the system clipboard37// using OSC52.38type readClipboardMsg struct{}3940// ReadClipboard produces a command that reads the system clipboard using OSC52.

fix: skip capability queries when input is disabled (#1801)draw me an elephantbefore adoption8b10e22

lines 41–42why, one step back
41// Note that OSC52 is not supported in all terminals. Use [WithInput] to enable
42// input, since the reply cannot be read otherwise.

Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97

lines 43–67why, one step back
43func ReadClipboard() Msg {
44 return readClipboardMsg{}45}4647// setPrimaryClipboardMsg is an internal message used to set the primary48// clipboard using OSC52.49type setPrimaryClipboardMsg string5051// SetPrimaryClipboard produces a command that sets the primary clipboard using52// OSC52. Primary clipboard selection is a feature present in X11 and Wayland53// only.54// Note that OSC52 is not supported in all terminals.55func SetPrimaryClipboard(s string) Cmd {56 return func() Msg {57 return setPrimaryClipboardMsg(s)58 }59}6061// readPrimaryClipboardMsg is an internal message used to read the primary62// clipboard using OSC52.63type readPrimaryClipboardMsg struct{}6465// ReadPrimaryClipboard produces a command that reads the primary clipboard66// using OSC52. Primary clipboard selection is a feature present in X11 and67// Wayland only.

fix: skip capability queries when input is disabled (#1801)draw me an elephantbefore adoption8b10e22

lines 68–69why, one step back
68// Note that OSC52 is not supported in all terminals. Use [WithInput] to enable
69// input, since the reply cannot be read otherwise.

Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97

lines 70–72why, one step back
70func ReadPrimaryClipboard() Msg {
71 return readPrimaryClipboardMsg{}72}