^[control-codes live in libghostty-vt

Escape sequences

ST String Terminator

End a control string, such as an operating system command or a device control string.

ST
ECMA-48
§8.3.143 ST – String Terminator, p. 70
DEC STD 070
§3.5.1.2.5 Universal Terminator, p. 3-19
VT510
4.2 Control Characters

ST closes a control string: one opened by OSC, DCS, or SOS, PM or APC. Everything between the opener and ST is the string’s content, which the terminal reads as a whole rather than printing.

xterm also accepts BEL in place of ST, but only to end an OSC. In any other string it rings the bell and the string goes on (CASE_BELL). libghostty-vt also ends only an OSC with BEL.

DEC STD 070 makes ST a universal terminator: sent on its own, it gets the terminal back to a known state whatever it was in the middle of (§3.5.1.2.5, p. 3-19). Its ESC cancels any escape or control sequence in progress, it ends any control string normally, and with nothing in progress it is ignored. So a program that is not sure what it last left unfinished can send ESC \ and carry on.

ST is a C1 control. ECMA-48 also defines it as the single byte 9C, which a terminal reading UTF-8 does not take as ST: a string opened with ESC ] goes on past it, in a default xterm and in libghostty-vt alike. The UTF-8 page has the details.

Validation

ST-1: Ends an operating system command

\e]2;hello\e\\
X
|X_____|
title "hello"

ST-2: On its own, it is ignored

A
\e\\
B
|AB____|
cursor 1,3

ST-3: It cancels a control sequence in progress

A
\e[2;     # an unfinished CUP
\e\\
B
|AB____|
|______|
cursor 1,3

ST-4: The 8-bit form does not end a string

\e]2;hello
\x9c      # not valid UTF-8 on its own
X         # still part of the command
|______|
title ""