clipboard.go

 1package tea
 2
 3// ClipboardMsg is a clipboard read message event. This message is emitted when
 4// a terminal receives an OSC52 clipboard read message event.
 5type ClipboardMsg string
 6
 7// String returns the string representation of the clipboard message.
 8func (e ClipboardMsg) String() string {
 9	return string(e)
10}
11
12// PrimaryClipboardMsg is a primary clipboard read message event. This message
13// is emitted when a terminal receives an OSC52 primary clipboard read message
14// event. Primary clipboard selection is a feature present in X11 and Wayland
15// only.
16type PrimaryClipboardMsg string
17
18// String returns the string representation of the primary clipboard message.
19func (e PrimaryClipboardMsg) String() string {
20	return string(e)
21}
22
23// setClipboardMsg is an internal message used to set the system clipboard
24// using OSC52.
25type setClipboardMsg string
26
27// SetClipboard produces a command that sets the system clipboard using OSC52.
28// Note that OSC52 is not supported in all terminals.
29func SetClipboard(s string) Cmd {
30	return func() Msg {
31		return setClipboardMsg(s)
32	}
33}
34
35// readClipboardMsg is an internal message used to read the system clipboard
36// using OSC52.
37type readClipboardMsg struct{}
38
39// ReadClipboard produces a command that reads the system clipboard using OSC52.
40// Note that OSC52 is not supported in all terminals.
41func ReadClipboard() Msg {
42	return readClipboardMsg{}
43}
44
45// setPrimaryClipboardMsg is an internal message used to set the primary
46// clipboard using OSC52.
47type setPrimaryClipboardMsg string
48
49// SetPrimaryClipboard produces a command that sets the primary clipboard using
50// OSC52. Primary clipboard selection is a feature present in X11 and Wayland
51// only.
52// Note that OSC52 is not supported in all terminals.
53func SetPrimaryClipboard(s string) Cmd {
54	return func() Msg {
55		return setPrimaryClipboardMsg(s)
56	}
57}
58
59// readPrimaryClipboardMsg is an internal message used to read the primary
60// clipboard using OSC52.
61type readPrimaryClipboardMsg struct{}
62
63// ReadPrimaryClipboard produces a command that reads the primary clipboard
64// using OSC52. Primary clipboard selection is a feature present in X11 and
65// Wayland only.
66// Note that OSC52 is not supported in all terminals.
67func ReadPrimaryClipboard() Msg {
68	return readPrimaryClipboardMsg{}
69}