^[control-codes
live in libghostty-vt

Control sequences

SM Set Mode

View as Markdown

Turn one or more ANSI modes on.

CSI Pm h
ECMA-48
§8.3.125 SM – Set Mode, p. 65
DEC STD 070
§5.10.1 SM/RM – Set Mode, Reset Mode, p. 5-133
VT220
§4.6.1 Set Mode (SM)
VT510
SM—Set Mode

CSI Pm h sets one or more modes. Each parameter names one mode, the modes are set in order, and ECMA-48 gives no default. RM, CSI Pm l, resets them again.

ECMA-48 numbers 22 modes, most of them for block-mode terminals, editing devices and bidirectional text, and each has a page under ANSI modes. DEC STD 070 lists only four a DEC terminal accepts, KAM, IRM, SRM and LNM, and says that a 0 is an error and is ignored; the VT220 manual’s table of ANSI modes is the same. xterm and libghostty-vt accept the same four (ansi_modes) and ignore every other number. They differ only in what DECRQM says about the rest:

PmModeNameIn xtermIn libghostty-vt
1GATMGuarded Area Transfer Modepermanently resetnot recognized
2KAMKeyboard Action Modeyesyes
3CRMControl Representation Modereported as resetnot recognized
4IRMInsertion Replacement Modeyesyes
5SRTMStatus Report Transfer Modepermanently resetnot recognized
6ERMErasure Modenot recognizednot recognized
7VEMLine Editing Modepermanently resetnot recognized
8BDSMBi-directional Support Modenot recognizednot recognized
9DCSMDevice Component Select Modenot recognizednot recognized
10HEMCharacter Editing Modepermanently resetnot recognized
11PUMPositioning Unit Modepermanently resetnot recognized
12SRMSend/Receive Modeyesyes
13FEAMFormat Effector Action Modepermanently resetnot recognized
14FETMFormat Effector Transfer Modepermanently resetnot recognized
15MATMMultiple Area Transfer Modepermanently resetnot recognized
16TTMTransfer Termination Modepermanently resetnot recognized
17SATMSelected Area Transfer Modepermanently resetnot recognized
18TSMTabulation Stop Modepermanently resetnot recognized
19EBMEditing Boundary Modepermanently resetnot recognized
20LNMLine Feed/New Line Modeyesyes
21GRCMGraphic Rendition Combination Modenot recognizednot recognized
22ZDMZero Default Modenot recognizednot recognized

Only IRM and LNM change what appears on the screen, so they are the ones the cases here use.

ANSI modes and DEC private modes cannot be mixed in one sequence. The DEC private form, CSI ? Pm h, is DECSET, and its numbers name the private modes.

Support

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984Yes§4.6.1 Set Mode (SM)
VT510manual, 1st ed., 1993YesSM
xtermpatch 412, xterm-411aYesKAM, IRM, SRM and LNM
libghostty-vt0f171f6YesKAM, IRM, SRM and LNM
kitty0.49.1, run in a VMYespasses the 2 cases that show it working
foot1.28.0, run in a VMNofails the 2 cases that show it working
pyte0.8.2, run as a libraryYespasses the 2 cases that show it working
xterm.js headless6.0.0, run as a libraryYespasses the 2 cases that show it working
alacritty_terminal0.26.0, run as a libraryPartlyfails SM-1 of the 2 cases that show it working
ConEmubuild 230724, its documentationPartlylists only 20 (LNM) and its own 7, line wrapping at a column; ANSI escape codes
rxvt-unicode9.31, run in a VMNofails the 2 cases that show it working
VTE0.84.1, run as a libraryPartlyfails SM-1 of the 2 cases that show it working

Validation

SM-1: Two modes in one sequence

abc
\e[1;1H
\e[4;20h  # IRM and LNM
X
\n
Y
|Xabc_|
|Y____|
cursor 2,2

SM-2: A mode that is not known does not stop the others

abc
\e[1;1H
\e[0;99;4h # 0 is an error, 99 is no mode
X
|Xabc_|
cursor 1,2

SM-3: A question mark makes it a different mode

abc
\e[1;1H
\e[?4h    # DECSCLM, smooth scrolling, not IRM
X
|Xbc__|
cursor 1,2
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.