SM Set Mode
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:
Pm | Mode | Name | In xterm | In libghostty-vt |
|---|---|---|---|---|
1 | GATM | Guarded Area Transfer Mode | permanently reset | not recognized |
2 | KAM | Keyboard Action Mode | yes | yes |
3 | CRM | Control Representation Mode | reported as reset | not recognized |
4 | IRM | Insertion Replacement Mode | yes | yes |
5 | SRTM | Status Report Transfer Mode | permanently reset | not recognized |
6 | ERM | Erasure Mode | not recognized | not recognized |
7 | VEM | Line Editing Mode | permanently reset | not recognized |
8 | BDSM | Bi-directional Support Mode | not recognized | not recognized |
9 | DCSM | Device Component Select Mode | not recognized | not recognized |
10 | HEM | Character Editing Mode | permanently reset | not recognized |
11 | PUM | Positioning Unit Mode | permanently reset | not recognized |
12 | SRM | Send/Receive Mode | yes | yes |
13 | FEAM | Format Effector Action Mode | permanently reset | not recognized |
14 | FETM | Format Effector Transfer Mode | permanently reset | not recognized |
15 | MATM | Multiple Area Transfer Mode | permanently reset | not recognized |
16 | TTM | Transfer Termination Mode | permanently reset | not recognized |
17 | SATM | Selected Area Transfer Mode | permanently reset | not recognized |
18 | TSM | Tabulation Stop Mode | permanently reset | not recognized |
19 | EBM | Editing Boundary Mode | permanently reset | not recognized |
20 | LNM | Line Feed/New Line Mode | yes | yes |
21 | GRCM | Graphic Rendition Combination Mode | not recognized | not recognized |
22 | ZDM | Zero Default Mode | not recognized | not 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
| Terminal | Version | Support | Notes |
|---|---|---|---|
| VT220 | manual, 2nd ed., 1984 | Yes | §4.6.1 Set Mode (SM) |
| VT510 | manual, 1st ed., 1993 | Yes | SM |
| xterm | patch 412, xterm-411a | Yes | KAM, IRM, SRM and LNM |
| libghostty-vt | 0f171f6 | Yes | KAM, IRM, SRM and LNM |
| kitty | 0.49.1, run in a VM | Yes | passes the 2 cases that show it working |
| foot | 1.28.0, run in a VM | No | fails the 2 cases that show it working |
| pyte | 0.8.2, run as a library | Yes | passes the 2 cases that show it working |
| xterm.js headless | 6.0.0, run as a library | Yes | passes the 2 cases that show it working |
| alacritty_terminal | 0.26.0, run as a library | Partly | fails SM-1 of the 2 cases that show it working |
| ConEmu | build 230724, its documentation | Partly | lists only 20 (LNM) and its own 7, line wrapping at a column; ANSI escape codes |
| rxvt-unicode | 9.31, run in a VM | No | fails the 2 cases that show it working |
| VTE | 0.84.1, run as a library | Partly | fails 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