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

Method insertCells

src/common/buffer/BufferLine.ts:256–282  ·  view source on GitHub ↗
(pos: number, n: number, fillCellData: ICellData)

Source from the content-addressed store, hash-verified

254 }
255
256 public insertCells(pos: number, n: number, fillCellData: ICellData): void {
257 pos %= this.length;
258
259 // handle fullwidth at pos: reset cell one to the left if pos is second cell of a wide char
260 if (pos && this.getWidth(pos - 1) === 2) {
261 this.setCellFromCodepoint(pos - 1, 0, 1, fillCellData);
262 }
263
264 if (n < this.length - pos) {
265 const cell = new CellData();
266 for (let i = this.length - pos - n - 1; i >= 0; --i) {
267 this.setCell(pos + n + i, this.loadCell(pos + i, cell));
268 }
269 for (let i = 0; i < n; ++i) {
270 this.setCell(pos + i, fillCellData);
271 }
272 } else {
273 for (let i = pos; i < this.length; ++i) {
274 this.setCell(i, fillCellData);
275 }
276 }
277
278 // handle fullwidth at line end: reset last cell if it is first cell of a wide char
279 if (this.getWidth(this.length - 1) === 2) {
280 this.setCellFromCodepoint(this.length - 1, 0, 1, fillCellData);
281 }
282 }
283
284 public deleteCells(pos: number, n: number, fillCellData: ICellData): void {
285 pos %= this.length;

Callers

nothing calls this directly

Calls 4

getWidthMethod · 0.95
setCellFromCodepointMethod · 0.95
setCellMethod · 0.95
loadCellMethod · 0.95

Tested by

no test coverage detected