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

Method repeatPrecedingCharacter

src/common/InputHandler.ts:1615–1640  ·  view source on GitHub ↗

* CSI Ps b Repeat the preceding graphic character Ps times (REP). * From ECMA 48 (@see http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf) * Notation: (Pn) * Representation: CSI Pn 06/02 * Parameter default value: Pn = 1 * REP is used to indicate th

(params: IParams)

Source from the content-addressed store, hash-verified

1613 * (NOOP for any other sequence in between or NON ASCII characters).
1614 */
1615 public repeatPrecedingCharacter(params: IParams): boolean {
1616 const joinState = this._parser.precedingJoinState;
1617 if (!joinState) {
1618 return true;
1619 }
1620 // call print to insert the chars and handle correct wrapping
1621 const length = params.params[0] || 1;
1622 const chWidth = UnicodeService.extractWidth(joinState);
1623 const x = this._activeBuffer.x - chWidth;
1624 const bufferRow = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y)!;
1625 const text = bufferRow.getString(x);
1626 const data = new Uint32Array(text.length * length);
1627 let idata = 0;
1628 for (let itext = 0; itext < text.length;) {
1629 const ch = text.codePointAt(itext) || 0;
1630 data[idata++] = ch;
1631 itext += ch > 0xffff ? 2 : 1;
1632 }
1633 let tlength = idata;
1634 for (let i = 1; i < length; ++i) {
1635 data.copyWithin(tlength, 0, idata);
1636 tlength += idata;
1637 }
1638 this.print(data, 0, tlength);
1639 return true;
1640 }
1641
1642 /**
1643 * CSI Ps c Send Device Attributes (Primary DA).

Callers 1

constructorMethod · 0.95

Calls 4

printMethod · 0.95
extractWidthMethod · 0.80
getMethod · 0.65
getStringMethod · 0.65

Tested by

no test coverage detected