^[control-codes live in libghostty-vt
View as Markdown

Whether the terminal or the host handles bidirectional text.

CSI 8 h/l
ECMA-48
§7.2.1 BDSM – Bi-directional Support Mode, p. 21

Mode 8 is one of the two modes the fifth edition of ECMA-48 added for bidirectional text. Reset, control functions act on the presentation or the data according to DCSM; set, they act on the data, and the device handles the bidirectional aspects of the text itself.

StateECMA-48 calls itMeaning
Reset, CSI 8 lEXPLICITcontrol functions act where DCSM says
Set, CSI 8 hIMPLICITcontrol functions act on the data, and the device handles bidirectional text itself

BiDi in Terminal Emulators, Egmont Koblinger’s recommendation for right-to-left text in terminals, keeps BDSM as the switch between the two modes but makes set, implicit, the default, so a reset sets it, as it does a few other modes that start out set. In implicit mode the terminal runs the Unicode Bidirectional Algorithm over each paragraph; in explicit mode it shows the text in the direction SCP set and leaves the rest to the program. A program that wants implicit mode leaves the mode alone. One that wants explicit mode resets it when it starts, sets a direction with SCP too, and sets the mode again on exit. The mode is kept for each paragraph, as the BiDi modes page describes under “How the sequences apply”.

VTE implements the recommendation’s BDSM, set by default, and answers DECRQM with 1 to begin with. mintty documents CSI 8 h and CSI 8 l the same way (documentation).

Neither xterm nor libghostty-vt implements it. Both ignore CSI 8 h and CSI 8 l, and both answer DECRQM with 0, not recognized: the mode is not among the ones xterm’s do_ansi_rqm answers for.

Support

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984Nonot in the manual, whose table of ANSI modes has only KAM, IRM, SRM and LNM
VT510manual, 1st ed., 1993Nonot in the manual
xtermpatch 412, xterm-411aNoignored; DECRQM answers 0
libghostty-vt919dca5Noignored; DECRQM answers 0
ConEmubuild 230724, its documentationNonot in its ANSI escape codes
mintty3.8.3, its documentationYesimplicit and explicit (documentation)
VTE0.84.1, sourceYesset by default, as the BiDi recommendation has it; DECRQM answers 1 (source)

Validation

BDSM-1: Not recognized

\e[8$p
|_____|
reply \e[8;0$y

BDSM-2: Not recognized after it is set, either

\e[8h
\e[8$p
|_____|
reply \e[8;0$y
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.