ED Erase in Display
Erase part or all of the screen.
CSI Ps J
- Defaults
- Ps = 0
- ECMA-48
- §8.3.39 ED – Erase in Page, p. 41
- DEC STD 070
- §5.11 Erase in Display, p. 5-156
- VT510
- ED—Erase in Display
Erase some of the screen, chosen by Ps:
Ps | Erases |
|---|---|
0 | from the cursor to the end of the screen, the cursor’s cell included |
1 | from the start of the screen to the cursor, the cursor’s cell included |
2 | the whole screen |
3 | the scrollback, which is not on the screen (an xterm extension) |
The cursor does not move. Erasing ignores the margins; it is the screen that is erased, not the scrolling region.
An erased cell takes the current background color, set with SGR, rather than the default. That is background color erase, and is why programs reset SGR before clearing the screen.
Validation
ED-1: Below
\e#8 # fill with E
\e[2;2H
\e[J
|EEEE|
|E___|
|____|
cursor 2,2
ED-2: Above
\e#8 # fill with E
\e[2;2H
\e[1J
|____|
|__EE|
|EEEE|
cursor 2,2
ED-3: Everything
\e#8 # fill with E
\e[2;2H
\e[2J
|____|
|____|
|____|
cursor 2,2
ED-4: With a background color
\e[44m # blue background
\e[2J
|____|
|____|
attr 1,1 bg=4
attr 2,4 bg=4