TermBuf::Prober
Stability: internal
Asks the terminal what it can do, rather than guessing from its name.
Every query goes out in one batch, and the last of them is a cursor position report. Every terminal answers that one, so its reply is the signal that everything else which was going to answer already has. The common case therefore costs one round trip rather than the full timeout, and the timeout is only a backstop for a terminal that answers nothing.
Bytes arriving during the probe window that are not replies are keystrokes. They are handed back rather than dropped, so a key pressed while the application was starting still reaches it.
Constants
DECRQSS for the cursor style: DCS $ q SP q ST asks the terminal to
report the DECSCUSR setting it is currently in.
An experiment, and the only query there is for Capability::CursorShape
— nothing else this shard can ask answers whether DECSCUSR does
anything. A terminal that implements DECRQSS answers DCS 1 $ r Ps SP q ST with the shape it is set to, which is evidence it knows the setting
exists; DCS 0 $ r ST is a terminal that understands the request and
refuses this particular one, which is evidence it does not. Terminal.app
and kitty answer neither, and silence changes nothing: the terminal's
name is still the best that can be done for them.
DCS Ps $ r ... ST, the DECRPSS reply, where a leading 1 means the
request was valid and 0 that it was not. The payload of a valid one is
the setting itself, Ps SP q for a cursor style, and it is matched
rather than read: the shape the terminal happens to be in says nothing
about whether it will take a new one.
Long enough for a terminal on the far end of a slow link, short enough not to be noticed when nothing answers.
A one pixel RGB image, asked about rather than displayed.
The DEC private modes worth asking about, and the capability each one
stands for. CSI ? Pm $ p is DECRQM and the reply is DECRPM, which is
the only mechanism a terminal offers for saying it does not have
something; every other query in the batch is silent about what it lacks.
Mode 2027 is asked about and never turned on. Enabling it changes how the
terminal counts grapheme clusters, and the width probe measures this
terminal with the mode off; switching it on afterwards would invalidate
every width already established. See Capability::GraphemeClusters.
Which query a mode report answered, for Result#answered. A separate
table because a symbol cannot be built out of a value at runtime.
Tc and RGB are the terminfo capabilities that mean 24 bit colour;
asking for them by hex name is how XTGETTCAP works.
Constructors
Instance methods
Sends the queries and folds whatever comes back into base.
A mode report for a capability in distrusted is recorded as answered
and adds nothing: it is the answer of something in the middle rather than
of the terminal at the end. A refusal is trusted whatever is in
distrusted, since nothing forwards a mode it does not know. See
EnvironmentDetector.distrusted.
Asks whether the terminal will read image data out of a file rather than take it inline. Only worth asking once the graphics protocol is known to be there, and it needs somewhere to write, so it is separate from the main batch.