Skip to content
Myr

termcap.go

This file

Path

termcap.go

49 lines · 1.6 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–7why, one step back
1package tea
23// requestCapabilityMsg is an internal message that requests the terminal to4// send its Termcap/Terminfo response.5type requestCapabilityMsg string67// RequestCapability is a command that requests the terminal to send its

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

lines 8–9why, one step back
8// Termcap/Terminfo response for the given capability. Use [WithInput] to
9// enable input, since the reply cannot be read otherwise.

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

lines 10–49why, one step back
10//
11// Bubble Tea recognizes the following capabilities and will use them to12// upgrade the program's color profile:13// - "RGB" Xterm direct color14// - "Tc" True color support15//16// Note: that some terminal's like Apple's Terminal.app do not support this and17// will send the wrong response to the terminal breaking the program's output.18//19// When the Bubble Tea advertises a non-TrueColor profile, you can use this20// command to query the terminal for its color capabilities. Example:21//22// switch msg := msg.(type) {23// case tea.ColorProfileMsg:24// if msg.Profile != colorprofile.TrueColor {25// return m, tea.Batch(26// tea.RequestCapability("RGB"),27// tea.RequestCapability("Tc"),28// )29// }30// }31func RequestCapability(s string) Cmd {32 return func() Msg {33 return requestCapabilityMsg(s)34 }35}3637// CapabilityMsg represents a Termcap/Terminfo response event. Termcap38// responses are generated by the terminal in response to RequestTermcap39// (XTGETTCAP) requests.40//41// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands42type CapabilityMsg struct {43 Content string44}4546// String returns the capability content as a string.47func (c CapabilityMsg) String() string {48 return c.Content49}