1package tea
2
3// requestCapabilityMsg is an internal message that requests the terminal to
4// send its Termcap/Terminfo response.
5type requestCapabilityMsg string
6
7// RequestCapability is a command that requests the terminal to send its
8// Termcap/Terminfo response for the given capability.
9//
10// Bubble Tea recognizes the following capabilities and will use them to
11// upgrade the program's color profile:
12// - "RGB" Xterm direct color
13// - "Tc" True color support
14//
15// Note: that some terminal's like Apple's Terminal.app do not support this and
16// will send the wrong response to the terminal breaking the program's output.
17//
18// When the Bubble Tea advertises a non-TrueColor profile, you can use this
19// command to query the terminal for its color capabilities. Example:
20//
21// switch msg := msg.(type) {
22// case tea.ColorProfileMsg:
23// if msg.Profile != colorprofile.TrueColor {
24// return m, tea.Batch(
25// tea.RequestCapability("RGB"),
26// tea.RequestCapability("Tc"),
27// )
28// }
29// }
30func RequestCapability(s string) Cmd {
31 return func() Msg {
32 return requestCapabilityMsg(s)
33 }
34}
35
36// CapabilityMsg represents a Termcap/Terminfo response event. Termcap
37// responses are generated by the terminal in response to RequestTermcap
38// (XTGETTCAP) requests.
39//
40// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
41type CapabilityMsg string