MCPcopy Index your code
hub / github.com/xtermjs/xterm.js / replaceCells

Method replaceCells

src/common/buffer/BufferLine.ts:311–341  ·  view source on GitHub ↗
(start: number, end: number, fillCellData: ICellData, respectProtect: boolean = false)

Source from the content-addressed store, hash-verified

309 }
310
311 public replaceCells(start: number, end: number, fillCellData: ICellData, respectProtect: boolean = false): void {
312 // full branching on respectProtect==true, hopefully getting fast JIT for standard case
313 if (respectProtect) {
314 if (start && this.getWidth(start - 1) === 2 && !this.isProtected(start - 1)) {
315 this.setCellFromCodepoint(start - 1, 0, 1, fillCellData);
316 }
317 if (end < this.length && this.getWidth(end - 1) === 2 && !this.isProtected(end)) {
318 this.setCellFromCodepoint(end, 0, 1, fillCellData);
319 }
320 while (start < end && start < this.length) {
321 if (!this.isProtected(start)) {
322 this.setCell(start, fillCellData);
323 }
324 start++;
325 }
326 return;
327 }
328
329 // handle fullwidth at start: reset cell one to the left if start is second cell of a wide char
330 if (start && this.getWidth(start - 1) === 2) {
331 this.setCellFromCodepoint(start - 1, 0, 1, fillCellData);
332 }
333 // handle fullwidth at last cell + 1: reset to empty cell if it is second part of a wide char
334 if (end < this.length && this.getWidth(end - 1) === 2) {
335 this.setCellFromCodepoint(end, 0, 1, fillCellData);
336 }
337
338 while (start < end && start < this.length) {
339 this.setCell(start++, fillCellData);
340 }
341 }
342
343 /**
344 * Resize BufferLine to `cols` filling excess cells with `fillCellData`.

Callers

nothing calls this directly

Calls 4

getWidthMethod · 0.95
isProtectedMethod · 0.95
setCellFromCodepointMethod · 0.95
setCellMethod · 0.95

Tested by

no test coverage detected