SPA Start of Guarded Area
Mark the characters written in between as protected from erasure.
ESC V
ESC V (SPA) starts a guarded area, and ESC W (EPA, ECMA-48 §8.3.46, p. 43) ends it. The characters written between them are guarded. ECMA-48 defines a guarded area as a protected one (§6.5.2.2, p. 19): its contents are protected against “manual alteration”, that is, from the keyboard, and may be protected against erasure, depending on the erasure mode, ERM. ERM’s reset state, which is the default, is PROTECT: “Only the contents of unprotected areas are affected by an erasure control function”, meaning EL, ED and ECH (§7.2.4, p. 22).
So in practice a guarded character survives erasing. It is not protected from anything else: a character written over it replaces it, and DCH, which deletes rather than erases, moves it along with the rest of the line.
DECSCA (CSI Ps " q) is DEC’s own way of protecting characters (DEC STD 070 §5.11.1, p. 5-166, VT510 DECSCA), and it works the other way round. A character protected with DECSCA survives only the selective erases, DECSEL (CSI ? K) and DECSED (CSI ? J), and is erased by EL and ED like any other. xterm keeps the two kinds apart: SPA sets its ISO protection (CASE_SPA), which every erase respects, while for DEC protection an ordinary erase switches protection off for its duration (do_erase_line). libghostty-vt does the same.
SPA and EPA are C1 controls, with single-byte forms 96 and 97 that libghostty-vt, decoding its input as UTF-8, does not accept. Neither DEC STD 070 nor the VT510 manual defines them.
Validation
SPA-1: EL does not erase a guarded area
AB
\eV # start of guarded area
CD
\eW # end of guarded area
EF
\e[1;1H
\e[K
|__CD__|
SPA-2: Nor does ED
AB\eVCD\eWEF
\e[2J
|__CD__|
|______|
SPA-3: Nor does ECH
AB\eVCD\eWEF
\e[1;1H
\e[6X
|__CD__|
SPA-4: Writing over it is allowed
AB\eVCD\eWEF
\e[1;3H
XY
|ABXYEF|
SPA-5: Deleting is not erasing
AB\eVCD\eWEF
\e[1;1H
\e[P # DCH
|BCDEF_|
SPA-6: DECSCA protection does not stop EL
AB
\e[1"q # DECSCA: protected
CD
\e[0"q # DECSCA: not protected
EF
\e[1;1H
\e[K
|______|
SPA-7: It stops a selective erase
AB\e[1"qCD\e[0"qEF
\e[1;1H
\e[?K # DECSEL
|__CD__|