Skip to main content
ansicode

DECSCA — Select character protection attribute (CSI Ps " q)

Mark subsequently-written cells as DECSED/DECSEL-protected (Ps=1) or unprotected (Ps=0/2).

Byte forms

Every common string-literal form so you can paste-and-search either direction.

\\x1b[\x1b[<Ps>"q
\\033[\033[1"q
\\e[\e[1"q
ESC [ESC [ Ps " q
hex1b 5b ... 22 71

Description

Select Character Protection Attribute — toggles the protection bit that DECSED (`\x1b[?<Ps>J`) and DECSEL (`\x1b[?<Ps>K`) honour. `Ps=0` (default) marks following cells unprotected; `Ps=1` marks them protected; `Ps=2` is the explicit unprotected synonym (per DEC STD 070). The intermediate byte is **literal `"` (0x22)** — easy to typo as the parameter byte. Once a region is painted with protected cells, DECSED / DECSEL skip those cells during a selective erase, while plain ED / EL still clear them. DEC's data-entry forms model used this pair to render immutable labels and accept user input in the gaps without redrawing labels on every clear. Modern emulators that don't track DECSCA at all (alacritty, wezterm, ghostty, kitty pre-0.32) silently no-op DECSCA and treat DECSED/DECSEL as plain ED/EL — design forms expecting that fallback or detect via DECRQSS (DCS $q"q). Most TUI authors today reach for a render diff in user-space instead of relying on DECSCA round-trips through the terminal.

Spec citation: DEC STD 070 (DECSCA) / DEC VT510 RM

Parameters

Ps`0` (default) unprotected · `1` protected · `2` unprotected (synonym, per DEC STD 070).

Examples

bash
# Protect the next bytes, write a label, accept input in the gap:\nprintf '\033[1"qLabel: \033[0"q'\n# now any user input written here is in an unprotected cell\nprintf '\033[?2K'    # selective EL: clears input only
python
import sys\nsys.stdout.write('\x1b[1"qStatic\x1b[0"q dynamic')   # 'Static' is DECSED/DECSEL-protected
go
fmt.Print("\x1b[1\"qHeader\x1b[0\"q body")
javascript
process.stdout.write('\x1b[1"qHeader\x1b[0"q body')
c
printf("\x1b[1\"qHeader\x1b[0\"q body\n");

Terminal support

xterm
yes
Linux console (fbcon)
no
macOS Terminal.app
partial
iTerm2
partial
Windows Terminal
no
cmd.exe / ConPTY
no
kitty
no
alacritty
no
WezTerm
no
Ghostty
no
GNOME Terminal
partial
Konsole
partial
tmux
no
GNU screen
no

Related sequences