MCPcopy
hub / github.com/xtermjs/xterm.js / eraseInDisplay

Method eraseInDisplay

src/common/InputHandler.ts:1198–1261  ·  view source on GitHub ↗

* CSI Ps J Erase in Display (ED). * Ps = 0 -> Erase Below (default). * Ps = 1 -> Erase Above. * Ps = 2 -> Erase All. * Ps = 3 -> Erase Saved Lines (xterm). * CSI ? Ps J * Erase in Display (DECSED). * Ps = 0 -> Selective Erase Below (default). *

(params: IParams, respectProtect: boolean = false)

Source from the content-addressed store, hash-verified

1196 * @vt: #Y CSI DECSED "Selective Erase In Display" "CSI ? Ps J" "Same as ED with respecting protection flag."
1197 */
1198 public eraseInDisplay(params: IParams, respectProtect: boolean = false): boolean {
1199 this._restrictCursor(this._bufferService.cols);
1200 let j;
1201 switch (params.params[0]) {
1202 case 0:
1203 j = this._activeBuffer.y;
1204 this._dirtyRowTracker.markDirty(j);
1205 this._eraseInBufferLine(j++, this._activeBuffer.x, this._bufferService.cols, this._activeBuffer.x === 0, respectProtect);
1206 for (; j < this._bufferService.rows; j++) {
1207 this._resetBufferLine(j, respectProtect);
1208 }
1209 this._dirtyRowTracker.markDirty(j);
1210 break;
1211 case 1:
1212 j = this._activeBuffer.y;
1213 this._dirtyRowTracker.markDirty(j);
1214 // Deleted front part of line and everything before. This line will no longer be wrapped.
1215 this._eraseInBufferLine(j, 0, this._activeBuffer.x + 1, true, respectProtect);
1216 if (this._activeBuffer.x + 1 >= this._bufferService.cols) {
1217 // Deleted entire previous line. This next line can no longer be wrapped.
1218 this._activeBuffer.lines.get(j + 1)!.isWrapped = false;
1219 }
1220 while (j--) {
1221 this._resetBufferLine(j, respectProtect);
1222 }
1223 this._dirtyRowTracker.markDirty(0);
1224 break;
1225 case 2:
1226 if (this._optionsService.rawOptions.scrollOnEraseInDisplay) {
1227 j = this._bufferService.rows;
1228 this._dirtyRowTracker.markRangeDirty(0, j - 1);
1229 while (j--) {
1230 const currentLine = this._activeBuffer.lines.get(this._activeBuffer.ybase + j);
1231 if (currentLine?.getTrimmedLength()) {
1232 break;
1233 }
1234 }
1235 for (; j >= 0; j--) {
1236 this._bufferService.scroll(this._eraseAttrData());
1237 }
1238 }
1239 else {
1240 j = this._bufferService.rows;
1241 this._dirtyRowTracker.markDirty(j - 1);
1242 while (j--) {
1243 this._resetBufferLine(j, respectProtect);
1244 }
1245 this._dirtyRowTracker.markDirty(0);
1246 }
1247 break;
1248 case 3:
1249 // Clear scrollback (everything not in viewport)
1250 const scrollBackSize = this._activeBuffer.lines.length - this._bufferService.rows;
1251 if (scrollBackSize > 0) {
1252 this._activeBuffer.lines.trimStart(scrollBackSize);
1253 this._activeBuffer.ybase = Math.max(this._activeBuffer.ybase - scrollBackSize, 0);
1254 this._activeBuffer.ydisp = Math.max(this._activeBuffer.ydisp - scrollBackSize, 0);
1255 // Force a scroll event to refresh viewport

Callers 1

constructorMethod · 0.95

Calls 11

_restrictCursorMethod · 0.95
_eraseInBufferLineMethod · 0.95
_resetBufferLineMethod · 0.95
_eraseAttrDataMethod · 0.95
markDirtyMethod · 0.65
getMethod · 0.65
markRangeDirtyMethod · 0.65
getTrimmedLengthMethod · 0.65
scrollMethod · 0.65
trimStartMethod · 0.65
fireMethod · 0.45

Tested by

no test coverage detected