^[control-codes
live in libghostty-vt

Private modes

?2004 Bracketed Paste

View as Markdown

Mark pasted text, so that a program can tell it from typing.

CSI ? 2004 h/l
xterm
Bracketed Paste Mode

With CSI ? 2004 h set, the terminal puts CSI 200 ~ before anything pasted into it and CSI 201 ~ after, so a program can tell a paste from typing: a shell need not run each pasted line as it arrives, and an editor need not auto-indent pasted code. CSI ? 2004 l stops it. It is xterm’s (dpmodes, the paste itself).

The brackets are only as safe as the paste between them: a pasted CSI 201 ~ would end the bracket early. A default xterm removes ESC from a paste before sending it, along with BS, DEL, ENQ, EOT, NUL and the characters the terminal driver treats specially, unless its allowPasteControls resource is set (removeControls, DEF_DISALLOWED_PASTE_CONTROLS).

It is off to begin with, DECSTR leaves it alone, and RIS turns it off (ReallyReset). A paste comes from the window, not from the data a case writes, so the cases check what DECRQM says. libghostty-vt passes them.

Support

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984Nonot in the manual
VT510manual, 1st ed., 1993Nonot in the manual; not in Table 5-6
xtermpatch 412, xterm-411aYes
libghostty-vt0f171f6Yes
kitty0.49.1, run in a VMYespasses the 3 cases that show it working
foot1.28.0, run in a VMYespasses the 3 cases that show it working
xterm.js headless6.0.0, run as a libraryYespasses the 3 cases that show it working
alacritty_terminal0.26.0, run as a libraryYespasses the 3 cases that show it working
ConEmubuild 230724, its documentationYesANSI escape codes
rxvt-unicode9.31, run in a VMPartlyfails PASTE-4 of the 3 cases that show it working
VTE0.84.1, run as a libraryYespasses the 3 cases that show it working

Validation

PASTE-1: Off to begin with

\e[?2004$p
|____|
reply \e[?2004;2$y

PASTE-2: Set and reset

\e[?2004h
\e[?2004$p
\e[?2004l
\e[?2004$p
|____|
reply \e[?2004;1$y\e[?2004;2$y

PASTE-3: DECSTR leaves it on

\e[?2004h
\e[!p
\e[?2004$p
|____|
reply \e[?2004;1$y

PASTE-4: RIS turns it off

\e[?2004h
\ec
\e[?2004$p
|____|
reply \e[?2004;2$y
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.