class
TermBuf::Prober
- TermBuf::Prober
- Reference
- Object
Overview
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.
Defined in:
termbuf/caps/prober.crConstant Summary
-
CURSOR_POSITION =
/\A\e\[(\d+);(\d+)R\z/ -
DEFAULT_TIMEOUT =
250.milliseconds -
Long enough for a terminal on the far end of a slow link, short enough not to be noticed when nothing answers.
-
KITTY_GRAPHICS_QUERY =
"\e_Gi=31,s=1,v=1,a=q,t=d,f=24;AAAA\e\\" -
A one pixel RGB image, asked about rather than displayed.
-
KITTY_KEYBOARD =
/\A\e\[\?\d*u\z/ -
PRIMARY_ATTRIBUTES =
/\A\e\[\?[\d;]*c\z/ -
QUERIES =
String.build do |io| io << "\e[c" io << "\e[>c" io << "\e[>0q" io << TCAP_QUERY io << "\e[?2026$p" io << "\e[?u" io << KITTY_GRAPHICS_QUERY io << "\e[6n" end -
TCAP_QUERY =
"\eP+q5463;524742\e\\" -
TcandRGBare the terminfo capabilities that mean 24 bit colour; asking for them by hex name is how XTGETTCAP works. -
TERMINAL_NAME =
/\A\eP>\|(.*)\e\\\z/m
Constructors
Instance Method Summary
-
#probe(base : Capabilities) : Result
Sends the queries and folds whatever comes back into base.
-
#probe_temp_file : Bool
Asks whether the terminal will read image data out of a file rather than take it inline.
-
#timeout : Time::Span
How long to wait for the sentinel before giving up on the batch.
Constructor Detail
Instance Method Detail
Sends the queries and folds whatever comes back into base.
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.