DECCRA / DECFRA / DECERA / DECSERA — Copy / Fill / Erase / Selective-erase rectangular area
The four content-side rectangle ops missing from the DEC rect family — copy a block, fill it with a glyph, erase to space, or erase only non-protected cells. Pairs with DECCARA / DECRARA (attribute-side) and DECSACE (block-vs-stream toggle).
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\x1b[<Pts>;<Pls>;<Pbs>;<Prs>;<Pps>;<Ptd>;<Pld>;<Ppd>$v DECCRA\n\x1b[<Pch>;<Pt>;<Pl>;<Pb>;<Pr>$x DECFRA\n\x1b[<Pt>;<Pl>;<Pb>;<Pr>$z DECERA\n\x1b[<Pt>;<Pl>;<Pb>;<Pr>${ DECSERA\033[1;1;10;40;1;15;5;1$v / \033[42;3;5;10;40$x / \033[3;5;10;40$z / \033[3;5;10;40${\e[1;1;10;40;1;15;5;1$v / \e[42;3;5;10;40$x / \e[3;5;10;40$z / \e[3;5;10;40${ESC [ Pts;Pls;Pbs;Prs;Pps;Ptd;Pld;Ppd $ v / $ x / $ z / $ {1b 5b … 24 76 / 1b 5b … 24 78 / 1b 5b … 24 7a / 1b 5b … 24 7bDescription
Four DEC ops sharing the `$` intermediate that *do* touch character data inside a rectangle — DECCARA / DECRARA only re-attribute. Each rectangle uses 1-indexed inclusive coordinates and obeys the current scroll region + origin mode. Block-vs-stream interpretation of the rectangle is selected by **DECSACE** (`\x1b[Ps*x`). **DECCRA** — *Copy Rectangular Area*, `$v`. Eight parameters: source rect (`Pts;Pls;Pbs;Prs;Pps`), then destination top-left (`Ptd;Pld;Ppd`). `Pps`/`Ppd` are page numbers (1 on every modern single-page emulator — DEC VT525 had multi-page memory). The op is a *cell-for-cell* copy: characters + their per-cell attributes move together; cells outside the destination's visible area are clipped, not wrapped. Overlapping source / destination is handled correctly (terminals typically copy through an internal scratch buffer so a top-to-bottom shift is safe). **DECFRA** — *Fill Rectangular Area*, `$x`. Five parameters: the glyph code (`Pch`, a 7-bit decimal code 32–126; or a 16-bit code on UTF-8-aware emulators), then `Pt;Pl;Pb;Pr` rectangle. Every cell is overwritten with the glyph, gaining the *current* SGR pen as its attributes. Common uses: clear an inset to a single character (DECFRA with `Pch=32` is the per-rect equivalent of `clear`), draw a solid frame with `█` (U+2588) on a UTF-8 emulator, or pre-fill scratch panes. **DECERA** — *Erase Rectangular Area*, `$z`. Four parameters: the rectangle. Equivalent to DECFRA with `Pch=32` (space) *and* the cell attributes reset to default — so it leaves a *fully cleared* rect, not a 'spaces with current pen'. The reset includes the SGR layer, foreground/background colour, and the selective-erase protection bit. **DECSERA** — *Selective Erase Rectangular Area*, `${`. Four parameters: the rectangle. Like DECERA *but* respects the **DECSCA-protected** bit: cells that were marked protected via `\x1b[1"q` survive. The other cells clear to space + default attrs. This is the rect-form of `decsed-decsel` (selective ED / EL) and the only way to clear a form template without wiping the labels. **Stream mode (DECSACE)**. With `\x1b[2*x` in effect, `Pt;Pl` and `Pb;Pr` are interpreted as stream-start and stream-end positions instead of rectangle corners — the affected cells are every cell between the two positions following normal text-flow (line-wrap aware). Stream-mode is **only** wired through DECCARA / DECRARA on every shipping emulator; the four content ops above keep block semantics regardless of DECSACE. This is a *DEC-vs-VT510* deviation in xterm and family — verify with DECRQM `?92` if you need to depend on it. **Coverage**: **xterm** = full all four. **Konsole** = full. **WezTerm** + **Ghostty** = full (DECFRA + DECERA), DECCRA + DECSERA partial. **gnome-terminal** + **mlterm** = full. **iTerm2** = partial (no DECSERA, others honour current SGR pen rather than reset). **Kitty** = DECERA + DECFRA full, DECCRA + DECSERA no-op. **Alacritty** + **Windows Terminal** + **cmd / ConPTY** + **Linux console** + **macOS Terminal** = no-op (silently consumed). Feature-probe with `xtversion` plus a DECRQSS round-trip on `$z` before relying.
Spec citation: DEC VT510 RM (DECCRA / DECFRA / DECERA / DECSERA) / xterm-ctlseqs (CSI ... $ v / x / z / {)
Parameters
| Pts;Pls;Pbs;Prs;Pps (DECCRA) | Source rectangle top / left / bottom / right / page (1-indexed, inclusive). |
| Ptd;Pld;Ppd (DECCRA) | Destination top-left row / col / page. |
| Pch (DECFRA) | Glyph code to fill with — 32–126 (7-bit ASCII) on classic DEC; many modern emulators accept up to U+FFFF. |
| Pt;Pl;Pb;Pr (DECFRA / DECERA / DECSERA) | Rectangle top row / left col / bottom row / right col, 1-indexed inclusive. |
Examples
# Copy rows 1-5 cols 1-40 to rows 20-24 cols 41-80.\nprintf '\\033[1;1;5;40;1;20;41;1$v'\n# Fill a status bar with U+2588 (decimal 9608) — needs UTF-8 emulator.\nprintf '\\033[9608;24;1;24;80$x'\n# Erase rows 5-10 cols 5-75 (clear an inset region).\nprintf '\\033[5;5;10;75$z'import sys\n# Form-field clear: keep DECSCA-protected labels, clear data cells.\nsys.stdout.write('\\x1b[3;10;20;70${') # DECSERA\nsys.stdout.flush()// Pre-fill a help pane with '·' (decimal 183) before drawing content.\nfmt.Print(\"\\x1b[183;1;1;24;80$x\")// 'Reset the canvas inset' — DECERA wipes both glyph + attrs to default.\nprocess.stdout.write('\\x1b[2;2;23;79$z');/* Duplicate a logo block from rows 1-6 cols 1-30 to a side panel. */\nprintf(\"\\x1b[1;1;6;30;1;1;51;1$v\");Terminal support
- xterm
- yes
- Linux console (fbcon)
- no
- macOS Terminal.app
- no
- iTerm2
- partial
- Windows Terminal
- no
- cmd.exe / ConPTY
- no
- kitty
- partial
- alacritty
- no
- WezTerm
- partial
- Ghostty
- partial
- GNOME Terminal
- yes
- Konsole
- yes
- tmux
- no
- GNU screen
- no
| xterm | Linux console (fbcon) | macOS Terminal.app | iTerm2 | Windows Terminal | cmd.exe / ConPTY | kitty | alacritty | WezTerm | Ghostty | GNOME Terminal | Konsole | tmux | GNU screen |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| yes | no | no | partial | no | no | partial | no | partial | partial | yes | yes | no | no |