Parameters Parameters
How many parameters a control sequence can carry, and what happens to ones that are malformed.
CSI Pn ; Pn ; … F
- DEC STD 070
- §3.5.3.1 Parameter Values in Control Sequences, p. 3-24
- xterm
- Definitions
The CSI page gives the rules for parameters as the standards write them. This page is about where terminals have to choose.
How many. ECMA-48 sets no limit on the number of parameters. DEC STD 070 leaves the limit to the terminal, but asks for at least 16, and lets it ignore any past its limit (§3.5.3.1, p. 3-24). xterm keeps 30 (NPARAM). Past that it does not give up: each further ; is ignored, and the digits after it run on into the 30th parameter, so 3 and then ;1 there make 31 (CASE_ESC_DIGIT, CASE_ESC_SEMI). libghostty-vt keeps 24, and ignores a sequence with more altogether (MAX_PARAMS in Parser.zig). The difference matters in practice for SGR, where programs string many settings together.
Malformed. DEC STD 070 makes a sequence invalid, to be ignored through its final byte, when a private marker (<, =, >, ?) comes anywhere but first (§3.5.3.4, p. 3-26), when a parameter byte follows an intermediate (§3.5.3, p. 3-23), and when it has :, which it reserves (§3.5.3.1, p. 3-24). xterm’s parse tables ignore all of these (csi2_table, dec_table), except that it lets a few functions take :-separated subparameters, SGR above all, and ignores any other function that is given them (doparsing). libghostty-vt does the same.
Validation
PRM-1: Twenty-four parameters
\e[0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;1m # 23 zeros, then bold
A
|A_______|
attr 1,1 bold
PRM-2: Twenty-five
\e[0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;1m # 24 zeros, then bold
A
|A_______|
attr 1,1 bold
PRM-3: Past thirty, the digits run together
\e[0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;3;1m # 29 zeros, 3, 1: the 30th is 31, red
A
|A_______|
attr 1,1 fg=1 -bold
PRM-4: Subparameters where none are taken
\e[2:3H # ignored
X
|X_______|
cursor 1,2
PRM-5: A private marker in the wrong place
\e[2?3H
\e[??5h
X
|X_______|
cursor 1,2
PRM-6: A parameter after an intermediate
\e[?1$2p # not DECRQM
|________|
reply none
PRM-7: Empty parameters
\e[;;3H # CUP with defaults: the third is not used
X
|X_______|
cursor 1,2