ESC sends
\x1b
. That's 1 byte: the actual escape character.Page Up sends
\x1b[H
. That's 3 bytes.F2 sends
\x1b[OQ
. That's 4 bytes.F5 sends
\x1b[15~
. That's 5 bytes.
What's the maximum length for one of these? Is this documented somewhere?
ESC sends \x1b
. That's 1 byte: the actual escape character.
Page Up sends \x1b[H
. That's 3 bytes.
F2 sends \x1b[OQ
. That's 4 bytes.
F5 sends \x1b[15~
. That's 5 bytes.
What's the maximum length for one of these? Is this documented somewhere?
There is no predefined limit for the length of control sequences. OP gives as examples some strings sent by special keys, which are documented in XTerm Control Sequences.
xterm starts with a list of possible key codes, may add codes for modifiers as outlined in the Alt and Meta keys section. There is no table of lengths. One complication for doing that is that there are several resource settings which work together to make a few thousand possible keyboard arrangements. Rather than describe all of those, the xterm terminal description is presented as a set of terminfo building blocks (the names with "+"), including user-defined capabilities for modified keys (e.g., control, shift, etc).
Some other terminals implement the xterm scheme, but only for particular combinations. So those would be easier to enumerate. They are in a sense "predefined".
However, special keys are not the only type of control sequence. Each of these terminals using the ECMA-48 format accepts control sequences sent from the host. Generally speaking, they accept numeric or string parameters:
Again, other terminal emulators may use their own limits on the length of control sequences that they accept.
man terminfo
andman termcap
– Ralph Rönnquist Feb 22 '16 at 05:06The termcap database is an obsolete facility
but thank you – cat Feb 22 '16 at 05:07