From edee1a106788e839651c1bc12269bd375d695d0d Mon Sep 17 00:00:00 2001 From: Mmis1000 Date: Sun, 13 Sep 2020 21:33:32 +0800 Subject: [PATCH 001/377] Handle alt screen --- .../src/SerializeAddon.ts | 28 +++++++++++++--- .../test/SerializeAddon.api.ts | 32 +++++++++++++++++++ 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index dad6aa4f..ba366c37 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -11,6 +11,11 @@ function constrain(value: number, low: number, high: number): number { return Math.max(low, Math.min(value, high)); } +interface ISerializeOptions { + withAlternate?: boolean; + +} + // TODO: Refine this template class later abstract class BaseSerializeHandler { constructor(private _buffer: IBuffer) { } @@ -167,7 +172,7 @@ export class SerializeAddon implements ITerminalAddon { this._terminal = terminal; } - public serialize(rows?: number): string { + public serialize(rows?: number, options: ISerializeOptions = {}): string { // TODO: Add re-position cursor support // TODO: Add word wrap mode support // TODO: Add combinedData support @@ -175,12 +180,25 @@ export class SerializeAddon implements ITerminalAddon { throw new Error('Cannot use addon until it has been loaded'); } - const maxRows = this._terminal.buffer.active.length; - const handler = new StringSerializeHandler(this._terminal.buffer.active); + if (this._terminal.buffer.active.type === 'normal' || !(options?.withAlternate ?? false)) { + const maxRows = this._terminal.buffer.active.length; + const handler = new StringSerializeHandler(this._terminal.buffer.active); - rows = (rows === undefined) ? maxRows : constrain(rows, 0, maxRows); + rows = (rows === undefined) ? maxRows : constrain(rows, 0, maxRows); - return handler.serialize(maxRows - rows, maxRows); + return handler.serialize(maxRows - rows, maxRows); + } + + const maxNormalRows = this._terminal.buffer.normal.length; + const maxAltRows = this._terminal.buffer.alternate.length; + const normalHandler = new StringSerializeHandler(this._terminal.buffer.normal); + const altHandler = new StringSerializeHandler(this._terminal.buffer.alternate); + const normalRows = (rows === undefined) ? maxNormalRows : constrain(rows, 0, maxNormalRows); + const altRows = (rows === undefined) ? maxAltRows : constrain(rows, 0, maxAltRows); + + return normalHandler.serialize(maxNormalRows - normalRows, maxNormalRows) + + '\u001b[?1049h\u001b[H' + + altHandler.serialize(maxAltRows - altRows, maxAltRows); } public dispose(): void { } diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index 5b615db1..32e816a1 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -299,6 +299,38 @@ describe('SerializeAddon', () => { await writeSync(page, lines.join('\\r\\n')); assert.equal(await page.evaluate(`serializeAddon.serialize();`), expected.join('\r\n')); }); + + it('serialize with alt screen correctly', async () => { + const SMCUP = '\u001b[?1049h'; + const CUP = '\u001b[H'; + + const lines = [ + `1${SMCUP}${CUP}2` + ]; + const expected = [ + `1${SMCUP}${CUP}2` + ]; + + await writeSync(page, lines.join('\\r\\n')); + assert.equal(JSON.stringify(await page.evaluate(`window.term.buffer.active.type`)), '"alternate"'); + assert.equal(JSON.stringify(await page.evaluate(`serializeAddon.serialize(undefined, { withAlternate: true });`)), JSON.stringify(expected.join('\r\n'))); + }); + + it('serialize without alt screen correctly', async () => { + const SMCUP = '\u001b[?1049h'; + const RMCUP = '\u001b[?1049l'; + + const lines = [ + `1${SMCUP}2${RMCUP}` + ]; + const expected = [ + `1` + ]; + + await writeSync(page, lines.join('\\r\\n')); + assert.equal(JSON.stringify(await page.evaluate(`window.term.buffer.active === window.term.buffer.alt`)), 'false'); + assert.equal(JSON.stringify(await page.evaluate(`serializeAddon.serialize(undefined, { withAlternate: true });`)), JSON.stringify(expected.join('\r\n'))); + }); }); function newArray(initial: T | ((index: number) => T), count: number): T[] { From 881a4a0dbb838231d9ed44450e539bd426d44417 Mon Sep 17 00:00:00 2001 From: mmis1000 Date: Tue, 15 Sep 2020 17:58:56 +0800 Subject: [PATCH 002/377] Try implement cursor restortion --- .../src/SerializeAddon.ts | 110 ++++++++++++++---- demo/client.ts | 2 +- 2 files changed, 89 insertions(+), 23 deletions(-) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index ba366c37..e03707e0 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -13,7 +13,7 @@ function constrain(value: number, low: number, high: number): number { interface ISerializeOptions { withAlternate?: boolean; - + withCursor?: boolean; } // TODO: Refine this template class later @@ -26,7 +26,7 @@ abstract class BaseSerializeHandler { const cell2 = this._buffer.getNullCell(); let oldCell = cell1; - this._beforeSerialize(endRow - startRow); + this._beforeSerialize(endRow - startRow, startRow, endRow); for (let row = startRow; row < endRow; row++) { const line = this._buffer.getLine(row); @@ -51,7 +51,7 @@ abstract class BaseSerializeHandler { protected _nextCell(cell: IBufferCell, oldCell: IBufferCell, row: number, col: number): void { } protected _rowEnd(row: number): void { } - protected _beforeSerialize(rows: number): void { } + protected _beforeSerialize(rows: number, startRow: number, endRow: number): void { } protected _afterSerialize(): void { } protected _serializeString(): string { return ''; } } @@ -82,12 +82,16 @@ class StringSerializeHandler extends BaseSerializeHandler { private _currentRow: string = ''; private _nullCellCount: number = 0; - constructor(buffer: IBuffer) { - super(buffer); + private _lastContentCellRow: number = 0; + private _lastContentCellCol: number = 0; + + constructor(private _buffer1: IBuffer,private _terminal: Terminal, private _option: ISerializeOptions = {}) { + super(_buffer1); } - protected _beforeSerialize(rows: number): void { + protected _beforeSerialize(rows: number, start: number, end: number): void { this._allRows = new Array(rows); + this._lastContentCellRow = start; } protected _rowEnd(row: number): void { @@ -147,6 +151,9 @@ class StringSerializeHandler extends BaseSerializeHandler { } else if (this._nullCellCount > 0) { this._currentRow += `\x1b[${this._nullCellCount}C`; this._nullCellCount = 0; + } else { + this._lastContentCellRow = row; + this._lastContentCellCol = col + cell.getWidth(); } this._currentRow += cell.getChars(); @@ -154,12 +161,71 @@ class StringSerializeHandler extends BaseSerializeHandler { protected _serializeString(): string { let rowEnd = this._allRows.length; + for (; rowEnd > 0; rowEnd--) { if (this._allRows[rowEnd - 1]) { break; } } - return this._allRows.slice(0, rowEnd).join('\r\n'); + + let content = this._allRows.slice(0, rowEnd).join('\r\n'); + + if (this._option.withCursor) { + const realCursorRow = this._buffer1.baseY + this._buffer1.cursorY; + const realCursorCol = this._buffer1.cursorX; + + const hasScroll = this._buffer1.length > this._terminal.rows!; + const hasEmptyLine = hasScroll ? (this._buffer1.length - 1 > this._lastContentCellRow) : (realCursorRow > this._lastContentCellRow); + const cursorMoved = + hasScroll + ? hasEmptyLine + ? (realCursorCol !== 0 || realCursorRow !== this._buffer1.length - 1) + : (realCursorRow !== this._lastContentCellRow || realCursorCol !== this._lastContentCellCol) + : hasEmptyLine + // we don't need to check the row because empty row count are based on cursor + ? realCursorCol !== 0 + : (realCursorRow !== this._lastContentCellRow || realCursorCol !== this._lastContentCellCol); + + const moveRight = (offset: number): void => { + if (offset > 0) { + content += `\u001b[${offset}C`; + } else if (offset < 0) { + content += `\u001b[${-offset}D`; + } + }; + const moveDown = (offset: number): void => { + if (offset > 0) { + content += `\u001b[${offset}B`; + } else if (offset < 0) { + content += `\u001b[${-offset}A`; + } + }; + + // Fix empty lines + if (hasEmptyLine) { + if (hasScroll) { + content += '\r\n'.repeat(this._buffer1.length - 1 - this._lastContentCellRow); + } else { + content += '\r\n'.repeat(realCursorRow - this._lastContentCellRow); + } + } + + if (cursorMoved) { + if (hasEmptyLine) { + if (hasScroll) { + moveRight(realCursorCol); + moveDown(realCursorRow - (this._buffer1.length - 1)); + } else { + moveRight(realCursorCol); + } + } else { + moveDown(realCursorRow - this._lastContentCellRow); + moveRight(realCursorCol - this._lastContentCellCol); + } + } + } + + return content; } } @@ -172,6 +238,15 @@ export class SerializeAddon implements ITerminalAddon { this._terminal = terminal; } + private _getString(buffer: IBuffer, rows?: number, option?: ISerializeOptions): string { + const maxRows = buffer.length; + const handler = new StringSerializeHandler(buffer, this._terminal!, option); + const correctRows = (rows === undefined) ? maxRows : constrain(rows, 0, maxRows); + const result = handler.serialize(maxRows - correctRows, maxRows); + + return result; + } + public serialize(rows?: number, options: ISerializeOptions = {}): string { // TODO: Add re-position cursor support // TODO: Add word wrap mode support @@ -180,25 +255,16 @@ export class SerializeAddon implements ITerminalAddon { throw new Error('Cannot use addon until it has been loaded'); } - if (this._terminal.buffer.active.type === 'normal' || !(options?.withAlternate ?? false)) { - const maxRows = this._terminal.buffer.active.length; - const handler = new StringSerializeHandler(this._terminal.buffer.active); - - rows = (rows === undefined) ? maxRows : constrain(rows, 0, maxRows); - - return handler.serialize(maxRows - rows, maxRows); + if (this._terminal.buffer.active.type === 'normal' || !(options.withAlternate ?? false)) { + return this._getString(this._terminal.buffer.active, rows, options); } - const maxNormalRows = this._terminal.buffer.normal.length; - const maxAltRows = this._terminal.buffer.alternate.length; - const normalHandler = new StringSerializeHandler(this._terminal.buffer.normal); - const altHandler = new StringSerializeHandler(this._terminal.buffer.alternate); - const normalRows = (rows === undefined) ? maxNormalRows : constrain(rows, 0, maxNormalRows); - const altRows = (rows === undefined) ? maxAltRows : constrain(rows, 0, maxAltRows); + const normalScreenContent = this._getString(this._terminal.buffer.normal, rows, options); + const alternativeScreenContent = this._getString(this._terminal.buffer.alternate, rows, options); - return normalHandler.serialize(maxNormalRows - normalRows, maxNormalRows) + return normalScreenContent + '\u001b[?1049h\u001b[H' - + altHandler.serialize(maxAltRows - altRows, maxAltRows); + + alternativeScreenContent; } public dispose(): void { } diff --git a/demo/client.ts b/demo/client.ts index 6efa181a..509b73a9 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -413,7 +413,7 @@ function updateTerminalSize(): void { } function serializeButtonHandler(): void { - const output = addons.serialize.instance.serialize(); + const output = addons.serialize.instance.serialize(undefined, { withAlternate: true, withCursor: true }); const outputString = JSON.stringify(output); document.getElementById('serialize-output').innerText = outputString; From 00a8b80ef729c9ed89a44288425c592601be8df1 Mon Sep 17 00:00:00 2001 From: mmis1000 Date: Wed, 16 Sep 2020 14:28:08 +0800 Subject: [PATCH 003/377] Implement cursor adn alt screen. Fix background serialize --- .../src/SerializeAddon.ts | 168 +++++++++++++++--- .../test/SerializeAddon.api.ts | 18 ++ 2 files changed, 161 insertions(+), 25 deletions(-) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index e03707e0..3113777e 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -82,8 +82,16 @@ class StringSerializeHandler extends BaseSerializeHandler { private _currentRow: string = ''; private _nullCellCount: number = 0; - private _lastContentCellRow: number = 0; - private _lastContentCellCol: number = 0; + // this is a null cell for reference for checking whether background is empty or not + private _nullCell: IBufferCell = this._buffer1.getNullCell(); + + // we can see a full colored cell and a null cell that only have background the same style + // but the information isn't preserved by null cell itself + // so wee need to record it when required. + private _cursorStyle: IBufferCell = this._buffer1.getNullCell(); + + private _lastCursorRow: number = 0; + private _lastCursorCol: number = 0; constructor(private _buffer1: IBuffer,private _terminal: Terminal, private _option: ISerializeOptions = {}) { super(_buffer1); @@ -91,16 +99,35 @@ class StringSerializeHandler extends BaseSerializeHandler { protected _beforeSerialize(rows: number, start: number, end: number): void { this._allRows = new Array(rows); - this._lastContentCellRow = start; + this._lastCursorRow = start; } protected _rowEnd(row: number): void { + // if there is colorful empty cell at line end, whe must pad it back, or the the color block will missing + if (this._nullCellCount > 0 && !equalBg(this._cursorStyle, this._nullCell)) { + // use clear right to set background. + // use move right to move cursor. + this._currentRow += `\x1b[${this._nullCellCount}X`; + + // set the cursor back because we aren't there + this._lastCursorRow = row; + this._lastCursorCol = this._terminal.cols - this._nullCellCount; + + this._nullCellCount = 0; + + // perform a style reset before next line, + // because scroll when having background set will change the whole background of next line. + this._currentRow += `\x1b[m`; + // FIXME: we just get a new one because we can't reset it. + this._cursorStyle = this._buffer1.getNullCell(); + } + this._allRows[this._rowIndex++] = this._currentRow; this._currentRow = ''; this._nullCellCount = 0; } - protected _nextCell(cell: IBufferCell, oldCell: IBufferCell, row: number, col: number): void { + private _diffStyle (cell: IBufferCell, oldCell: IBufferCell): number[] { const sgrSeq: number[] = []; const fgChanged = !equalFg(cell, oldCell); const bgChanged = !equalBg(cell, oldCell); @@ -108,7 +135,9 @@ class StringSerializeHandler extends BaseSerializeHandler { if (fgChanged || bgChanged || flagsChanged) { if (cell.isAttributeDefault()) { - this._currentRow += '\x1b[0m'; + if (!oldCell.isAttributeDefault()) { + sgrSeq.push(0); + } } else { if (fgChanged) { const color = cell.getFgColor(); @@ -140,23 +169,76 @@ class StringSerializeHandler extends BaseSerializeHandler { } } - if (sgrSeq.length) { + return sgrSeq; + } + + protected _nextCell(cell: IBufferCell, oldCell: IBufferCell, row: number, col: number): void { + // a width 0 cell don't need to be count because it is just a placeholder after a CJK character; + const isPlaceHolderCell = cell.getWidth() === 0; + + if (isPlaceHolderCell) { + return; + } + + // this cell don't have content + const isEmptyCell = cell.getChars() === ''; + + // this cell don't have content and style + const isNullCell = cell.getWidth() === 1 && cell.getChars() === '' && cell.isAttributeDefault(); + + const sgrSeq = this._diffStyle(cell, this._cursorStyle); + + // the empty cell style is only assumed to be changed when background changed, because foreground is always 0. + const styleChanged = isEmptyCell ? !equalBg(this._cursorStyle, cell) : sgrSeq.length > 0; + + /** + * handles style change + */ + if (styleChanged) { + // before update the style, we need to fill empty cell back + if (this._nullCellCount > 0) { + // use clear right to set background. + // use move right to move cursor. + if (equalBg(this._cursorStyle, this._nullCell)) { + this._currentRow += `\x1b[${this._nullCellCount}C`; + } else { + this._currentRow += `\x1b[${this._nullCellCount}X`; + this._currentRow += `\x1b[${this._nullCellCount}C`; + } + this._nullCellCount = 0; + } + this._currentRow += `\x1b[${sgrSeq.join(';')}m`; + + // update the last cursor style + this._buffer1.getLine(row)?.getCell(col, this._cursorStyle); } - // Count number of null cells encountered after the last non-null cell and move the cursor - // if a non-null cell is found (eg. \t or cursor move) - if (cell.getChars() === '') { + /** + * handles actual content + */ + if (isEmptyCell) { this._nullCellCount += cell.getWidth(); - } else if (this._nullCellCount > 0) { - this._currentRow += `\x1b[${this._nullCellCount}C`; - this._nullCellCount = 0; } else { - this._lastContentCellRow = row; - this._lastContentCellCol = col + cell.getWidth(); + if (this._nullCellCount > 0) { + // we can just assume we have same style with previous one here + // because style change is handled by previous stage + // use move right when background is empty, use clear right when there is background. + if (equalBg(this._cursorStyle, this._nullCell)) { + this._currentRow += `\x1b[${this._nullCellCount}C`; + } else { + this._currentRow += `\x1b[${this._nullCellCount}X`; + this._currentRow += `\x1b[${this._nullCellCount}C`; + } + this._nullCellCount = 0; + } + this._currentRow += cell.getChars(); } - this._currentRow += cell.getChars(); + if (!isNullCell) { + this._lastCursorRow = row; + this._lastCursorCol = col + cell.getWidth(); + } } protected _serializeString(): string { @@ -170,21 +252,21 @@ class StringSerializeHandler extends BaseSerializeHandler { let content = this._allRows.slice(0, rowEnd).join('\r\n'); - if (this._option.withCursor) { + if (this._option.withCursor ?? true) { const realCursorRow = this._buffer1.baseY + this._buffer1.cursorY; const realCursorCol = this._buffer1.cursorX; const hasScroll = this._buffer1.length > this._terminal.rows!; - const hasEmptyLine = hasScroll ? (this._buffer1.length - 1 > this._lastContentCellRow) : (realCursorRow > this._lastContentCellRow); + const hasEmptyLine = hasScroll ? (this._buffer1.length - 1 > this._lastCursorRow) : (realCursorRow > this._lastCursorRow); const cursorMoved = hasScroll ? hasEmptyLine ? (realCursorCol !== 0 || realCursorRow !== this._buffer1.length - 1) - : (realCursorRow !== this._lastContentCellRow || realCursorCol !== this._lastContentCellCol) + : (realCursorRow !== this._lastCursorRow || realCursorCol !== this._lastCursorCol) : hasEmptyLine // we don't need to check the row because empty row count are based on cursor ? realCursorCol !== 0 - : (realCursorRow !== this._lastContentCellRow || realCursorCol !== this._lastContentCellCol); + : (realCursorRow !== this._lastCursorRow || realCursorCol !== this._lastCursorCol); const moveRight = (offset: number): void => { if (offset > 0) { @@ -204,9 +286,9 @@ class StringSerializeHandler extends BaseSerializeHandler { // Fix empty lines if (hasEmptyLine) { if (hasScroll) { - content += '\r\n'.repeat(this._buffer1.length - 1 - this._lastContentCellRow); + content += '\r\n'.repeat(this._buffer1.length - 1 - this._lastCursorRow); } else { - content += '\r\n'.repeat(realCursorRow - this._lastContentCellRow); + content += '\r\n'.repeat(realCursorRow - this._lastCursorRow); } } @@ -219,8 +301,8 @@ class StringSerializeHandler extends BaseSerializeHandler { moveRight(realCursorCol); } } else { - moveDown(realCursorRow - this._lastContentCellRow); - moveRight(realCursorCol - this._lastContentCellCol); + moveDown(realCursorRow - this._lastCursorRow); + moveRight(realCursorCol - this._lastCursorCol); } } } @@ -247,15 +329,51 @@ export class SerializeAddon implements ITerminalAddon { return result; } + public inspectBuffer(buffer: IBuffer): { x: number, y: number, data: any[][] } { + const lines: any[] = []; + const cell = buffer.getNullCell(); + + for (let i = 0; i < buffer.length; i++) { + const line = []; + const bufferLine = buffer.getLine(i)!; + for (let j = 0; j < bufferLine.length; j++) { + const cellData: any = {}; + bufferLine.getCell(j, cell)!; + cellData.getBgColor = cell.getBgColor(); + cellData.getBgColorMode = cell.getBgColorMode(); + cellData.getChars = cell.getChars(); + cellData.getCode = cell.getCode(); + cellData.getFgColor = cell.getFgColor(); + cellData.getFgColorMode = cell.getFgColorMode(); + cellData.getWidth = cell.getWidth(); + cellData.isAttributeDefault = cell.isAttributeDefault(); + cellData.isBlink = cell.isBlink(); + cellData.isBold = cell.isBold(); + cellData.isDim = cell.isDim(); + cellData.isInverse = cell.isInverse(); + cellData.isInvisible = cell.isInvisible(); + + line.push(cellData); + } + + lines.push(line); + } + + return { + x: buffer.cursorX, + y: buffer.cursorY, + data: lines + }; + } + public serialize(rows?: number, options: ISerializeOptions = {}): string { - // TODO: Add re-position cursor support // TODO: Add word wrap mode support // TODO: Add combinedData support if (!this._terminal) { throw new Error('Cannot use addon until it has been loaded'); } - if (this._terminal.buffer.active.type === 'normal' || !(options.withAlternate ?? false)) { + if (this._terminal.buffer.active.type === 'normal' || !(options.withAlternate ?? true)) { return this._getString(this._terminal.buffer.active, rows, options); } diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index 32e816a1..a63e386b 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -331,6 +331,24 @@ describe('SerializeAddon', () => { assert.equal(JSON.stringify(await page.evaluate(`window.term.buffer.active === window.term.buffer.alt`)), 'false'); assert.equal(JSON.stringify(await page.evaluate(`serializeAddon.serialize(undefined, { withAlternate: true });`)), JSON.stringify(expected.join('\r\n'))); }); + + it('serialize with background', async () => { + const CLEAR_RIGHT = (l: number): string => `\u001b[${l}X`; + + const lines = [ + `1\u001b[44m${CLEAR_RIGHT(5)}`, + `2${CLEAR_RIGHT(9)}` + ]; + + await writeSync(page, lines.join('\\r\\n')); + const originalBuffer = await page.evaluate(`serializeAddon.inspectBuffer(term.buffer.normal);`); + const result = await page.evaluate(`serializeAddon.serialize(undefined, { withAlternate: true, withCursor: true });`); + + await writeSync(page, '\' +' + JSON.stringify('\x1bc' + result) + '+ \''); + const newBuffer = await page.evaluate(`serializeAddon.inspectBuffer(term.buffer.normal);`); + + assert.deepEqual(originalBuffer, newBuffer); + }); }); function newArray(initial: T | ((index: number) => T), count: number): T[] { From 8518b354a71c6ef3fb1b2e7c5fed51ff04be401a Mon Sep 17 00:00:00 2001 From: mmis1000 Date: Wed, 16 Sep 2020 14:45:14 +0800 Subject: [PATCH 004/377] Fix test that breaks by the option change --- .../src/SerializeAddon.ts | 14 ++++++++------ .../test/SerializeAddon.api.ts | 19 ++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index 3113777e..2363e326 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -320,10 +320,11 @@ export class SerializeAddon implements ITerminalAddon { this._terminal = terminal; } - private _getString(buffer: IBuffer, rows?: number, option?: ISerializeOptions): string { + private _getString(buffer: IBuffer, scrollback?: number, option?: ISerializeOptions): string { const maxRows = buffer.length; const handler = new StringSerializeHandler(buffer, this._terminal!, option); - const correctRows = (rows === undefined) ? maxRows : constrain(rows, 0, maxRows); + + const correctRows = (scrollback === undefined) ? maxRows : constrain(scrollback + this!._terminal!.rows, 0, maxRows); const result = handler.serialize(maxRows - correctRows, maxRows); return result; @@ -366,7 +367,7 @@ export class SerializeAddon implements ITerminalAddon { }; } - public serialize(rows?: number, options: ISerializeOptions = {}): string { + public serialize(scrollback?: number, options: ISerializeOptions = {}): string { // TODO: Add word wrap mode support // TODO: Add combinedData support if (!this._terminal) { @@ -374,11 +375,12 @@ export class SerializeAddon implements ITerminalAddon { } if (this._terminal.buffer.active.type === 'normal' || !(options.withAlternate ?? true)) { - return this._getString(this._terminal.buffer.active, rows, options); + return this._getString(this._terminal.buffer.active, scrollback, options); } - const normalScreenContent = this._getString(this._terminal.buffer.normal, rows, options); - const alternativeScreenContent = this._getString(this._terminal.buffer.alternate, rows, options); + const normalScreenContent = this._getString(this._terminal.buffer.normal, scrollback, options); + // alt screen don't have scrollback + const alternativeScreenContent = this._getString(this._terminal.buffer.alternate, undefined, options); return normalScreenContent + '\u001b[?1049h\u001b[H' diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index a63e386b..0401953d 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -39,7 +39,7 @@ describe('SerializeAddon', () => { assert.equal(await page.evaluate(`serializeAddon.serialize();`), ''); }); - it('trim last empty lines', async function(): Promise { + it('preserve last empty lines', async function(): Promise { const cols = 10; const lines = [ '', @@ -55,7 +55,7 @@ describe('SerializeAddon', () => { '' ]; await writeSync(page, lines.join('\\r\\n')); - assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.slice(0, 8).join('\r\n')); + assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n')); }); it('digits content', async function(): Promise { @@ -67,21 +67,22 @@ describe('SerializeAddon', () => { assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n')); }); - it('serialize half rows of content', async function(): Promise { - const rows = 10; - const halfRows = rows >> 1; + it('serialize with half of scrollback', async function(): Promise { + const rows = 20; + const scrollback = rows - 10; + const halfScrollback = scrollback / 2; const cols = 10; const lines = newArray((index: number) => digitsString(cols, index), rows); await writeSync(page, lines.join('\\r\\n')); - assert.equal(await page.evaluate(`serializeAddon.serialize(${halfRows});`), lines.slice(halfRows, 2 * halfRows).join('\r\n')); + assert.equal(await page.evaluate(`serializeAddon.serialize(${halfScrollback});`), lines.slice(halfScrollback, rows).join('\r\n')); }); - it('serialize 0 rows of content', async function(): Promise { - const rows = 10; + it('serialize 0 rows of scrollback', async function(): Promise { + const rows = 20; const cols = 10; const lines = newArray((index: number) => digitsString(cols, index), rows); await writeSync(page, lines.join('\\r\\n')); - assert.equal(await page.evaluate(`serializeAddon.serialize(0);`), ''); + assert.equal(await page.evaluate(`serializeAddon.serialize(0);`), lines.slice(rows - 10, rows).join('\r\n')); }); it('serialize all rows of content with color16', async function(): Promise { From 10282e4cb1d0d1d0a26cefa679afeb0cda82479e Mon Sep 17 00:00:00 2001 From: mmis1000 Date: Wed, 16 Sep 2020 14:54:15 +0800 Subject: [PATCH 005/377] Move the test util to static method --- .../src/SerializeAddon.ts | 43 ++++++++++--------- .../test/SerializeAddon.api.ts | 5 ++- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index 2363e326..32cab90c 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -330,7 +330,28 @@ export class SerializeAddon implements ITerminalAddon { return result; } - public inspectBuffer(buffer: IBuffer): { x: number, y: number, data: any[][] } { + public serialize(scrollback?: number, options: ISerializeOptions = {}): string { + // TODO: Add word wrap mode support + // TODO: Add combinedData support + if (!this._terminal) { + throw new Error('Cannot use addon until it has been loaded'); + } + + if (this._terminal.buffer.active.type === 'normal' || !(options.withAlternate ?? true)) { + return this._getString(this._terminal.buffer.active, scrollback, options); + } + + const normalScreenContent = this._getString(this._terminal.buffer.normal, scrollback, options); + // alt screen don't have scrollback + const alternativeScreenContent = this._getString(this._terminal.buffer.alternate, undefined, options); + + return normalScreenContent + + '\u001b[?1049h\u001b[H' + + alternativeScreenContent; + } + + // this is a util used only for test + private static _inspectBuffer(buffer: IBuffer): { x: number, y: number, data: any[][] } { const lines: any[] = []; const cell = buffer.getNullCell(); @@ -367,25 +388,5 @@ export class SerializeAddon implements ITerminalAddon { }; } - public serialize(scrollback?: number, options: ISerializeOptions = {}): string { - // TODO: Add word wrap mode support - // TODO: Add combinedData support - if (!this._terminal) { - throw new Error('Cannot use addon until it has been loaded'); - } - - if (this._terminal.buffer.active.type === 'normal' || !(options.withAlternate ?? true)) { - return this._getString(this._terminal.buffer.active, scrollback, options); - } - - const normalScreenContent = this._getString(this._terminal.buffer.normal, scrollback, options); - // alt screen don't have scrollback - const alternativeScreenContent = this._getString(this._terminal.buffer.alternate, undefined, options); - - return normalScreenContent - + '\u001b[?1049h\u001b[H' - + alternativeScreenContent; - } - public dispose(): void { } } diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index 0401953d..281a3154 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -342,11 +342,12 @@ describe('SerializeAddon', () => { ]; await writeSync(page, lines.join('\\r\\n')); - const originalBuffer = await page.evaluate(`serializeAddon.inspectBuffer(term.buffer.normal);`); + const originalBuffer = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); + const result = await page.evaluate(`serializeAddon.serialize(undefined, { withAlternate: true, withCursor: true });`); await writeSync(page, '\' +' + JSON.stringify('\x1bc' + result) + '+ \''); - const newBuffer = await page.evaluate(`serializeAddon.inspectBuffer(term.buffer.normal);`); + const newBuffer = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); assert.deepEqual(originalBuffer, newBuffer); }); From 6c0163009051652ac8348ddcc03067e8da713d86 Mon Sep 17 00:00:00 2001 From: mmis1000 Date: Wed, 16 Sep 2020 15:13:30 +0800 Subject: [PATCH 006/377] Remove the unused options --- .../src/SerializeAddon.ts | 117 +++++++++--------- .../test/SerializeAddon.api.ts | 6 +- demo/client.ts | 2 +- 3 files changed, 60 insertions(+), 65 deletions(-) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index 32cab90c..f4dcf35b 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -11,11 +11,6 @@ function constrain(value: number, low: number, high: number): number { return Math.max(low, Math.min(value, high)); } -interface ISerializeOptions { - withAlternate?: boolean; - withCursor?: boolean; -} - // TODO: Refine this template class later abstract class BaseSerializeHandler { constructor(private _buffer: IBuffer) { } @@ -93,7 +88,7 @@ class StringSerializeHandler extends BaseSerializeHandler { private _lastCursorRow: number = 0; private _lastCursorCol: number = 0; - constructor(private _buffer1: IBuffer,private _terminal: Terminal, private _option: ISerializeOptions = {}) { + constructor(private _buffer1: IBuffer,private _terminal: Terminal) { super(_buffer1); } @@ -252,61 +247,61 @@ class StringSerializeHandler extends BaseSerializeHandler { let content = this._allRows.slice(0, rowEnd).join('\r\n'); - if (this._option.withCursor ?? true) { - const realCursorRow = this._buffer1.baseY + this._buffer1.cursorY; - const realCursorCol = this._buffer1.cursorX; + // restore the cursor + const realCursorRow = this._buffer1.baseY + this._buffer1.cursorY; + const realCursorCol = this._buffer1.cursorX; - const hasScroll = this._buffer1.length > this._terminal.rows!; - const hasEmptyLine = hasScroll ? (this._buffer1.length - 1 > this._lastCursorRow) : (realCursorRow > this._lastCursorRow); - const cursorMoved = - hasScroll - ? hasEmptyLine - ? (realCursorCol !== 0 || realCursorRow !== this._buffer1.length - 1) - : (realCursorRow !== this._lastCursorRow || realCursorCol !== this._lastCursorCol) - : hasEmptyLine - // we don't need to check the row because empty row count are based on cursor - ? realCursorCol !== 0 - : (realCursorRow !== this._lastCursorRow || realCursorCol !== this._lastCursorCol); + const hasScroll = this._buffer1.length > this._terminal.rows!; + const hasEmptyLine = hasScroll ? (this._buffer1.length - 1 > this._lastCursorRow) : (realCursorRow > this._lastCursorRow); + const cursorMoved = + hasScroll + ? hasEmptyLine + ? (realCursorCol !== 0 || realCursorRow !== this._buffer1.length - 1) + : (realCursorRow !== this._lastCursorRow || realCursorCol !== this._lastCursorCol) + : hasEmptyLine + // we don't need to check the row because empty row count are based on cursor + ? realCursorCol !== 0 + : (realCursorRow !== this._lastCursorRow || realCursorCol !== this._lastCursorCol); - const moveRight = (offset: number): void => { - if (offset > 0) { - content += `\u001b[${offset}C`; - } else if (offset < 0) { - content += `\u001b[${-offset}D`; - } - }; - const moveDown = (offset: number): void => { - if (offset > 0) { - content += `\u001b[${offset}B`; - } else if (offset < 0) { - content += `\u001b[${-offset}A`; - } - }; - - // Fix empty lines - if (hasEmptyLine) { - if (hasScroll) { - content += '\r\n'.repeat(this._buffer1.length - 1 - this._lastCursorRow); - } else { - content += '\r\n'.repeat(realCursorRow - this._lastCursorRow); - } + const moveRight = (offset: number): void => { + if (offset > 0) { + content += `\u001b[${offset}C`; + } else if (offset < 0) { + content += `\u001b[${-offset}D`; } + }; + const moveDown = (offset: number): void => { + if (offset > 0) { + content += `\u001b[${offset}B`; + } else if (offset < 0) { + content += `\u001b[${-offset}A`; + } + }; - if (cursorMoved) { - if (hasEmptyLine) { - if (hasScroll) { - moveRight(realCursorCol); - moveDown(realCursorRow - (this._buffer1.length - 1)); - } else { - moveRight(realCursorCol); - } - } else { - moveDown(realCursorRow - this._lastCursorRow); - moveRight(realCursorCol - this._lastCursorCol); - } + // Fix empty lines + if (hasEmptyLine) { + if (hasScroll) { + content += '\r\n'.repeat(this._buffer1.length - 1 - this._lastCursorRow); + } else { + content += '\r\n'.repeat(realCursorRow - this._lastCursorRow); } } + if (cursorMoved) { + if (hasEmptyLine) { + if (hasScroll) { + moveRight(realCursorCol); + moveDown(realCursorRow - (this._buffer1.length - 1)); + } else { + moveRight(realCursorCol); + } + } else { + moveDown(realCursorRow - this._lastCursorRow); + moveRight(realCursorCol - this._lastCursorCol); + } + } + + return content; } } @@ -320,9 +315,9 @@ export class SerializeAddon implements ITerminalAddon { this._terminal = terminal; } - private _getString(buffer: IBuffer, scrollback?: number, option?: ISerializeOptions): string { + private _getString(buffer: IBuffer, scrollback?: number): string { const maxRows = buffer.length; - const handler = new StringSerializeHandler(buffer, this._terminal!, option); + const handler = new StringSerializeHandler(buffer, this._terminal!); const correctRows = (scrollback === undefined) ? maxRows : constrain(scrollback + this!._terminal!.rows, 0, maxRows); const result = handler.serialize(maxRows - correctRows, maxRows); @@ -330,20 +325,20 @@ export class SerializeAddon implements ITerminalAddon { return result; } - public serialize(scrollback?: number, options: ISerializeOptions = {}): string { + public serialize(scrollback?: number): string { // TODO: Add word wrap mode support // TODO: Add combinedData support if (!this._terminal) { throw new Error('Cannot use addon until it has been loaded'); } - if (this._terminal.buffer.active.type === 'normal' || !(options.withAlternate ?? true)) { - return this._getString(this._terminal.buffer.active, scrollback, options); + if (this._terminal.buffer.active.type === 'normal') { + return this._getString(this._terminal.buffer.active, scrollback); } - const normalScreenContent = this._getString(this._terminal.buffer.normal, scrollback, options); + const normalScreenContent = this._getString(this._terminal.buffer.normal, scrollback); // alt screen don't have scrollback - const alternativeScreenContent = this._getString(this._terminal.buffer.alternate, undefined, options); + const alternativeScreenContent = this._getString(this._terminal.buffer.alternate, undefined); return normalScreenContent + '\u001b[?1049h\u001b[H' diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index 281a3154..2e570120 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -314,7 +314,7 @@ describe('SerializeAddon', () => { await writeSync(page, lines.join('\\r\\n')); assert.equal(JSON.stringify(await page.evaluate(`window.term.buffer.active.type`)), '"alternate"'); - assert.equal(JSON.stringify(await page.evaluate(`serializeAddon.serialize(undefined, { withAlternate: true });`)), JSON.stringify(expected.join('\r\n'))); + assert.equal(JSON.stringify(await page.evaluate(`serializeAddon.serialize();`)), JSON.stringify(expected.join('\r\n'))); }); it('serialize without alt screen correctly', async () => { @@ -330,7 +330,7 @@ describe('SerializeAddon', () => { await writeSync(page, lines.join('\\r\\n')); assert.equal(JSON.stringify(await page.evaluate(`window.term.buffer.active === window.term.buffer.alt`)), 'false'); - assert.equal(JSON.stringify(await page.evaluate(`serializeAddon.serialize(undefined, { withAlternate: true });`)), JSON.stringify(expected.join('\r\n'))); + assert.equal(JSON.stringify(await page.evaluate(`serializeAddon.serialize();`)), JSON.stringify(expected.join('\r\n'))); }); it('serialize with background', async () => { @@ -344,7 +344,7 @@ describe('SerializeAddon', () => { await writeSync(page, lines.join('\\r\\n')); const originalBuffer = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); - const result = await page.evaluate(`serializeAddon.serialize(undefined, { withAlternate: true, withCursor: true });`); + const result = await page.evaluate(`serializeAddon.serialize();`); await writeSync(page, '\' +' + JSON.stringify('\x1bc' + result) + '+ \''); const newBuffer = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); diff --git a/demo/client.ts b/demo/client.ts index 509b73a9..6efa181a 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -413,7 +413,7 @@ function updateTerminalSize(): void { } function serializeButtonHandler(): void { - const output = addons.serialize.instance.serialize(undefined, { withAlternate: true, withCursor: true }); + const output = addons.serialize.instance.serialize(); const outputString = JSON.stringify(output); document.getElementById('serialize-output').innerText = outputString; From b89227d365f6e6e6062115c62ec8ba4491f926b3 Mon Sep 17 00:00:00 2001 From: Mmis1000 Date: Wed, 16 Sep 2020 22:47:23 +0800 Subject: [PATCH 007/377] Workaround firefox bug that yield -0 on bit op --- .../xterm-addon-serialize/test/SerializeAddon.api.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index 2e570120..4d90f3c5 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -14,6 +14,8 @@ let page: Page; const width = 800; const height = 600; +const writeRawSync = (page: any, str: string): Promise => writeSync(page, '\' +' + JSON.stringify(str) + '+ \''); + describe('SerializeAddon', () => { before(async function(): Promise { const browserType = getBrowserType(); @@ -344,12 +346,14 @@ describe('SerializeAddon', () => { await writeSync(page, lines.join('\\r\\n')); const originalBuffer = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); - const result = await page.evaluate(`serializeAddon.serialize();`); - - await writeSync(page, '\' +' + JSON.stringify('\x1bc' + result) + '+ \''); + const result = await page.evaluate(`serializeAddon.serialize();`) as string; + await page.evaluate(`term.reset();`); + await writeRawSync(page, result); const newBuffer = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); - assert.deepEqual(originalBuffer, newBuffer); + // chai decides -0 and 0 are different number... + // and firefox have a bug that output -0 for unknown reason + assert.equal(JSON.stringify(originalBuffer), JSON.stringify(newBuffer)); }); }); From 6904dc50092d979f47108d1fd89f2bfbf7fcd4e6 Mon Sep 17 00:00:00 2001 From: Mmis1000 Date: Fri, 18 Sep 2020 00:36:10 +0800 Subject: [PATCH 008/377] Handle BCE + line scroll Using an additional field for store the current background and compare against it to generate proper color sequence --- .../xterm-addon-serialize/src/MyBufferCell.ts | 96 +++++++++++++++++++ .../src/SerializeAddon.ts | 51 +++++----- .../test/SerializeAddon.api.ts | 27 ++++++ 3 files changed, 148 insertions(+), 26 deletions(-) create mode 100644 addons/xterm-addon-serialize/src/MyBufferCell.ts diff --git a/addons/xterm-addon-serialize/src/MyBufferCell.ts b/addons/xterm-addon-serialize/src/MyBufferCell.ts new file mode 100644 index 00000000..56efcb3c --- /dev/null +++ b/addons/xterm-addon-serialize/src/MyBufferCell.ts @@ -0,0 +1,96 @@ +import { IBufferCell } from 'xterm'; + +/** + * This is a dummy buffer cell to hold data from real buffer cell + */ +export class MyBufferCell implements IBufferCell { + constructor (private _cell: IBufferCell) {} + private _width: number = this._cell.getWidth(); + private _chars: string = this._cell.getChars(); + private _code: number = this._cell.getCode(); + private _fgColorMode: number = this._cell.getFgColorMode(); + private _bgColorMode: number = this._cell.getBgColorMode(); + private _fgColor: number = this._cell.getFgColor(); + private _bgColor: number = this._cell.getBgColor(); + private _bold: number = this._cell.isBold(); + private _italic: number = this._cell.isItalic(); + private _dim: number = this._cell.isDim(); + private _underline: number = this._cell.isUnderline(); + private _blink: number = this._cell.isBlink(); + private _inverse: number = this._cell.isInverse(); + private _invisible: number = this._cell.isInvisible(); + private _fgRGB: boolean = this._cell.isFgRGB(); + private _bgRGB: boolean = this._cell.isBgRGB(); + private _fgPalette: boolean = this._cell.isFgPalette(); + private _bgPallette: boolean = this._cell.isBgPalette(); + private _fgDefault: boolean = this._cell.isFgDefault(); + private _bgDefault: boolean = this._cell.isBgDefault(); + private _attributeDefault: boolean = this._cell.isAttributeDefault(); + public getWidth(): number { + return this._width; + } + public getChars(): string { + return this._chars; + } + public getCode(): number { + return this._code; + } + public getFgColorMode(): number { + return this._fgColorMode; + } + public getBgColorMode(): number { + return this._bgColorMode; + } + public getFgColor(): number { + return this._fgColor; + } + public getBgColor(): number { + return this._bgColor; + } + public isBold(): number { + return this._bold; + } + public isItalic(): number { + return this._italic; + } + public isDim(): number { + return this._dim; + } + public isUnderline(): number { + return this._underline; + } + public isBlink(): number { + return this._blink; + } + public isInverse(): number { + return this._inverse; + } + public isInvisible(): number { + return this._invisible; + } + public isFgRGB(): boolean { + return this._fgRGB; + } + public isBgRGB(): boolean { + return this._bgRGB; + } + public isFgPalette(): boolean { + return this._fgPalette; + } + public isBgPalette(): boolean { + return this._bgPallette; + } + public isFgDefault(): boolean { + return this._fgDefault; + } + public isBgDefault(): boolean { + return this._bgDefault; + } + public isAttributeDefault(): boolean { + return this._attributeDefault; + } + + public static from(cell: IBufferCell): MyBufferCell { + return new MyBufferCell(cell); + } +} diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index f4dcf35b..9518fcbf 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -6,6 +6,7 @@ */ import { Terminal, ITerminalAddon, IBuffer, IBufferCell } from 'xterm'; +import { MyBufferCell } from './MyBufferCell'; function constrain(value: number, low: number, high: number): number { return Math.max(low, Math.min(value, high)); @@ -36,7 +37,7 @@ abstract class BaseSerializeHandler { oldCell = c; } } - this._rowEnd(row); + this._rowEnd(row, row === endRow - 1); } this._afterSerialize(); @@ -45,7 +46,7 @@ abstract class BaseSerializeHandler { } protected _nextCell(cell: IBufferCell, oldCell: IBufferCell, row: number, col: number): void { } - protected _rowEnd(row: number): void { } + protected _rowEnd(row: number, isLastRow: boolean): void { } protected _beforeSerialize(rows: number, startRow: number, endRow: number): void { } protected _afterSerialize(): void { } protected _serializeString(): string { return ''; } @@ -71,20 +72,23 @@ function equalFlags(cell1: IBufferCell, cell2: IBufferCell): boolean { && cell1.isDim() === cell2.isDim(); } + + class StringSerializeHandler extends BaseSerializeHandler { private _rowIndex: number = 0; private _allRows: string[] = new Array(); private _currentRow: string = ''; private _nullCellCount: number = 0; - // this is a null cell for reference for checking whether background is empty or not - private _nullCell: IBufferCell = this._buffer1.getNullCell(); - // we can see a full colored cell and a null cell that only have background the same style // but the information isn't preserved by null cell itself // so wee need to record it when required. private _cursorStyle: IBufferCell = this._buffer1.getNullCell(); + // this is a null cell for reference for checking whether background is empty or not + private _backgroundCell: MyBufferCell = MyBufferCell.from(this._cursorStyle); + + private _firstRow: number = 0; private _lastCursorRow: number = 0; private _lastCursorCol: number = 0; @@ -95,26 +99,21 @@ class StringSerializeHandler extends BaseSerializeHandler { protected _beforeSerialize(rows: number, start: number, end: number): void { this._allRows = new Array(rows); this._lastCursorRow = start; + this._firstRow = start; } - protected _rowEnd(row: number): void { + protected _rowEnd(row: number, isLastRow: boolean): void { // if there is colorful empty cell at line end, whe must pad it back, or the the color block will missing - if (this._nullCellCount > 0 && !equalBg(this._cursorStyle, this._nullCell)) { + if (this._nullCellCount > 0 && !equalBg(this._cursorStyle, this._backgroundCell)) { // use clear right to set background. // use move right to move cursor. this._currentRow += `\x1b[${this._nullCellCount}X`; + } - // set the cursor back because we aren't there - this._lastCursorRow = row; - this._lastCursorCol = this._terminal.cols - this._nullCellCount; - - this._nullCellCount = 0; - - // perform a style reset before next line, - // because scroll when having background set will change the whole background of next line. - this._currentRow += `\x1b[m`; - // FIXME: we just get a new one because we can't reset it. - this._cursorStyle = this._buffer1.getNullCell(); + if (!isLastRow) { + if (row - this._firstRow >= this._terminal.rows) { + this._backgroundCell = MyBufferCell.from(this._cursorStyle); + } } this._allRows[this._rowIndex++] = this._currentRow; @@ -178,9 +177,6 @@ class StringSerializeHandler extends BaseSerializeHandler { // this cell don't have content const isEmptyCell = cell.getChars() === ''; - // this cell don't have content and style - const isNullCell = cell.getWidth() === 1 && cell.getChars() === '' && cell.isAttributeDefault(); - const sgrSeq = this._diffStyle(cell, this._cursorStyle); // the empty cell style is only assumed to be changed when background changed, because foreground is always 0. @@ -194,7 +190,7 @@ class StringSerializeHandler extends BaseSerializeHandler { if (this._nullCellCount > 0) { // use clear right to set background. // use move right to move cursor. - if (equalBg(this._cursorStyle, this._nullCell)) { + if (equalBg(this._cursorStyle, this._backgroundCell)) { this._currentRow += `\x1b[${this._nullCellCount}C`; } else { this._currentRow += `\x1b[${this._nullCellCount}X`; @@ -203,6 +199,9 @@ class StringSerializeHandler extends BaseSerializeHandler { this._nullCellCount = 0; } + this._lastCursorRow = row; + this._lastCursorCol = col; + this._currentRow += `\x1b[${sgrSeq.join(';')}m`; // update the last cursor style @@ -219,7 +218,7 @@ class StringSerializeHandler extends BaseSerializeHandler { // we can just assume we have same style with previous one here // because style change is handled by previous stage // use move right when background is empty, use clear right when there is background. - if (equalBg(this._cursorStyle, this._nullCell)) { + if (equalBg(this._cursorStyle, this._backgroundCell)) { this._currentRow += `\x1b[${this._nullCellCount}C`; } else { this._currentRow += `\x1b[${this._nullCellCount}X`; @@ -227,10 +226,10 @@ class StringSerializeHandler extends BaseSerializeHandler { } this._nullCellCount = 0; } - this._currentRow += cell.getChars(); - } - if (!isNullCell) { + this._currentRow += cell.getChars(); + + // update cursor this._lastCursorRow = row; this._lastCursorCol = col + cell.getWidth(); } diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index 4d90f3c5..afbe3b39 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -355,6 +355,33 @@ describe('SerializeAddon', () => { // and firefox have a bug that output -0 for unknown reason assert.equal(JSON.stringify(originalBuffer), JSON.stringify(newBuffer)); }); + + it('cause the BCE on scroll', async () => { + const CLEAR_RIGHT = (l: number): string => `\u001b[${l}X`; + + const padLines = newArray( + (index: number) => digitsString(10, index), + 10 + ); + + const lines = [ + ...padLines, + `\u001b[44m${CLEAR_RIGHT(5)}1111111111111111` + ]; + + await writeSync(page, lines.join('\\r\\n')); + const originalBuffer = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); + + const result = await page.evaluate(`serializeAddon.serialize();`) as string; + + await page.evaluate(`term.reset();`); + await writeRawSync(page, result); + const newBuffer = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); + + // chai decides -0 and 0 are different number... + // and firefox have a bug that output -0 for unknown reason + assert.equal(JSON.stringify(originalBuffer), JSON.stringify(newBuffer)); + }); }); function newArray(initial: T | ((index: number) => T), count: number): T[] { From 84dfe8fcccb283656216e03933cebe2623d236b5 Mon Sep 17 00:00:00 2001 From: Mmis1000 Date: Fri, 18 Sep 2020 01:20:41 +0800 Subject: [PATCH 009/377] CLearup comment --- addons/xterm-addon-serialize/src/SerializeAddon.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index 9518fcbf..a05250cf 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -106,7 +106,6 @@ class StringSerializeHandler extends BaseSerializeHandler { // if there is colorful empty cell at line end, whe must pad it back, or the the color block will missing if (this._nullCellCount > 0 && !equalBg(this._cursorStyle, this._backgroundCell)) { // use clear right to set background. - // use move right to move cursor. this._currentRow += `\x1b[${this._nullCellCount}X`; } @@ -189,13 +188,11 @@ class StringSerializeHandler extends BaseSerializeHandler { // before update the style, we need to fill empty cell back if (this._nullCellCount > 0) { // use clear right to set background. - // use move right to move cursor. - if (equalBg(this._cursorStyle, this._backgroundCell)) { - this._currentRow += `\x1b[${this._nullCellCount}C`; - } else { + if (!equalBg(this._cursorStyle, this._backgroundCell)) { this._currentRow += `\x1b[${this._nullCellCount}X`; - this._currentRow += `\x1b[${this._nullCellCount}C`; } + // use move right to move cursor. + this._currentRow += `\x1b[${this._nullCellCount}C`; this._nullCellCount = 0; } From d7ed109f9d65b86599cd35eae517407486137757 Mon Sep 17 00:00:00 2001 From: mmis1000 Date: Fri, 18 Sep 2020 15:21:59 +0800 Subject: [PATCH 010/377] Support the isWrapped handling --- .../src/SerializeAddon.ts | 165 +++++++++++------- .../test/SerializeAddon.api.ts | 104 +++++++---- 2 files changed, 174 insertions(+), 95 deletions(-) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index a05250cf..025f1833 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -77,6 +77,7 @@ function equalFlags(cell1: IBufferCell, cell2: IBufferCell): boolean { class StringSerializeHandler extends BaseSerializeHandler { private _rowIndex: number = 0; private _allRows: string[] = new Array(); + private _allRowSeparators: string[] = new Array(); private _currentRow: string = ''; private _nullCellCount: number = 0; @@ -91,6 +92,8 @@ class StringSerializeHandler extends BaseSerializeHandler { private _firstRow: number = 0; private _lastCursorRow: number = 0; private _lastCursorCol: number = 0; + private _lastContentCursorRow: number = 0; + private _lastContentCursorCol: number = 0; constructor(private _buffer1: IBuffer,private _terminal: Terminal) { super(_buffer1); @@ -98,6 +101,7 @@ class StringSerializeHandler extends BaseSerializeHandler { protected _beforeSerialize(rows: number, start: number, end: number): void { this._allRows = new Array(rows); + this._lastContentCursorRow = start; this._lastCursorRow = start; this._firstRow = start; } @@ -109,13 +113,82 @@ class StringSerializeHandler extends BaseSerializeHandler { this._currentRow += `\x1b[${this._nullCellCount}X`; } + let rowSeparator = ''; + + // handle row separator if (!isLastRow) { + // Enable BCE if (row - this._firstRow >= this._terminal.rows) { this._backgroundCell = MyBufferCell.from(this._cursorStyle); } + + // Fetch current line + const currentLine = this._buffer1.getLine(row)!; + // Fetch next line + const nextLine = this._buffer1.getLine(row + 1)!; + + if (!nextLine.isWrapped) { + // just insert the line break + rowSeparator = '\r\n'; + // we sended the enter + this._lastCursorRow = row + 1; + this._lastCursorCol = 0; + } else { + rowSeparator = ''; + const thisRowLastChar = currentLine.getCell(currentLine.length - 1)!; + const thisRowLastSecondChar = currentLine.getCell(currentLine.length - 2)!; + const nextRowFirstChar = nextLine.getCell(0)!; + const isNextRowFirstCharDoubleWidth = nextRowFirstChar.getWidth() > 1; + + // validate whether this line wrap is ever possible + let isValid = false; + + if ( + nextRowFirstChar.getChars() && + isNextRowFirstCharDoubleWidth ? this._nullCellCount <= 1 : this._nullCellCount <= 0 + ) { + if ( + (thisRowLastChar.getChars() || thisRowLastChar.getWidth() === 0) && + equalBg(thisRowLastChar, nextRowFirstChar) + ) { + isValid = true; + } + + if ( + isNextRowFirstCharDoubleWidth && + (thisRowLastSecondChar.getChars() || thisRowLastSecondChar.getWidth() === 0) && + equalBg(thisRowLastChar, nextRowFirstChar) && + equalBg(thisRowLastSecondChar, nextRowFirstChar) + ) { + isValid = true; + } + } + + if (!isValid) { + // force the wrap with magic + // insert enough character to force the wrap + rowSeparator = '-'.repeat(this._nullCellCount + 1); + // move back and erase next line head + rowSeparator += '\x1b[1D\x1b[1X'; + + // do these because we filled the last several null slot, which we shouldn't + if (this._nullCellCount > 0) { + rowSeparator += '\x1b[A'; + rowSeparator += `\x1b[${currentLine.length - this._nullCellCount}C`; + rowSeparator += `\x1b[${this._nullCellCount}X`; + rowSeparator += `\x1b[${currentLine.length - this._nullCellCount}D`; + rowSeparator += '\x1b[B'; + } + + // force commit the cursor position + this._lastCursorRow = row + 1; + this._lastCursorCol = 0; + } + } } - this._allRows[this._rowIndex++] = this._currentRow; + this._allRows[this._rowIndex] = this._currentRow; + this._allRowSeparators[this._rowIndex++] = rowSeparator; this._currentRow = ''; this._nullCellCount = 0; } @@ -196,8 +269,8 @@ class StringSerializeHandler extends BaseSerializeHandler { this._nullCellCount = 0; } - this._lastCursorRow = row; - this._lastCursorCol = col; + this._lastContentCursorRow = this._lastCursorRow = row; + this._lastContentCursorCol = this._lastCursorCol = col; this._currentRow += `\x1b[${sgrSeq.join(';')}m`; @@ -227,37 +300,36 @@ class StringSerializeHandler extends BaseSerializeHandler { this._currentRow += cell.getChars(); // update cursor - this._lastCursorRow = row; - this._lastCursorCol = col + cell.getWidth(); + this._lastContentCursorRow = this._lastCursorRow = row; + this._lastContentCursorCol = this._lastCursorCol = col + cell.getWidth(); } } protected _serializeString(): string { let rowEnd = this._allRows.length; - for (; rowEnd > 0; rowEnd--) { - if (this._allRows[rowEnd - 1]) { - break; - } + // the fixup is only required for data without scrollback + // because it will always be placed at last line otherwise + if (this._buffer1.length - this._firstRow <= this._terminal.rows) { + rowEnd = this._lastContentCursorRow + 1 - this._firstRow; + this._lastCursorCol = this._lastContentCursorCol; + this._lastCursorRow = this._lastContentCursorRow; } - let content = this._allRows.slice(0, rowEnd).join('\r\n'); + let content = ''; + + for (let i = 0; i < rowEnd; i++) { + content += this._allRows[i]; + if (i + 1 < rowEnd) { + content += this._allRowSeparators[i]; + } + } // restore the cursor const realCursorRow = this._buffer1.baseY + this._buffer1.cursorY; const realCursorCol = this._buffer1.cursorX; - const hasScroll = this._buffer1.length > this._terminal.rows!; - const hasEmptyLine = hasScroll ? (this._buffer1.length - 1 > this._lastCursorRow) : (realCursorRow > this._lastCursorRow); - const cursorMoved = - hasScroll - ? hasEmptyLine - ? (realCursorCol !== 0 || realCursorRow !== this._buffer1.length - 1) - : (realCursorRow !== this._lastCursorRow || realCursorCol !== this._lastCursorCol) - : hasEmptyLine - // we don't need to check the row because empty row count are based on cursor - ? realCursorCol !== 0 - : (realCursorRow !== this._lastCursorRow || realCursorCol !== this._lastCursorCol); + const cursorMoved = (realCursorRow !== this._lastCursorRow || realCursorCol !== this._lastCursorCol); const moveRight = (offset: number): void => { if (offset > 0) { @@ -274,27 +346,9 @@ class StringSerializeHandler extends BaseSerializeHandler { } }; - // Fix empty lines - if (hasEmptyLine) { - if (hasScroll) { - content += '\r\n'.repeat(this._buffer1.length - 1 - this._lastCursorRow); - } else { - content += '\r\n'.repeat(realCursorRow - this._lastCursorRow); - } - } - if (cursorMoved) { - if (hasEmptyLine) { - if (hasScroll) { - moveRight(realCursorCol); - moveDown(realCursorRow - (this._buffer1.length - 1)); - } else { - moveRight(realCursorCol); - } - } else { - moveDown(realCursorRow - this._lastCursorRow); - moveRight(realCursorCol - this._lastCursorCol); - } + moveDown(realCursorRow - this._lastCursorRow); + moveRight(realCursorCol - this._lastCursorCol); } @@ -322,7 +376,6 @@ export class SerializeAddon implements ITerminalAddon { } public serialize(scrollback?: number): string { - // TODO: Add word wrap mode support // TODO: Add combinedData support if (!this._terminal) { throw new Error('Cannot use addon until it has been loaded'); @@ -344,32 +397,14 @@ export class SerializeAddon implements ITerminalAddon { // this is a util used only for test private static _inspectBuffer(buffer: IBuffer): { x: number, y: number, data: any[][] } { const lines: any[] = []; - const cell = buffer.getNullCell(); for (let i = 0; i < buffer.length; i++) { - const line = []; - const bufferLine = buffer.getLine(i)!; - for (let j = 0; j < bufferLine.length; j++) { - const cellData: any = {}; - bufferLine.getCell(j, cell)!; - cellData.getBgColor = cell.getBgColor(); - cellData.getBgColorMode = cell.getBgColorMode(); - cellData.getChars = cell.getChars(); - cellData.getCode = cell.getCode(); - cellData.getFgColor = cell.getFgColor(); - cellData.getFgColorMode = cell.getFgColorMode(); - cellData.getWidth = cell.getWidth(); - cellData.isAttributeDefault = cell.isAttributeDefault(); - cellData.isBlink = cell.isBlink(); - cellData.isBold = cell.isBold(); - cellData.isDim = cell.isDim(); - cellData.isInverse = cell.isInverse(); - cellData.isInvisible = cell.isInvisible(); + /** + * Do this intentionally to get content of underlining source + */ + const bufferLine = (buffer.getLine(i)! as any)._line; - line.push(cellData); - } - - lines.push(line); + lines.push(JSON.stringify(bufferLine)); } return { diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index afbe3b39..4bf6d1b5 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -16,6 +16,20 @@ const height = 600; const writeRawSync = (page: any, str: string): Promise => writeSync(page, '\' +' + JSON.stringify(str) + '+ \''); +const testNormalScreenEqual = async (page: any, str: string): Promise => { + await writeRawSync(page, str); + const originalBuffer = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); + + const result = await page.evaluate(`serializeAddon.serialize();`) as string; + await page.evaluate(`term.reset();`); + await writeRawSync(page, result); + const newBuffer = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); + + // chai decides -0 and 0 are different number... + // and firefox have a bug that output -0 for unknown reason + assert.equal(JSON.stringify(originalBuffer), JSON.stringify(newBuffer)); +}; + describe('SerializeAddon', () => { before(async function(): Promise { const browserType = getBrowserType(); @@ -35,12 +49,54 @@ describe('SerializeAddon', () => { after(async () => await browser.close()); beforeEach(async () => await page.evaluate(`window.term.reset()`)); + it('produce different output when we call test util with different text', async function(): Promise { + await writeRawSync(page, '12345'); + const buffer1 = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); + + await page.evaluate(`term.reset();`); + await writeRawSync(page, '67890'); + const buffer2 = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); + + assert.throw(() => { + assert.equal(JSON.stringify(buffer1), JSON.stringify(buffer2)); + }); + }); + + it('produce different output when we call test util with different line wrap', async function(): Promise { + await writeRawSync(page, '1234567890\r\n12345'); + const buffer3 = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); + + await page.evaluate(`term.reset();`); + await writeRawSync(page, '1234567890n12345'); + const buffer4 = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); + + assert.throw(() => { + assert.equal(JSON.stringify(buffer3), JSON.stringify(buffer4)); + }); + }); + it('empty content', async function(): Promise { const rows = 10; const cols = 10; assert.equal(await page.evaluate(`serializeAddon.serialize();`), ''); }); + it('unwrap wrapped line', async function(): Promise { + const lines = ['123456789123456789']; + await writeSync(page, lines.join('\\r\\n')); + assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n')); + }); + + it('does not unwrap non-wrapped line', async function(): Promise { + const lines = [ + '123456789', + '123456789' + ]; + await writeSync(page, lines.join('\\r\\n')); + assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n')); + }); + + it('preserve last empty lines', async function(): Promise { const cols = 10; const lines = [ @@ -281,15 +337,8 @@ describe('SerializeAddon', () => { '中文12', '1中文中文中' // this line is going to be wrapped at last character because it has line length of 11 (1+2*5) ]; - const expected = [ - '中文中文', - '12中文', - '中文12', - '1中文中文', - '中' - ]; await writeSync(page, lines.join('\\r\\n')); - assert.equal(await page.evaluate(`serializeAddon.serialize();`), expected.join('\r\n')); + assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n')); }); it('serialize CJK Mixed with tab correctly', async () => { @@ -315,7 +364,7 @@ describe('SerializeAddon', () => { ]; await writeSync(page, lines.join('\\r\\n')); - assert.equal(JSON.stringify(await page.evaluate(`window.term.buffer.active.type`)), '"alternate"'); + assert.equal(await page.evaluate(`window.term.buffer.active.type`), 'alternate'); assert.equal(JSON.stringify(await page.evaluate(`serializeAddon.serialize();`)), JSON.stringify(expected.join('\r\n'))); }); @@ -331,7 +380,7 @@ describe('SerializeAddon', () => { ]; await writeSync(page, lines.join('\\r\\n')); - assert.equal(JSON.stringify(await page.evaluate(`window.term.buffer.active === window.term.buffer.alt`)), 'false'); + assert.equal(await page.evaluate(`window.term.buffer.active.type`), 'normal'); assert.equal(JSON.stringify(await page.evaluate(`serializeAddon.serialize();`)), JSON.stringify(expected.join('\r\n'))); }); @@ -343,17 +392,7 @@ describe('SerializeAddon', () => { `2${CLEAR_RIGHT(9)}` ]; - await writeSync(page, lines.join('\\r\\n')); - const originalBuffer = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); - - const result = await page.evaluate(`serializeAddon.serialize();`) as string; - await page.evaluate(`term.reset();`); - await writeRawSync(page, result); - const newBuffer = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); - - // chai decides -0 and 0 are different number... - // and firefox have a bug that output -0 for unknown reason - assert.equal(JSON.stringify(originalBuffer), JSON.stringify(newBuffer)); + await testNormalScreenEqual(page, lines.join('\r\n')); }); it('cause the BCE on scroll', async () => { @@ -369,18 +408,23 @@ describe('SerializeAddon', () => { `\u001b[44m${CLEAR_RIGHT(5)}1111111111111111` ]; - await writeSync(page, lines.join('\\r\\n')); - const originalBuffer = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); + await testNormalScreenEqual(page, lines.join('\r\n')); + }); + it('handle invalid wrap', async () => { + const CLEAR_RIGHT = (l: number): string => `\u001b[${l}X`; + const MOVE_UP = (l: number): string => `\u001b[${l}A`; + const MOVE_DOWN = (l: number): string => `\u001b[${l}B`; - const result = await page.evaluate(`serializeAddon.serialize();`) as string; + const padLines = newArray( + (index: number) => digitsString(10, index), + 10 + ); - await page.evaluate(`term.reset();`); - await writeRawSync(page, result); - const newBuffer = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); + const lines = [ + `\u001b[44m${CLEAR_RIGHT(5)}123456789012345${MOVE_UP(1)}${CLEAR_RIGHT(5)}${MOVE_DOWN(1)}` + ]; - // chai decides -0 and 0 are different number... - // and firefox have a bug that output -0 for unknown reason - assert.equal(JSON.stringify(originalBuffer), JSON.stringify(newBuffer)); + await testNormalScreenEqual(page, lines.join('\r\n')); }); }); From aee1629c258939d9034f066bba1a91b99df8dc6b Mon Sep 17 00:00:00 2001 From: Mmis1000 Date: Fri, 18 Sep 2020 21:02:56 +0800 Subject: [PATCH 011/377] Reuse the cell object to redice gc --- addons/xterm-addon-serialize/src/SerializeAddon.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index 025f1833..dd34f780 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -106,6 +106,9 @@ class StringSerializeHandler extends BaseSerializeHandler { this._firstRow = start; } + private _thisRowLastChar: IBufferCell = this._buffer1.getNullCell(); + private _thisRowLastSecondChar: IBufferCell = this._buffer1.getNullCell(); + private _nextRowFirstChar: IBufferCell = this._buffer1.getNullCell(); protected _rowEnd(row: number, isLastRow: boolean): void { // if there is colorful empty cell at line end, whe must pad it back, or the the color block will missing if (this._nullCellCount > 0 && !equalBg(this._cursorStyle, this._backgroundCell)) { @@ -135,9 +138,9 @@ class StringSerializeHandler extends BaseSerializeHandler { this._lastCursorCol = 0; } else { rowSeparator = ''; - const thisRowLastChar = currentLine.getCell(currentLine.length - 1)!; - const thisRowLastSecondChar = currentLine.getCell(currentLine.length - 2)!; - const nextRowFirstChar = nextLine.getCell(0)!; + const thisRowLastChar = currentLine.getCell(currentLine.length - 1, this._thisRowLastChar)!; + const thisRowLastSecondChar = currentLine.getCell(currentLine.length - 2, this._thisRowLastSecondChar)!; + const nextRowFirstChar = nextLine.getCell(0, this._nextRowFirstChar)!; const isNextRowFirstCharDoubleWidth = nextRowFirstChar.getWidth() > 1; // validate whether this line wrap is ever possible From 47be9a2df4b7238c303357c658068d55a8a5ea68 Mon Sep 17 00:00:00 2001 From: Mmis1000 Date: Fri, 18 Sep 2020 22:02:30 +0800 Subject: [PATCH 012/377] Fix another error about impossible wrap --- .../src/SerializeAddon.ts | 5 ++ .../test/SerializeAddon.api.ts | 50 +++++++++++++++++-- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index dd34f780..ec8c6d0d 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -181,6 +181,11 @@ class StringSerializeHandler extends BaseSerializeHandler { rowSeparator += `\x1b[${this._nullCellCount}X`; rowSeparator += `\x1b[${currentLine.length - this._nullCellCount}D`; rowSeparator += '\x1b[B'; + + // This is content even it is invisible + // without this, wrap will be missing + this._lastContentCursorRow = row + 1; + this._lastContentCursorCol = 0; } // force commit the cursor position diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index 4bf6d1b5..5dc29d0d 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -335,7 +335,12 @@ describe('SerializeAddon', () => { '中文中文', '12中文', '中文12', - '1中文中文中' // this line is going to be wrapped at last character because it has line length of 11 (1+2*5) + // This line is going to be wrapped at last character + // because it has line length of 11 (1+2*5). + // We concat it back without the null cell currently. + // But this may be incorrect. + // see also #3097 + '1中文中文中' ]; await writeSync(page, lines.join('\\r\\n')); assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n')); @@ -410,21 +415,58 @@ describe('SerializeAddon', () => { await testNormalScreenEqual(page, lines.join('\r\n')); }); - it('handle invalid wrap', async () => { + + it('handle invalid wrap before scroll', async () => { const CLEAR_RIGHT = (l: number): string => `\u001b[${l}X`; const MOVE_UP = (l: number): string => `\u001b[${l}A`; const MOVE_DOWN = (l: number): string => `\u001b[${l}B`; + const MOVE_LEFT = (l: number): string => `\u001b[${l}D`; + + // A line wrap happened after current line. + // But there is no content. + // so wrap shouldn't even be able to happen. + const segments = [ + `123456789012345`, + MOVE_UP(1), + CLEAR_RIGHT(5), + MOVE_DOWN(1), + MOVE_LEFT(5), + CLEAR_RIGHT(5), + MOVE_UP(1), + '1' + ]; + + await testNormalScreenEqual(page, segments.join('')); + }); + + it('handle invalid wrap after scroll', async () => { + const CLEAR_RIGHT = (l: number): string => `\u001b[${l}X`; + const MOVE_UP = (l: number): string => `\u001b[${l}A`; + const MOVE_DOWN = (l: number): string => `\u001b[${l}B`; + const MOVE_LEFT = (l: number): string => `\u001b[${l}D`; const padLines = newArray( (index: number) => digitsString(10, index), 10 ); + // A line wrap happened after current line. + // But there is no content. + // so wrap shouldn't even be able to happen. const lines = [ - `\u001b[44m${CLEAR_RIGHT(5)}123456789012345${MOVE_UP(1)}${CLEAR_RIGHT(5)}${MOVE_DOWN(1)}` + padLines.join('\r\n'), + '\r\n', + `123456789012345`, + MOVE_UP(1), + CLEAR_RIGHT(5), + MOVE_DOWN(1), + MOVE_LEFT(5), + CLEAR_RIGHT(5), + MOVE_UP(1), + '1' ]; - await testNormalScreenEqual(page, lines.join('\r\n')); + await testNormalScreenEqual(page, lines.join('')); }); }); From a9d2b8a55c40b4d0b477edba5ef3c7d2f1d9fd4e Mon Sep 17 00:00:00 2001 From: Ken Aoki Date: Sat, 10 Oct 2020 04:04:52 +0000 Subject: [PATCH 013/377] Fix search not expanding selection to left when appropriate --- addons/xterm-addon-search/src/SearchAddon.ts | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/addons/xterm-addon-search/src/SearchAddon.ts b/addons/xterm-addon-search/src/SearchAddon.ts index f5505689..561794e1 100644 --- a/addons/xterm-addon-search/src/SearchAddon.ts +++ b/addons/xterm-addon-search/src/SearchAddon.ts @@ -141,14 +141,14 @@ export class SearchAddon implements ITerminalAddon { const isReverseSearch = true; let startRow = this._terminal.buffer.active.baseY + this._terminal.rows; let startCol = this._terminal.cols; - let result: ISearchResult | undefined; - const incremental = searchOptions ? searchOptions.incremental : false; let currentSelection: ISelectionPosition | undefined; if (this._terminal.hasSelection()) { - currentSelection = this._terminal.getSelectionPosition()!; + const incremental = searchOptions ? searchOptions.incremental : false; // Start from selection start if there is a selection - startRow = currentSelection.startRow; - startCol = currentSelection.startColumn; + // For incremental search, use selection end + currentSelection = this._terminal.getSelectionPosition()!; + startRow = incremental ? currentSelection.endRow : currentSelection.startRow; + startCol = incremental ? currentSelection.endColumn : currentSelection.startColumn; } this._initLinesCache(); @@ -157,14 +157,8 @@ export class SearchAddon implements ITerminalAddon { startCol }; - if (incremental) { - result = this._findInLine(term, searchPosition, searchOptions, false); - if (!(result && result.row === startRow && result.col === startCol)) { - result = this._findInLine(term, searchPosition, searchOptions, true); - } - } else { - result = this._findInLine(term, searchPosition, searchOptions, isReverseSearch); - } + // Search startRow + let result = this._findInLine(term, searchPosition, searchOptions, isReverseSearch); // Search from startRow - 1 to top if (!result) { From b6074df4bf76e996fea449dc718a2122ceeab30a Mon Sep 17 00:00:00 2001 From: Ken Aoki Date: Tue, 13 Oct 2020 06:44:01 +0000 Subject: [PATCH 014/377] Revert "Fix search not expanding selection to left when appropriate" This reverts commit a9d2b8a55c40b4d0b477edba5ef3c7d2f1d9fd4e. --- addons/xterm-addon-search/src/SearchAddon.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/addons/xterm-addon-search/src/SearchAddon.ts b/addons/xterm-addon-search/src/SearchAddon.ts index 561794e1..f5505689 100644 --- a/addons/xterm-addon-search/src/SearchAddon.ts +++ b/addons/xterm-addon-search/src/SearchAddon.ts @@ -141,14 +141,14 @@ export class SearchAddon implements ITerminalAddon { const isReverseSearch = true; let startRow = this._terminal.buffer.active.baseY + this._terminal.rows; let startCol = this._terminal.cols; + let result: ISearchResult | undefined; + const incremental = searchOptions ? searchOptions.incremental : false; let currentSelection: ISelectionPosition | undefined; if (this._terminal.hasSelection()) { - const incremental = searchOptions ? searchOptions.incremental : false; - // Start from selection start if there is a selection - // For incremental search, use selection end currentSelection = this._terminal.getSelectionPosition()!; - startRow = incremental ? currentSelection.endRow : currentSelection.startRow; - startCol = incremental ? currentSelection.endColumn : currentSelection.startColumn; + // Start from selection start if there is a selection + startRow = currentSelection.startRow; + startCol = currentSelection.startColumn; } this._initLinesCache(); @@ -157,8 +157,14 @@ export class SearchAddon implements ITerminalAddon { startCol }; - // Search startRow - let result = this._findInLine(term, searchPosition, searchOptions, isReverseSearch); + if (incremental) { + result = this._findInLine(term, searchPosition, searchOptions, false); + if (!(result && result.row === startRow && result.col === startCol)) { + result = this._findInLine(term, searchPosition, searchOptions, true); + } + } else { + result = this._findInLine(term, searchPosition, searchOptions, isReverseSearch); + } // Search from startRow - 1 to top if (!result) { From d3d8ec3b2018c51f6cbd3ee8b5225d8449d044db Mon Sep 17 00:00:00 2001 From: Ken Aoki Date: Tue, 13 Oct 2020 09:55:10 +0000 Subject: [PATCH 015/377] Fix search not expanding selection to left when appropriate (revenge) --- addons/xterm-addon-search/src/SearchAddon.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/xterm-addon-search/src/SearchAddon.ts b/addons/xterm-addon-search/src/SearchAddon.ts index f5505689..54a4a198 100644 --- a/addons/xterm-addon-search/src/SearchAddon.ts +++ b/addons/xterm-addon-search/src/SearchAddon.ts @@ -158,8 +158,13 @@ export class SearchAddon implements ITerminalAddon { }; if (incremental) { - result = this._findInLine(term, searchPosition, searchOptions, false); + result = this._findInLine(term, searchPosition, searchOptions, false); // Try to expand selection to right first. if (!(result && result.row === startRow && result.col === startCol)) { + // If selection was not able to be expanded to right, then reverse search begin. + if (currentSelection) { + searchPosition.startRow = currentSelection.endRow; + searchPosition.startCol = currentSelection.endColumn; + } result = this._findInLine(term, searchPosition, searchOptions, true); } } else { From 5c7644adc0bb6fc2691fe29cd5d0a69dfee5cd42 Mon Sep 17 00:00:00 2001 From: Slawek Zachcial Date: Tue, 3 Nov 2020 18:36:28 +0100 Subject: [PATCH 016/377] Add rudimenatary and not fully working support of OSC 4 --- src/browser/Terminal.ts | 17 +++++++++++++++++ src/common/InputHandler.ts | 17 +++++++++++++++++ src/common/Types.d.ts | 1 + 3 files changed, 35 insertions(+) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index f8b8b3e4..115ccce7 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -53,6 +53,7 @@ import { Linkifier2 } from 'browser/Linkifier2'; import { CoreBrowserService } from 'browser/services/CoreBrowserService'; import { CoreTerminal } from 'common/CoreTerminal'; import { ITerminalOptions as IInitializedTerminalOptions } from 'common/services/Services'; +import { css } from 'browser/Color'; // Let it work inside Node.js for automated testing purposes. const document: Document = (typeof window !== 'undefined') ? window.document : null as any; @@ -150,6 +151,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this.register(this._inputHandler.onRequestWindowsOptionsReport(type => this._reportWindowsOptions(type))); this.register(forwardEvent(this._inputHandler.onCursorMove, this._onCursorMove)); this.register(forwardEvent(this._inputHandler.onTitleChange, this._onTitleChange)); + this.register(this._inputHandler.onAnsiColorChange((index, color) => this.changeAnsiColor(index, color))); this.register(forwardEvent(this._inputHandler.onA11yChar, this._onA11yCharEmitter)); this.register(forwardEvent(this._inputHandler.onA11yTab, this._onA11yTabEmitter)); @@ -157,6 +159,21 @@ export class Terminal extends CoreTerminal implements ITerminal { this.register(this._bufferService.onResize(e => this._afterResize(e.cols, e.rows))); } + private changeAnsiColor(colorIndex: number, colorValue: string): void { + // colorValue = rgb:xx/yy/zz + const r = colorValue.substring(4, 6); + const g = colorValue.substring(7, 9); + const b = colorValue.substring(10, 12); + const color = `#${r}${g}${b}`; + + //TODO: remove debug + console.log(`Change ANSI color[${colorIndex}]=${colorValue} (${color})`); + + this._colorManager!.colors.ansi[colorIndex] = css.toColor(color); + this._renderService?.setColors(this._colorManager!.colors); + this.viewport?.onThemeChange(this._colorManager!.colors); + } + public dispose(): void { if (this._isDisposed) { return; diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index dbf695e6..3dd0c11b 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -250,6 +250,8 @@ export class InputHandler extends Disposable implements IInputHandler { public get onScroll(): IEvent { return this._onScroll.event; } private _onTitleChange = new EventEmitter(); public get onTitleChange(): IEvent { return this._onTitleChange.event; } + private _onAnsiColorChange = new EventEmitter(); + public get onAnsiColorChange(): IEvent { return this._onAnsiColorChange.event; } constructor( private readonly _bufferService: IBufferService, @@ -372,6 +374,12 @@ export class InputHandler extends Disposable implements IInputHandler { this._parser.setOscHandler(2, new OscHandler((data: string) => this.setTitle(data))); // 3 - set property X in the form "prop=value" // 4 - Change Color Number + this._parser.setOscHandler(4, new OscHandler((data: string) => { + const ansiColor = data.split(';'); + const colorIndex = parseInt(ansiColor[0]); + const colorValue = ansiColor[1]; + this.setAnsiColor(colorIndex, colorValue); + })); // 5 - Change Special Color Number // 6 - Enable/disable Special Color Number c // 7 - current directory? (not in xterm spec, see https://gitlab.com/gnachman/iterm2/issues/3939) @@ -2711,6 +2719,15 @@ export class InputHandler extends Disposable implements IInputHandler { this._iconName = data; } + /** + * OSC 4; ; ST (set ANSI color to ) + */ + public setAnsiColor(colorIndex: number, colorData: string): void { + //TODO: remove debug + console.log(`Setting ANSI color ${colorIndex} to value ${colorData}`); + this._onAnsiColorChange.fire(colorIndex, colorData); + } + /** * ESC E * C1.NEL diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index bd0d11c6..00497932 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -389,6 +389,7 @@ export interface IInputHandler { /** CSI ' ~ */ deleteColumns(params: IParams): void; /** OSC 0 OSC 2 */ setTitle(data: string): void; + /** OSC 4 */ setAnsiColor(colorIndex: number, colorData: string): void; /** ESC E */ nextLine(): void; /** ESC = */ keypadApplicationMode(): void; /** ESC > */ keypadNumericMode(): void; From b22d7f1140676e1e39b08fcbe7b62d0ce4660243 Mon Sep 17 00:00:00 2001 From: Slawek Zachcial Date: Wed, 4 Nov 2020 22:19:55 +0100 Subject: [PATCH 017/377] Move color parsing from Terminal to InputHandler --- src/browser/Terminal.ts | 19 ++++++------------- src/common/InputHandler.ts | 39 +++++++++++++++++++++++++------------- src/common/Types.d.ts | 2 +- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 115ccce7..216b541a 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -39,7 +39,7 @@ import { MouseZoneManager } from 'browser/MouseZoneManager'; import { AccessibilityManager } from './AccessibilityManager'; import { ITheme, IMarker, IDisposable, ISelectionPosition, ILinkProvider } from 'xterm'; import { DomRenderer } from 'browser/renderer/dom/DomRenderer'; -import { IKeyboardEvent, KeyboardResultType, CoreMouseEventType, CoreMouseButton, CoreMouseAction, ITerminalOptions } from 'common/Types'; +import { IKeyboardEvent, KeyboardResultType, CoreMouseEventType, CoreMouseButton, CoreMouseAction, ITerminalOptions, IColorRGB } from 'common/Types'; import { evaluateKeyboardEvent } from 'common/input/Keyboard'; import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter'; import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; @@ -53,7 +53,7 @@ import { Linkifier2 } from 'browser/Linkifier2'; import { CoreBrowserService } from 'browser/services/CoreBrowserService'; import { CoreTerminal } from 'common/CoreTerminal'; import { ITerminalOptions as IInitializedTerminalOptions } from 'common/services/Services'; -import { css } from 'browser/Color'; +import { rgba } from 'browser/Color'; // Let it work inside Node.js for automated testing purposes. const document: Document = (typeof window !== 'undefined') ? window.document : null as any; @@ -151,7 +151,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this.register(this._inputHandler.onRequestWindowsOptionsReport(type => this._reportWindowsOptions(type))); this.register(forwardEvent(this._inputHandler.onCursorMove, this._onCursorMove)); this.register(forwardEvent(this._inputHandler.onTitleChange, this._onTitleChange)); - this.register(this._inputHandler.onAnsiColorChange((index, color) => this.changeAnsiColor(index, color))); + this.register(this._inputHandler.onAnsiColorChange((index, color) => this._changeAnsiColor(index, color))); this.register(forwardEvent(this._inputHandler.onA11yChar, this._onA11yCharEmitter)); this.register(forwardEvent(this._inputHandler.onA11yTab, this._onA11yTabEmitter)); @@ -159,17 +159,10 @@ export class Terminal extends CoreTerminal implements ITerminal { this.register(this._bufferService.onResize(e => this._afterResize(e.cols, e.rows))); } - private changeAnsiColor(colorIndex: number, colorValue: string): void { - // colorValue = rgb:xx/yy/zz - const r = colorValue.substring(4, 6); - const g = colorValue.substring(7, 9); - const b = colorValue.substring(10, 12); - const color = `#${r}${g}${b}`; + private _changeAnsiColor(colorIndex: number, colorRGB: IColorRGB): void { + const color = rgba.toColor(colorRGB[0], colorRGB[1], colorRGB[2]); - //TODO: remove debug - console.log(`Change ANSI color[${colorIndex}]=${colorValue} (${color})`); - - this._colorManager!.colors.ansi[colorIndex] = css.toColor(color); + this._colorManager!.colors.ansi[colorIndex] = color; this._renderService?.setColors(this._colorManager!.colors); this.viewport?.onThemeChange(this._colorManager!.colors); } diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 3dd0c11b..46350a14 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -4,7 +4,7 @@ * @license MIT */ -import { IInputHandler, IAttributeData, IDisposable, IWindowOptions } from 'common/Types'; +import { IInputHandler, IAttributeData, IDisposable, IWindowOptions, IColorRGB } from 'common/Types'; import { C0, C1 } from 'common/data/EscapeSequences'; import { CHARSETS, DEFAULT_CHARSET } from 'common/data/Charsets'; import { EscapeSequenceParser } from 'common/parser/EscapeSequenceParser'; @@ -250,8 +250,8 @@ export class InputHandler extends Disposable implements IInputHandler { public get onScroll(): IEvent { return this._onScroll.event; } private _onTitleChange = new EventEmitter(); public get onTitleChange(): IEvent { return this._onTitleChange.event; } - private _onAnsiColorChange = new EventEmitter(); - public get onAnsiColorChange(): IEvent { return this._onAnsiColorChange.event; } + private _onAnsiColorChange = new EventEmitter(); + public get onAnsiColorChange(): IEvent { return this._onAnsiColorChange.event; } constructor( private readonly _bufferService: IBufferService, @@ -374,12 +374,7 @@ export class InputHandler extends Disposable implements IInputHandler { this._parser.setOscHandler(2, new OscHandler((data: string) => this.setTitle(data))); // 3 - set property X in the form "prop=value" // 4 - Change Color Number - this._parser.setOscHandler(4, new OscHandler((data: string) => { - const ansiColor = data.split(';'); - const colorIndex = parseInt(ansiColor[0]); - const colorValue = ansiColor[1]; - this.setAnsiColor(colorIndex, colorValue); - })); + this._parser.setOscHandler(4, new OscHandler((data: string) => this.setAnsiColor(data))); // 5 - Change Special Color Number // 6 - Enable/disable Special Color Number c // 7 - current directory? (not in xterm spec, see https://gitlab.com/gnachman/iterm2/issues/3939) @@ -2721,11 +2716,29 @@ export class InputHandler extends Disposable implements IInputHandler { /** * OSC 4; ; ST (set ANSI color to ) + * + * The expected content of data is: ;rgb:// where rr, gg, bb are hex numbers. */ - public setAnsiColor(colorIndex: number, colorData: string): void { - //TODO: remove debug - console.log(`Setting ANSI color ${colorIndex} to value ${colorData}`); - this._onAnsiColorChange.fire(colorIndex, colorData); + public setAnsiColor(data: string): void { + // example data: 5;rgb:aa/bb/cc + const regex = /(\d+);rgb:([0-9a-fA-F]{2})\/([0-9a-fA-F]{2})\/([0-9a-fA-F]{2})/; + const match = data.match(regex); + + if (match) { + const colorIndex = parseInt(match[1]); + const color: IColorRGB = [ + parseInt(match[2], 16), + parseInt(match[3], 16), + parseInt(match[4], 16) + ]; + + //TODO: remove debug + console.log(`Setting ANSI color ${colorIndex} to RGB value ${color}`); + this._onAnsiColorChange.fire(colorIndex, color); + } + else { + this._logService.warn(`Expected format ;rgb:// but got data: ${data}`); + } } /** diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index 00497932..4967da12 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -389,7 +389,7 @@ export interface IInputHandler { /** CSI ' ~ */ deleteColumns(params: IParams): void; /** OSC 0 OSC 2 */ setTitle(data: string): void; - /** OSC 4 */ setAnsiColor(colorIndex: number, colorData: string): void; + /** OSC 4 */ setAnsiColor(data: string): void; /** ESC E */ nextLine(): void; /** ESC = */ keypadApplicationMode(): void; /** ESC > */ keypadNumericMode(): void; From b127436cc4f004964b252404605c66843ebe131c Mon Sep 17 00:00:00 2001 From: Slawek Zachcial Date: Thu, 5 Nov 2020 08:51:01 +0100 Subject: [PATCH 018/377] Fix TODO comment --- src/common/InputHandler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 46350a14..1b235abf 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -2732,7 +2732,7 @@ export class InputHandler extends Disposable implements IInputHandler { parseInt(match[4], 16) ]; - //TODO: remove debug + // TODO: remove debug console.log(`Setting ANSI color ${colorIndex} to RGB value ${color}`); this._onAnsiColorChange.fire(colorIndex, color); } From b898e016f3e252f4e8ca65a520ef6a65803cc9d1 Mon Sep 17 00:00:00 2001 From: Slawek Zachcial Date: Sat, 7 Nov 2020 21:33:42 +0100 Subject: [PATCH 019/377] Add IAnsiColorChangeEvent type --- src/browser/Terminal.ts | 10 ++++---- src/common/InputHandler.test.ts | 2 +- src/common/InputHandler.ts | 42 +++++++++++++++++++-------------- src/common/Types.d.ts | 10 ++++++++ 4 files changed, 40 insertions(+), 24 deletions(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 216b541a..9452833e 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -39,7 +39,7 @@ import { MouseZoneManager } from 'browser/MouseZoneManager'; import { AccessibilityManager } from './AccessibilityManager'; import { ITheme, IMarker, IDisposable, ISelectionPosition, ILinkProvider } from 'xterm'; import { DomRenderer } from 'browser/renderer/dom/DomRenderer'; -import { IKeyboardEvent, KeyboardResultType, CoreMouseEventType, CoreMouseButton, CoreMouseAction, ITerminalOptions, IColorRGB } from 'common/Types'; +import { IKeyboardEvent, KeyboardResultType, CoreMouseEventType, CoreMouseButton, CoreMouseAction, ITerminalOptions, IAnsiColorChangeEvent } from 'common/Types'; import { evaluateKeyboardEvent } from 'common/input/Keyboard'; import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter'; import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; @@ -149,9 +149,9 @@ export class Terminal extends CoreTerminal implements ITerminal { this.register(this._inputHandler.onRequestReset(() => this.reset())); this.register(this._inputHandler.onRequestScroll((eraseAttr, isWrapped) => this.scroll(eraseAttr, isWrapped || undefined))); this.register(this._inputHandler.onRequestWindowsOptionsReport(type => this._reportWindowsOptions(type))); + this.register(this._inputHandler.onAnsiColorChange((event) => this._changeAnsiColor(event))); this.register(forwardEvent(this._inputHandler.onCursorMove, this._onCursorMove)); this.register(forwardEvent(this._inputHandler.onTitleChange, this._onTitleChange)); - this.register(this._inputHandler.onAnsiColorChange((index, color) => this._changeAnsiColor(index, color))); this.register(forwardEvent(this._inputHandler.onA11yChar, this._onA11yCharEmitter)); this.register(forwardEvent(this._inputHandler.onA11yTab, this._onA11yTabEmitter)); @@ -159,10 +159,10 @@ export class Terminal extends CoreTerminal implements ITerminal { this.register(this._bufferService.onResize(e => this._afterResize(e.cols, e.rows))); } - private _changeAnsiColor(colorIndex: number, colorRGB: IColorRGB): void { - const color = rgba.toColor(colorRGB[0], colorRGB[1], colorRGB[2]); + private _changeAnsiColor(event: IAnsiColorChangeEvent): void { + const color = rgba.toColor(event.red, event.green, event.blue); - this._colorManager!.colors.ansi[colorIndex] = color; + this._colorManager!.colors.ansi[event.colorIndex] = color; this._renderService?.setColors(this._colorManager!.colors); this.viewport?.onThemeChange(this._colorManager!.colors); } diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index 46f8eacc..6ff0fd57 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -5,7 +5,7 @@ import { assert, expect } from 'chai'; import { InputHandler } from 'common/InputHandler'; -import { IBufferLine, IAttributeData } from 'common/Types'; +import { IBufferLine, IAttributeData, IAnsiColorChangeEvent } from 'common/Types'; import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; import { CellData } from 'common/buffer/CellData'; import { Attributes, UnderlineStyle } from 'common/buffer/Constants'; diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 1b235abf..0bd1b3a6 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -4,7 +4,7 @@ * @license MIT */ -import { IInputHandler, IAttributeData, IDisposable, IWindowOptions, IColorRGB } from 'common/Types'; +import { IInputHandler, IAttributeData, IDisposable, IWindowOptions, IAnsiColorChangeEvent } from 'common/Types'; import { C0, C1 } from 'common/data/EscapeSequences'; import { CHARSETS, DEFAULT_CHARSET } from 'common/data/Charsets'; import { EscapeSequenceParser } from 'common/parser/EscapeSequenceParser'; @@ -250,8 +250,8 @@ export class InputHandler extends Disposable implements IInputHandler { public get onScroll(): IEvent { return this._onScroll.event; } private _onTitleChange = new EventEmitter(); public get onTitleChange(): IEvent { return this._onTitleChange.event; } - private _onAnsiColorChange = new EventEmitter(); - public get onAnsiColorChange(): IEvent { return this._onAnsiColorChange.event; } + private _onAnsiColorChange = new EventEmitter(); + public get onAnsiColorChange(): IEvent { return this._onAnsiColorChange.event; } constructor( private readonly _bufferService: IBufferService, @@ -2714,27 +2714,33 @@ export class InputHandler extends Disposable implements IInputHandler { this._iconName = data; } + // This is really an internal method and not part of IInputHandler implementation. + // Making it public so that I can test it. + public parseAnsiColorChange(data: string): IAnsiColorChangeEvent | null { + // example data: 5;rgb:aa/bb/cc + const regex = /(\d+);rgb:([0-9a-fA-F]{2})\/([0-9a-fA-F]{2})\/([0-9a-fA-F]{2})/; + const match = data.match(regex); + + if (match) { + return { + colorIndex: parseInt(match[1]), + red: parseInt(match[2], 16), + green: parseInt(match[3], 16), + blue: parseInt(match[4], 16) + }; + } + return null; + } + /** * OSC 4; ; ST (set ANSI color to ) * * The expected content of data is: ;rgb:// where rr, gg, bb are hex numbers. */ public setAnsiColor(data: string): void { - // example data: 5;rgb:aa/bb/cc - const regex = /(\d+);rgb:([0-9a-fA-F]{2})\/([0-9a-fA-F]{2})\/([0-9a-fA-F]{2})/; - const match = data.match(regex); - - if (match) { - const colorIndex = parseInt(match[1]); - const color: IColorRGB = [ - parseInt(match[2], 16), - parseInt(match[3], 16), - parseInt(match[4], 16) - ]; - - // TODO: remove debug - console.log(`Setting ANSI color ${colorIndex} to RGB value ${color}`); - this._onAnsiColorChange.fire(colorIndex, color); + const event = this.parseAnsiColorChange(data); + if (event) { + this._onAnsiColorChange.fire(event); } else { this._logService.warn(`Expected format ;rgb:// but got data: ${data}`); diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index 4967da12..cbb11b3f 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -328,6 +328,16 @@ export interface IWindowOptions { setWinLines?: boolean; } +/** + * Event fired for OSC 4 command - to change ANSI color based on its index. + */ +export interface IAnsiColorChangeEvent { + colorIndex: number; + red: number; + green: number; + blue: number; +} + /** * Calls the parser and handles actions generated by the parser. */ From d5f4ae53c902ed972cc0bf7d57b083ad61160b03 Mon Sep 17 00:00:00 2001 From: Slawek Zachcial Date: Sat, 7 Nov 2020 21:34:21 +0100 Subject: [PATCH 020/377] Add IAnsiColorChangeEvent related tests --- src/common/InputHandler.test.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index 6ff0fd57..3b8d1387 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -1692,4 +1692,25 @@ describe('InputHandler', () => { assert.equal(coreService.decPrivateModes.origin, false); }); }); + describe('OSC', () => { + it('should ignore incorrect Ansi color change data', () => { + assert.deepEqual(inputHandler.parseAnsiColorChange('17;rgb:1a/2b/3c'), { + colorIndex: 17, + red: 0x1a, + green: 0x2b, + blue: 0x3c + }); + assert.isNull(inputHandler.parseAnsiColorChange('17;rgb:a/b/c')); + assert.isNull(inputHandler.parseAnsiColorChange('17;rgb:#aabbcc')); + assert.isNull(inputHandler.parseAnsiColorChange('17;rgba:aa/bb/cc')); + assert.isNull(inputHandler.parseAnsiColorChange('rgb:aa/bb/cc')); + }); + it('should fire event on Ansi color change', (done) => { + inputHandler.onAnsiColorChange(e => { + assert.deepEqual(e, { colorIndex: 17, red: 0x1a, green: 0x2b, blue: 0x3c }); + done(); + }); + inputHandler.parse('\x1b]4;17;rgb:1a/2b/3c\x1b\\'); + }); + }); }); From bc86b7804c40f5036b8fc97c93b6dfccb5e5ea07 Mon Sep 17 00:00:00 2001 From: Slawek Zachcial Date: Sat, 7 Nov 2020 21:35:36 +0100 Subject: [PATCH 021/377] Use all and not only 16 Ansi colors in CharAtlas config --- src/browser/renderer/atlas/CharAtlasUtils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/browser/renderer/atlas/CharAtlasUtils.ts b/src/browser/renderer/atlas/CharAtlasUtils.ts index 346b35f8..2b876f2b 100644 --- a/src/browser/renderer/atlas/CharAtlasUtils.ts +++ b/src/browser/renderer/atlas/CharAtlasUtils.ts @@ -18,7 +18,9 @@ export function generateConfig(scaledCharWidth: number, scaledCharHeight: number selection: undefined, // For the static char atlas, we only use the first 16 colors, but we need all 256 for the // dynamic character atlas. - ansi: colors.ansi.slice(0, 16) + // ansi: colors.ansi.slice(0, 16) + // TODO: Using entire array to support OSC 4; can this break anything? + ansi: colors.ansi }; return { devicePixelRatio: window.devicePixelRatio, From 77ed5ba7edf6445655c5a4efe61d37315f34500b Mon Sep 17 00:00:00 2001 From: Slawek Zachcial Date: Sun, 8 Nov 2020 10:19:12 +0100 Subject: [PATCH 022/377] Add terminal sequence doc --- src/common/InputHandler.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 0bd1b3a6..aec5c7a9 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -2735,7 +2735,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * OSC 4; ; ST (set ANSI color to ) * - * The expected content of data is: ;rgb:// where rr, gg, bb are hex numbers. + * @vt: #Y OSC 4 "Set ANSI color" "OSC 4 ; Ps ; Pt BEL" "Set ANSI color `Ps` to `Pt`." + * `Ps` is the color index between 0 and 255. `Pt` color format is 'rgb:rr/gg/bb' where r, g, b are hexadecimal digits. */ public setAnsiColor(data: string): void { const event = this.parseAnsiColorChange(data); From 653599575359c382eac3670525a1ec4cd911b742 Mon Sep 17 00:00:00 2001 From: Slawek Zachcial Date: Sun, 8 Nov 2020 22:05:25 +0100 Subject: [PATCH 023/377] Update OSC 4 description to match #3036 --- src/common/InputHandler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index aec5c7a9..235515b1 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -2735,8 +2735,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * OSC 4; ; ST (set ANSI color to ) * - * @vt: #Y OSC 4 "Set ANSI color" "OSC 4 ; Ps ; Pt BEL" "Set ANSI color `Ps` to `Pt`." - * `Ps` is the color index between 0 and 255. `Pt` color format is 'rgb:rr/gg/bb' where r, g, b are hexadecimal digits. + * @vt: #Y OSC 4 "Set ANSI color" "OSC 4 ; c ; spec BEL" "Change color number `c` to the color specified by `spec`." + * `c` is the color index between 0 and 255. `spec` color format is 'rgb:rr/gg/bb' where r, g, b are hexadecimal digits. */ public setAnsiColor(data: string): void { const event = this.parseAnsiColorChange(data); From e6917d19330364e4eb3d274644ad08b442cc8cf0 Mon Sep 17 00:00:00 2001 From: Slawek Zachcial Date: Sun, 8 Nov 2020 22:07:24 +0100 Subject: [PATCH 024/377] Clarify color spec description --- src/common/InputHandler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 235515b1..7867a3fe 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -2736,7 +2736,7 @@ export class InputHandler extends Disposable implements IInputHandler { * OSC 4; ; ST (set ANSI color to ) * * @vt: #Y OSC 4 "Set ANSI color" "OSC 4 ; c ; spec BEL" "Change color number `c` to the color specified by `spec`." - * `c` is the color index between 0 and 255. `spec` color format is 'rgb:rr/gg/bb' where r, g, b are hexadecimal digits. + * `c` is the color index between 0 and 255. `spec` color format is 'rgb:hh/hh/hh' where `h` are hexadecimal digits. */ public setAnsiColor(data: string): void { const event = this.parseAnsiColorChange(data); From 04e2bdd6ec6a80846322464243067bde2d0fc240 Mon Sep 17 00:00:00 2001 From: Tony Mottaz Date: Fri, 20 Nov 2020 19:50:03 -0600 Subject: [PATCH 025/377] Make alt+click behavior configurable --- src/browser/services/SelectionService.ts | 2 +- src/common/services/OptionsService.ts | 2 +- src/common/services/Services.ts | 1 + typings/xterm.d.ts | 5 +++++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/browser/services/SelectionService.ts b/src/browser/services/SelectionService.ts index 81e72087..6caca2a0 100644 --- a/src/browser/services/SelectionService.ts +++ b/src/browser/services/SelectionService.ts @@ -676,7 +676,7 @@ export class SelectionService extends Disposable implements ISelectionService { this._bufferService.rows, false ); - if (coordinates && coordinates[0] !== undefined && coordinates[1] !== undefined) { + if (this._optionsService.getOption('altClickMovesCursor') && coordinates && coordinates[0] !== undefined && coordinates[1] !== undefined) { const sequence = moveToCellSequence(coordinates[0] - 1, coordinates[1] - 1, this._bufferService, this._coreService.decPrivateModes.applicationCursorKeys); this._coreService.triggerDataEvent(sequence, true); } diff --git a/src/common/services/OptionsService.ts b/src/common/services/OptionsService.ts index 6c43c303..b7a1c58e 100644 --- a/src/common/services/OptionsService.ts +++ b/src/common/services/OptionsService.ts @@ -50,7 +50,7 @@ export const DEFAULT_OPTIONS: ITerminalOptions = Object.freeze({ windowOptions: {}, windowsMode: false, wordSeparator: ' ()[]{}\',"`', - + altClickMovesCursor: true, convertEol: false, termName: 'xterm', cancelEvents: false diff --git a/src/common/services/Services.ts b/src/common/services/Services.ts index 0ea7a308..9845fdc4 100644 --- a/src/common/services/Services.ts +++ b/src/common/services/Services.ts @@ -220,6 +220,7 @@ export interface IPartialTerminalOptions { export interface ITerminalOptions { allowProposedApi: boolean; allowTransparency: boolean; + altClickMovesCursor: boolean; bellSound: string; bellStyle: 'none' | 'sound' /* | 'visual' | 'both' */; cols: number; diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index b5a736a7..795dd2c6 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -44,6 +44,11 @@ declare module 'xterm' { */ allowTransparency?: boolean; + /** + * If enabled, alt + click will move the prompt cursor to position underneath the mouse. + */ + altClickMovesCursor?: boolean; + /** * A data uri of the sound to use for the bell when `bellStyle = 'sound'`. */ From f68ff2a455f3618d638baf25503c8c932e291506 Mon Sep 17 00:00:00 2001 From: Tony Mottaz Date: Sun, 22 Nov 2020 10:00:02 -0600 Subject: [PATCH 026/377] Check for alt+click option sooner --- src/browser/services/SelectionService.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/browser/services/SelectionService.ts b/src/browser/services/SelectionService.ts index 6caca2a0..a3d8d12c 100644 --- a/src/browser/services/SelectionService.ts +++ b/src/browser/services/SelectionService.ts @@ -667,7 +667,7 @@ export class SelectionService extends Disposable implements ISelectionService { this._removeMouseDownListeners(); - if (this.selectionText.length <= 1 && timeElapsed < ALT_CLICK_MOVE_CURSOR_TIME && event.altKey) { + if (this.selectionText.length <= 1 && timeElapsed < ALT_CLICK_MOVE_CURSOR_TIME && event.altKey && this._optionsService.getOption('altClickMovesCursor')) { if (this._bufferService.buffer.ybase === this._bufferService.buffer.ydisp) { const coordinates = this._mouseService.getCoords( event, @@ -676,7 +676,7 @@ export class SelectionService extends Disposable implements ISelectionService { this._bufferService.rows, false ); - if (this._optionsService.getOption('altClickMovesCursor') && coordinates && coordinates[0] !== undefined && coordinates[1] !== undefined) { + if (coordinates && coordinates[0] !== undefined && coordinates[1] !== undefined) { const sequence = moveToCellSequence(coordinates[0] - 1, coordinates[1] - 1, this._bufferService, this._coreService.decPrivateModes.applicationCursorKeys); this._coreService.triggerDataEvent(sequence, true); } From 78ddb9febaac00bddd5c0953c15a6534d619a833 Mon Sep 17 00:00:00 2001 From: Tony Mottaz Date: Sun, 22 Nov 2020 10:00:41 -0600 Subject: [PATCH 027/377] Add 'altClickMovesCursor' option to getOption/setOption in Terminal --- src/browser/public/Terminal.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index 33aa9024..64c65fe9 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -170,7 +170,7 @@ export class Terminal implements ITerminalApi { this._core.paste(data); } public getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string; - public getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell'): boolean; + public getOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell'): boolean; public getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; public getOption(key: 'fontWeight' | 'fontWeightBold'): FontWeight; public getOption(key: string): any; @@ -182,7 +182,7 @@ export class Terminal implements ITerminalApi { public setOption(key: 'logLevel', value: 'debug' | 'info' | 'warn' | 'error' | 'off'): void; public setOption(key: 'bellStyle', value: 'none' | 'visual' | 'sound' | 'both'): void; public setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void; - public setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell', value: boolean): void; + public setOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell', value: boolean): void; public setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; public setOption(key: 'theme', value: ITheme): void; public setOption(key: 'cols' | 'rows', value: number): void; From 88f0b91056adc444bd1197d42c2bfdc112d4c1b2 Mon Sep 17 00:00:00 2001 From: Tony Mottaz Date: Sun, 22 Nov 2020 10:01:02 -0600 Subject: [PATCH 028/377] add altClickMovesCursor option to Services type --- src/common/services/Services.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/services/Services.ts b/src/common/services/Services.ts index 9845fdc4..c733e73e 100644 --- a/src/common/services/Services.ts +++ b/src/common/services/Services.ts @@ -184,6 +184,7 @@ export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off'; export type RendererType = 'dom' | 'canvas'; export interface IPartialTerminalOptions { + altClickMovesCursor?: boolean; allowTransparency?: boolean; bellSound?: string; bellStyle?: 'none' | 'sound' /* | 'visual' | 'both' */; From e3cccd619b541bf7ce88e65a9c3d10a7fca0af58 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 24 Nov 2020 09:03:59 -0800 Subject: [PATCH 029/377] Update typings/xterm.d.ts --- typings/xterm.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 795dd2c6..d860ddfa 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -45,7 +45,8 @@ declare module 'xterm' { allowTransparency?: boolean; /** - * If enabled, alt + click will move the prompt cursor to position underneath the mouse. + * If enabled, alt + click will move the prompt cursor to position + * underneath the mouse. The default is true. */ altClickMovesCursor?: boolean; From b7695d2fd64fc06aa3a41c8d4ec15be6bfd21170 Mon Sep 17 00:00:00 2001 From: "condichen@tencent.com" <178854407@qq.com> Date: Sat, 28 Nov 2020 00:54:56 +0800 Subject: [PATCH 030/377] fix shift+cmd+a will Select all --- src/common/input/Keyboard.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/input/Keyboard.ts b/src/common/input/Keyboard.ts index fdb777b4..20a28f61 100644 --- a/src/common/input/Keyboard.ts +++ b/src/common/input/Keyboard.ts @@ -356,7 +356,7 @@ export function evaluateKeyboardEvent( const keyCode = ev.ctrlKey ? ev.keyCode - 64 : ev.keyCode + 32; result.key = C0.ESC + String.fromCharCode(keyCode); } - } else if (isMac && !ev.altKey && !ev.ctrlKey && ev.metaKey) { + } else if (isMac && !ev.altKey && !ev.ctrlKey && !ev.shiftKey && ev.metaKey) { if (ev.keyCode === 65) { // cmd + a result.type = KeyboardResultType.SELECT_ALL; } From ec1234e8d8ed2b2dd635badf16000cfb697484e2 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Fri, 27 Nov 2020 14:17:57 -0600 Subject: [PATCH 031/377] fix: update font-finder to v1.1.0 --- addons/xterm-addon-ligatures/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/xterm-addon-ligatures/package.json b/addons/xterm-addon-ligatures/package.json index df85c020..a35cfc5c 100644 --- a/addons/xterm-addon-ligatures/package.json +++ b/addons/xterm-addon-ligatures/package.json @@ -31,7 +31,7 @@ ], "license": "MIT", "dependencies": { - "font-finder": "^1.0.4", + "font-finder": "^1.1.0", "font-ligatures": "^1.3.3" }, "devDependencies": { From 52b64beefce87e48f0b3d81ee795b643f6faa7cd Mon Sep 17 00:00:00 2001 From: Slawek Zachcial Date: Sun, 29 Nov 2020 16:30:05 +0100 Subject: [PATCH 032/377] Make InputHandler parseAnsiColorChange private --- src/common/InputHandler.test.ts | 17 +++++++---------- src/common/InputHandler.ts | 6 ++---- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index 3b8d1387..8cc1bc97 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -1694,16 +1694,13 @@ describe('InputHandler', () => { }); describe('OSC', () => { it('should ignore incorrect Ansi color change data', () => { - assert.deepEqual(inputHandler.parseAnsiColorChange('17;rgb:1a/2b/3c'), { - colorIndex: 17, - red: 0x1a, - green: 0x2b, - blue: 0x3c - }); - assert.isNull(inputHandler.parseAnsiColorChange('17;rgb:a/b/c')); - assert.isNull(inputHandler.parseAnsiColorChange('17;rgb:#aabbcc')); - assert.isNull(inputHandler.parseAnsiColorChange('17;rgba:aa/bb/cc')); - assert.isNull(inputHandler.parseAnsiColorChange('rgb:aa/bb/cc')); + // this is testing a private method + const parseAnsiColorChange = inputHandler["_parseAnsiColorChange"]; + + assert.isNull(parseAnsiColorChange('17;rgb:a/b/c')); + assert.isNull(parseAnsiColorChange('17;rgb:#aabbcc')); + assert.isNull(parseAnsiColorChange('17;rgba:aa/bb/cc')); + assert.isNull(parseAnsiColorChange('rgb:aa/bb/cc')); }); it('should fire event on Ansi color change', (done) => { inputHandler.onAnsiColorChange(e => { diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 7867a3fe..3560ee6a 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -2714,9 +2714,7 @@ export class InputHandler extends Disposable implements IInputHandler { this._iconName = data; } - // This is really an internal method and not part of IInputHandler implementation. - // Making it public so that I can test it. - public parseAnsiColorChange(data: string): IAnsiColorChangeEvent | null { + private _parseAnsiColorChange(data: string): IAnsiColorChangeEvent | null { // example data: 5;rgb:aa/bb/cc const regex = /(\d+);rgb:([0-9a-fA-F]{2})\/([0-9a-fA-F]{2})\/([0-9a-fA-F]{2})/; const match = data.match(regex); @@ -2739,7 +2737,7 @@ export class InputHandler extends Disposable implements IInputHandler { * `c` is the color index between 0 and 255. `spec` color format is 'rgb:hh/hh/hh' where `h` are hexadecimal digits. */ public setAnsiColor(data: string): void { - const event = this.parseAnsiColorChange(data); + const event = this._parseAnsiColorChange(data); if (event) { this._onAnsiColorChange.fire(event); } From f4a56389cdabeea2919125eb63fa07d5410b6954 Mon Sep 17 00:00:00 2001 From: Slawek Zachcial Date: Sun, 29 Nov 2020 23:22:31 +0100 Subject: [PATCH 033/377] Fix quotes --- src/common/InputHandler.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index 8cc1bc97..eff8c76d 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -1695,7 +1695,7 @@ describe('InputHandler', () => { describe('OSC', () => { it('should ignore incorrect Ansi color change data', () => { // this is testing a private method - const parseAnsiColorChange = inputHandler["_parseAnsiColorChange"]; + const parseAnsiColorChange = inputHandler['_parseAnsiColorChange']; assert.isNull(parseAnsiColorChange('17;rgb:a/b/c')); assert.isNull(parseAnsiColorChange('17;rgb:#aabbcc')); From 5a74ce2e596e085e390c31d79286069ef8a0ee0d Mon Sep 17 00:00:00 2001 From: Slawek Zachcial Date: Mon, 30 Nov 2020 22:00:04 +0100 Subject: [PATCH 034/377] Add Ansi color change positive test --- src/common/InputHandler.test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index eff8c76d..57680052 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -1693,6 +1693,15 @@ describe('InputHandler', () => { }); }); describe('OSC', () => { + it('should parse correct Ansi color change data', () => { + // this is testing a private method + const parseAnsiColorChange = inputHandler['_parseAnsiColorChange']; + + assert.deepEqual( + parseAnsiColorChange('19;rgb:a1/b2/c3'), + { colorIndex: 19, red: 0xa1, green: 0xb2, blue: 0xc3 } + ); + }), it('should ignore incorrect Ansi color change data', () => { // this is testing a private method const parseAnsiColorChange = inputHandler['_parseAnsiColorChange']; From 64ac67026a1be56ff7a90b96995f8510aeeb9566 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 2 Dec 2020 16:25:19 +0000 Subject: [PATCH 035/377] avoid innerHTML usages --- src/browser/AccessibilityManager.ts | 2 +- src/browser/renderer/dom/DomRenderer.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/browser/AccessibilityManager.ts b/src/browser/AccessibilityManager.ts index c55aaad9..f1a9b5d0 100644 --- a/src/browser/AccessibilityManager.ts +++ b/src/browser/AccessibilityManager.ts @@ -263,7 +263,7 @@ export class AccessibilityManager extends Disposable { const element = this._rowElements[i]; if (element) { if (lineData.length === 0) { - element.innerHTML = ' '; + element.innerText = '\u00a0;'; } else { element.textContent = lineData; } diff --git a/src/browser/renderer/dom/DomRenderer.ts b/src/browser/renderer/dom/DomRenderer.ts index ed2c340b..f0a92259 100644 --- a/src/browser/renderer/dom/DomRenderer.ts +++ b/src/browser/renderer/dom/DomRenderer.ts @@ -138,7 +138,7 @@ export class DomRenderer extends Disposable implements IRenderer { ` width: ${this.dimensions.actualCellWidth}px` + `}`; - this._dimensionsStyleElement.innerHTML = styles; + this._dimensionsStyleElement.textContent = styles; this._selectionContainer.style.height = this._viewportElement.style.height; this._screenElement.style.width = `${this.dimensions.canvasWidth}px`; @@ -237,7 +237,7 @@ export class DomRenderer extends Disposable implements IRenderer { `${this._terminalSelector} .${FG_CLASS_PREFIX}${INVERTED_DEFAULT_COLOR} { color: ${color.opaque(this._colors.background).css}; }` + `${this._terminalSelector} .${BG_CLASS_PREFIX}${INVERTED_DEFAULT_COLOR} { background-color: ${this._colors.foreground.css}; }`; - this._themeStyleElement.innerHTML = styles; + this._themeStyleElement.textContent = styles; } public onDevicePixelRatioChange(): void { @@ -348,7 +348,7 @@ export class DomRenderer extends Disposable implements IRenderer { public clear(): void { for (const e of this._rowElements) { - e.innerHTML = ''; + e.innerText = ''; } } @@ -359,7 +359,7 @@ export class DomRenderer extends Disposable implements IRenderer { for (let y = start; y <= end; y++) { const rowElement = this._rowElements[y]; - rowElement.innerHTML = ''; + rowElement.innerText = ''; const row = y + this._bufferService.buffer.ydisp; const lineData = this._bufferService.buffer.lines.get(row); From 2804bfa8b7403aa515ce14ae78fdd8a2110d96d1 Mon Sep 17 00:00:00 2001 From: Slawek Zachcial Date: Mon, 7 Dec 2020 23:20:10 +0100 Subject: [PATCH 036/377] Make safe references to colorManager in _changeAnsiColor --- src/browser/Terminal.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 9452833e..1c65559a 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -160,11 +160,13 @@ export class Terminal extends CoreTerminal implements ITerminal { } private _changeAnsiColor(event: IAnsiColorChangeEvent): void { + if (!this._colorManager) { return; } + const color = rgba.toColor(event.red, event.green, event.blue); - this._colorManager!.colors.ansi[event.colorIndex] = color; - this._renderService?.setColors(this._colorManager!.colors); - this.viewport?.onThemeChange(this._colorManager!.colors); + this._colorManager.colors.ansi[event.colorIndex] = color; + this._renderService?.setColors(this._colorManager.colors); + this.viewport?.onThemeChange(this._colorManager.colors); } public dispose(): void { From b2c4ed638bb61278bce8855d8a3dab5106ebf142 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 9 Dec 2020 09:08:14 +0000 Subject: [PATCH 037/377] fix bad none-breaking whitespace --- src/browser/AccessibilityManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/AccessibilityManager.ts b/src/browser/AccessibilityManager.ts index f1a9b5d0..e5cbb372 100644 --- a/src/browser/AccessibilityManager.ts +++ b/src/browser/AccessibilityManager.ts @@ -263,7 +263,7 @@ export class AccessibilityManager extends Disposable { const element = this._rowElements[i]; if (element) { if (lineData.length === 0) { - element.innerText = '\u00a0;'; + element.innerText = '\u00a0'; } else { element.textContent = lineData; } From 7d3f5375a81d8efda13fa0e93e738a0f911a1afd Mon Sep 17 00:00:00 2001 From: Slawek Zachcial Date: Mon, 7 Dec 2020 23:20:52 +0100 Subject: [PATCH 038/377] Implement OSC 4 for list of colors --- src/browser/Terminal.ts | 11 +++++--- src/common/InputHandler.test.ts | 48 ++++++++++++++++++++++++++------- src/common/InputHandler.ts | 19 ++++++++----- src/common/Types.d.ts | 12 ++++++--- 4 files changed, 67 insertions(+), 23 deletions(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 1c65559a..06ac57f3 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -162,11 +162,14 @@ export class Terminal extends CoreTerminal implements ITerminal { private _changeAnsiColor(event: IAnsiColorChangeEvent): void { if (!this._colorManager) { return; } - const color = rgba.toColor(event.red, event.green, event.blue); + event.colors.forEach(ansiColor => { + const color = rgba.toColor(ansiColor.red, ansiColor.green, ansiColor.blue); - this._colorManager.colors.ansi[event.colorIndex] = color; - this._renderService?.setColors(this._colorManager.colors); - this.viewport?.onThemeChange(this._colorManager.colors); + this._colorManager!.colors.ansi[ansiColor.colorIndex] = color; + }); + + this._renderService?.setColors(this._colorManager!.colors); + this.viewport?.onThemeChange(this._colorManager!.colors); } public dispose(): void { diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index 57680052..05b6ea2f 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -1693,16 +1693,15 @@ describe('InputHandler', () => { }); }); describe('OSC', () => { - it('should parse correct Ansi color change data', () => { + it('4: should parse correct Ansi color change data', () => { // this is testing a private method const parseAnsiColorChange = inputHandler['_parseAnsiColorChange']; + const event = parseAnsiColorChange('19;rgb:a1/b2/c3'); - assert.deepEqual( - parseAnsiColorChange('19;rgb:a1/b2/c3'), - { colorIndex: 19, red: 0xa1, green: 0xb2, blue: 0xc3 } - ); + assert.isNotNull(event); + assert.deepEqual(event!.colors[0], { colorIndex: 19, red: 0xa1, green: 0xb2, blue: 0xc3 }); }), - it('should ignore incorrect Ansi color change data', () => { + it('4: should ignore incorrect Ansi color change data', () => { // this is testing a private method const parseAnsiColorChange = inputHandler['_parseAnsiColorChange']; @@ -1711,12 +1710,43 @@ describe('InputHandler', () => { assert.isNull(parseAnsiColorChange('17;rgba:aa/bb/cc')); assert.isNull(parseAnsiColorChange('rgb:aa/bb/cc')); }); - it('should fire event on Ansi color change', (done) => { + it('4: should parse a list of Ansi color changes', () => { + // this is testing a private method + const parseAnsiColorChange = inputHandler['_parseAnsiColorChange']; + const event = parseAnsiColorChange('19;rgb:a1/b2/c3;17;rgb:00/11/22;255;rgb:01/ef/2d'); + + assert.isNotNull(event); + assert.equal(event!.colors.length, 3); + assert.deepEqual(event!.colors[0], { colorIndex: 19, red: 0xa1, green: 0xb2, blue: 0xc3 }); + assert.deepEqual(event!.colors[1], { colorIndex: 17, red: 0x00, green: 0x11, blue: 0x22 }); + assert.deepEqual(event!.colors[2], { colorIndex: 255, red: 0x01, green: 0xef, blue: 0x2d }); + }); + it('4: should ignore incorrect colors in a list of Ansi color changes', () => { + // this is testing a private method + const parseAnsiColorChange = inputHandler['_parseAnsiColorChange']; + const event = parseAnsiColorChange('19;rgb:a1/b2/c3;17;rgb:WR/ON/G;255;rgb:01/ef/2d'); + + assert.equal(event!.colors.length, 2); + assert.deepEqual(event!.colors[0], { colorIndex: 19, red: 0xa1, green: 0xb2, blue: 0xc3 }); + assert.deepEqual(event!.colors[1], { colorIndex: 255, red: 0x01, green: 0xef, blue: 0x2d }); + }); + it('4: should be case insensitive when parsing Ansi color changes', () => { + // this is testing a private method + const parseAnsiColorChange = inputHandler['_parseAnsiColorChange']; + const event = parseAnsiColorChange('19;rGb:A1/b2/C3'); + + assert.equal(event!.colors.length, 1); + assert.deepEqual(event!.colors[0], { colorIndex: 19, red: 0xa1, green: 0xb2, blue: 0xc3 }); + }); + it('4: should fire event on Ansi color change', (done) => { inputHandler.onAnsiColorChange(e => { - assert.deepEqual(e, { colorIndex: 17, red: 0x1a, green: 0x2b, blue: 0x3c }); + assert.isNotNull(e); + assert.isNotNull(e!.colors); + assert.deepEqual(e!.colors[0], { colorIndex: 17, red: 0x1a, green: 0x2b, blue: 0x3c }); + assert.deepEqual(e!.colors[1], { colorIndex: 12, red: 0x11, green: 0x22, blue: 0x33 }); done(); }); - inputHandler.parse('\x1b]4;17;rgb:1a/2b/3c\x1b\\'); + inputHandler.parse('\x1b]4;17;rgb:1a/2b/3c;12;rgb:11/22/33\x1b\\'); }); }); }); diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 3560ee6a..44520cb9 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -2715,19 +2715,25 @@ export class InputHandler extends Disposable implements IInputHandler { } private _parseAnsiColorChange(data: string): IAnsiColorChangeEvent | null { + const result: IAnsiColorChangeEvent = { colors: [] }; // example data: 5;rgb:aa/bb/cc - const regex = /(\d+);rgb:([0-9a-fA-F]{2})\/([0-9a-fA-F]{2})\/([0-9a-fA-F]{2})/; - const match = data.match(regex); + const regex = /(\d+);rgb:([0-9a-f]{2})\/([0-9a-f]{2})\/([0-9a-f]{2})/gi; + let match; - if (match) { - return { + while ((match = regex.exec(data)) !== null) { + result.colors.push({ colorIndex: parseInt(match[1]), red: parseInt(match[2], 16), green: parseInt(match[3], 16), blue: parseInt(match[4], 16) - }; + }); } - return null; + + if (result.colors.length === 0) { + return null; + } + + return result; } /** @@ -2735,6 +2741,7 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #Y OSC 4 "Set ANSI color" "OSC 4 ; c ; spec BEL" "Change color number `c` to the color specified by `spec`." * `c` is the color index between 0 and 255. `spec` color format is 'rgb:hh/hh/hh' where `h` are hexadecimal digits. + * There may be multipe c ; spec elements present in the same instruction, e.g. 1;rgb:10/20/30;2;rgb:a0/b0/c0. */ public setAnsiColor(data: string): void { const event = this._parseAnsiColorChange(data); diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index cbb11b3f..1ea26c2a 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -328,16 +328,20 @@ export interface IWindowOptions { setWinLines?: boolean; } -/** - * Event fired for OSC 4 command - to change ANSI color based on its index. - */ -export interface IAnsiColorChangeEvent { +export interface IAnsiColorChangeEventColor { colorIndex: number; red: number; green: number; blue: number; } +/** + * Event fired for OSC 4 command - to change ANSI color based on its index. + */ +export interface IAnsiColorChangeEvent { + colors: IAnsiColorChangeEventColor[]; +} + /** * Calls the parser and handles actions generated by the parser. */ From 3cab8511e49eae5aa5e66dcc960cbc4586db98e8 Mon Sep 17 00:00:00 2001 From: kena0ki Date: Thu, 31 Dec 2020 22:55:54 +0900 Subject: [PATCH 039/377] Prevent input characters using IME from being duplicated --- src/browser/input/CompositionHelper.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/browser/input/CompositionHelper.ts b/src/browser/input/CompositionHelper.ts index 8d393e33..f93483d3 100644 --- a/src/browser/input/CompositionHelper.ts +++ b/src/browser/input/CompositionHelper.ts @@ -35,6 +35,11 @@ export class CompositionHelper { */ private _isSendingComposition: boolean; + /** + * Data already sent due to keydown event. + */ + private _dataAlreadySent: string; + constructor( private readonly _textarea: HTMLTextAreaElement, private readonly _compositionView: HTMLElement, @@ -46,6 +51,7 @@ export class CompositionHelper { this._isComposing = false; this._isSendingComposition = false; this._compositionPosition = { start: 0, end: 0 }; + this._dataAlreadySent = ''; } /** @@ -55,6 +61,7 @@ export class CompositionHelper { this._isComposing = true; this._compositionPosition.start = this._textarea.value.length; this._compositionView.textContent = ''; + this._dataAlreadySent = ''; this._compositionView.classList.add('active'); } @@ -147,6 +154,9 @@ export class CompositionHelper { if (this._isSendingComposition) { this._isSendingComposition = false; let input; + // Add length of data already sent due to keydown event, + // otherwise input characters can be duplicated. (Issue #3191) + currentCompositionPosition.start += this._dataAlreadySent.length; if (this._isComposing) { // Use the end position to get the string if a new composition has started. input = this._textarea.value.substring(currentCompositionPosition.start, currentCompositionPosition.end); @@ -156,7 +166,9 @@ export class CompositionHelper { // (eg. 2) after a composition character. input = this._textarea.value.substring(currentCompositionPosition.start); } - this._coreService.triggerDataEvent(input, true); + if (input.length > 0) { + this._coreService.triggerDataEvent(input, true); + } } }, 0); } @@ -176,6 +188,7 @@ export class CompositionHelper { const newValue = this._textarea.value; const diff = newValue.replace(oldValue, ''); if (diff.length > 0) { + this._dataAlreadySent = diff; this._coreService.triggerDataEvent(diff, true); } } From 8baff9bade19dbde2f381311d31ece8077f0220c Mon Sep 17 00:00:00 2001 From: meganrogge Date: Mon, 4 Jan 2021 08:31:22 -0800 Subject: [PATCH 040/377] cache buffer --- src/browser/public/Terminal.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index 64c65fe9..4db82240 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -18,6 +18,7 @@ export class Terminal implements ITerminalApi { private _core: ITerminal; private _addonManager: AddonManager; private _parser: IParser | undefined; + private _buffer: BufferNamespaceApi | undefined; constructor(options?: ITerminalOptions) { this._core = new TerminalCore(options); @@ -58,7 +59,10 @@ export class Terminal implements ITerminalApi { public get cols(): number { return this._core.cols; } public get buffer(): IBufferNamespaceApi { this._checkProposedApi(); - return new BufferNamespaceApi(this._core.buffers); + if (!this._buffer) { + return new BufferNamespaceApi(this._core.buffers); + } + return this._buffer; } public get markers(): ReadonlyArray { this._checkProposedApi(); From fe2b1c0d43d661b3a63023cfedb118c6e0dbf08e Mon Sep 17 00:00:00 2001 From: meganrogge Date: Mon, 4 Jan 2021 11:32:11 -0800 Subject: [PATCH 041/377] set this._buffer to new buffer --- src/browser/public/Terminal.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index 4db82240..6c485a5c 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -60,7 +60,7 @@ export class Terminal implements ITerminalApi { public get buffer(): IBufferNamespaceApi { this._checkProposedApi(); if (!this._buffer) { - return new BufferNamespaceApi(this._core.buffers); + this._buffer = new BufferNamespaceApi(this._core.buffers); } return this._buffer; } From b34289cc441ab09a4bb54c97edc4014a7e241e13 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Tue, 5 Jan 2021 07:10:27 -0800 Subject: [PATCH 042/377] use reset --- src/browser/public/Terminal.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index 6c485a5c..517f7c4f 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -13,6 +13,7 @@ import * as Strings from '../LocalizableStrings'; import { IEvent, EventEmitter } from 'common/EventEmitter'; import { AddonManager } from './AddonManager'; import { IParams } from 'common/parser/Types'; +import { BufferSet } from 'common/buffer/BufferSet'; export class Terminal implements ITerminalApi { private _core: ITerminal; @@ -59,6 +60,7 @@ export class Terminal implements ITerminalApi { public get cols(): number { return this._core.cols; } public get buffer(): IBufferNamespaceApi { this._checkProposedApi(); + this._core.reset(); if (!this._buffer) { this._buffer = new BufferNamespaceApi(this._core.buffers); } From 714513083560612b30f127a36f6a366f2d84977e Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 5 Jan 2021 09:32:09 -0800 Subject: [PATCH 043/377] Fix onBufferChange event not working after reset Co-authored-by: Megan Rogge (megan.rogge@microsoft.com) --- src/browser/public/Terminal.ts | 19 +++++++++---------- src/common/buffer/BufferSet.ts | 18 ++++++++++-------- src/common/buffer/Types.d.ts | 1 + src/common/services/BufferService.ts | 3 +-- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index 517f7c4f..70247f88 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -60,9 +60,8 @@ export class Terminal implements ITerminalApi { public get cols(): number { return this._core.cols; } public get buffer(): IBufferNamespaceApi { this._checkProposedApi(); - this._core.reset(); if (!this._buffer) { - this._buffer = new BufferNamespaceApi(this._core.buffers); + this._buffer = new BufferNamespaceApi(this._core); } return this._buffer; } @@ -251,21 +250,21 @@ class BufferNamespaceApi implements IBufferNamespaceApi { private _onBufferChange = new EventEmitter(); public get onBufferChange(): IEvent { return this._onBufferChange.event; } - constructor(private _buffers: IBufferSet) { - this._normal = new BufferApiView(this._buffers.normal, 'normal'); - this._alternate = new BufferApiView(this._buffers.alt, 'alternate'); - this._buffers.onBufferActivate(() => this._onBufferChange.fire(this.active)); + constructor(private _core: ITerminal) { + this._normal = new BufferApiView(this._core.buffers.normal, 'normal'); + this._alternate = new BufferApiView(this._core.buffers.alt, 'alternate'); + this._core.buffers.onBufferActivate(() => this._onBufferChange.fire(this.active)); } public get active(): IBufferApi { - if (this._buffers.active === this._buffers.normal) { return this.normal; } - if (this._buffers.active === this._buffers.alt) { return this.alternate; } + if (this._core.buffers.active === this._core.buffers.normal) { return this.normal; } + if (this._core.buffers.active === this._core.buffers.alt) { return this.alternate; } throw new Error('Active buffer is neither normal nor alternate'); } public get normal(): IBufferApi { - return this._normal.init(this._buffers.normal); + return this._normal.init(this._core.buffers.normal); } public get alternate(): IBufferApi { - return this._alternate.init(this._buffers.alt); + return this._alternate.init(this._core.buffers.alt); } } diff --git a/src/common/buffer/BufferSet.ts b/src/common/buffer/BufferSet.ts index b9dc7995..b74c4eac 100644 --- a/src/common/buffer/BufferSet.ts +++ b/src/common/buffer/BufferSet.ts @@ -15,10 +15,9 @@ import { Disposable } from 'common/Lifecycle'; * provides also utilities for working with them. */ export class BufferSet extends Disposable implements IBufferSet { - private _normal: Buffer; - private _alt: Buffer; - private _activeBuffer: Buffer; - + private _normal!: Buffer; + private _alt!: Buffer; + private _activeBuffer!: Buffer; private _onBufferActivate = this.register(new EventEmitter<{activeBuffer: IBuffer, inactiveBuffer: IBuffer}>()); public get onBufferActivate(): IEvent<{activeBuffer: IBuffer, inactiveBuffer: IBuffer}> { return this._onBufferActivate.event; } @@ -28,17 +27,20 @@ export class BufferSet extends Disposable implements IBufferSet { * @param _terminal - The terminal the BufferSet will belong to */ constructor( - optionsService: IOptionsService, - bufferService: IBufferService + private readonly _optionsService: IOptionsService, + private readonly _bufferService: IBufferService ) { super(); + this.reset(); + } - this._normal = new Buffer(true, optionsService, bufferService); + public reset(): void { + this._normal = new Buffer(true, this._optionsService, this._bufferService); this._normal.fillViewportRows(); // The alt buffer should never have scrollback. // See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer - this._alt = new Buffer(false, optionsService, bufferService); + this._alt = new Buffer(false, this._optionsService, this._bufferService); this._activeBuffer = this._normal; this.setupTabStops(); diff --git a/src/common/buffer/Types.d.ts b/src/common/buffer/Types.d.ts index 752b1a26..cbf40a03 100644 --- a/src/common/buffer/Types.d.ts +++ b/src/common/buffer/Types.d.ts @@ -56,6 +56,7 @@ export interface IBufferSet extends IDisposable { activateNormalBuffer(): void; activateAltBuffer(fillAttr?: IAttributeData): void; + reset(): void; resize(newCols: number, newRows: number): void; setupTabStops(i?: number): void; } diff --git a/src/common/services/BufferService.ts b/src/common/services/BufferService.ts index 301146e1..47e54729 100644 --- a/src/common/services/BufferService.ts +++ b/src/common/services/BufferService.ts @@ -49,8 +49,7 @@ export class BufferService extends Disposable implements IBufferService { } public reset(): void { - this.buffers.dispose(); - this.buffers = new BufferSet(this._optionsService, this); + this.buffers.reset(); this.isUserScrolling = false; } } From cbe5abcf278524f73a771dc8b0f049edc6d59e83 Mon Sep 17 00:00:00 2001 From: Sun Xiaoran Date: Wed, 6 Jan 2021 14:10:10 +0800 Subject: [PATCH 044/377] Add Commas to the Real-world uses List --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4ef592c2..0e7df5ac 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,7 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**TeleType**](https://github.com/akshaykmr/TeleType): cli tool that allows you to share your terminal online conveniently. Show off mad cli-fu, help a colleague, teach, or troubleshoot. - [**Intervue**](https://www.intervue.io): Pair programming for interviews. Multiple programming languages supported, with results displayed by xterm.js. - [**TRASA**](https://trasa.io): Zero trust access to Web, SSH, RDP and Database services. +- [**Commas**](https://github.com/CyanSalt/commas): Commas is a hackable terminal and command runner. [And much more...](https://github.com/xtermjs/xterm.js/network/dependents) Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it in our list. Note: Please add any new contributions to the end of the list only. From 5bab94730f35f0955d9a6546480083acef19c26b Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Fri, 8 Jan 2021 09:46:12 -0500 Subject: [PATCH 045/377] freeze the default ANSI colours const --- src/browser/ColorManager.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/browser/ColorManager.ts b/src/browser/ColorManager.ts index 9a0fd7ee..b6950d28 100644 --- a/src/browser/ColorManager.ts +++ b/src/browser/ColorManager.ts @@ -17,9 +17,8 @@ const DEFAULT_SELECTION = { rgba: 0xFFFFFF4D }; -// An IIFE to generate DEFAULT_ANSI_COLORS. Do not mutate DEFAULT_ANSI_COLORS, instead make a copy -// and mutate that. -export const DEFAULT_ANSI_COLORS = (() => { +// An IIFE to generate DEFAULT_ANSI_COLORS. +export const DEFAULT_ANSI_COLORS = Object.freeze((() => { const colors = [ // dark: css.toColor('#2e3436'), @@ -64,7 +63,7 @@ export const DEFAULT_ANSI_COLORS = (() => { } return colors; -})(); +})()); /** * Manages the source of truth for a terminal's colors. From 66be7797cf620d23e458b945eff1523ed5dfc9d8 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Fri, 8 Jan 2021 11:02:34 -0800 Subject: [PATCH 046/377] Get demo working for git bash on windows Co-authored-by: Megan Rogge merogge@microsoft.com Co-authored-by: Daniel Imms daimms@microsoft.com --- demo/server.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/demo/server.js b/demo/server.js index c04c48ea..c0d5e1f6 100644 --- a/demo/server.js +++ b/demo/server.js @@ -43,15 +43,15 @@ function startServer() { const env = Object.assign({}, process.env); env['COLORTERM'] = 'truecolor'; var cols = parseInt(req.query.cols), - rows = parseInt(req.query.rows), - term = pty.spawn(process.platform === 'win32' ? 'cmd.exe' : 'bash', [], { - name: 'xterm-256color', - cols: cols || 80, - rows: rows || 24, - cwd: env.PWD, - env: env, - encoding: USE_BINARY ? null : 'utf8' - }); + rows = parseInt(req.query.rows), + term = pty.spawn(process.platform === 'win32' ? 'cmd.exe' : 'bash', [], { + name: 'xterm-256color', + cols: cols || 80, + rows: rows || 24, + cwd: process.platform === 'win32' ? undefined : env.PWD, + env: env, + encoding: USE_BINARY ? null : 'utf8' + }); console.log('Created terminal with PID: ' + term.pid); terminals[term.pid] = term; From 5c33e4008db483d54beec303c08bd01d821c190b Mon Sep 17 00:00:00 2001 From: Slawek Zachcial Date: Sat, 9 Jan 2021 14:30:24 +0100 Subject: [PATCH 047/377] Make _parseAnsiColorChange available for tests in TestInputHandler --- src/common/InputHandler.test.ts | 23 +++++++++-------------- src/common/InputHandler.ts | 2 +- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index 05b6ea2f..4c0d8559 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -40,6 +40,7 @@ class TestInputHandler extends InputHandler { public get curAttrData(): IAttributeData { return (this as any)._curAttrData; } public get windowTitleStack(): string[] { return this._windowTitleStack; } public get iconNameStack(): string[] { return this._iconNameStack; } + public parseAnsiColorChange(data: string): IAnsiColorChangeEvent | null { return this._parseAnsiColorChange(data); } } describe('InputHandler', () => { @@ -1695,25 +1696,21 @@ describe('InputHandler', () => { describe('OSC', () => { it('4: should parse correct Ansi color change data', () => { // this is testing a private method - const parseAnsiColorChange = inputHandler['_parseAnsiColorChange']; - const event = parseAnsiColorChange('19;rgb:a1/b2/c3'); + const event = inputHandler.parseAnsiColorChange('19;rgb:a1/b2/c3'); assert.isNotNull(event); assert.deepEqual(event!.colors[0], { colorIndex: 19, red: 0xa1, green: 0xb2, blue: 0xc3 }); }), it('4: should ignore incorrect Ansi color change data', () => { // this is testing a private method - const parseAnsiColorChange = inputHandler['_parseAnsiColorChange']; - - assert.isNull(parseAnsiColorChange('17;rgb:a/b/c')); - assert.isNull(parseAnsiColorChange('17;rgb:#aabbcc')); - assert.isNull(parseAnsiColorChange('17;rgba:aa/bb/cc')); - assert.isNull(parseAnsiColorChange('rgb:aa/bb/cc')); + assert.isNull(inputHandler.parseAnsiColorChange('17;rgb:a/b/c')); + assert.isNull(inputHandler.parseAnsiColorChange('17;rgb:#aabbcc')); + assert.isNull(inputHandler.parseAnsiColorChange('17;rgba:aa/bb/cc')); + assert.isNull(inputHandler.parseAnsiColorChange('rgb:aa/bb/cc')); }); it('4: should parse a list of Ansi color changes', () => { // this is testing a private method - const parseAnsiColorChange = inputHandler['_parseAnsiColorChange']; - const event = parseAnsiColorChange('19;rgb:a1/b2/c3;17;rgb:00/11/22;255;rgb:01/ef/2d'); + const event = inputHandler.parseAnsiColorChange('19;rgb:a1/b2/c3;17;rgb:00/11/22;255;rgb:01/ef/2d'); assert.isNotNull(event); assert.equal(event!.colors.length, 3); @@ -1723,8 +1720,7 @@ describe('InputHandler', () => { }); it('4: should ignore incorrect colors in a list of Ansi color changes', () => { // this is testing a private method - const parseAnsiColorChange = inputHandler['_parseAnsiColorChange']; - const event = parseAnsiColorChange('19;rgb:a1/b2/c3;17;rgb:WR/ON/G;255;rgb:01/ef/2d'); + const event = inputHandler.parseAnsiColorChange('19;rgb:a1/b2/c3;17;rgb:WR/ON/G;255;rgb:01/ef/2d'); assert.equal(event!.colors.length, 2); assert.deepEqual(event!.colors[0], { colorIndex: 19, red: 0xa1, green: 0xb2, blue: 0xc3 }); @@ -1732,8 +1728,7 @@ describe('InputHandler', () => { }); it('4: should be case insensitive when parsing Ansi color changes', () => { // this is testing a private method - const parseAnsiColorChange = inputHandler['_parseAnsiColorChange']; - const event = parseAnsiColorChange('19;rGb:A1/b2/C3'); + const event = inputHandler.parseAnsiColorChange('19;rGb:A1/b2/C3'); assert.equal(event!.colors.length, 1); assert.deepEqual(event!.colors[0], { colorIndex: 19, red: 0xa1, green: 0xb2, blue: 0xc3 }); diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 44520cb9..626e1fe2 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -2714,7 +2714,7 @@ export class InputHandler extends Disposable implements IInputHandler { this._iconName = data; } - private _parseAnsiColorChange(data: string): IAnsiColorChangeEvent | null { + protected _parseAnsiColorChange(data: string): IAnsiColorChangeEvent | null { const result: IAnsiColorChangeEvent = { colors: [] }; // example data: 5;rgb:aa/bb/cc const regex = /(\d+);rgb:([0-9a-f]{2})\/([0-9a-f]{2})\/([0-9a-f]{2})/gi; From 157055c03ba861d9b5a5153b19aa21039c1d08b1 Mon Sep 17 00:00:00 2001 From: joyceerhl Date: Sun, 10 Jan 2021 00:14:29 -0800 Subject: [PATCH 048/377] Original files --- src/common/public/Terminal.ts | 339 +++++++++ typings/xterm-core.d.ts | 1207 +++++++++++++++++++++++++++++++++ 2 files changed, 1546 insertions(+) create mode 100644 src/common/public/Terminal.ts create mode 100644 typings/xterm-core.d.ts diff --git a/src/common/public/Terminal.ts b/src/common/public/Terminal.ts new file mode 100644 index 00000000..70247f88 --- /dev/null +++ b/src/common/public/Terminal.ts @@ -0,0 +1,339 @@ +/** + * Copyright (c) 2018 The xterm.js authors. All rights reserved. + * @license MIT + */ + +import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi, IParser, IFunctionIdentifier, ILinkProvider, IUnicodeHandling, IUnicodeVersionProvider, FontWeight } from 'xterm'; +import { ITerminal } from 'browser/Types'; +import { IBufferLine, ICellData } from 'common/Types'; +import { IBuffer, IBufferSet } from 'common/buffer/Types'; +import { CellData } from 'common/buffer/CellData'; +import { Terminal as TerminalCore } from '../Terminal'; +import * as Strings from '../LocalizableStrings'; +import { IEvent, EventEmitter } from 'common/EventEmitter'; +import { AddonManager } from './AddonManager'; +import { IParams } from 'common/parser/Types'; +import { BufferSet } from 'common/buffer/BufferSet'; + +export class Terminal implements ITerminalApi { + private _core: ITerminal; + private _addonManager: AddonManager; + private _parser: IParser | undefined; + private _buffer: BufferNamespaceApi | undefined; + + constructor(options?: ITerminalOptions) { + this._core = new TerminalCore(options); + this._addonManager = new AddonManager(); + } + + private _checkProposedApi(): void { + if (!this._core.optionsService.options.allowProposedApi) { + throw new Error('You must set the allowProposedApi option to true to use proposed API'); + } + } + + public get onCursorMove(): IEvent { return this._core.onCursorMove; } + public get onLineFeed(): IEvent { return this._core.onLineFeed; } + public get onSelectionChange(): IEvent { return this._core.onSelectionChange; } + public get onData(): IEvent { return this._core.onData; } + public get onBinary(): IEvent { return this._core.onBinary; } + public get onTitleChange(): IEvent { return this._core.onTitleChange; } + public get onScroll(): IEvent { return this._core.onScroll; } + public get onKey(): IEvent<{ key: string, domEvent: KeyboardEvent }> { return this._core.onKey; } + public get onRender(): IEvent<{ start: number, end: number }> { return this._core.onRender; } + public get onResize(): IEvent<{ cols: number, rows: number }> { return this._core.onResize; } + + public get element(): HTMLElement | undefined { return this._core.element; } + public get parser(): IParser { + this._checkProposedApi(); + if (!this._parser) { + this._parser = new ParserApi(this._core); + } + return this._parser; + } + public get unicode(): IUnicodeHandling { + this._checkProposedApi(); + return new UnicodeApi(this._core); + } + public get textarea(): HTMLTextAreaElement | undefined { return this._core.textarea; } + public get rows(): number { return this._core.rows; } + public get cols(): number { return this._core.cols; } + public get buffer(): IBufferNamespaceApi { + this._checkProposedApi(); + if (!this._buffer) { + this._buffer = new BufferNamespaceApi(this._core); + } + return this._buffer; + } + public get markers(): ReadonlyArray { + this._checkProposedApi(); + return this._core.markers; + } + public blur(): void { + this._core.blur(); + } + public focus(): void { + this._core.focus(); + } + public resize(columns: number, rows: number): void { + this._verifyIntegers(columns, rows); + this._core.resize(columns, rows); + } + public open(parent: HTMLElement): void { + this._core.open(parent); + } + public attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void { + this._core.attachCustomKeyEventHandler(customKeyEventHandler); + } + public registerLinkMatcher(regex: RegExp, handler: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions): number { + this._checkProposedApi(); + return this._core.registerLinkMatcher(regex, handler, options); + } + public deregisterLinkMatcher(matcherId: number): void { + this._checkProposedApi(); + this._core.deregisterLinkMatcher(matcherId); + } + public registerLinkProvider(linkProvider: ILinkProvider): IDisposable { + this._checkProposedApi(); + return this._core.registerLinkProvider(linkProvider); + } + public registerCharacterJoiner(handler: (text: string) => [number, number][]): number { + this._checkProposedApi(); + return this._core.registerCharacterJoiner(handler); + } + public deregisterCharacterJoiner(joinerId: number): void { + this._checkProposedApi(); + this._core.deregisterCharacterJoiner(joinerId); + } + public registerMarker(cursorYOffset: number): IMarker | undefined { + this._checkProposedApi(); + this._verifyIntegers(cursorYOffset); + return this._core.addMarker(cursorYOffset); + } + public addMarker(cursorYOffset: number): IMarker | undefined { + return this.registerMarker(cursorYOffset); + } + public hasSelection(): boolean { + return this._core.hasSelection(); + } + public select(column: number, row: number, length: number): void { + this._verifyIntegers(column, row, length); + this._core.select(column, row, length); + } + public getSelection(): string { + return this._core.getSelection(); + } + public getSelectionPosition(): ISelectionPosition | undefined { + return this._core.getSelectionPosition(); + } + public clearSelection(): void { + this._core.clearSelection(); + } + public selectAll(): void { + this._core.selectAll(); + } + public selectLines(start: number, end: number): void { + this._verifyIntegers(start, end); + this._core.selectLines(start, end); + } + public dispose(): void { + this._addonManager.dispose(); + this._core.dispose(); + } + public scrollLines(amount: number): void { + this._verifyIntegers(amount); + this._core.scrollLines(amount); + } + public scrollPages(pageCount: number): void { + this._verifyIntegers(pageCount); + this._core.scrollPages(pageCount); + } + public scrollToTop(): void { + this._core.scrollToTop(); + } + public scrollToBottom(): void { + this._core.scrollToBottom(); + } + public scrollToLine(line: number): void { + this._verifyIntegers(line); + this._core.scrollToLine(line); + } + public clear(): void { + this._core.clear(); + } + public write(data: string | Uint8Array, callback?: () => void): void { + this._core.write(data, callback); + } + public writeUtf8(data: Uint8Array, callback?: () => void): void { + this._core.write(data, callback); + } + public writeln(data: string | Uint8Array, callback?: () => void): void { + this._core.write(data); + this._core.write('\r\n', callback); + } + public paste(data: string): void { + this._core.paste(data); + } + public getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string; + public getOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell'): boolean; + public getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; + public getOption(key: 'fontWeight' | 'fontWeightBold'): FontWeight; + public getOption(key: string): any; + public getOption(key: any): any { + return this._core.optionsService.getOption(key); + } + public setOption(key: 'bellSound' | 'fontFamily' | 'termName' | 'wordSeparator', value: string): void; + public setOption(key: 'fontWeight' | 'fontWeightBold', value: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void; + public setOption(key: 'logLevel', value: 'debug' | 'info' | 'warn' | 'error' | 'off'): void; + public setOption(key: 'bellStyle', value: 'none' | 'visual' | 'sound' | 'both'): void; + public setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void; + public setOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell', value: boolean): void; + public setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; + public setOption(key: 'theme', value: ITheme): void; + public setOption(key: 'cols' | 'rows', value: number): void; + public setOption(key: string, value: any): void; + public setOption(key: any, value: any): void { + this._core.optionsService.setOption(key, value); + } + public refresh(start: number, end: number): void { + this._verifyIntegers(start, end); + this._core.refresh(start, end); + } + public reset(): void { + this._core.reset(); + } + public loadAddon(addon: ITerminalAddon): void { + return this._addonManager.loadAddon(this, addon); + } + public static get strings(): ILocalizableStrings { + return Strings; + } + + private _verifyIntegers(...values: number[]): void { + for (const value of values) { + if (value === Infinity || isNaN(value) || value % 1 !== 0) { + throw new Error('This API only accepts integers'); + } + } + } +} + +class BufferApiView implements IBufferApi { + constructor( + private _buffer: IBuffer, + public readonly type: 'normal' | 'alternate' + ) { } + + public init(buffer: IBuffer): BufferApiView { + this._buffer = buffer; + return this; + } + + public get cursorY(): number { return this._buffer.y; } + public get cursorX(): number { return this._buffer.x; } + public get viewportY(): number { return this._buffer.ydisp; } + public get baseY(): number { return this._buffer.ybase; } + public get length(): number { return this._buffer.lines.length; } + public getLine(y: number): IBufferLineApi | undefined { + const line = this._buffer.lines.get(y); + if (!line) { + return undefined; + } + return new BufferLineApiView(line); + } + public getNullCell(): IBufferCellApi { return new CellData(); } +} + +class BufferNamespaceApi implements IBufferNamespaceApi { + private _normal: BufferApiView; + private _alternate: BufferApiView; + private _onBufferChange = new EventEmitter(); + public get onBufferChange(): IEvent { return this._onBufferChange.event; } + + constructor(private _core: ITerminal) { + this._normal = new BufferApiView(this._core.buffers.normal, 'normal'); + this._alternate = new BufferApiView(this._core.buffers.alt, 'alternate'); + this._core.buffers.onBufferActivate(() => this._onBufferChange.fire(this.active)); + } + public get active(): IBufferApi { + if (this._core.buffers.active === this._core.buffers.normal) { return this.normal; } + if (this._core.buffers.active === this._core.buffers.alt) { return this.alternate; } + throw new Error('Active buffer is neither normal nor alternate'); + } + public get normal(): IBufferApi { + return this._normal.init(this._core.buffers.normal); + } + public get alternate(): IBufferApi { + return this._alternate.init(this._core.buffers.alt); + } +} + +class BufferLineApiView implements IBufferLineApi { + constructor(private _line: IBufferLine) { } + + public get isWrapped(): boolean { return this._line.isWrapped; } + public get length(): number { return this._line.length; } + public getCell(x: number, cell?: IBufferCellApi): IBufferCellApi | undefined { + if (x < 0 || x >= this._line.length) { + return undefined; + } + + if (cell) { + this._line.loadCell(x, cell); + return cell; + } + return this._line.loadCell(x, new CellData()); + } + public translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string { + return this._line.translateToString(trimRight, startColumn, endColumn); + } +} + +class ParserApi implements IParser { + constructor(private _core: ITerminal) { } + + public registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable { + return this._core.addCsiHandler(id, (params: IParams) => callback(params.toArray())); + } + public addCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable { + return this.registerCsiHandler(id, callback); + } + public registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable { + return this._core.addDcsHandler(id, (data: string, params: IParams) => callback(data, params.toArray())); + } + public addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable { + return this.registerDcsHandler(id, callback); + } + public registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable { + return this._core.addEscHandler(id, handler); + } + public addEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable { + return this.registerEscHandler(id, handler); + } + public registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { + return this._core.addOscHandler(ident, callback); + } + public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { + return this.registerOscHandler(ident, callback); + } +} + +class UnicodeApi implements IUnicodeHandling { + constructor(private _core: ITerminal) { } + + public register(provider: IUnicodeVersionProvider): void { + this._core.unicodeService.register(provider); + } + + public get versions(): string[] { + return this._core.unicodeService.versions; + } + + public get activeVersion(): string { + return this._core.unicodeService.activeVersion; + } + + public set activeVersion(version: string) { + this._core.unicodeService.activeVersion = version; + } +} diff --git a/typings/xterm-core.d.ts b/typings/xterm-core.d.ts new file mode 100644 index 00000000..06964ca0 --- /dev/null +++ b/typings/xterm-core.d.ts @@ -0,0 +1,1207 @@ +/** + * @license MIT + * + * This contains the type declarations for the xterm.js library. Note that + * some interfaces differ between this file and the actual implementation in + * src/, that's because this file declares the *public* API which is intended + * to be stable and consumed by external programs. + */ + +declare module 'xterm-core' { + /** + * A string representing log level. + */ + export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off'; + + /** + * An object containing start up options for the terminal. + */ + export interface ITerminalOptions { + /** + * Whether to allow the use of proposed API. When false, any usage of APIs + * marked as experimental/proposed will throw an error. This defaults to + * true currently, but will change to false in v5.0. + */ + allowProposedApi?: boolean; + + /** + * Whether background should support non-opaque color. It must be set before + * executing the `Terminal.open()` method and can't be changed later without + * executing it again. Note that enabling this can negatively impact + * performance. + */ + allowTransparency?: boolean; + + /** + * If enabled, alt + click will move the prompt cursor to position + * underneath the mouse. The default is true. + */ + altClickMovesCursor?: boolean; + + /** + * A data uri of the sound to use for the bell when `bellStyle = 'sound'`. + */ + bellSound?: string; + + /** + * The type of the bell notification the terminal will use. + */ + bellStyle?: 'none' | 'sound'; + + /** + * When enabled the cursor will be set to the beginning of the next line + * with every new line. This is equivalent to sending '\r\n' for each '\n'. + * Normally the termios settings of the underlying PTY deals with the + * translation of '\n' to '\r\n' and this setting should not be used. If you + * deal with data from a non-PTY related source, this settings might be + * useful. + */ + convertEol?: boolean; + + /** + * The number of columns in the terminal. + */ + cols?: number; + + /** + * Whether the cursor blinks. + */ + cursorBlink?: boolean; + + /** + * The style of the cursor. + */ + cursorStyle?: 'block' | 'underline' | 'bar'; + + /** + * The width of the cursor in CSS pixels when `cursorStyle` is set to 'bar'. + */ + cursorWidth?: number; + + /** + * Whether input should be disabled. + */ + disableStdin?: boolean; + + /** + * Whether to draw bold text in bright colors. The default is true. + */ + drawBoldTextInBrightColors?: boolean; + + /** + * The modifier key hold to multiply scroll speed. + */ + fastScrollModifier?: 'alt' | 'ctrl' | 'shift' | undefined; + + /** + * The spacing in whole pixels between characters. + */ + letterSpacing?: number; + + /** + * The line height used to render text. + */ + lineHeight?: number; + + /** + * The duration in milliseconds before link tooltip events fire when + * hovering on a link. + * @deprecated This will be removed when the link matcher API is removed. + */ + linkTooltipHoverDuration?: number; + + /** + * What log level to use, this will log for all levels below and including + * what is set: + * + * 1. debug + * 2. info (default) + * 3. warn + * 4. error + * 5. off + */ + logLevel?: LogLevel; + + /** + * Whether to treat option as the meta key. + */ + macOptionIsMeta?: boolean; + + /** + * Whether holding a modifier key will force normal selection behavior, + * regardless of whether the terminal is in mouse events mode. This will + * also prevent mouse events from being emitted by the terminal. For + * example, this allows you to use xterm.js' regular selection inside tmux + * with mouse mode enabled. + */ + macOptionClickForcesSelection?: boolean; + + /** + * The minimum contrast ratio for text in the terminal, setting this will + * change the foreground color dynamically depending on whether the contrast + * ratio is met. Example values: + * + * - 1: The default, do nothing. + * - 4.5: Minimum for WCAG AA compliance. + * - 7: Minimum for WCAG AAA compliance. + * - 21: White on black or black on white. + */ + minimumContrastRatio?: number; + + /** + * Whether to select the word under the cursor on right click, this is + * standard behavior in a lot of macOS applications. + */ + rightClickSelectsWord?: boolean; + + /** + * The number of rows in the terminal. + */ + rows?: number; + + /** + * Whether screen reader support is enabled. When on this will expose + * supporting elements in the DOM to support NVDA on Windows and VoiceOver + * on macOS. + */ + screenReaderMode?: boolean; + + /** + * The amount of scrollback in the terminal. Scrollback is the amount of + * rows that are retained when lines are scrolled beyond the initial + * viewport. + */ + scrollback?: number; + + /** + * The scrolling speed multiplier used for adjusting normal scrolling speed. + */ + scrollSensitivity?: number; + + /** + * The size of tab stops in the terminal. + */ + tabStopWidth?: number; + + /** + * The color theme of the terminal. + */ + theme?: ITheme; + + /** + * Whether "Windows mode" is enabled. Because Windows backends winpty and + * conpty operate by doing line wrapping on their side, xterm.js does not + * have access to wrapped lines. When Windows mode is enabled the following + * changes will be in effect: + * + * - Reflow is disabled. + * - Lines are assumed to be wrapped if the last character of the line is + * not whitespace. + */ + windowsMode?: boolean; + + /** + * A string containing all characters that are considered word separated by the + * double click to select work logic. + */ + wordSeparator?: string; + + /** + * Enable various window manipulation and report features. + * All features are disabled by default for security reasons. + */ + windowOptions?: IWindowOptions; + } + + /** + * Contains colors to theme the terminal with. + */ + export interface ITheme { + /** The default foreground color */ + foreground?: string; + /** The default background color */ + background?: string; + /** The cursor color */ + cursor?: string; + /** The accent color of the cursor (fg color for a block cursor) */ + cursorAccent?: string; + /** The selection background color (can be transparent) */ + selection?: string; + /** ANSI black (eg. `\x1b[30m`) */ + black?: string; + /** ANSI red (eg. `\x1b[31m`) */ + red?: string; + /** ANSI green (eg. `\x1b[32m`) */ + green?: string; + /** ANSI yellow (eg. `\x1b[33m`) */ + yellow?: string; + /** ANSI blue (eg. `\x1b[34m`) */ + blue?: string; + /** ANSI magenta (eg. `\x1b[35m`) */ + magenta?: string; + /** ANSI cyan (eg. `\x1b[36m`) */ + cyan?: string; + /** ANSI white (eg. `\x1b[37m`) */ + white?: string; + /** ANSI bright black (eg. `\x1b[1;30m`) */ + brightBlack?: string; + /** ANSI bright red (eg. `\x1b[1;31m`) */ + brightRed?: string; + /** ANSI bright green (eg. `\x1b[1;32m`) */ + brightGreen?: string; + /** ANSI bright yellow (eg. `\x1b[1;33m`) */ + brightYellow?: string; + /** ANSI bright blue (eg. `\x1b[1;34m`) */ + brightBlue?: string; + /** ANSI bright magenta (eg. `\x1b[1;35m`) */ + brightMagenta?: string; + /** ANSI bright cyan (eg. `\x1b[1;36m`) */ + brightCyan?: string; + /** ANSI bright white (eg. `\x1b[1;37m`) */ + brightWhite?: string; + } + + /** + * An object that can be disposed via a dispose function. + */ + export interface IDisposable { + dispose(): void; + } + + /** + * An event that can be listened to. + * @returns an `IDisposable` to stop listening. + */ + export interface IEvent { + (listener: (arg1: T, arg2: U) => any): IDisposable; + } + + /** + * Represents a specific line in the terminal that is tracked when scrollback + * is trimmed and lines are added or removed. This is a single line that may + * be part of a larger wrapped line. + */ + export interface IMarker extends IDisposable { + /** + * A unique identifier for this marker. + */ + readonly id: number; + + /** + * Whether this marker is disposed. + */ + readonly isDisposed: boolean; + + /** + * The actual line index in the buffer at this point in time. This is set to + * -1 if the marker has been disposed. + */ + readonly line: number; + + /** + * Event listener to get notified when the marker gets disposed. Automatic disposal + * might happen for a marker, that got invalidated by scrolling out or removal of + * a line from the buffer. + */ + onDispose: IEvent; + } + + /** + * The set of localizable strings. + */ + export interface ILocalizableStrings { + /** + * The aria label for the underlying input textarea for the terminal. + */ + promptLabel: string; + + /** + * Announcement for when line reading is suppressed due to too many lines + * being printed to the terminal when `screenReaderMode` is enabled. + */ + tooMuchOutput: string; + } + + /** + * Enable various window manipulation and report features (CSI Ps ; Ps ; Ps t). + * + * Most settings have no default implementation, as they heavily rely on + * the embedding environment. + * + * To implement a feature, create a custom CSI hook like this: + * ```ts + * term.parser.addCsiHandler({final: 't'}, params => { + * const ps = params[0]; + * switch (ps) { + * case XY: + * ... // your implementation for option XY + * return true; // signal Ps=XY was handled + * } + * return false; // any Ps that was not handled + * }); + * ``` + * + * Note on security: + * Most features are meant to deal with some information of the host machine + * where the terminal runs on. This is seen as a security risk possibly leaking + * sensitive data of the host to the program in the terminal. Therefore all options + * (even those without a default implementation) are guarded by the boolean flag + * and disabled by default. + */ + export interface IWindowOptions { + /** + * Ps=1 De-iconify window. + * No default implementation. + */ + restoreWin?: boolean; + /** + * Ps=2 Iconify window. + * No default implementation. + */ + minimizeWin?: boolean; + /** + * Ps=3 ; x ; y + * Move window to [x, y]. + * No default implementation. + */ + setWinPosition?: boolean; + /** + * Ps = 4 ; height ; width + * Resize the window to given `height` and `width` in pixels. + * Omitted parameters should reuse the current height or width. + * Zero parameters should use the display's height or width. + * No default implementation. + */ + setWinSizePixels?: boolean; + /** + * Ps=5 Raise the window to the front of the stacking order. + * No default implementation. + */ + raiseWin?: boolean; + /** + * Ps=6 Lower the xterm window to the bottom of the stacking order. + * No default implementation. + */ + lowerWin?: boolean; + /** Ps=7 Refresh the window. */ + refreshWin?: boolean; + /** + * Ps = 8 ; height ; width + * Resize the text area to given height and width in characters. + * Omitted parameters should reuse the current height or width. + * Zero parameters use the display's height or width. + * No default implementation. + */ + setWinSizeChars?: boolean; + /** + * Ps=9 ; 0 Restore maximized window. + * Ps=9 ; 1 Maximize window (i.e., resize to screen size). + * Ps=9 ; 2 Maximize window vertically. + * Ps=9 ; 3 Maximize window horizontally. + * No default implementation. + */ + maximizeWin?: boolean; + /** + * Ps=10 ; 0 Undo full-screen mode. + * Ps=10 ; 1 Change to full-screen. + * Ps=10 ; 2 Toggle full-screen. + * No default implementation. + */ + fullscreenWin?: boolean; + /** Ps=11 Report xterm window state. + * If the xterm window is non-iconified, it returns "CSI 1 t". + * If the xterm window is iconified, it returns "CSI 2 t". + * No default implementation. + */ + getWinState?: boolean; + /** + * Ps=13 Report xterm window position. Result is "CSI 3 ; x ; y t". + * Ps=13 ; 2 Report xterm text-area position. Result is "CSI 3 ; x ; y t". + * No default implementation. + */ + getWinPosition?: boolean; + /** + * Ps=14 Report xterm text area size in pixels. Result is "CSI 4 ; height ; width t". + * Ps=14 ; 2 Report xterm window size in pixels. Result is "CSI 4 ; height ; width t". + * Has a default implementation. + */ + getWinSizePixels?: boolean; + /** + * Ps=15 Report size of the screen in pixels. Result is "CSI 5 ; height ; width t". + * No default implementation. + */ + getScreenSizePixels?: boolean; + /** + * Ps=16 Report xterm character cell size in pixels. Result is "CSI 6 ; height ; width t". + * Has a default implementation. + */ + getCellSizePixels?: boolean; + /** + * Ps=18 Report the size of the text area in characters. Result is "CSI 8 ; height ; width t". + * Has a default implementation. + */ + getWinSizeChars?: boolean; + /** + * Ps=19 Report the size of the screen in characters. Result is "CSI 9 ; height ; width t". + * No default implementation. + */ + getScreenSizeChars?: boolean; + /** + * Ps=20 Report xterm window's icon label. Result is "OSC L label ST". + * No default implementation. + */ + getIconTitle?: boolean; + /** + * Ps=21 Report xterm window's title. Result is "OSC l label ST". + * No default implementation. + */ + getWinTitle?: boolean; + /** + * Ps=22 ; 0 Save xterm icon and window title on stack. + * Ps=22 ; 1 Save xterm icon title on stack. + * Ps=22 ; 2 Save xterm window title on stack. + * All variants have a default implementation. + */ + pushTitle?: boolean; + /** + * Ps=23 ; 0 Restore xterm icon and window title from stack. + * Ps=23 ; 1 Restore xterm icon title from stack. + * Ps=23 ; 2 Restore xterm window title from stack. + * All variants have a default implementation. + */ + popTitle?: boolean; + /** + * Ps>=24 Resize to Ps lines (DECSLPP). + * DECSLPP is not implemented. This settings is also used to + * enable / disable DECCOLM (earlier variant of DECSLPP). + */ + setWinLines?: boolean; + } + + /** + * The class that represents an xterm.js terminal. + */ + export class Terminal implements IDisposable { + /** + * The number of rows in the terminal's viewport. Use + * `ITerminalOptions.rows` to set this in the constructor and + * `Terminal.resize` for when the terminal exists. + */ + readonly rows: number; + + /** + * The number of columns in the terminal's viewport. Use + * `ITerminalOptions.cols` to set this in the constructor and + * `Terminal.resize` for when the terminal exists. + */ + readonly cols: number; + + /** + * (EXPERIMENTAL) The terminal's current buffer, this might be either the + * normal buffer or the alt buffer depending on what's running in the + * terminal. + */ + readonly buffer: IBufferNamespace; + + /** + * (EXPERIMENTAL) Get all markers registered against the buffer. If the alt + * buffer is active this will always return []. + */ + readonly markers: ReadonlyArray; + + /** + * (EXPERIMENTAL) Get the parser interface to register + * custom escape sequence handlers. + */ + readonly parser: IParser; + + /** + * (EXPERIMENTAL) Get the Unicode handling interface + * to register and switch Unicode version. + */ + readonly unicode: IUnicodeHandling; + + /** + * Natural language strings that can be localized. + */ + static strings: ILocalizableStrings; + + /** + * Creates a new `Terminal` object. + * + * @param options An object containing a set of options. + */ + constructor(options?: ITerminalOptions); + + /** + * Adds an event listener for when a binary event fires. This is used to + * enable non UTF-8 conformant binary messages to be sent to the backend. + * Currently this is only used for a certain type of mouse reports that + * happen to be not UTF-8 compatible. + * The event value is a JS string, pass it to the underlying pty as + * binary data, e.g. `pty.write(Buffer.from(data, 'binary'))`. + * @returns an `IDisposable` to stop listening. + */ + onBinary: IEvent; + + /** + * Adds an event listener for the cursor moves. + * @returns an `IDisposable` to stop listening. + */ + onCursorMove: IEvent; + + /** + * Adds an event listener for when a data event fires. This happens for + * example when the user types or pastes into the terminal. The event value + * is whatever `string` results, in a typical setup, this should be passed + * on to the backing pty. + * @returns an `IDisposable` to stop listening. + */ + onData: IEvent; + + /** + * Adds an event listener for when a line feed is added. + * @returns an `IDisposable` to stop listening. + */ + onLineFeed: IEvent; + + /** + * Adds an event listener for when the terminal is resized. The event value + * contains the new size. + * @returns an `IDisposable` to stop listening. + */ + onResize: IEvent<{ cols: number, rows: number }>; + + /** + * Adds an event listener for when an OSC 0 or OSC 2 title change occurs. + * The event value is the new title. + * @returns an `IDisposable` to stop listening. + */ + onTitleChange: IEvent; + + /** + * Resizes the terminal. It's best practice to debounce calls to resize, + * this will help ensure that the pty can respond to the resize event + * before another one occurs. + * @param x The number of columns to resize to. + * @param y The number of rows to resize to. + */ + resize(columns: number, rows: number): void; + + /** + * (EXPERIMENTAL) Adds a marker to the normal buffer and returns it. If the + * alt buffer is active, undefined is returned. + * @param cursorYOffset The y position offset of the marker from the cursor. + * @returns The new marker or undefined. + */ + registerMarker(cursorYOffset: number): IMarker | undefined; + + /** + * @deprecated use `registerMarker` instead. + */ + addMarker(cursorYOffset: number): IMarker | undefined; + + /* + * Disposes of the terminal, detaching it from the DOM and removing any + * active listeners. + */ + dispose(): void; + + /** + * Clear the entire buffer, making the prompt line the new first line. + */ + clear(): void; + + /** + * Write data to the terminal. + * @param data The data to write to the terminal. This can either be raw + * bytes given as Uint8Array from the pty or a string. Raw bytes will always + * be treated as UTF-8 encoded, string data as UTF-16. + * @param callback Optional callback that fires when the data was processed + * by the parser. + */ + write(data: string | Uint8Array, callback?: () => void): void; + + /** + * Writes data to the terminal, followed by a break line character (\n). + * @param data The data to write to the terminal. This can either be raw + * bytes given as Uint8Array from the pty or a string. Raw bytes will always + * be treated as UTF-8 encoded, string data as UTF-16. + * @param callback Optional callback that fires when the data was processed + * by the parser. + */ + writeln(data: string | Uint8Array, callback?: () => void): void; + + /** + * Write UTF8 data to the terminal. + * @param data The data to write to the terminal. + * @param callback Optional callback when data was processed. + * @deprecated use `write` instead + */ + writeUtf8(data: Uint8Array, callback?: () => void): void; + + /** + * Retrieves an option's value from the terminal. + * @param key The option key. + */ + getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string; + /** + * Retrieves an option's value from the terminal. + * @param key The option key. + */ + getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell' | 'windowsMode'): boolean; + /** + * Retrieves an option's value from the terminal. + * @param key The option key. + */ + getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; + /** + * Retrieves an option's value from the terminal. + * @param key The option key. + */ + getOption(key: string): any; + + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'fontFamily' | 'termName' | 'bellSound' | 'wordSeparator', value: string): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'fontWeight' | 'fontWeightBold', value: null | 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'logLevel', value: LogLevel): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'bellStyle', value: null | 'none' | 'visual' | 'sound' | 'both'): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'cursorStyle', value: null | 'block' | 'underline' | 'bar'): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'popOnBell' | 'rightClickSelectsWord' | 'visualBell' | 'windowsMode', value: boolean): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'theme', value: ITheme): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'cols' | 'rows', value: number): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: string, value: any): void; + + /** + * Perform a full reset (RIS, aka '\x1bc'). + */ + reset(): void; + } + + /** + * An addon that can provide additional functionality to the terminal. + */ + export interface ITerminalAddon extends IDisposable { + /** + * This is called when the addon is activated. + */ + activate(terminal: Terminal): void; + } + + /** + * An object representing a selection within the terminal. + */ + interface ISelectionPosition { + /** + * The start column of the selection. + */ + startColumn: number; + + /** + * The start row of the selection. + */ + startRow: number; + + /** + * The end column of the selection. + */ + endColumn: number; + + /** + * The end row of the selection. + */ + endRow: number; + } + + /** + * An object representing a range within the viewport of the terminal. + */ + export interface IViewportRange { + /** + * The start of the range. + */ + start: IViewportRangePosition; + + /** + * The end of the range. + */ + end: IViewportRangePosition; + } + + /** + * An object representing a cell position within the viewport of the terminal. + */ + interface IViewportRangePosition { + /** + * The x position of the cell. This is a 0-based index that refers to the + * space in between columns, not the column itself. Index 0 refers to the + * left side of the viewport, index `Terminal.cols` refers to the right side + * of the viewport. This can be thought of as how a cursor is positioned in + * a text editor. + */ + x: number; + + /** + * The y position of the cell. This is a 0-based index that refers to a + * specific row. + */ + y: number; + } + + /** + * A range within a buffer. + */ + interface IBufferRange { + /** + * The start position of the range. + */ + start: IBufferCellPosition; + + /** + * The end position of the range. + */ + end: IBufferCellPosition; + } + + /** + * A position within a buffer. + */ + interface IBufferCellPosition { + /** + * The x position within the buffer. + */ + x: number; + + /** + * The y position within the buffer. + */ + y: number; + } + + /** + * Represents a terminal buffer. + */ + interface IBuffer { + /** + * The type of the buffer. + */ + readonly type: 'normal' | 'alternate'; + + /** + * The y position of the cursor. This ranges between `0` (when the + * cursor is at baseY) and `Terminal.rows - 1` (when the cursor is on the + * last row). + */ + readonly cursorY: number; + + /** + * The x position of the cursor. This ranges between `0` (left side) and + * `Terminal.cols` (after last cell of the row). + */ + readonly cursorX: number; + + /** + * The line within the buffer where the top of the viewport is. + */ + readonly viewportY: number; + + /** + * The line within the buffer where the top of the bottom page is (when + * fully scrolled down). + */ + readonly baseY: number; + + /** + * The amount of lines in the buffer. + */ + readonly length: number; + + /** + * Gets a line from the buffer, or undefined if the line index does not + * exist. + * + * Note that the result of this function should be used immediately after + * calling as when the terminal updates it could lead to unexpected + * behavior. + * + * @param y The line index to get. + */ + getLine(y: number): IBufferLine | undefined; + + /** + * Creates an empty cell object suitable as a cell reference in + * `line.getCell(x, cell)`. Use this to avoid costly recreation of + * cell objects when dealing with tons of cells. + */ + getNullCell(): IBufferCell; + } + + /** + * Represents the terminal's set of buffers. + */ + interface IBufferNamespace { + /** + * The active buffer, this will either be the normal or alternate buffers. + */ + readonly active: IBuffer; + + /** + * The normal buffer. + */ + readonly normal: IBuffer; + + /** + * The alternate buffer, this becomes the active buffer when an application + * enters this mode via DECSET (`CSI ? 4 7 h`) + */ + readonly alternate: IBuffer; + + /** + * Adds an event listener for when the active buffer changes. + * @returns an `IDisposable` to stop listening. + */ + onBufferChange: IEvent; + } + + /** + * Represents a line in the terminal's buffer. + */ + interface IBufferLine { + /** + * Whether the line is wrapped from the previous line. + */ + readonly isWrapped: boolean; + + /** + * The length of the line, all call to getCell beyond the length will result + * in `undefined`. + */ + readonly length: number; + + /** + * Gets a cell from the line, or undefined if the line index does not exist. + * + * Note that the result of this function should be used immediately after + * calling as when the terminal updates it could lead to unexpected + * behavior. + * + * @param x The character index to get. + * @param cell Optional cell object to load data into for performance + * reasons. This is mainly useful when every cell in the buffer is being + * looped over to avoid creating new objects for every cell. + */ + getCell(x: number, cell?: IBufferCell): IBufferCell | undefined; + + /** + * Gets the line as a string. Note that this is gets only the string for the + * line, not taking isWrapped into account. + * + * @param trimRight Whether to trim any whitespace at the right of the line. + * @param startColumn The column to start from (inclusive). + * @param endColumn The column to end at (exclusive). + */ + translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string; + } + + /** + * Represents a single cell in the terminal's buffer. + */ + interface IBufferCell { + /** + * The width of the character. Some examples: + * + * - `1` for most cells. + * - `2` for wide character like CJK glyphs. + * - `0` for cells immediately following cells with a width of `2`. + */ + getWidth(): number; + + /** + * The character(s) within the cell. Examples of what this can contain: + * + * - A normal width character + * - A wide character (eg. CJK) + * - An emoji + */ + getChars(): string; + + /** + * Gets the UTF32 codepoint of single characters, if content is a combined + * string it returns the codepoint of the last character in the string. + */ + getCode(): number; + + /** + * Gets the number representation of the foreground color mode, this can be + * used to perform quick comparisons of 2 cells to see if they're the same. + * Use `isFgRGB`, `isFgPalette` and `isFgDefault` to check what color mode + * a cell is. + */ + getFgColorMode(): number; + + /** + * Gets the number representation of the background color mode, this can be + * used to perform quick comparisons of 2 cells to see if they're the same. + * Use `isBgRGB`, `isBgPalette` and `isBgDefault` to check what color mode + * a cell is. + */ + getBgColorMode(): number; + + /** + * Gets a cell's foreground color number, this differs depending on what the + * color mode of the cell is: + * + * - Default: This should be 0, representing the default foreground color + * (CSI 39 m). + * - Palette: This is a number from 0 to 255 of ANSI colors (CSI 3(0-7) m, + * CSI 9(0-7) m, CSI 38 ; 5 ; 0-255 m). + * - RGB: A hex value representing a 'true color': 0xRRGGBB. + * (CSI 3 8 ; 2 ; Pi ; Pr ; Pg ; Pb) + */ + getFgColor(): number; + + /** + * Gets a cell's background color number, this differs depending on what the + * color mode of the cell is: + * + * - Default: This should be 0, representing the default background color + * (CSI 49 m). + * - Palette: This is a number from 0 to 255 of ANSI colors + * (CSI 4(0-7) m, CSI 10(0-7) m, CSI 48 ; 5 ; 0-255 m). + * - RGB: A hex value representing a 'true color': 0xRRGGBB + * (CSI 4 8 ; 2 ; Pi ; Pr ; Pg ; Pb) + */ + getBgColor(): number; + + /** Whether the cell has the bold attribute (CSI 1 m). */ + isBold(): number; + /** Whether the cell has the inverse attribute (CSI 3 m). */ + isItalic(): number; + /** Whether the cell has the inverse attribute (CSI 2 m). */ + isDim(): number; + /** Whether the cell has the underline attribute (CSI 4 m). */ + isUnderline(): number; + /** Whether the cell has the inverse attribute (CSI 5 m). */ + isBlink(): number; + /** Whether the cell has the inverse attribute (CSI 7 m). */ + isInverse(): number; + /** Whether the cell has the inverse attribute (CSI 8 m). */ + isInvisible(): number; + + /** Whether the cell is using the RGB foreground color mode. */ + isFgRGB(): boolean; + /** Whether the cell is using the RGB background color mode. */ + isBgRGB(): boolean; + /** Whether the cell is using the palette foreground color mode. */ + isFgPalette(): boolean; + /** Whether the cell is using the palette background color mode. */ + isBgPalette(): boolean; + /** Whether the cell is using the default foreground color mode. */ + isFgDefault(): boolean; + /** Whether the cell is using the default background color mode. */ + isBgDefault(): boolean; + + /** Whether the cell has the default attribute (no color or style). */ + isAttributeDefault(): boolean; + } + + /** + * Data type to register a CSI, DCS or ESC callback in the parser + * in the form: + * ESC I..I F + * CSI Prefix P..P I..I F + * DCS Prefix P..P I..I F data_bytes ST + * + * with these rules/restrictions: + * - prefix can only be used with CSI and DCS + * - only one leading prefix byte is recognized by the parser + * before any other parameter bytes (P..P) + * - intermediate bytes are recognized up to 2 + * + * For custom sequences make sure to read ECMA-48 and the resources at + * vt100.net to not clash with existing sequences or reserved address space. + * General recommendations: + * - use private address space (see ECMA-48) + * - use max one intermediate byte (technically not limited by the spec, + * in practice there are no sequences with more than one intermediate byte, + * thus parsers might get confused with more intermediates) + * - test against other common emulators to check whether they escape/ignore + * the sequence correctly + * + * Notes: OSC command registration is handled differently (see addOscHandler) + * APC, PM or SOS is currently not supported. + */ + export interface IFunctionIdentifier { + /** + * Optional prefix byte, must be in range \x3c .. \x3f. + * Usable in CSI and DCS. + */ + prefix?: string; + /** + * Optional intermediate bytes, must be in range \x20 .. \x2f. + * Usable in CSI, DCS and ESC. + */ + intermediates?: string; + /** + * Final byte, must be in range \x40 .. \x7e for CSI and DCS, + * \x30 .. \x7e for ESC. + */ + final: string; + } + + /** + * Allows hooking into the parser for custom handling of escape sequences. + */ + export interface IParser { + /** + * Adds a handler for CSI escape sequences. + * @param id Specifies the function identifier under which the callback + * gets registered, e.g. {final: 'm'} for SGR. + * @param callback The function to handle the sequence. The callback is + * called with the numerical params. If the sequence has subparams the + * array will contain subarrays with their numercial values. + * Return true if the sequence was handled; false if we should try + * a previous handler (set by addCsiHandler or setCsiHandler). + * The most recently added handler is tried first. + * @return An IDisposable you can call to remove this handler. + */ + registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable; + + /** + * Adds a handler for DCS escape sequences. + * @param id Specifies the function identifier under which the callback + * gets registered, e.g. {intermediates: '$' final: 'q'} for DECRQSS. + * @param callback The function to handle the sequence. Note that the + * function will only be called once if the sequence finished sucessfully. + * There is currently no way to intercept smaller data chunks, data chunks + * will be stored up until the sequence is finished. Since DCS sequences + * are not limited by the amount of data this might impose a problem for + * big payloads. Currently xterm.js limits DCS payload to 10 MB + * which should give enough room for most use cases. + * The function gets the payload and numerical parameters as arguments. + * Return true if the sequence was handled; false if we should try + * a previous handler (set by addDcsHandler or setDcsHandler). + * The most recently added handler is tried first. + * @return An IDisposable you can call to remove this handler. + */ + registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable; + + /** + * Adds a handler for ESC escape sequences. + * @param id Specifies the function identifier under which the callback + * gets registered, e.g. {intermediates: '%' final: 'G'} for + * default charset selection. + * @param callback The function to handle the sequence. + * Return true if the sequence was handled; false if we should try + * a previous handler (set by addEscHandler or setEscHandler). + * The most recently added handler is tried first. + * @return An IDisposable you can call to remove this handler. + */ + registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable; + + /** + * Adds a handler for OSC escape sequences. + * @param ident The number (first parameter) of the sequence. + * @param callback The function to handle the sequence. Note that the + * function will only be called once if the sequence finished sucessfully. + * There is currently no way to intercept smaller data chunks, data chunks + * will be stored up until the sequence is finished. Since OSC sequences + * are not limited by the amount of data this might impose a problem for + * big payloads. Currently xterm.js limits OSC payload to 10 MB + * which should give enough room for most use cases. + * The callback is called with OSC data string. + * Return true if the sequence was handled; false if we should try + * a previous handler (set by addOscHandler or setOscHandler). + * The most recently added handler is tried first. + * @return An IDisposable you can call to remove this handler. + */ + registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable; + } + + /** + * (EXPERIMENTAL) Unicode version provider. + * Used to register custom Unicode versions with `Terminal.unicode.register`. + */ + export interface IUnicodeVersionProvider { + /** + * String indicating the Unicode version provided. + */ + readonly version: string; + + /** + * Unicode version dependent wcwidth implementation. + */ + wcwidth(codepoint: number): 0 | 1 | 2; + } + + /** + * (EXPERIMENTAL) Unicode handling interface. + */ + export interface IUnicodeHandling { + /** + * Register a custom Unicode version provider. + */ + register(provider: IUnicodeVersionProvider): void; + + /** + * Registered Unicode versions. + */ + readonly versions: ReadonlyArray; + + /** + * Getter/setter for active Unicode version. + */ + activeVersion: string; + } + } + \ No newline at end of file From 5e6e65c8da6ee21bb8c669702aa7a3f4e91a10fa Mon Sep 17 00:00:00 2001 From: joyceerhl Date: Sun, 10 Jan 2021 22:18:41 -0800 Subject: [PATCH 049/377] Get dupe of src/browser/public/Terminal compiling --- core-webpack.config.js | 41 ++++++++ package.json | 1 + src/common/public/Terminal.ts | 108 +-------------------- src/common/public/TerminalCore.ts | 155 ++++++++++++++++++++++++++++++ src/common/public/tsconfig.json | 21 ++++ src/common/public/types.ts | 31 ++++++ 6 files changed, 253 insertions(+), 104 deletions(-) create mode 100644 core-webpack.config.js create mode 100644 src/common/public/TerminalCore.ts create mode 100644 src/common/public/tsconfig.json create mode 100644 src/common/public/types.ts diff --git a/core-webpack.config.js b/core-webpack.config.js new file mode 100644 index 00000000..85c37ff1 --- /dev/null +++ b/core-webpack.config.js @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2019 The xterm.js authors. All rights reserved. + * @license MIT + */ + +const path = require('path'); + +/** + * This webpack config does a production build for xterm-core.js. It works by taking the output from tsc + * (via `yarn watch` or `yarn prebuild`) which are put into `xterm-core/` and webpacks them into a + * production mode commonjs library module in `lib/`. The aliases are used fix up the absolute paths + * output by tsc (because of `baseUrl` and `paths` in `tsconfig.json`. + */ +module.exports = { + entry: './xterm-core/common/public/Terminal.js', + devtool: 'source-map', + module: { + rules: [ + { + test: /\.js$/, + use: ["source-map-loader"], + enforce: "pre", + exclude: /node_modules/ + } + ] + }, + resolve: { + modules: ['./node_modules'], + extensions: [ '.js' ], + alias: { + common: path.resolve('./xterm-core/common') + } + }, + output: { + filename: 'xterm-core.js', + path: path.resolve('./lib'), + libraryTarget: 'commonjs' + }, + mode: 'production', + target: 'node', +}; diff --git a/package.json b/package.json index 59902931..aa6f5a1b 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "scripts": { "prepackage": "npm run build", "package": "webpack", + "compile": "tsc -b ./src/common/public/tsconfig.json", "start": "node demo/start", "lint": "eslint -c .eslintrc.json --max-warnings 0 --ext .ts src/ addons/", "test": "npm run test-unit", diff --git a/src/common/public/Terminal.ts b/src/common/public/Terminal.ts index 70247f88..39ad5cd4 100644 --- a/src/common/public/Terminal.ts +++ b/src/common/public/Terminal.ts @@ -3,27 +3,22 @@ * @license MIT */ -import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi, IParser, IFunctionIdentifier, ILinkProvider, IUnicodeHandling, IUnicodeVersionProvider, FontWeight } from 'xterm'; -import { ITerminal } from 'browser/Types'; +import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi, IParser, IFunctionIdentifier, IUnicodeHandling, IUnicodeVersionProvider } from 'xterm-core'; import { IBufferLine, ICellData } from 'common/Types'; -import { IBuffer, IBufferSet } from 'common/buffer/Types'; +import { IBuffer } from 'common/buffer/Types'; import { CellData } from 'common/buffer/CellData'; -import { Terminal as TerminalCore } from '../Terminal'; -import * as Strings from '../LocalizableStrings'; +import { Terminal as TerminalCore } from './TerminalCore'; import { IEvent, EventEmitter } from 'common/EventEmitter'; -import { AddonManager } from './AddonManager'; import { IParams } from 'common/parser/Types'; -import { BufferSet } from 'common/buffer/BufferSet'; +import { ITerminal } from 'common/public/types'; export class Terminal implements ITerminalApi { private _core: ITerminal; - private _addonManager: AddonManager; private _parser: IParser | undefined; private _buffer: BufferNamespaceApi | undefined; constructor(options?: ITerminalOptions) { this._core = new TerminalCore(options); - this._addonManager = new AddonManager(); } private _checkProposedApi(): void { @@ -34,16 +29,11 @@ export class Terminal implements ITerminalApi { public get onCursorMove(): IEvent { return this._core.onCursorMove; } public get onLineFeed(): IEvent { return this._core.onLineFeed; } - public get onSelectionChange(): IEvent { return this._core.onSelectionChange; } public get onData(): IEvent { return this._core.onData; } public get onBinary(): IEvent { return this._core.onBinary; } public get onTitleChange(): IEvent { return this._core.onTitleChange; } - public get onScroll(): IEvent { return this._core.onScroll; } - public get onKey(): IEvent<{ key: string, domEvent: KeyboardEvent }> { return this._core.onKey; } - public get onRender(): IEvent<{ start: number, end: number }> { return this._core.onRender; } public get onResize(): IEvent<{ cols: number, rows: number }> { return this._core.onResize; } - public get element(): HTMLElement | undefined { return this._core.element; } public get parser(): IParser { this._checkProposedApi(); if (!this._parser) { @@ -55,7 +45,6 @@ export class Terminal implements ITerminalApi { this._checkProposedApi(); return new UnicodeApi(this._core); } - public get textarea(): HTMLTextAreaElement | undefined { return this._core.textarea; } public get rows(): number { return this._core.rows; } public get cols(): number { return this._core.cols; } public get buffer(): IBufferNamespaceApi { @@ -69,42 +58,10 @@ export class Terminal implements ITerminalApi { this._checkProposedApi(); return this._core.markers; } - public blur(): void { - this._core.blur(); - } - public focus(): void { - this._core.focus(); - } public resize(columns: number, rows: number): void { this._verifyIntegers(columns, rows); this._core.resize(columns, rows); } - public open(parent: HTMLElement): void { - this._core.open(parent); - } - public attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void { - this._core.attachCustomKeyEventHandler(customKeyEventHandler); - } - public registerLinkMatcher(regex: RegExp, handler: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions): number { - this._checkProposedApi(); - return this._core.registerLinkMatcher(regex, handler, options); - } - public deregisterLinkMatcher(matcherId: number): void { - this._checkProposedApi(); - this._core.deregisterLinkMatcher(matcherId); - } - public registerLinkProvider(linkProvider: ILinkProvider): IDisposable { - this._checkProposedApi(); - return this._core.registerLinkProvider(linkProvider); - } - public registerCharacterJoiner(handler: (text: string) => [number, number][]): number { - this._checkProposedApi(); - return this._core.registerCharacterJoiner(handler); - } - public deregisterCharacterJoiner(joinerId: number): void { - this._checkProposedApi(); - this._core.deregisterCharacterJoiner(joinerId); - } public registerMarker(cursorYOffset: number): IMarker | undefined { this._checkProposedApi(); this._verifyIntegers(cursorYOffset); @@ -113,51 +70,9 @@ export class Terminal implements ITerminalApi { public addMarker(cursorYOffset: number): IMarker | undefined { return this.registerMarker(cursorYOffset); } - public hasSelection(): boolean { - return this._core.hasSelection(); - } - public select(column: number, row: number, length: number): void { - this._verifyIntegers(column, row, length); - this._core.select(column, row, length); - } - public getSelection(): string { - return this._core.getSelection(); - } - public getSelectionPosition(): ISelectionPosition | undefined { - return this._core.getSelectionPosition(); - } - public clearSelection(): void { - this._core.clearSelection(); - } - public selectAll(): void { - this._core.selectAll(); - } - public selectLines(start: number, end: number): void { - this._verifyIntegers(start, end); - this._core.selectLines(start, end); - } public dispose(): void { - this._addonManager.dispose(); this._core.dispose(); } - public scrollLines(amount: number): void { - this._verifyIntegers(amount); - this._core.scrollLines(amount); - } - public scrollPages(pageCount: number): void { - this._verifyIntegers(pageCount); - this._core.scrollPages(pageCount); - } - public scrollToTop(): void { - this._core.scrollToTop(); - } - public scrollToBottom(): void { - this._core.scrollToBottom(); - } - public scrollToLine(line: number): void { - this._verifyIntegers(line); - this._core.scrollToLine(line); - } public clear(): void { this._core.clear(); } @@ -171,13 +86,9 @@ export class Terminal implements ITerminalApi { this._core.write(data); this._core.write('\r\n', callback); } - public paste(data: string): void { - this._core.paste(data); - } public getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string; public getOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell'): boolean; public getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; - public getOption(key: 'fontWeight' | 'fontWeightBold'): FontWeight; public getOption(key: string): any; public getOption(key: any): any { return this._core.optionsService.getOption(key); @@ -189,25 +100,14 @@ export class Terminal implements ITerminalApi { public setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void; public setOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell', value: boolean): void; public setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; - public setOption(key: 'theme', value: ITheme): void; public setOption(key: 'cols' | 'rows', value: number): void; public setOption(key: string, value: any): void; public setOption(key: any, value: any): void { this._core.optionsService.setOption(key, value); } - public refresh(start: number, end: number): void { - this._verifyIntegers(start, end); - this._core.refresh(start, end); - } public reset(): void { this._core.reset(); } - public loadAddon(addon: ITerminalAddon): void { - return this._addonManager.loadAddon(this, addon); - } - public static get strings(): ILocalizableStrings { - return Strings; - } private _verifyIntegers(...values: number[]): void { for (const value of values) { diff --git a/src/common/public/TerminalCore.ts b/src/common/public/TerminalCore.ts new file mode 100644 index 00000000..2aae1ee2 --- /dev/null +++ b/src/common/public/TerminalCore.ts @@ -0,0 +1,155 @@ +/** + * Copyright (c) 2014 The xterm.js authors. All rights reserved. + * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) + * @license MIT + * + * Originally forked from (with the author's permission): + * Fabrice Bellard's javascript vt100 for jslinux: + * http://bellard.org/jslinux/ + * Copyright (c) 2011 Fabrice Bellard + * The original design remains. The terminal itself + * has been extended to include xterm CSI codes, among + * other features. + * + * Terminal Emulation References: + * http://vt100.net/ + * http://invisible-island.net/xterm/ctlseqs/ctlseqs.txt + * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html + * http://invisible-island.net/vttest/ + * http://www.inwap.com/pdp10/ansicode.txt + * http://linux.die.net/man/4/console_codes + * http://linux.die.net/man/7/urxvt + */ + +import { ICoreTerminal, IDisposable, IMarker, ITerminalOptions } from 'common/Types'; +import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter'; +import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; +import { IBuffer, IBufferSet } from 'common/buffer/Types'; +import { CoreTerminal } from 'common/CoreTerminal'; +import { ITerminalOptions as IInitializedTerminalOptions } from 'common/services/Services'; +import { IFunctionIdentifier, IParams } from 'common/parser/Types'; + +export class Terminal extends CoreTerminal { + // TODO: We should remove options once components adopt optionsService + public get options(): IInitializedTerminalOptions { return this.optionsService.options; } + + + private _onCursorMove = new EventEmitter(); + public get onCursorMove(): IEvent { return this._onCursorMove.event; } + private _onTitleChange = new EventEmitter(); + public get onTitleChange(): IEvent { return this._onTitleChange.event; } + + private _onA11yCharEmitter = new EventEmitter(); + public get onA11yChar(): IEvent { return this._onA11yCharEmitter.event; } + private _onA11yTabEmitter = new EventEmitter(); + public get onA11yTab(): IEvent { return this._onA11yTabEmitter.event; } + + /** + * Creates a new `Terminal` object. + * + * @param options An object containing a set of options, the available options are: + * - `cursorBlink` (boolean): Whether the terminal cursor blinks + * - `cols` (number): The number of columns of the terminal (horizontal size) + * - `rows` (number): The number of rows of the terminal (vertical size) + * + * @public + * @class Xterm Xterm + * @alias module:xterm/src/xterm + */ + constructor( + options: ITerminalOptions = {} + ) { + super(options); + + this._setup(); + + // Setup InputHandler listeners + this.register(this._inputHandler.onRequestReset(() => this.reset())); + this.register(this._inputHandler.onRequestScroll((eraseAttr, isWrapped) => this.scroll(eraseAttr, isWrapped || undefined))); + this.register(forwardEvent(this._inputHandler.onCursorMove, this._onCursorMove)); + this.register(forwardEvent(this._inputHandler.onTitleChange, this._onTitleChange)); + this.register(forwardEvent(this._inputHandler.onA11yChar, this._onA11yCharEmitter)); + this.register(forwardEvent(this._inputHandler.onA11yTab, this._onA11yTabEmitter)); + } + + public dispose(): void { + if (this._isDisposed) { + return; + } + super.dispose(); + this.write = () => { }; + } + + /** + * Convenience property to active buffer. + */ + public get buffer(): IBuffer { + return this.buffers.active; + } + + public get markers(): IMarker[] { + return this.buffer.markers; + } + + public addMarker(cursorYOffset: number): IMarker | undefined { + // Disallow markers on the alt buffer + if (this.buffer !== this.buffers.normal) { + return; + } + + return this.buffer.addMarker(this.buffer.ybase + this.buffer.y + cursorYOffset); + } + + /** + * Resizes the terminal. + * + * @param x The number of columns to resize to. + * @param y The number of rows to resize to. + */ + public resize(x: number, y: number): void { + if (x === this.cols && y === this.rows) { + return; + } + + super.resize(x, y); + } + + /** + * Clear the entire buffer, making the prompt line the new first line. + */ + public clear(): void { + if (this.buffer.ybase === 0 && this.buffer.y === 0) { + // Don't clear if it's already clear + return; + } + this.buffer.lines.set(0, this.buffer.lines.get(this.buffer.ybase + this.buffer.y)!); + this.buffer.lines.length = 1; + this.buffer.ydisp = 0; + this.buffer.ybase = 0; + this.buffer.y = 0; + for (let i = 1; i < this.rows; i++) { + this.buffer.lines.push(this.buffer.getBlankLine(DEFAULT_ATTR_DATA)); + } + this._onScroll.fire(this.buffer.ydisp); + } + + /** + * Reset terminal. + * Note: Calling this directly from JS is synchronous but does not clear + * input buffers and does not reset the parser, thus the terminal will + * continue to apply pending input data. + * If you need in band reset (synchronous with input data) consider + * using DECSTR (soft reset, CSI ! p) or RIS instead (hard reset, ESC c). + */ + public reset(): void { + /** + * Since _setup handles a full terminal creation, we have to carry forward + * a few things that should not reset. + */ + this.options.rows = this.rows; + this.options.cols = this.cols; + + this._setup(); + super.reset(); + } +} diff --git a/src/common/public/tsconfig.json b/src/common/public/tsconfig.json new file mode 100644 index 00000000..6e14ddf7 --- /dev/null +++ b/src/common/public/tsconfig.json @@ -0,0 +1,21 @@ +{ + "extends": "../../tsconfig-library-base", + "compilerOptions": { + "lib": [ + "es2015", + "es2016.Array.Include" + ], + "outDir": "../../../xterm-core", // Temporary outdir to avoid collisions with 'xterm' + "types": [ + "../../../node_modules/@types/mocha", + "../../../node_modules/@types/node" + ], + "baseUrl": "../../", + "extendedDiagnostics": true + }, + "include": [ + "../**/*", + "../../../typings/xterm-core.d.ts", + "../../../typings/xterm.d.ts", // common/Types.d.ts imports from 'xterm' + ], +} diff --git a/src/common/public/types.ts b/src/common/public/types.ts new file mode 100644 index 00000000..1c20bd6d --- /dev/null +++ b/src/common/public/types.ts @@ -0,0 +1,31 @@ +import { IBuffer, IBufferSet } from 'common/buffer/Types'; +import { IEvent } from 'common/EventEmitter'; +import { IFunctionIdentifier, IParams } from 'common/parser/Types'; +import { ICoreTerminal, IDisposable, IMarker, ITerminalOptions } from 'common/Types'; + +export interface ITerminal extends ICoreTerminal { + rows: number; + cols: number; + buffer: IBuffer; + buffers: IBufferSet; + markers: IMarker[]; + // TODO: We should remove options once components adopt optionsService + options: ITerminalOptions; + + onCursorMove: IEvent; + onData: IEvent; + onBinary: IEvent; + onLineFeed: IEvent; + onResize: IEvent<{ cols: number, rows: number }>; + onTitleChange: IEvent; + resize(columns: number, rows: number): void; + addCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean): IDisposable; + addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean): IDisposable; + addEscHandler(id: IFunctionIdentifier, callback: () => boolean): IDisposable; + addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable; + addMarker(cursorYOffset: number): IMarker | undefined; + dispose(): void; + clear(): void; + write(data: string | Uint8Array, callback?: () => void): void; + reset(): void; +} \ No newline at end of file From 2f88498ad5cb74756204f9a2f441b05136833d68 Mon Sep 17 00:00:00 2001 From: joyceerhl Date: Sun, 10 Jan 2021 22:32:36 -0800 Subject: [PATCH 050/377] Add index.js used to test xterm-core --- node-test/README.md | 10 ++++++++++ node-test/index.js | 12 ++++++++++++ node-test/package.json | 11 +++++++++++ 3 files changed, 33 insertions(+) create mode 100644 node-test/README.md create mode 100644 node-test/index.js create mode 100644 node-test/package.json diff --git a/node-test/README.md b/node-test/README.md new file mode 100644 index 00000000..e4cf19b0 --- /dev/null +++ b/node-test/README.md @@ -0,0 +1,10 @@ +Cursory test that 'xterm-core' works: + +``` +# From root of this repo +npm run compile # Outputs to xterm-core +npx webpack --config core-webpack.config.js # Outputs to lib +cd node-test +npm link ../lib/ +node index.js +``` \ No newline at end of file diff --git a/node-test/index.js b/node-test/index.js new file mode 100644 index 00000000..19bff5dc --- /dev/null +++ b/node-test/index.js @@ -0,0 +1,12 @@ +import { createRequire } from 'module'; +const require = createRequire(import.meta.url); +const xterm = require('xterm-core'); + +console.log('Creating xterm-core terminal...'); +const terminal = new xterm.Terminal(); +console.log('Writing `ls` to terminal...') +terminal.write('ls', () => { + const bufferLine = terminal.buffer.normal.getLine(terminal.buffer.normal.cursorY); + const contents = bufferLine.translateToString(); + console.log(`Contents of terminal active buffer are: ${contents}`); // ls +}); diff --git a/node-test/package.json b/node-test/package.json new file mode 100644 index 00000000..93549623 --- /dev/null +++ b/node-test/package.json @@ -0,0 +1,11 @@ +{ + "name": "test", + "version": "1.0.0", + "description": "", + "main": "index.js", + "type": "module", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "" +} From 19c14b076b018ac3faa86dff2f147757528a4b84 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 11 Jan 2021 07:40:25 -0800 Subject: [PATCH 051/377] Remove resolved TODO --- src/browser/renderer/atlas/CharAtlasUtils.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/browser/renderer/atlas/CharAtlasUtils.ts b/src/browser/renderer/atlas/CharAtlasUtils.ts index 2b876f2b..20695d3c 100644 --- a/src/browser/renderer/atlas/CharAtlasUtils.ts +++ b/src/browser/renderer/atlas/CharAtlasUtils.ts @@ -16,10 +16,6 @@ export function generateConfig(scaledCharWidth: number, scaledCharHeight: number cursor: undefined, cursorAccent: undefined, selection: undefined, - // For the static char atlas, we only use the first 16 colors, but we need all 256 for the - // dynamic character atlas. - // ansi: colors.ansi.slice(0, 16) - // TODO: Using entire array to support OSC 4; can this break anything? ansi: colors.ansi }; return { From 5ada5f0c0c1e9cf221706607414e34ffa554b0a1 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 11 Jan 2021 08:31:56 -0800 Subject: [PATCH 052/377] Update yarn.lock for font-finder Previous update was likely done using npm, not yarn --- addons/xterm-addon-ligatures/yarn.lock | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/xterm-addon-ligatures/yarn.lock b/addons/xterm-addon-ligatures/yarn.lock index d8e64e49..049b798a 100644 --- a/addons/xterm-addon-ligatures/yarn.lock +++ b/addons/xterm-addon-ligatures/yarn.lock @@ -78,13 +78,21 @@ follow-redirects@1.5.10: dependencies: debug "=3.1.0" -font-finder@^1.0.3, font-finder@^1.0.4: +font-finder@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/font-finder/-/font-finder-1.0.4.tgz#2ca944954dd8d0e1b5bdc4c596cc08607761d89b" dependencies: get-system-fonts "^2.0.0" promise-stream-reader "^1.0.1" +font-finder@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/font-finder/-/font-finder-1.1.0.tgz#2bff2b2762acba720239c8bec898a96daae90858" + integrity sha512-wpCL2uIbi6GurJbU7ZlQ3nGd61Ho+dSU6U83/xJT5UPFfN35EeCW/rOtS+5k+IuEZu2SYmHzDIPL9eA5tSYRAw== + dependencies: + get-system-fonts "^2.0.0" + promise-stream-reader "^1.0.1" + font-ligatures@^1.3.3: version "1.3.3" resolved "https://registry.yarnpkg.com/font-ligatures/-/font-ligatures-1.3.3.tgz#63fff18dc8adb3a11fe5eec1f4e8d7edfa8075b9" From 519e44d30e45c86b8c9f27a2e2e49a1bc2ae31b0 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 11 Jan 2021 09:19:53 -0800 Subject: [PATCH 053/377] Clean up, improve comments Co-authored-by: Megan Rogge --- addons/xterm-addon-search/src/SearchAddon.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/xterm-addon-search/src/SearchAddon.ts b/addons/xterm-addon-search/src/SearchAddon.ts index 54a4a198..efc12662 100644 --- a/addons/xterm-addon-search/src/SearchAddon.ts +++ b/addons/xterm-addon-search/src/SearchAddon.ts @@ -158,9 +158,11 @@ export class SearchAddon implements ITerminalAddon { }; if (incremental) { - result = this._findInLine(term, searchPosition, searchOptions, false); // Try to expand selection to right first. - if (!(result && result.row === startRow && result.col === startCol)) { - // If selection was not able to be expanded to right, then reverse search begin. + // Try to expand selection to right first. + result = this._findInLine(term, searchPosition, searchOptions, false); + const isOldResultHighlighted = result && result.row === startRow && result.col === startCol; + if (!isOldResultHighlighted) { + // If selection was not able to be expanded to the right, then try reverse search if (currentSelection) { searchPosition.startRow = currentSelection.endRow; searchPosition.startCol = currentSelection.endColumn; @@ -250,6 +252,7 @@ export class SearchAddon implements ITerminalAddon { * @param term The search term. * @param position The position to start the search. * @param searchOptions Search options. + * @param isReverseSearch Whether the search should start from the right side of the terminal and search to the left. * @return The search result if it was found. */ protected _findInLine(term: string, searchPosition: ISearchPosition, searchOptions: ISearchOptions = {}, isReverseSearch: boolean = false): ISearchResult | undefined { From 0f9240207d19ffb731ed810fdc9a3679eb36593b Mon Sep 17 00:00:00 2001 From: joyceerhl Date: Mon, 11 Jan 2021 20:29:15 -0800 Subject: [PATCH 054/377] Move API view classes under common/public --- src/browser/public/Terminal.ts | 132 +----------------------- src/common/public/BufferApiView.ts | 30 ++++++ src/common/public/BufferLineApiView.ts | 24 +++++ src/common/public/BufferNamespaceApi.ts | 28 +++++ src/common/public/ParserApi.ts | 32 ++++++ src/common/public/UnicodeApi.ts | 22 ++++ 6 files changed, 141 insertions(+), 127 deletions(-) create mode 100644 src/common/public/BufferApiView.ts create mode 100644 src/common/public/BufferLineApiView.ts create mode 100644 src/common/public/BufferNamespaceApi.ts create mode 100644 src/common/public/ParserApi.ts create mode 100644 src/common/public/UnicodeApi.ts diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index 70247f88..21ec6948 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -3,17 +3,15 @@ * @license MIT */ -import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi, IParser, IFunctionIdentifier, ILinkProvider, IUnicodeHandling, IUnicodeVersionProvider, FontWeight } from 'xterm'; +import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBufferNamespace as IBufferNamespaceApi, IParser, ILinkProvider, IUnicodeHandling, FontWeight } from 'xterm'; import { ITerminal } from 'browser/Types'; -import { IBufferLine, ICellData } from 'common/Types'; -import { IBuffer, IBufferSet } from 'common/buffer/Types'; -import { CellData } from 'common/buffer/CellData'; import { Terminal as TerminalCore } from '../Terminal'; import * as Strings from '../LocalizableStrings'; -import { IEvent, EventEmitter } from 'common/EventEmitter'; +import { IEvent } from 'common/EventEmitter'; +import { ParserApi } from 'common/public/ParserApi'; +import { UnicodeApi } from 'common/public/UnicodeApi'; import { AddonManager } from './AddonManager'; -import { IParams } from 'common/parser/Types'; -import { BufferSet } from 'common/buffer/BufferSet'; +import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi'; export class Terminal implements ITerminalApi { private _core: ITerminal; @@ -217,123 +215,3 @@ export class Terminal implements ITerminalApi { } } } - -class BufferApiView implements IBufferApi { - constructor( - private _buffer: IBuffer, - public readonly type: 'normal' | 'alternate' - ) { } - - public init(buffer: IBuffer): BufferApiView { - this._buffer = buffer; - return this; - } - - public get cursorY(): number { return this._buffer.y; } - public get cursorX(): number { return this._buffer.x; } - public get viewportY(): number { return this._buffer.ydisp; } - public get baseY(): number { return this._buffer.ybase; } - public get length(): number { return this._buffer.lines.length; } - public getLine(y: number): IBufferLineApi | undefined { - const line = this._buffer.lines.get(y); - if (!line) { - return undefined; - } - return new BufferLineApiView(line); - } - public getNullCell(): IBufferCellApi { return new CellData(); } -} - -class BufferNamespaceApi implements IBufferNamespaceApi { - private _normal: BufferApiView; - private _alternate: BufferApiView; - private _onBufferChange = new EventEmitter(); - public get onBufferChange(): IEvent { return this._onBufferChange.event; } - - constructor(private _core: ITerminal) { - this._normal = new BufferApiView(this._core.buffers.normal, 'normal'); - this._alternate = new BufferApiView(this._core.buffers.alt, 'alternate'); - this._core.buffers.onBufferActivate(() => this._onBufferChange.fire(this.active)); - } - public get active(): IBufferApi { - if (this._core.buffers.active === this._core.buffers.normal) { return this.normal; } - if (this._core.buffers.active === this._core.buffers.alt) { return this.alternate; } - throw new Error('Active buffer is neither normal nor alternate'); - } - public get normal(): IBufferApi { - return this._normal.init(this._core.buffers.normal); - } - public get alternate(): IBufferApi { - return this._alternate.init(this._core.buffers.alt); - } -} - -class BufferLineApiView implements IBufferLineApi { - constructor(private _line: IBufferLine) { } - - public get isWrapped(): boolean { return this._line.isWrapped; } - public get length(): number { return this._line.length; } - public getCell(x: number, cell?: IBufferCellApi): IBufferCellApi | undefined { - if (x < 0 || x >= this._line.length) { - return undefined; - } - - if (cell) { - this._line.loadCell(x, cell); - return cell; - } - return this._line.loadCell(x, new CellData()); - } - public translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string { - return this._line.translateToString(trimRight, startColumn, endColumn); - } -} - -class ParserApi implements IParser { - constructor(private _core: ITerminal) { } - - public registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable { - return this._core.addCsiHandler(id, (params: IParams) => callback(params.toArray())); - } - public addCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable { - return this.registerCsiHandler(id, callback); - } - public registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable { - return this._core.addDcsHandler(id, (data: string, params: IParams) => callback(data, params.toArray())); - } - public addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable { - return this.registerDcsHandler(id, callback); - } - public registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable { - return this._core.addEscHandler(id, handler); - } - public addEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable { - return this.registerEscHandler(id, handler); - } - public registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { - return this._core.addOscHandler(ident, callback); - } - public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { - return this.registerOscHandler(ident, callback); - } -} - -class UnicodeApi implements IUnicodeHandling { - constructor(private _core: ITerminal) { } - - public register(provider: IUnicodeVersionProvider): void { - this._core.unicodeService.register(provider); - } - - public get versions(): string[] { - return this._core.unicodeService.versions; - } - - public get activeVersion(): string { - return this._core.unicodeService.activeVersion; - } - - public set activeVersion(version: string) { - this._core.unicodeService.activeVersion = version; - } -} diff --git a/src/common/public/BufferApiView.ts b/src/common/public/BufferApiView.ts new file mode 100644 index 00000000..f6f12744 --- /dev/null +++ b/src/common/public/BufferApiView.ts @@ -0,0 +1,30 @@ +import { IBuffer as IBufferApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi } from 'xterm'; +import { IBuffer } from 'common/buffer/Types'; +import { BufferLineApiView } from 'common/public/BufferLineApiView'; +import { CellData } from 'common/buffer/CellData'; + +export class BufferApiView implements IBufferApi { + constructor( + private _buffer: IBuffer, + public readonly type: 'normal' | 'alternate' + ) { } + + public init(buffer: IBuffer): BufferApiView { + this._buffer = buffer; + return this; + } + + public get cursorY(): number { return this._buffer.y; } + public get cursorX(): number { return this._buffer.x; } + public get viewportY(): number { return this._buffer.ydisp; } + public get baseY(): number { return this._buffer.ybase; } + public get length(): number { return this._buffer.lines.length; } + public getLine(y: number): IBufferLineApi | undefined { + const line = this._buffer.lines.get(y); + if (!line) { + return undefined; + } + return new BufferLineApiView(line); + } + public getNullCell(): IBufferCellApi { return new CellData(); } +} diff --git a/src/common/public/BufferLineApiView.ts b/src/common/public/BufferLineApiView.ts new file mode 100644 index 00000000..112d6f84 --- /dev/null +++ b/src/common/public/BufferLineApiView.ts @@ -0,0 +1,24 @@ +import { CellData } from 'common/buffer/CellData'; +import { IBufferLine, ICellData } from 'common/Types'; +import { IBufferCell as IBufferCellApi, IBufferLine as IBufferLineApi } from 'xterm'; + +export class BufferLineApiView implements IBufferLineApi { + constructor(private _line: IBufferLine) { } + + public get isWrapped(): boolean { return this._line.isWrapped; } + public get length(): number { return this._line.length; } + public getCell(x: number, cell?: IBufferCellApi): IBufferCellApi | undefined { + if (x < 0 || x >= this._line.length) { + return undefined; + } + + if (cell) { + this._line.loadCell(x, cell); + return cell; + } + return this._line.loadCell(x, new CellData()); + } + public translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string { + return this._line.translateToString(trimRight, startColumn, endColumn); + } +} diff --git a/src/common/public/BufferNamespaceApi.ts b/src/common/public/BufferNamespaceApi.ts new file mode 100644 index 00000000..8d787700 --- /dev/null +++ b/src/common/public/BufferNamespaceApi.ts @@ -0,0 +1,28 @@ +import { IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi } from 'xterm'; +import { BufferApiView } from 'common/public/BufferApiView'; +import { IEvent, EventEmitter } from 'common/EventEmitter'; +import { ITerminal } from 'browser/Types'; + +export class BufferNamespaceApi implements IBufferNamespaceApi { + private _normal: BufferApiView; + private _alternate: BufferApiView; + private _onBufferChange = new EventEmitter(); + public get onBufferChange(): IEvent { return this._onBufferChange.event; } + + constructor(private _core: ITerminal) { + this._normal = new BufferApiView(this._core.buffers.normal, 'normal'); + this._alternate = new BufferApiView(this._core.buffers.alt, 'alternate'); + this._core.buffers.onBufferActivate(() => this._onBufferChange.fire(this.active)); + } + public get active(): IBufferApi { + if (this._core.buffers.active === this._core.buffers.normal) { return this.normal; } + if (this._core.buffers.active === this._core.buffers.alt) { return this.alternate; } + throw new Error('Active buffer is neither normal nor alternate'); + } + public get normal(): IBufferApi { + return this._normal.init(this._core.buffers.normal); + } + public get alternate(): IBufferApi { + return this._alternate.init(this._core.buffers.alt); + } +} diff --git a/src/common/public/ParserApi.ts b/src/common/public/ParserApi.ts new file mode 100644 index 00000000..350d2864 --- /dev/null +++ b/src/common/public/ParserApi.ts @@ -0,0 +1,32 @@ +import { IParams } from 'common/parser/Types'; +import { ITerminal } from 'browser/Types'; +import { IDisposable, IFunctionIdentifier, IParser } from 'xterm'; + +export class ParserApi implements IParser { + constructor(private _core: ITerminal) { } + + public registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable { + return this._core.addCsiHandler(id, (params: IParams) => callback(params.toArray())); + } + public addCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable { + return this.registerCsiHandler(id, callback); + } + public registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable { + return this._core.addDcsHandler(id, (data: string, params: IParams) => callback(data, params.toArray())); + } + public addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable { + return this.registerDcsHandler(id, callback); + } + public registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable { + return this._core.addEscHandler(id, handler); + } + public addEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable { + return this.registerEscHandler(id, handler); + } + public registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { + return this._core.addOscHandler(ident, callback); + } + public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { + return this.registerOscHandler(ident, callback); + } +} diff --git a/src/common/public/UnicodeApi.ts b/src/common/public/UnicodeApi.ts new file mode 100644 index 00000000..1bfd7a92 --- /dev/null +++ b/src/common/public/UnicodeApi.ts @@ -0,0 +1,22 @@ +import { ITerminal } from 'browser/Types'; +import { IUnicodeHandling, IUnicodeVersionProvider } from 'xterm'; + +export class UnicodeApi implements IUnicodeHandling { + constructor(private _core: ITerminal) { } + + public register(provider: IUnicodeVersionProvider): void { + this._core.unicodeService.register(provider); + } + + public get versions(): string[] { + return this._core.unicodeService.versions; + } + + public get activeVersion(): string { + return this._core.unicodeService.activeVersion; + } + + public set activeVersion(version: string) { + this._core.unicodeService.activeVersion = version; + } +} From 8b2b0f6abc44a53f7434620bba1103df69e37d27 Mon Sep 17 00:00:00 2001 From: Jakob Schrettenbrunner Date: Tue, 12 Jan 2021 22:32:20 +0000 Subject: [PATCH 055/377] add richer ScrollEvent that includes the source --- src/browser/Terminal.ts | 12 ++++++------ src/common/CoreTerminal.ts | 32 +++++++++++++++++++++++--------- src/common/Types.d.ts | 10 ++++++++++ 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index f8b8b3e4..b507a6b1 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -39,7 +39,7 @@ import { MouseZoneManager } from 'browser/MouseZoneManager'; import { AccessibilityManager } from './AccessibilityManager'; import { ITheme, IMarker, IDisposable, ISelectionPosition, ILinkProvider } from 'xterm'; import { DomRenderer } from 'browser/renderer/dom/DomRenderer'; -import { IKeyboardEvent, KeyboardResultType, CoreMouseEventType, CoreMouseButton, CoreMouseAction, ITerminalOptions } from 'common/Types'; +import { IKeyboardEvent, KeyboardResultType, CoreMouseEventType, CoreMouseButton, CoreMouseAction, ITerminalOptions, ScrollSource } from 'common/Types'; import { evaluateKeyboardEvent } from 'common/input/Keyboard'; import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter'; import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; @@ -448,7 +448,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this._instantiationService.setService(IMouseService, this._mouseService); this.viewport = this._instantiationService.createInstance(Viewport, - (amount: number, suppressEvent: boolean) => this.scrollLines(amount, suppressEvent), + (amount: number, suppressEvent: boolean) => this.scrollLines(amount, suppressEvent, ScrollSource.VIEWPORT), this._viewportElement, this._viewportScrollArea ); @@ -481,7 +481,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this.textarea!.select(); })); this.register(this.onScroll(() => { - this.viewport!.syncScrollArea(); + this.viewport!.syncScrollArea(); this._selectionService!.refresh(); })); this.register(addDisposableDomListener(this._viewportElement, 'scroll', () => this._selectionService!.refresh())); @@ -836,8 +836,8 @@ export class Terminal extends CoreTerminal implements ITerminal { } } - public scrollLines(disp: number, suppressScrollEvent?: boolean): void { - super.scrollLines(disp, suppressScrollEvent); + public scrollLines(disp: number, suppressScrollEvent?: boolean, source = ScrollSource.TERMINAL): void { + super.scrollLines(disp, suppressScrollEvent, source); this.refresh(0, this.rows - 1); } @@ -1168,7 +1168,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this.buffer.lines.push(this.buffer.getBlankLine(DEFAULT_ATTR_DATA)); } this.refresh(0, this.rows - 1); - this._onScroll.fire(this.buffer.ydisp); + this._onScroll.fire({position: this.buffer.ydisp, source: ScrollSource.TERMINAL }); } /** diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 2f636349..86492ab3 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -27,7 +27,7 @@ import { InstantiationService } from 'common/services/InstantiationService'; import { LogService } from 'common/services/LogService'; import { BufferService, MINIMUM_COLS, MINIMUM_ROWS } from 'common/services/BufferService'; import { OptionsService } from 'common/services/OptionsService'; -import { ITerminalOptions, IDisposable, IBufferLine, IAttributeData, ICoreTerminal } from 'common/Types'; +import { ITerminalOptions, IDisposable, IBufferLine, IAttributeData, ICoreTerminal, IKeyboardEvent, IScrollEvent, ScrollSource } from 'common/Types'; import { CoreService } from 'common/services/CoreService'; import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter'; import { CoreMouseService } from 'common/services/CoreMouseService'; @@ -66,8 +66,12 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { public get onLineFeed(): IEvent { return this._onLineFeed.event; } private _onResize = new EventEmitter<{ cols: number, rows: number }>(); public get onResize(): IEvent<{ cols: number, rows: number }> { return this._onResize.event; } - protected _onScroll = new EventEmitter(); - public get onScroll(): IEvent { return this._onScroll.event; } + protected _onScroll = new EventEmitter(); + /** + * An emitter for legacy on scroll events that just included the position, and not the source. + * Used to maintain API consistency for the onScroll method. + */ + protected _legacyOnScroll?: EventEmitter; public get cols(): number { return this._bufferService.cols; } public get rows(): number { return this._bufferService.rows; } @@ -204,17 +208,17 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { // Flag rows that need updating this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); - this._onScroll.fire(buffer.ydisp); + this._onScroll.fire({position: buffer.ydisp, source: ScrollSource.TERMINAL}); } /** * Scroll the display of the terminal * @param disp The number of lines to scroll down (negative scroll up). - * @param suppressScrollEvent Don't emit the scroll event as scrollLines. This is used - * to avoid unwanted events being handled by the viewport when the event was triggered from the - * viewport originally. + * @param suppressScrollEvent Don't emit an onScroll event. + * @param source The source of the scroll action. Emitted as part of the onScroll event + * to avoid cyclic invocations if the event originated from the Viewport. */ - public scrollLines(disp: number, suppressScrollEvent?: boolean): void { + public scrollLines(disp: number, suppressScrollEvent = false, source = ScrollSource.TERMINAL): void { const buffer = this._bufferService.buffer; if (disp < 0) { if (buffer.ydisp === 0) { @@ -234,7 +238,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { } if (!suppressScrollEvent) { - this._onScroll.fire(buffer.ydisp); + this._onScroll.fire({position: buffer.ydisp, source}); } } @@ -267,6 +271,16 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { } } + public get onScroll(): IEvent { + if (!this._legacyOnScroll) { + this._legacyOnScroll = new EventEmitter(); + this.register(this._onScroll.event(ev => { + this._legacyOnScroll?.fire(ev.position); + })); + } + return this._legacyOnScroll.event; + } + /** Add handler for ESC escape sequence. See xterm.d.ts for details. */ public addEscHandler(id: IFunctionIdentifier, callback: () => boolean): IDisposable { return this._inputHandler.addEscHandler(id, callback); diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index bd0d11c6..4fff64f5 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -42,6 +42,16 @@ export interface IKeyboardEvent { type: string; } +export interface IScrollEvent { + position: number; + source: ScrollSource; +} + +export const enum ScrollSource { + TERMINAL, + VIEWPORT, +} + export interface ICircularList { length: number; maxLength: number; From 82a9ee62d77d04cb26db3282900b3c7a83ea1d28 Mon Sep 17 00:00:00 2001 From: Jakob Schrettenbrunner Date: Tue, 12 Jan 2021 22:35:47 +0000 Subject: [PATCH 056/377] emit onScroll event when user is scrolling --- src/browser/Terminal.ts | 6 ++++-- src/browser/Viewport.ts | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index b507a6b1..2a43405f 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -448,7 +448,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this._instantiationService.setService(IMouseService, this._mouseService); this.viewport = this._instantiationService.createInstance(Viewport, - (amount: number, suppressEvent: boolean) => this.scrollLines(amount, suppressEvent, ScrollSource.VIEWPORT), + (amount: number) => this.scrollLines(amount, false, ScrollSource.VIEWPORT), this._viewportElement, this._viewportScrollArea ); @@ -480,8 +480,10 @@ export class Terminal extends CoreTerminal implements ITerminal { this.textarea!.focus(); this.textarea!.select(); })); - this.register(this.onScroll(() => { + this.register(this._onScroll.event(ev => { + if (ev.source !== ScrollSource.VIEWPORT) { this.viewport!.syncScrollArea(); + } this._selectionService!.refresh(); })); this.register(addDisposableDomListener(this._viewportElement, 'scroll', () => this._selectionService!.refresh())); diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index 29edce6f..02f74ce8 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -33,7 +33,7 @@ export class Viewport extends Disposable implements IViewport { private _ignoreNextScrollEvent: boolean = false; constructor( - private readonly _scrollLines: (amount: number, suppressEvent: boolean) => void, + private readonly _scrollLines: (amount: number) => void, private readonly _viewportElement: HTMLElement, private readonly _scrollArea: HTMLElement, @IBufferService private readonly _bufferService: IBufferService, @@ -156,7 +156,7 @@ export class Viewport extends Disposable implements IViewport { const newRow = Math.round(this._lastScrollTop / this._currentRowHeight); const diff = newRow - this._bufferService.buffer.ydisp; - this._scrollLines(diff, true); + this._scrollLines(diff); } /** From 0cb38cfdcbe67eb99625b3f78205ccd2ea4b49d5 Mon Sep 17 00:00:00 2001 From: Martin Sander Date: Thu, 14 Jan 2021 23:08:34 +0100 Subject: [PATCH 057/377] fire onSelectionChange on empty selection Fire the onSelectionChange event when a selection is cleared by single-clicking somewhere inside the terminal area. fixes #3193. This also slightly changes the behaviour when re-selecting the same area in the terminal. Before, this fired onSelectionChange, but it does not anymore, even when changing the direction of the selection. --- src/browser/services/SelectionService.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/browser/services/SelectionService.ts b/src/browser/services/SelectionService.ts index a3d8d12c..9e7d6531 100644 --- a/src/browser/services/SelectionService.ts +++ b/src/browser/services/SelectionService.ts @@ -105,6 +105,9 @@ export class SelectionService extends Disposable implements ISelectionService { private _workCell: CellData = new CellData(); private _mouseDownTimeStamp: number = 0; + private _oldHasSelection: boolean = false; + private _oldSelectionStart: [number, number] | undefined = undefined; + private _oldSelectionEnd: [number, number] | undefined = undefined; private _onLinuxMouseSelection = this.register(new EventEmitter()); public get onLinuxMouseSelection(): IEvent { return this._onLinuxMouseSelection.event; } @@ -681,7 +684,26 @@ export class SelectionService extends Disposable implements ISelectionService { this._coreService.triggerDataEvent(sequence, true); } } - } else if (this.hasSelection) { + } else { + this._fireIfSelectionChanged(); + } + } + + private _fireIfSelectionChanged(): void { + const hasSelection = this.hasSelection; + if (!hasSelection && !this._oldHasSelection) { + return; + } + + const start = this._model.finalSelectionStart; + const end = this._model.finalSelectionEnd; + + if (start?.[0] !== this._oldSelectionStart?.[0] || start?.[1] !== this._oldSelectionStart?.[1] || + end?.[0] !== this._oldSelectionEnd?.[0] || end?.[1] !== this._oldSelectionEnd?.[1]) { + + this._oldSelectionStart = start; + this._oldSelectionEnd = end; + this._oldHasSelection = hasSelection; this._onSelectionChange.fire(); } } From 66c80d8b788dae552df63f3df7a32e198767ae8e Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 15 Jan 2021 09:39:34 -0800 Subject: [PATCH 058/377] Simplify checks Co-authored-by: Megan Rogge --- src/browser/services/SelectionService.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/browser/services/SelectionService.ts b/src/browser/services/SelectionService.ts index 9e7d6531..f4c8f58c 100644 --- a/src/browser/services/SelectionService.ts +++ b/src/browser/services/SelectionService.ts @@ -690,16 +690,26 @@ export class SelectionService extends Disposable implements ISelectionService { } private _fireIfSelectionChanged(): void { + // Fire if there is no selection const hasSelection = this.hasSelection; - if (!hasSelection && !this._oldHasSelection) { + if (!hasSelection) { + if (this._oldHasSelection) { + this._onSelectionChange.fire(); + } return; } const start = this._model.finalSelectionStart; const end = this._model.finalSelectionEnd; - if (start?.[0] !== this._oldSelectionStart?.[0] || start?.[1] !== this._oldSelectionStart?.[1] || - end?.[0] !== this._oldSelectionEnd?.[0] || end?.[1] !== this._oldSelectionEnd?.[1]) { + // Sanity check, these should not be undefined as there is a selection + if (!start || !end) { + return; + } + + if (!this._oldSelectionStart || !this._oldSelectionEnd || ( + start[0] !== this._oldSelectionStart[0] || start[1] !== this._oldSelectionStart[1] || + end[0] !== this._oldSelectionEnd[0] || end[1] !== this._oldSelectionEnd[1])) { this._oldSelectionStart = start; this._oldSelectionEnd = end; From c6f93701f542862f1534c57795146b62b004125f Mon Sep 17 00:00:00 2001 From: Martin Sander Date: Sat, 16 Jan 2021 10:06:55 +0100 Subject: [PATCH 059/377] fire onSelectionChange on right click select fixes #3216. --- src/browser/Clipboard.ts | 4 ++-- src/browser/services/SelectionService.ts | 11 +++++++++-- src/browser/services/Services.ts | 3 +-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/browser/Clipboard.ts b/src/browser/Clipboard.ts index b0b42022..29e865c8 100644 --- a/src/browser/Clipboard.ts +++ b/src/browser/Clipboard.ts @@ -89,8 +89,8 @@ export function moveTextAreaUnderMouseCursor(ev: MouseEvent, textarea: HTMLTextA export function rightClickHandler(ev: MouseEvent, textarea: HTMLTextAreaElement, screenElement: HTMLElement, selectionService: ISelectionService, shouldSelectWord: boolean): void { moveTextAreaUnderMouseCursor(ev, textarea, screenElement); - if (shouldSelectWord && !selectionService.isClickInSelection(ev)) { - selectionService.selectWordAtCursor(ev); + if (shouldSelectWord) { + selectionService.rightClickSelect(ev); } // Get textarea ready to copy from the context menu diff --git a/src/browser/services/SelectionService.ts b/src/browser/services/SelectionService.ts index f4c8f58c..7feaf9eb 100644 --- a/src/browser/services/SelectionService.ts +++ b/src/browser/services/SelectionService.ts @@ -293,7 +293,7 @@ export class SelectionService extends Disposable implements ISelectionService { * Checks if the current click was inside the current selection * @param event The mouse event */ - public isClickInSelection(event: MouseEvent): boolean { + private _isClickInSelection(event: MouseEvent): boolean { const coords = this._getMouseBufferCoords(event); const start = this._model.finalSelectionStart; const end = this._model.finalSelectionEnd; @@ -316,7 +316,7 @@ export class SelectionService extends Disposable implements ISelectionService { * Selects word at the current mouse event coordinates. * @param event The mouse event. */ - public selectWordAtCursor(event: MouseEvent): void { + private _selectWordAtCursor(event: MouseEvent): void { const coords = this._getMouseBufferCoords(event); if (coords) { this._selectWordAt(coords, false); @@ -759,6 +759,13 @@ export class SelectionService extends Disposable implements ISelectionService { this.refresh(); } + public rightClickSelect(ev: MouseEvent): void { + if (!this._isClickInSelection(ev)) { + this._selectWordAtCursor(ev); + this._fireIfSelectionChanged(); + } + } + /** * Gets positional information for the word at the coordinated specified. * @param coords The coordinates to get the word at. diff --git a/src/browser/services/Services.ts b/src/browser/services/Services.ts index 1c71d387..f06e320b 100644 --- a/src/browser/services/Services.ts +++ b/src/browser/services/Services.ts @@ -91,8 +91,7 @@ export interface ISelectionService { selectAll(): void; selectLines(start: number, end: number): void; clearSelection(): void; - isClickInSelection(event: MouseEvent): boolean; - selectWordAtCursor(event: MouseEvent): void; + rightClickSelect(event: MouseEvent): void; shouldColumnSelect(event: KeyboardEvent | MouseEvent): boolean; shouldForceSelection(event: MouseEvent): boolean; refresh(isLinuxMouseSelection?: boolean): void; From bc1048062dda8d64020309c425a5bb8094c37490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Wed, 20 Jan 2021 20:05:14 +0100 Subject: [PATCH 060/377] early version of async support for CSI and ESC handlers --- src/common/CoreTerminal.ts | 2 +- src/common/InputHandler.ts | 66 +++++++++++--- src/common/input/WriteBuffer.ts | 65 +++++++++++-- src/common/parser/EscapeSequenceParser.ts | 106 +++++++++++++++++++++- src/common/parser/Types.d.ts | 2 +- test/benchmark/Terminal.benchmark.ts | 36 ++++++-- 6 files changed, 245 insertions(+), 32 deletions(-) diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 2f636349..11e71bad 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -109,7 +109,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this.register(this.optionsService.onOptionChange(key => this._updateOptions(key))); // Setup WriteBuffer - this._writeBuffer = new WriteBuffer(data => this._inputHandler.parse(data)); + this._writeBuffer = new WriteBuffer((data, promiseResult) => this._inputHandler.parse(data, promiseResult)); } public dispose(): void { diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 626e1fe2..32428c77 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -333,7 +333,7 @@ export class InputHandler extends Disposable implements IInputHandler { this._parser.setCsiHandler({prefix: '?', final: 'h'}, params => this.setModePrivate(params)); this._parser.setCsiHandler({final: 'l'}, params => this.resetMode(params)); this._parser.setCsiHandler({prefix: '?', final: 'l'}, params => this.resetModePrivate(params)); - this._parser.setCsiHandler({final: 'm'}, params => this.charAttributes(params)); + this._parser.setCsiHandler({final: 'm'}, (params => this.charAttributes(params)) as (p: any) => void); this._parser.setCsiHandler({final: 'n'}, params => this.deviceStatus(params)); this._parser.setCsiHandler({prefix: '?', final: 'n'}, params => this.deviceStatusPrivate(params)); this._parser.setCsiHandler({intermediates: '!', final: 'p'}, params => this.softReset(params)); @@ -454,10 +454,43 @@ export class InputHandler extends Disposable implements IInputHandler { super.dispose(); } - public parse(data: string | Uint8Array): void { + // FIXME: cleanup async handling + private _parseStack = { + paused: false, + cursorStartX: 0, + cursorStartY: 0, + decodedLength: 0, + position: 0 + }; + + private _preserveStack(cursorStartX: number, cursorStartY: number, decodedLength: number, position: number): void { + this._parseStack.paused = true; + this._parseStack.cursorStartX = cursorStartX; + this._parseStack.cursorStartY = cursorStartY; + this._parseStack.decodedLength = decodedLength; + this._parseStack.position = position; + } + + public parse(data: string | Uint8Array, promiseResult?: boolean): void | Promise { + let result: void | Promise; let buffer = this._bufferService.buffer; - const cursorStartX = buffer.x; - const cursorStartY = buffer.y; + let cursorStartX = buffer.x; + let cursorStartY = buffer.y; + let start = 0; + const wasPaused = this._parseStack.paused; + + if (wasPaused) { + // assumption: _parseBuffer never mutates between async calls + if (result = this._parser.parse(this._parseBuffer, this._parseStack.decodedLength, promiseResult)) { + return result; + } + cursorStartX = this._parseStack.cursorStartX; + cursorStartY = this._parseStack.cursorStartY; + this._parseStack.paused = false; + if (data.length > MAX_PARSEBUFFER_LENGTH) { + start = this._parseStack.position + MAX_PARSEBUFFER_LENGTH; + } + } this._logService.debug('parsing data', data); @@ -469,22 +502,33 @@ export class InputHandler extends Disposable implements IInputHandler { } // Clear the dirty row service so we know which lines changed as a result of parsing - this._dirtyRowService.clearRange(); + // Important: do not clear between async calls, otherwise we lost pending update information. + if (!wasPaused) { + this._dirtyRowService.clearRange(); + } // process big data in smaller chunks if (data.length > MAX_PARSEBUFFER_LENGTH) { - for (let i = 0; i < data.length; i += MAX_PARSEBUFFER_LENGTH) { + for (let i = start; i < data.length; i += MAX_PARSEBUFFER_LENGTH) { const end = i + MAX_PARSEBUFFER_LENGTH < data.length ? i + MAX_PARSEBUFFER_LENGTH : data.length; const len = (typeof data === 'string') ? this._stringDecoder.decode(data.substring(i, end), this._parseBuffer) : this._utf8Decoder.decode(data.subarray(i, end), this._parseBuffer); - this._parser.parse(this._parseBuffer, len); + if (result = this._parser.parse(this._parseBuffer, len)) { + this._preserveStack(cursorStartX, cursorStartY, len, i); + return result; + } } } else { - const len = (typeof data === 'string') - ? this._stringDecoder.decode(data, this._parseBuffer) - : this._utf8Decoder.decode(data, this._parseBuffer); - this._parser.parse(this._parseBuffer, len); + if (!wasPaused) { + const len = (typeof data === 'string') + ? this._stringDecoder.decode(data, this._parseBuffer) + : this._utf8Decoder.decode(data, this._parseBuffer); + if (result = this._parser.parse(this._parseBuffer, len)) { + this._preserveStack(cursorStartX, cursorStartY, len, 0); + return result; + } + } } buffer = this._bufferService.buffer; diff --git a/src/common/input/WriteBuffer.ts b/src/common/input/WriteBuffer.ts index c7d82458..c6178024 100644 --- a/src/common/input/WriteBuffer.ts +++ b/src/common/input/WriteBuffer.ts @@ -37,8 +37,9 @@ export class WriteBuffer { private _pendingData = 0; private _bufferOffset = 0; - constructor(private _action: (data: string | Uint8Array) => void) { } + constructor(private _action: (data: string | Uint8Array, promiseResult?: boolean) => void | Promise) { } + // FIXME: does not work that way anymore with async handlers!!! public writeSync(data: string | Uint8Array): void { // force sync processing on pending data chunks to avoid in-band data scrambling // does the same as innerWrite but without event loop @@ -76,16 +77,64 @@ export class WriteBuffer { this._callbacks.push(callback); } - protected _innerWrite(): void { - const startTime = Date.now(); + protected _innerWrite(d: number = 0, promiseResult: boolean = true): void { + let result: void | Promise; + const startTime = d || Date.now(); while (this._writeBuffer.length > this._bufferOffset) { const data = this._writeBuffer[this._bufferOffset]; - const cb = this._callbacks[this._bufferOffset]; - this._bufferOffset++; - this._action(data); - this._pendingData -= data.length; + if (result = this._action(data, promiseResult)) { + /** + * If we get a promise as return value, we re-schedule the continuation + * as thenable on the promise and exit right away. + * + * The exit here means, that we block input processing at the current active chunk, + * the exact execution position within the chunk is preserved by the saved + * stack content in InputHandler and EscapeSequenceParser. + * + * Resuming happens automatically from that saved stack state. + * Also the resolved promise value is passed along the callstack to + * `EscapeSequenceParser.parse` to correctly resume the stopped handler loop. + * + * Exceptions on async handlers will be logged to console async, but do not interrupt + * the input processing (continues with next handler at the current input position). + * FIXME: No clear exception handling rules for sync handlers yet (will exit whole processing?). + */ + + /** + * If a promise takes long to resolve, we should schedule continuation behind setTimeout. + * This might already be too late, if our .then enters really late (executor + prev thens took very long). + * This cannot be solved here for the handler itself (it is the handlers responsibility to slice hard work), + * but we can at least schedule a screen update as we gain control. + */ + const continuation: (r: boolean) => void = (r: boolean) => Date.now() - startTime >= WRITE_TIMEOUT_MS + ? setTimeout(() => this._innerWrite(0, r)) + : this._innerWrite(startTime, r); + + /** + * Optimization considerations: + * The continuation above favors FPS over throughput by eval'ing `startTime` on resolve. + * This might schedule too many screen updates with bad throughput drops (in case a slow + * resolving handler sliced its work properly behind setTimeout calls). We cannot spot + * this condition here, also the renderer has no way to spot nonsense updates either. + * FIXME: A proper fix for this would track the FPS at the renderer entry level separately. + * + * If favoring of FPS shows bad throughtput impact, use the following instead. It favors + * throughput by eval'ing `startTime` upfront pulling at least one more chunk into the + * current microtask queue (executed before setTimeout). + */ + // const continuation: (r: boolean) => void = Date.now() - startTime >= WRITE_TIMEOUT_MS + // ? r => setTimeout(() => this._innerWrite(0, r)) + // : r => this._innerWrite(startTime, r); + + result.then(continuation, err => { setTimeout(() => { throw err; }); continuation(true); }); + return; + } + + const cb = this._callbacks[this._bufferOffset]; if (cb) cb(); + this._bufferOffset++; + this._pendingData -= data.length; if (Date.now() - startTime >= WRITE_TIMEOUT_MS) { break; @@ -99,7 +148,7 @@ export class WriteBuffer { this._callbacks = this._callbacks.slice(this._bufferOffset); this._bufferOffset = 0; } - setTimeout(() => this._innerWrite(), 0); + setTimeout(() => this._innerWrite()); } else { this._writeBuffer = []; this._callbacks = []; diff --git a/src/common/parser/EscapeSequenceParser.ts b/src/common/parser/EscapeSequenceParser.ts index 96d206b9..daf9e6eb 100644 --- a/src/common/parser/EscapeSequenceParser.ts +++ b/src/common/parser/EscapeSequenceParser.ts @@ -449,7 +449,45 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP this.precedingCodepoint = 0; } + // FIXME: cleanup async handling + private _parseStack: { + paused: boolean; + type: 'ESC' | 'CSI'; // FIXME: support for DCS and OSC + handlers: CsiHandlerType[] | EscHandlerType[]; + handlerPos: number; + transition: number; + currentState: ParserState; + collect: number; + pos: number; + } = { + paused: false, + type: 'ESC', + handlers: [], + handlerPos: 0, + transition: 0, + currentState: 0, + collect: 0, + pos: 0 + }; + private _preserveStack( + type: 'ESC' | 'CSI', + handlers: CsiHandlerType[] | EscHandlerType[], + handlerPos: number, + transition: number, + currentState: ParserState, + collect: number, + pos: number + ): void { + this._parseStack.paused = true; + this._parseStack.type = type; + this._parseStack.handlers = handlers; + this._parseStack.handlerPos = handlerPos; + this._parseStack.transition = transition; + this._parseStack.currentState = currentState; + this._parseStack.collect = collect; + this._parseStack.pos = pos; + } /** * Parse UTF32 codepoints in `data` up to `length`. @@ -465,7 +503,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP * - OSC_STRING:OSC_PUT * - DCS_PASSTHROUGH:DCS_PUT */ - public parse(data: Uint32Array, length: number): void { + public parse(data: Uint32Array, length: number, promiseResult?: boolean): void | Promise { let code = 0; let transition = 0; let currentState = this.currentState; @@ -475,8 +513,58 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP const params = this._params; const table: Uint8Array = this._transitions.table; + let res: any; + let start = 0; + if (this._parseStack.paused) { + const handlers = this._parseStack.handlers; + let handlerPos = this._parseStack.handlerPos - 1; + transition = this._parseStack.transition; + currentState = this._parseStack.currentState; + collect = this._parseStack.collect; + start = this._parseStack.pos; + + // we have to resume the old handler loop if: + // - return value of the promise was `false` + // - handlers are not exhausted yet + // FIXME: removing handlers from within a handler of the same sequence + // is not supported atm (also true for sync handlers)!! + if (promiseResult === false && handlerPos > -1) { + switch (this._parseStack.type) { + case 'CSI': + for (; handlerPos >= 0; handlerPos--) { + if ((res = (handlers as CsiHandlerType[])[handlerPos](params)) !== false) { + if (res instanceof Promise) { + this._parseStack.handlerPos = handlerPos; + return res; + } + break; + } + } + break; + case 'ESC': + for (; handlerPos >= 0; handlerPos--) { + if ((res = (handlers as EscHandlerType[])[handlerPos]()) !== false) { + if (res instanceof Promise) { + this._parseStack.handlerPos = handlerPos; + return res; + } + break; + } + } + break; + } + } + // cleanup before continuing with the main loop + this.precedingCodepoint = 0; + this._parseStack.paused = false; + start++; + currentState = transition & TableAccess.TRANSITION_STATE_MASK; + } + + // console.log('startPos', start, length); + // process input string - for (let i = 0; i < length; ++i) { + for (let i = start; i < length; ++i) { code = data[i]; // normal transition & action lookup @@ -534,7 +622,13 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP let j = handlers ? handlers.length - 1 : -1; for (; j >= 0; j--) { // undefined or true means success and to stop bubbling - if (handlers[j](params) !== false) { + // FIXME: remove setHandler interface, always use addHandler with proper return value in true|false + // background - result of undefined leads to nonsense instanceof Promise test below + if ((res = handlers[j](params)) !== false) { + if (res && res instanceof Promise) { + this._preserveStack('CSI', handlers, j, transition, currentState, collect, i); + return res; + } break; } } @@ -568,7 +662,11 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP let jj = handlersEsc ? handlersEsc.length - 1 : -1; for (; jj >= 0; jj--) { // undefined or true means success and to stop bubbling - if (handlersEsc[jj]() !== false) { + if ((res = handlersEsc[jj]()) !== false) { + if (res && res instanceof Promise) { + this._preserveStack('ESC', handlersEsc, jj, transition, currentState, collect, i); + return res; + } break; } } diff --git a/src/common/parser/Types.d.ts b/src/common/parser/Types.d.ts index e2fac89f..8d55c51a 100644 --- a/src/common/parser/Types.d.ts +++ b/src/common/parser/Types.d.ts @@ -160,7 +160,7 @@ export interface IEscapeSequenceParser extends IDisposable { * Parse UTF32 codepoints in `data` up to `length`. * @param data The data to parse. */ - parse(data: Uint32Array, length: number): void; + parse(data: Uint32Array, length: number, promiseResult?: boolean): void | Promise; /** * Get string from numercial function identifier `ident`. diff --git a/test/benchmark/Terminal.benchmark.ts b/test/benchmark/Terminal.benchmark.ts index 76139cb6..7d0f5d84 100644 --- a/test/benchmark/Terminal.benchmark.ts +++ b/test/benchmark/Terminal.benchmark.ts @@ -29,7 +29,7 @@ perfContext('Terminal: ls -lR /usr/lib', () => { chunks.push(data as unknown as Buffer); length += data.length; }); - await new Promise(resolve => p.on('exit', () => resolve())); + await new Promise(resolve => p.on('exit', () => resolve())); contentUtf8 = Buffer.concat(chunks, length); // translate to content string const buffer = new Uint32Array(contentUtf8.length); @@ -44,24 +44,46 @@ perfContext('Terminal: ls -lR /usr/lib', () => { } }); - perfContext('write', () => { + // perfContext('write/string/sync', () => { + // let terminal: Terminal; + // before(() => { + // terminal = new Terminal({cols: 80, rows: 25, scrollback: 1000}); + // }); + // new ThroughputRuntimeCase('', () => { + // terminal.writeSync(content); + // return {payloadSize: contentUtf8.length}; + // }, {fork: false}).showAverageThroughput(); + // }); + // + // perfContext('write/Utf8/sync', () => { + // let terminal: Terminal; + // before(() => { + // terminal = new Terminal({cols: 80, rows: 25, scrollback: 1000}); + // }); + // new ThroughputRuntimeCase('', () => { + // terminal.writeSync(content); + // return {payloadSize: contentUtf8.length}; + // }, {fork: false}).showAverageThroughput(); + // }); + + perfContext('write/string/async', () => { let terminal: Terminal; before(() => { terminal = new Terminal({cols: 80, rows: 25, scrollback: 1000}); }); - new ThroughputRuntimeCase('', () => { - terminal.writeSync(content); + new ThroughputRuntimeCase('', async () => { + await new Promise(res => terminal.write(content, res)); return {payloadSize: contentUtf8.length}; }, {fork: false}).showAverageThroughput(); }); - perfContext('writeUtf8', () => { + perfContext('write/Utf8/async', () => { let terminal: Terminal; before(() => { terminal = new Terminal({cols: 80, rows: 25, scrollback: 1000}); }); - new ThroughputRuntimeCase('', () => { - terminal.writeSync(content); + new ThroughputRuntimeCase('', async () => { + await new Promise(res => terminal.write(content, res)); return {payloadSize: contentUtf8.length}; }, {fork: false}).showAverageThroughput(); }); From c50c134e25b78693787366ae3c1af6461fae920c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Wed, 20 Jan 2021 23:03:55 +0100 Subject: [PATCH 061/377] simplify parser handler interface: - remove setHandler - apply boolean return to ESC|CSI|OSC|DCS handlers (rewrite empty return defaulting to true) - rename addHandler to registerHandler --- src/common/InputHandler.ts | 418 ++++++++++-------- src/common/parser/DcsParser.test.ts | 35 +- src/common/parser/DcsParser.ts | 12 +- .../parser/EscapeSequenceParser.test.ts | 197 +++++---- src/common/parser/EscapeSequenceParser.ts | 26 +- src/common/parser/OscParser.test.ts | 35 +- src/common/parser/OscParser.ts | 11 +- src/common/parser/Types.d.ts | 25 +- .../EscapeSequenceParser.benchmark.ts | 136 +++--- 9 files changed, 476 insertions(+), 419 deletions(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 626e1fe2..60c1e357 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -146,36 +146,42 @@ class DECRQSS implements IDcsHandler { this._data = concat(this._data, data.subarray(start, end)); } - public unhook(success: boolean): void { + public unhook(success: boolean): boolean { if (!success) { this._data = new Uint32Array(0); - return; + return true; } const data = utf32ToString(this._data); this._data = new Uint32Array(0); switch (data) { // valid: DCS 1 $ r Pt ST (xterm) case '"q': // DECSCA - return this._coreService.triggerDataEvent(`${C0.ESC}P1$r0"q${C0.ESC}\\`); + this._coreService.triggerDataEvent(`${C0.ESC}P1$r0"q${C0.ESC}\\`); + break; case '"p': // DECSCL - return this._coreService.triggerDataEvent(`${C0.ESC}P1$r61;1"p${C0.ESC}\\`); + this._coreService.triggerDataEvent(`${C0.ESC}P1$r61;1"p${C0.ESC}\\`); + break; case 'r': // DECSTBM const pt = '' + (this._bufferService.buffer.scrollTop + 1) + ';' + (this._bufferService.buffer.scrollBottom + 1) + 'r'; - return this._coreService.triggerDataEvent(`${C0.ESC}P1$r${pt}${C0.ESC}\\`); + this._coreService.triggerDataEvent(`${C0.ESC}P1$r${pt}${C0.ESC}\\`); + break; case 'm': // SGR // TODO: report real settings instead of 0m - return this._coreService.triggerDataEvent(`${C0.ESC}P1$r0m${C0.ESC}\\`); + this._coreService.triggerDataEvent(`${C0.ESC}P1$r0m${C0.ESC}\\`); + break; case ' q': // DECSCUSR const STYLES: {[key: string]: number} = {'block': 2, 'underline': 4, 'bar': 6}; let style = STYLES[this._optionsService.options.cursorStyle]; style -= this._optionsService.options.cursorBlink ? 1 : 0; - return this._coreService.triggerDataEvent(`${C0.ESC}P1$r${style} q${C0.ESC}\\`); + this._coreService.triggerDataEvent(`${C0.ESC}P1$r${style} q${C0.ESC}\\`); + break; default: // invalid: DCS 0 $ r Pt ST (xterm) this._logService.debug('Unknown DCS $q %s', data); this._coreService.triggerDataEvent(`${C0.ESC}P0$r${C0.ESC}\\`); } + return true; } } @@ -297,53 +303,53 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI handler */ - this._parser.setCsiHandler({final: '@'}, params => this.insertChars(params)); - this._parser.setCsiHandler({intermediates: ' ', final: '@'}, params => this.scrollLeft(params)); - this._parser.setCsiHandler({final: 'A'}, params => this.cursorUp(params)); - this._parser.setCsiHandler({intermediates: ' ', final: 'A'}, params => this.scrollRight(params)); - this._parser.setCsiHandler({final: 'B'}, params => this.cursorDown(params)); - this._parser.setCsiHandler({final: 'C'}, params => this.cursorForward(params)); - this._parser.setCsiHandler({final: 'D'}, params => this.cursorBackward(params)); - this._parser.setCsiHandler({final: 'E'}, params => this.cursorNextLine(params)); - this._parser.setCsiHandler({final: 'F'}, params => this.cursorPrecedingLine(params)); - this._parser.setCsiHandler({final: 'G'}, params => this.cursorCharAbsolute(params)); - this._parser.setCsiHandler({final: 'H'}, params => this.cursorPosition(params)); - this._parser.setCsiHandler({final: 'I'}, params => this.cursorForwardTab(params)); - this._parser.setCsiHandler({final: 'J'}, params => this.eraseInDisplay(params)); - this._parser.setCsiHandler({prefix: '?', final: 'J'}, params => this.eraseInDisplay(params)); - this._parser.setCsiHandler({final: 'K'}, params => this.eraseInLine(params)); - this._parser.setCsiHandler({prefix: '?', final: 'K'}, params => this.eraseInLine(params)); - this._parser.setCsiHandler({final: 'L'}, params => this.insertLines(params)); - this._parser.setCsiHandler({final: 'M'}, params => this.deleteLines(params)); - this._parser.setCsiHandler({final: 'P'}, params => this.deleteChars(params)); - this._parser.setCsiHandler({final: 'S'}, params => this.scrollUp(params)); - this._parser.setCsiHandler({final: 'T'}, params => this.scrollDown(params)); - this._parser.setCsiHandler({final: 'X'}, params => this.eraseChars(params)); - this._parser.setCsiHandler({final: 'Z'}, params => this.cursorBackwardTab(params)); - this._parser.setCsiHandler({final: '`'}, params => this.charPosAbsolute(params)); - this._parser.setCsiHandler({final: 'a'}, params => this.hPositionRelative(params)); - this._parser.setCsiHandler({final: 'b'}, params => this.repeatPrecedingCharacter(params)); - this._parser.setCsiHandler({final: 'c'}, params => this.sendDeviceAttributesPrimary(params)); - this._parser.setCsiHandler({prefix: '>', final: 'c'}, params => this.sendDeviceAttributesSecondary(params)); - this._parser.setCsiHandler({final: 'd'}, params => this.linePosAbsolute(params)); - this._parser.setCsiHandler({final: 'e'}, params => this.vPositionRelative(params)); - this._parser.setCsiHandler({final: 'f'}, params => this.hVPosition(params)); - this._parser.setCsiHandler({final: 'g'}, params => this.tabClear(params)); - this._parser.setCsiHandler({final: 'h'}, params => this.setMode(params)); - this._parser.setCsiHandler({prefix: '?', final: 'h'}, params => this.setModePrivate(params)); - this._parser.setCsiHandler({final: 'l'}, params => this.resetMode(params)); - this._parser.setCsiHandler({prefix: '?', final: 'l'}, params => this.resetModePrivate(params)); - this._parser.setCsiHandler({final: 'm'}, params => this.charAttributes(params)); - this._parser.setCsiHandler({final: 'n'}, params => this.deviceStatus(params)); - this._parser.setCsiHandler({prefix: '?', final: 'n'}, params => this.deviceStatusPrivate(params)); - this._parser.setCsiHandler({intermediates: '!', final: 'p'}, params => this.softReset(params)); - this._parser.setCsiHandler({intermediates: ' ', final: 'q'}, params => this.setCursorStyle(params)); - this._parser.setCsiHandler({final: 'r'}, params => this.setScrollRegion(params)); - this._parser.setCsiHandler({final: 's'}, params => this.saveCursor(params)); - this._parser.setCsiHandler({final: 't'}, params => this.windowOptions(params)); - this._parser.setCsiHandler({final: 'u'}, params => this.restoreCursor(params)); - this._parser.setCsiHandler({intermediates: '\'', final: '}'}, params => this.insertColumns(params)); - this._parser.setCsiHandler({intermediates: '\'', final: '~'}, params => this.deleteColumns(params)); + this._parser.registerCsiHandler({final: '@'}, params => this.insertChars(params)); + this._parser.registerCsiHandler({intermediates: ' ', final: '@'}, params => this.scrollLeft(params)); + this._parser.registerCsiHandler({final: 'A'}, params => this.cursorUp(params)); + this._parser.registerCsiHandler({intermediates: ' ', final: 'A'}, params => this.scrollRight(params)); + this._parser.registerCsiHandler({final: 'B'}, params => this.cursorDown(params)); + this._parser.registerCsiHandler({final: 'C'}, params => this.cursorForward(params)); + this._parser.registerCsiHandler({final: 'D'}, params => this.cursorBackward(params)); + this._parser.registerCsiHandler({final: 'E'}, params => this.cursorNextLine(params)); + this._parser.registerCsiHandler({final: 'F'}, params => this.cursorPrecedingLine(params)); + this._parser.registerCsiHandler({final: 'G'}, params => this.cursorCharAbsolute(params)); + this._parser.registerCsiHandler({final: 'H'}, params => this.cursorPosition(params)); + this._parser.registerCsiHandler({final: 'I'}, params => this.cursorForwardTab(params)); + this._parser.registerCsiHandler({final: 'J'}, params => this.eraseInDisplay(params)); + this._parser.registerCsiHandler({prefix: '?', final: 'J'}, params => this.eraseInDisplay(params)); + this._parser.registerCsiHandler({final: 'K'}, params => this.eraseInLine(params)); + this._parser.registerCsiHandler({prefix: '?', final: 'K'}, params => this.eraseInLine(params)); + this._parser.registerCsiHandler({final: 'L'}, params => this.insertLines(params)); + this._parser.registerCsiHandler({final: 'M'}, params => this.deleteLines(params)); + this._parser.registerCsiHandler({final: 'P'}, params => this.deleteChars(params)); + this._parser.registerCsiHandler({final: 'S'}, params => this.scrollUp(params)); + this._parser.registerCsiHandler({final: 'T'}, params => this.scrollDown(params)); + this._parser.registerCsiHandler({final: 'X'}, params => this.eraseChars(params)); + this._parser.registerCsiHandler({final: 'Z'}, params => this.cursorBackwardTab(params)); + this._parser.registerCsiHandler({final: '`'}, params => this.charPosAbsolute(params)); + this._parser.registerCsiHandler({final: 'a'}, params => this.hPositionRelative(params)); + this._parser.registerCsiHandler({final: 'b'}, params => this.repeatPrecedingCharacter(params)); + this._parser.registerCsiHandler({final: 'c'}, params => this.sendDeviceAttributesPrimary(params)); + this._parser.registerCsiHandler({prefix: '>', final: 'c'}, params => this.sendDeviceAttributesSecondary(params)); + this._parser.registerCsiHandler({final: 'd'}, params => this.linePosAbsolute(params)); + this._parser.registerCsiHandler({final: 'e'}, params => this.vPositionRelative(params)); + this._parser.registerCsiHandler({final: 'f'}, params => this.hVPosition(params)); + this._parser.registerCsiHandler({final: 'g'}, params => this.tabClear(params)); + this._parser.registerCsiHandler({final: 'h'}, params => this.setMode(params)); + this._parser.registerCsiHandler({prefix: '?', final: 'h'}, params => this.setModePrivate(params)); + this._parser.registerCsiHandler({final: 'l'}, params => this.resetMode(params)); + this._parser.registerCsiHandler({prefix: '?', final: 'l'}, params => this.resetModePrivate(params)); + this._parser.registerCsiHandler({final: 'm'}, params => this.charAttributes(params)); + this._parser.registerCsiHandler({final: 'n'}, params => this.deviceStatus(params)); + this._parser.registerCsiHandler({prefix: '?', final: 'n'}, params => this.deviceStatusPrivate(params)); + this._parser.registerCsiHandler({intermediates: '!', final: 'p'}, params => this.softReset(params)); + this._parser.registerCsiHandler({intermediates: ' ', final: 'q'}, params => this.setCursorStyle(params)); + this._parser.registerCsiHandler({final: 'r'}, params => this.setScrollRegion(params)); + this._parser.registerCsiHandler({final: 's'}, params => this.saveCursor(params)); + this._parser.registerCsiHandler({final: 't'}, params => this.windowOptions(params)); + this._parser.registerCsiHandler({final: 'u'}, params => this.restoreCursor(params)); + this._parser.registerCsiHandler({intermediates: '\'', final: '}'}, params => this.insertColumns(params)); + this._parser.registerCsiHandler({intermediates: '\'', final: '~'}, params => this.deleteColumns(params)); /** * execute handler @@ -367,14 +373,14 @@ export class InputHandler extends Disposable implements IInputHandler { * OSC handler */ // 0 - icon name + title - this._parser.setOscHandler(0, new OscHandler((data: string) => { this.setTitle(data); this.setIconName(data); })); + this._parser.registerOscHandler(0, new OscHandler(data => { this.setTitle(data); this.setIconName(data); return true; })); // 1 - icon name - this._parser.setOscHandler(1, new OscHandler((data: string) => this.setIconName(data))); + this._parser.registerOscHandler(1, new OscHandler(data => this.setIconName(data))); // 2 - title - this._parser.setOscHandler(2, new OscHandler((data: string) => this.setTitle(data))); + this._parser.registerOscHandler(2, new OscHandler(data => this.setTitle(data))); // 3 - set property X in the form "prop=value" // 4 - Change Color Number - this._parser.setOscHandler(4, new OscHandler((data: string) => this.setAnsiColor(data))); + this._parser.registerOscHandler(4, new OscHandler(data => this.setAnsiColor(data))); // 5 - Change Special Color Number // 6 - Enable/disable Special Color Number c // 7 - current directory? (not in xterm spec, see https://gitlab.com/gnachman/iterm2/issues/3939) @@ -409,32 +415,32 @@ export class InputHandler extends Disposable implements IInputHandler { /** * ESC handlers */ - this._parser.setEscHandler({final: '7'}, () => this.saveCursor()); - this._parser.setEscHandler({final: '8'}, () => this.restoreCursor()); - this._parser.setEscHandler({final: 'D'}, () => this.index()); - this._parser.setEscHandler({final: 'E'}, () => this.nextLine()); - this._parser.setEscHandler({final: 'H'}, () => this.tabSet()); - this._parser.setEscHandler({final: 'M'}, () => this.reverseIndex()); - this._parser.setEscHandler({final: '='}, () => this.keypadApplicationMode()); - this._parser.setEscHandler({final: '>'}, () => this.keypadNumericMode()); - this._parser.setEscHandler({final: 'c'}, () => this.fullReset()); - this._parser.setEscHandler({final: 'n'}, () => this.setgLevel(2)); - this._parser.setEscHandler({final: 'o'}, () => this.setgLevel(3)); - this._parser.setEscHandler({final: '|'}, () => this.setgLevel(3)); - this._parser.setEscHandler({final: '}'}, () => this.setgLevel(2)); - this._parser.setEscHandler({final: '~'}, () => this.setgLevel(1)); - this._parser.setEscHandler({intermediates: '%', final: '@'}, () => this.selectDefaultCharset()); - this._parser.setEscHandler({intermediates: '%', final: 'G'}, () => this.selectDefaultCharset()); + this._parser.registerEscHandler({final: '7'}, () => this.saveCursor()); + this._parser.registerEscHandler({final: '8'}, () => this.restoreCursor()); + this._parser.registerEscHandler({final: 'D'}, () => this.index()); + this._parser.registerEscHandler({final: 'E'}, () => this.nextLine()); + this._parser.registerEscHandler({final: 'H'}, () => this.tabSet()); + this._parser.registerEscHandler({final: 'M'}, () => this.reverseIndex()); + this._parser.registerEscHandler({final: '='}, () => this.keypadApplicationMode()); + this._parser.registerEscHandler({final: '>'}, () => this.keypadNumericMode()); + this._parser.registerEscHandler({final: 'c'}, () => this.fullReset()); + this._parser.registerEscHandler({final: 'n'}, () => this.setgLevel(2)); + this._parser.registerEscHandler({final: 'o'}, () => this.setgLevel(3)); + this._parser.registerEscHandler({final: '|'}, () => this.setgLevel(3)); + this._parser.registerEscHandler({final: '}'}, () => this.setgLevel(2)); + this._parser.registerEscHandler({final: '~'}, () => this.setgLevel(1)); + this._parser.registerEscHandler({intermediates: '%', final: '@'}, () => this.selectDefaultCharset()); + this._parser.registerEscHandler({intermediates: '%', final: 'G'}, () => this.selectDefaultCharset()); for (const flag in CHARSETS) { - this._parser.setEscHandler({intermediates: '(', final: flag}, () => this.selectCharset('(' + flag)); - this._parser.setEscHandler({intermediates: ')', final: flag}, () => this.selectCharset(')' + flag)); - this._parser.setEscHandler({intermediates: '*', final: flag}, () => this.selectCharset('*' + flag)); - this._parser.setEscHandler({intermediates: '+', final: flag}, () => this.selectCharset('+' + flag)); - this._parser.setEscHandler({intermediates: '-', final: flag}, () => this.selectCharset('-' + flag)); - this._parser.setEscHandler({intermediates: '.', final: flag}, () => this.selectCharset('.' + flag)); - this._parser.setEscHandler({intermediates: '/', final: flag}, () => this.selectCharset('/' + flag)); // TODO: supported? + this._parser.registerEscHandler({intermediates: '(', final: flag}, () => this.selectCharset('(' + flag)); + this._parser.registerEscHandler({intermediates: ')', final: flag}, () => this.selectCharset(')' + flag)); + this._parser.registerEscHandler({intermediates: '*', final: flag}, () => this.selectCharset('*' + flag)); + this._parser.registerEscHandler({intermediates: '+', final: flag}, () => this.selectCharset('+' + flag)); + this._parser.registerEscHandler({intermediates: '-', final: flag}, () => this.selectCharset('-' + flag)); + this._parser.registerEscHandler({intermediates: '.', final: flag}, () => this.selectCharset('.' + flag)); + this._parser.registerEscHandler({intermediates: '/', final: flag}, () => this.selectCharset('/' + flag)); // TODO: supported? } - this._parser.setEscHandler({intermediates: '#', final: '8'}, () => this.screenAlignmentPattern()); + this._parser.registerEscHandler({intermediates: '#', final: '8'}, () => this.screenAlignmentPattern()); /** * error handler @@ -447,7 +453,7 @@ export class InputHandler extends Disposable implements IInputHandler { /** * DCS handler */ - this._parser.setDcsHandler({intermediates: '$', final: 'q'}, new DECRQSS(this._bufferService, this._coreService, this._logService, this._optionsService)); + this._parser.registerDcsHandler({intermediates: '$', final: 'q'}, new DECRQSS(this._bufferService, this._coreService, this._logService, this._optionsService)); } public dispose(): void { @@ -642,35 +648,35 @@ export class InputHandler extends Disposable implements IInputHandler { public addCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean): IDisposable { if (id.final === 't' && !id.prefix && !id.intermediates) { // security: always check whether window option is allowed - return this._parser.addCsiHandler(id, params => { + return this._parser.registerCsiHandler(id, params => { if (!paramToWindowOption(params.params[0], this._optionsService.options.windowOptions)) { return true; } return callback(params); }); } - return this._parser.addCsiHandler(id, callback); + return this._parser.registerCsiHandler(id, callback); } /** * Forward addDcsHandler from parser. */ public addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean): IDisposable { - return this._parser.addDcsHandler(id, new DcsHandler(callback)); + return this._parser.registerDcsHandler(id, new DcsHandler(callback)); } /** * Forward addEscHandler from parser. */ public addEscHandler(id: IFunctionIdentifier, callback: () => boolean): IDisposable { - return this._parser.addEscHandler(id, callback); + return this._parser.registerEscHandler(id, callback); } /** * Forward addOscHandler from parser. */ public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { - return this._parser.addOscHandler(ident, new OscHandler(callback)); + return this._parser.registerOscHandler(ident, new OscHandler(callback)); } /** @@ -681,8 +687,9 @@ export class InputHandler extends Disposable implements IInputHandler { * The behavior of the bell is further customizable with `ITerminalOptions.bellStyle` * and `ITerminalOptions.bellSound`. */ - public bell(): void { + public bell(): boolean { this._onRequestBell.fire(); + return true; } /** @@ -695,7 +702,7 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y C0 VT "Vertical Tabulation" "\v, \x0B" "Treated as LF." * @vt: #Y C0 FF "Form Feed" "\f, \x0C" "Treated as LF." */ - public lineFeed(): void { + public lineFeed(): boolean { // make buffer local for faster access const buffer = this._bufferService.buffer; @@ -717,6 +724,7 @@ export class InputHandler extends Disposable implements IInputHandler { this._dirtyRowService.markDirty(buffer.y); this._onLineFeed.fire(); + return true; } /** @@ -725,8 +733,9 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #Y C0 CR "Carriage Return" "\r, \x0D" "Move the cursor to the beginning of the row." */ - public carriageReturn(): void { + public carriageReturn(): boolean { this._bufferService.buffer.x = 0; + return true; } /** @@ -740,7 +749,7 @@ export class InputHandler extends Disposable implements IInputHandler { * to the end of the previous row. Note that it is not possible to peek back into the scrollbuffer * with the cursor, thus at the home position (top-leftmost cell) this has no effect. */ - public backspace(): void { + public backspace(): boolean { const buffer = this._bufferService.buffer; // reverse wrap-around is disabled @@ -749,7 +758,7 @@ export class InputHandler extends Disposable implements IInputHandler { if (buffer.x > 0) { buffer.x--; } - return; + return true; } // reverse wrap-around is enabled @@ -790,6 +799,7 @@ export class InputHandler extends Disposable implements IInputHandler { } } this._restrictCursor(); + return true; } /** @@ -798,15 +808,16 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #Y C0 HT "Horizontal Tabulation" "\t, \x09" "Move the cursor to the next character tab stop." */ - public tab(): void { + public tab(): boolean { if (this._bufferService.buffer.x >= this._bufferService.cols) { - return; + return true; } const originalX = this._bufferService.buffer.x; this._bufferService.buffer.x = this._bufferService.buffer.nextStop(); if (this._optionsService.options.screenReaderMode) { this._onA11yTab.fire(this._bufferService.buffer.x - originalX); } + return true; } /** @@ -816,8 +827,9 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #P[Only limited ISO-2022 charset support.] C0 SO "Shift Out" "\x0E" "Switch to an alternative character set." */ - public shiftOut(): void { + public shiftOut(): boolean { this._charsetService.setgLevel(1); + return true; } /** @@ -827,8 +839,9 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #Y C0 SI "Shift In" "\x0F" "Return to regular character set after Shift Out." */ - public shiftIn(): void { + public shiftIn(): boolean { this._charsetService.setgLevel(0); + return true; } /** @@ -875,7 +888,7 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y CSI CUU "Cursor Up" "CSI Ps A" "Move cursor `Ps` times up (default=1)." * If the cursor would pass the top scroll margin, it will stop there. */ - public cursorUp(params: IParams): void { + public cursorUp(params: IParams): boolean { // stop at scrollTop const diffToTop = this._bufferService.buffer.y - this._bufferService.buffer.scrollTop; if (diffToTop >= 0) { @@ -883,6 +896,7 @@ export class InputHandler extends Disposable implements IInputHandler { } else { this._moveCursor(0, -(params.params[0] || 1)); } + return true; } /** @@ -892,7 +906,7 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y CSI CUD "Cursor Down" "CSI Ps B" "Move cursor `Ps` times down (default=1)." * If the cursor would pass the bottom scroll margin, it will stop there. */ - public cursorDown(params: IParams): void { + public cursorDown(params: IParams): boolean { // stop at scrollBottom const diffToBottom = this._bufferService.buffer.scrollBottom - this._bufferService.buffer.y; if (diffToBottom >= 0) { @@ -900,6 +914,7 @@ export class InputHandler extends Disposable implements IInputHandler { } else { this._moveCursor(0, params.params[0] || 1); } + return true; } /** @@ -908,8 +923,9 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #Y CSI CUF "Cursor Forward" "CSI Ps C" "Move cursor `Ps` times forward (default=1)." */ - public cursorForward(params: IParams): void { + public cursorForward(params: IParams): boolean { this._moveCursor(params.params[0] || 1, 0); + return true; } /** @@ -918,8 +934,9 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #Y CSI CUB "Cursor Backward" "CSI Ps D" "Move cursor `Ps` times backward (default=1)." */ - public cursorBackward(params: IParams): void { + public cursorBackward(params: IParams): boolean { this._moveCursor(-(params.params[0] || 1), 0); + return true; } /** @@ -930,9 +947,10 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y CSI CNL "Cursor Next Line" "CSI Ps E" "Move cursor `Ps` times down (default=1) and to the first column." * Same as CUD, additionally places the cursor at the first column. */ - public cursorNextLine(params: IParams): void { + public cursorNextLine(params: IParams): boolean { this.cursorDown(params); this._bufferService.buffer.x = 0; + return true; } /** @@ -943,9 +961,10 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y CSI CPL "Cursor Backward" "CSI Ps F" "Move cursor `Ps` times up (default=1) and to the first column." * Same as CUU, additionally places the cursor at the first column. */ - public cursorPrecedingLine(params: IParams): void { + public cursorPrecedingLine(params: IParams): boolean { this.cursorUp(params); this._bufferService.buffer.x = 0; + return true; } /** @@ -954,8 +973,9 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #Y CSI CHA "Cursor Horizontal Absolute" "CSI Ps G" "Move cursor to `Ps`-th column of the active row (default=1)." */ - public cursorCharAbsolute(params: IParams): void { + public cursorCharAbsolute(params: IParams): boolean { this._setCursor((params.params[0] || 1) - 1, this._bufferService.buffer.y); + return true; } /** @@ -967,12 +987,14 @@ export class InputHandler extends Disposable implements IInputHandler { * If ORIGIN mode is not set, places the cursor to the absolute position within the viewport. * Note that the coordinates are 1-based, thus the top left position starts at `1 ; 1`. */ - public cursorPosition(params: IParams): void { + public cursorPosition(params: IParams): boolean { this._setCursor( // col (params.length >= 2) ? (params.params[1] || 1) - 1 : 0, // row - (params.params[0] || 1) - 1); + (params.params[0] || 1) - 1 + ); + return true; } /** @@ -982,8 +1004,9 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #Y CSI HPA "Horizontal Position Absolute" "CSI Ps ` " "Same as CHA." */ - public charPosAbsolute(params: IParams): void { + public charPosAbsolute(params: IParams): boolean { this._setCursor((params.params[0] || 1) - 1, this._bufferService.buffer.y); + return true; } /** @@ -992,8 +1015,9 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #Y CSI HPR "Horizontal Position Relative" "CSI Ps a" "Same as CUF." */ - public hPositionRelative(params: IParams): void { + public hPositionRelative(params: IParams): boolean { this._moveCursor(params.params[0] || 1, 0); + return true; } /** @@ -1002,8 +1026,9 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #Y CSI VPA "Vertical Position Absolute" "CSI Ps d" "Move cursor to `Ps`-th row (default=1)." */ - public linePosAbsolute(params: IParams): void { + public linePosAbsolute(params: IParams): boolean { this._setCursor(this._bufferService.buffer.x, (params.params[0] || 1) - 1); + return true; } /** @@ -1013,8 +1038,9 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #Y CSI VPR "Vertical Position Relative" "CSI Ps e" "Move cursor `Ps` times down (default=1)." */ - public vPositionRelative(params: IParams): void { + public vPositionRelative(params: IParams): boolean { this._moveCursor(0, params.params[0] || 1); + return true; } /** @@ -1025,8 +1051,9 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #Y CSI HVP "Horizontal and Vertical Position" "CSI Ps ; Ps f" "Same as CUP." */ - public hVPosition(params: IParams): void { + public hVPosition(params: IParams): boolean { this.cursorPosition(params); + return true; } /** @@ -1040,13 +1067,14 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y CSI TBC "Tab Clear" "CSI Ps g" "Clear tab stops at current position (0) or all (3) (default=0)." * Clearing tabstops off the active row (Ps = 2, VT100) is currently not supported. */ - public tabClear(params: IParams): void { + public tabClear(params: IParams): boolean { const param = params.params[0]; if (param === 0) { delete this._bufferService.buffer.tabs[this._bufferService.buffer.x]; } else if (param === 3) { this._bufferService.buffer.tabs = {}; } + return true; } /** @@ -1055,14 +1083,15 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #Y CSI CHT "Cursor Horizontal Tabulation" "CSI Ps I" "Move cursor `Ps` times tabs forward (default=1)." */ - public cursorForwardTab(params: IParams): void { + public cursorForwardTab(params: IParams): boolean { if (this._bufferService.buffer.x >= this._bufferService.cols) { - return; + return true; } let param = params.params[0] || 1; while (param--) { this._bufferService.buffer.x = this._bufferService.buffer.nextStop(); } + return true; } /** @@ -1070,9 +1099,9 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #Y CSI CBT "Cursor Backward Tabulation" "CSI Ps Z" "Move cursor `Ps` tabs backward (default=1)." */ - public cursorBackwardTab(params: IParams): void { + public cursorBackwardTab(params: IParams): boolean { if (this._bufferService.buffer.x >= this._bufferService.cols) { - return; + return true; } let param = params.params[0] || 1; @@ -1082,6 +1111,7 @@ export class InputHandler extends Disposable implements IInputHandler { while (param--) { buffer.x = buffer.prevStop(); } + return true; } @@ -1140,7 +1170,7 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #P[Protection attributes are not supported.] CSI DECSED "Selective Erase In Display" "CSI ? Ps J" "Currently the same as ED." */ - public eraseInDisplay(params: IParams): void { + public eraseInDisplay(params: IParams): boolean { this._restrictCursor(); let j; switch (params.params[0]) { @@ -1187,6 +1217,7 @@ export class InputHandler extends Disposable implements IInputHandler { } break; } + return true; } /** @@ -1211,7 +1242,7 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #P[Protection attributes are not supported.] CSI DECSEL "Selective Erase In Line" "CSI ? Ps K" "Currently the same as EL." */ - public eraseInLine(params: IParams): void { + public eraseInLine(params: IParams): boolean { this._restrictCursor(); switch (params.params[0]) { case 0: @@ -1225,6 +1256,7 @@ export class InputHandler extends Disposable implements IInputHandler { break; } this._dirtyRowService.markDirty(this._bufferService.buffer.y); + return true; } /** @@ -1236,7 +1268,7 @@ export class InputHandler extends Disposable implements IInputHandler { * The cursor is set to the first column. * IL has no effect if the cursor is outside the scroll margins. */ - public insertLines(params: IParams): void { + public insertLines(params: IParams): boolean { this._restrictCursor(); let param = params.params[0] || 1; @@ -1244,7 +1276,7 @@ export class InputHandler extends Disposable implements IInputHandler { const buffer = this._bufferService.buffer; if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) { - return; + return true; } const row: number = buffer.ybase + buffer.y; @@ -1260,6 +1292,7 @@ export class InputHandler extends Disposable implements IInputHandler { this._dirtyRowService.markRangeDirty(buffer.y, buffer.scrollBottom); buffer.x = 0; // see https://vt100.net/docs/vt220-rm/chapter4.html - vt220 only? + return true; } /** @@ -1271,7 +1304,7 @@ export class InputHandler extends Disposable implements IInputHandler { * The cursor is set to the first column. * DL has no effect if the cursor is outside the scroll margins. */ - public deleteLines(params: IParams): void { + public deleteLines(params: IParams): boolean { this._restrictCursor(); let param = params.params[0] || 1; @@ -1279,7 +1312,7 @@ export class InputHandler extends Disposable implements IInputHandler { const buffer = this._bufferService.buffer; if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) { - return; + return true; } const row: number = buffer.ybase + buffer.y; @@ -1296,6 +1329,7 @@ export class InputHandler extends Disposable implements IInputHandler { this._dirtyRowService.markRangeDirty(buffer.y, buffer.scrollBottom); buffer.x = 0; // see https://vt100.net/docs/vt220-rm/chapter4.html - vt220 only? + return true; } /** @@ -1309,7 +1343,7 @@ export class InputHandler extends Disposable implements IInputHandler { * * FIXME: check against xterm - should not work outside of scroll margins (see VT520 manual) */ - public insertChars(params: IParams): void { + public insertChars(params: IParams): boolean { this._restrictCursor(); const line = this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase + this._bufferService.buffer.y); if (line) { @@ -1321,6 +1355,7 @@ export class InputHandler extends Disposable implements IInputHandler { ); this._dirtyRowService.markDirty(this._bufferService.buffer.y); } + return true; } /** @@ -1334,7 +1369,7 @@ export class InputHandler extends Disposable implements IInputHandler { * * FIXME: check against xterm - should not work outside of scroll margins (see VT520 manual) */ - public deleteChars(params: IParams): void { + public deleteChars(params: IParams): boolean { this._restrictCursor(); const line = this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase + this._bufferService.buffer.y); if (line) { @@ -1346,6 +1381,7 @@ export class InputHandler extends Disposable implements IInputHandler { ); this._dirtyRowService.markDirty(this._bufferService.buffer.y); } + return true; } /** @@ -1356,7 +1392,7 @@ export class InputHandler extends Disposable implements IInputHandler { * * FIXME: scrolled out lines at top = 1 should add to scrollback (xterm) */ - public scrollUp(params: IParams): void { + public scrollUp(params: IParams): boolean { let param = params.params[0] || 1; // make buffer local for faster access @@ -1367,6 +1403,7 @@ export class InputHandler extends Disposable implements IInputHandler { buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 0, buffer.getBlankLine(this._eraseAttrData())); } this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + return true; } /** @@ -1374,7 +1411,7 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #Y CSI SD "Scroll Down" "CSI Ps T" "Scroll `Ps` lines down (default=1)." */ - public scrollDown(params: IParams): void { + public scrollDown(params: IParams): boolean { let param = params.params[0] || 1; // make buffer local for faster access @@ -1385,6 +1422,7 @@ export class InputHandler extends Disposable implements IInputHandler { buffer.lines.splice(buffer.ybase + buffer.scrollTop, 0, buffer.getBlankLine(DEFAULT_ATTR_DATA)); } this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + return true; } /** @@ -1405,10 +1443,10 @@ export class InputHandler extends Disposable implements IInputHandler { * SL moves the content of all lines within the scroll margins `Ps` times to the left. * SL has no effect outside of the scroll margins. */ - public scrollLeft(params: IParams): void { + public scrollLeft(params: IParams): boolean { const buffer = this._bufferService.buffer; if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) { - return; + return true; } const param = params.params[0] || 1; for (let y = buffer.scrollTop; y <= buffer.scrollBottom; ++y) { @@ -1417,6 +1455,7 @@ export class InputHandler extends Disposable implements IInputHandler { line.isWrapped = false; } this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + return true; } /** @@ -1438,10 +1477,10 @@ export class InputHandler extends Disposable implements IInputHandler { * Content at the right margin is lost. * SL has no effect outside of the scroll margins. */ - public scrollRight(params: IParams): void { + public scrollRight(params: IParams): boolean { const buffer = this._bufferService.buffer; if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) { - return; + return true; } const param = params.params[0] || 1; for (let y = buffer.scrollTop; y <= buffer.scrollBottom; ++y) { @@ -1450,6 +1489,7 @@ export class InputHandler extends Disposable implements IInputHandler { line.isWrapped = false; } this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + return true; } /** @@ -1461,10 +1501,10 @@ export class InputHandler extends Disposable implements IInputHandler { * moving content to the right. Content at the right margin is lost. * DECIC has no effect outside the scrolling margins. */ - public insertColumns(params: IParams): void { + public insertColumns(params: IParams): boolean { const buffer = this._bufferService.buffer; if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) { - return; + return true; } const param = params.params[0] || 1; for (let y = buffer.scrollTop; y <= buffer.scrollBottom; ++y) { @@ -1473,6 +1513,7 @@ export class InputHandler extends Disposable implements IInputHandler { line.isWrapped = false; } this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + return true; } /** @@ -1484,10 +1525,10 @@ export class InputHandler extends Disposable implements IInputHandler { * moving content to the left. Blank columns are added at the right margin. * DECDC has no effect outside the scrolling margins. */ - public deleteColumns(params: IParams): void { + public deleteColumns(params: IParams): boolean { const buffer = this._bufferService.buffer; if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) { - return; + return true; } const param = params.params[0] || 1; for (let y = buffer.scrollTop; y <= buffer.scrollBottom; ++y) { @@ -1496,6 +1537,7 @@ export class InputHandler extends Disposable implements IInputHandler { line.isWrapped = false; } this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + return true; } /** @@ -1506,7 +1548,7 @@ export class InputHandler extends Disposable implements IInputHandler { * ED erases `Ps` characters from current cursor position to the right. * ED works inside or outside the scrolling margins. */ - public eraseChars(params: IParams): void { + public eraseChars(params: IParams): boolean { this._restrictCursor(); const line = this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase + this._bufferService.buffer.y); if (line) { @@ -1518,6 +1560,7 @@ export class InputHandler extends Disposable implements IInputHandler { ); this._dirtyRowService.markDirty(this._bufferService.buffer.y); } + return true; } /** @@ -1547,9 +1590,9 @@ export class InputHandler extends Disposable implements IInputHandler { * REP has no effect if the sequence does not follow a printable ASCII character * (NOOP for any other sequence in between or NON ASCII characters). */ - public repeatPrecedingCharacter(params: IParams): void { + public repeatPrecedingCharacter(params: IParams): boolean { if (!this._parser.precedingCodepoint) { - return; + return true; } // call print to insert the chars and handle correct wrapping const length = params.params[0] || 1; @@ -1558,6 +1601,7 @@ export class InputHandler extends Disposable implements IInputHandler { data[i] = this._parser.precedingCodepoint; } this.print(data, 0, data.length); + return true; } /** @@ -1585,15 +1629,16 @@ export class InputHandler extends Disposable implements IInputHandler { * * TODO: fix and cleanup response */ - public sendDeviceAttributesPrimary(params: IParams): void { + public sendDeviceAttributesPrimary(params: IParams): boolean { if (params.params[0] > 0) { - return; + return true; } if (this._is('xterm') || this._is('rxvt-unicode') || this._is('screen')) { this._coreService.triggerDataEvent(C0.ESC + '[?1;2c'); } else if (this._is('linux')) { this._coreService.triggerDataEvent(C0.ESC + '[?6c'); } + return true; } /** @@ -1620,9 +1665,9 @@ export class InputHandler extends Disposable implements IInputHandler { * * TODO: fix and cleanup response */ - public sendDeviceAttributesSecondary(params: IParams): void { + public sendDeviceAttributesSecondary(params: IParams): boolean { if (params.params[0] > 0) { - return; + return true; } // xterm and urxvt // seem to spit this @@ -1638,6 +1683,7 @@ export class InputHandler extends Disposable implements IInputHandler { } else if (this._is('screen')) { this._coreService.triggerDataEvent(C0.ESC + '[>83;40003;0c'); } + return true; } /** @@ -1665,7 +1711,7 @@ export class InputHandler extends Disposable implements IInputHandler { * | 12 | Send/receive (SRM). Always off. | #N | * | 20 | Automatic Newline (LNM). Always off. | #N | */ - public setMode(params: IParams): void { + public setMode(params: IParams): boolean { for (let i = 0; i < params.length; i++) { switch (params.params[i]) { case 4: @@ -1676,6 +1722,7 @@ export class InputHandler extends Disposable implements IInputHandler { break; } } + return true; } /** @@ -1791,7 +1838,7 @@ export class InputHandler extends Disposable implements IInputHandler { * * FIXME: implement DECSCNM, 1049 should clear altbuffer */ - public setModePrivate(params: IParams): void { + public setModePrivate(params: IParams): boolean { for (let i = 0; i < params.length; i++) { switch (params.params[i]) { case 1: @@ -1884,6 +1931,7 @@ export class InputHandler extends Disposable implements IInputHandler { break; } } + return true; } @@ -1907,7 +1955,7 @@ export class InputHandler extends Disposable implements IInputHandler { * * FIXME: why is LNM commented out? */ - public resetMode(params: IParams): void { + public resetMode(params: IParams): boolean { for (let i = 0; i < params.length; i++) { switch (params.params[i]) { case 4: @@ -1918,6 +1966,7 @@ export class InputHandler extends Disposable implements IInputHandler { break; } } + return true; } /** @@ -2029,7 +2078,7 @@ export class InputHandler extends Disposable implements IInputHandler { * * FIXME: DECCOLM is currently broken (already fixed in window options PR) */ - public resetModePrivate(params: IParams): void { + public resetModePrivate(params: IParams): boolean { for (let i = 0; i < params.length; i++) { switch (params.params[i]) { case 1: @@ -2106,6 +2155,7 @@ export class InputHandler extends Disposable implements IInputHandler { break; } } + return true; } /** @@ -2298,12 +2348,12 @@ export class InputHandler extends Disposable implements IInputHandler { * FIXME: blinking is implemented in attrs, but not working in renderers? * FIXME: remove dead branch for p=100 */ - public charAttributes(params: IParams): void { + public charAttributes(params: IParams): boolean { // Optimize a single SGR0. if (params.length === 1 && params.params[0] === 0) { this._curAttrData.fg = DEFAULT_ATTR_DATA.fg; this._curAttrData.bg = DEFAULT_ATTR_DATA.bg; - return; + return true; } const l = params.length; @@ -2402,6 +2452,7 @@ export class InputHandler extends Disposable implements IInputHandler { this._logService.debug('Unknown SGR attribute: %d.', p); } } + return true; } /** @@ -2429,7 +2480,7 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #Y CSI DSR "Device Status Report" "CSI Ps n" "Request cursor position (CPR) with `Ps` = 6." */ - public deviceStatus(params: IParams): void { + public deviceStatus(params: IParams): boolean { switch (params.params[0]) { case 5: // status report @@ -2442,10 +2493,11 @@ export class InputHandler extends Disposable implements IInputHandler { this._coreService.triggerDataEvent(`${C0.ESC}[${y};${x}R`); break; } + return true; } // @vt: #P[Only CPR is supported.] CSI DECDSR "DEC Device Status Report" "CSI ? Ps n" "Only CPR is supported (same as DSR)." - public deviceStatusPrivate(params: IParams): void { + public deviceStatusPrivate(params: IParams): boolean { // modern xterm doesnt seem to // respond to any of these except ?6, 6, and 5 switch (params.params[0]) { @@ -2472,6 +2524,7 @@ export class InputHandler extends Disposable implements IInputHandler { // this.handler(C0.ESC + '[?50n'); break; } + return true; } /** @@ -2493,7 +2546,7 @@ export class InputHandler extends Disposable implements IInputHandler { * * FIXME: there are several more attributes missing (see VT520 manual) */ - public softReset(params: IParams): void { + public softReset(params: IParams): boolean { this._coreService.isCursorHidden = false; this._onRequestSyncScrollBar.fire(); this._bufferService.buffer.scrollTop = 0; @@ -2511,6 +2564,7 @@ export class InputHandler extends Disposable implements IInputHandler { // reset DECOM this._coreService.decPrivateModes.origin = false; + return true; } /** @@ -2532,7 +2586,7 @@ export class InputHandler extends Disposable implements IInputHandler { * - 5: steady bar * - 6: blink bar */ - public setCursorStyle(params: IParams): void { + public setCursorStyle(params: IParams): boolean { const param = params.params[0] || 1; switch (param) { case 1: @@ -2550,6 +2604,7 @@ export class InputHandler extends Disposable implements IInputHandler { } const isBlinking = param % 2 === 1; this._optionsService.options.cursorBlink = isBlinking; + return true; } /** @@ -2559,7 +2614,7 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #Y CSI DECSTBM "Set Top and Bottom Margin" "CSI Ps ; Ps r" "Set top and bottom margins of the viewport [top;bottom] (default = viewport size)." */ - public setScrollRegion(params: IParams): void { + public setScrollRegion(params: IParams): boolean { const top = params.params[0] || 1; let bottom: number; @@ -2572,6 +2627,7 @@ export class InputHandler extends Disposable implements IInputHandler { this._bufferService.buffer.scrollBottom = bottom - 1; this._setCursor(0, 0); } + return true; } /** @@ -2604,9 +2660,9 @@ export class InputHandler extends Disposable implements IInputHandler { * Ps = 23 ; 2 -> Restore xterm window title from stack. supported * Ps >= 24 not implemented */ - public windowOptions(params: IParams): void { + public windowOptions(params: IParams): boolean { if (!paramToWindowOption(params.params[0], this._optionsService.options.windowOptions)) { - return; + return true; } const second = (params.length > 1) ? params.params[1] : 0; switch (params.params[0]) { @@ -2650,6 +2706,7 @@ export class InputHandler extends Disposable implements IInputHandler { } break; } + return true; } @@ -2661,12 +2718,13 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #P[TODO...] CSI SCOSC "Save Cursor" "CSI s" "Save cursor position, charmap and text attributes." * @vt: #Y ESC SC "Save Cursor" "ESC 7" "Save cursor position, charmap and text attributes." */ - public saveCursor(params?: IParams): void { + public saveCursor(params?: IParams): boolean { this._bufferService.buffer.savedX = this._bufferService.buffer.x; this._bufferService.buffer.savedY = this._bufferService.buffer.ybase + this._bufferService.buffer.y; this._bufferService.buffer.savedCurAttrData.fg = this._curAttrData.fg; this._bufferService.buffer.savedCurAttrData.bg = this._curAttrData.bg; this._bufferService.buffer.savedCharset = this._charsetService.charset; + return true; } @@ -2678,7 +2736,7 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #P[TODO...] CSI SCORC "Restore Cursor" "CSI u" "Restore cursor position, charmap and text attributes." * @vt: #Y ESC RC "Restore Cursor" "ESC 8" "Restore cursor position, charmap and text attributes." */ - public restoreCursor(params?: IParams): void { + public restoreCursor(params?: IParams): boolean { this._bufferService.buffer.x = this._bufferService.buffer.savedX || 0; this._bufferService.buffer.y = Math.max(this._bufferService.buffer.savedY - this._bufferService.buffer.ybase, 0); this._curAttrData.fg = this._bufferService.buffer.savedCurAttrData.fg; @@ -2688,6 +2746,7 @@ export class InputHandler extends Disposable implements IInputHandler { this._charsetService.charset = this._bufferService.buffer.savedCharset; } this._restrictCursor(); + return true; } @@ -2701,17 +2760,19 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y OSC 2 "Set Windows Title" "OSC 2 ; Pt BEL" "Set window title." * xterm.js does not manipulate the title directly, instead exposes changes via the event `Terminal.onTitleChange`. */ - public setTitle(data: string): void { + public setTitle(data: string): boolean { this._windowTitle = data; this._onTitleChange.fire(data); + return true; } /** * OSC 1; ST * Note: Icon name is not exposed. */ - public setIconName(data: string): void { + public setIconName(data: string): boolean { this._iconName = data; + return true; } protected _parseAnsiColorChange(data: string): IAnsiColorChangeEvent | null { @@ -2743,7 +2804,7 @@ export class InputHandler extends Disposable implements IInputHandler { * `c` is the color index between 0 and 255. `spec` color format is 'rgb:hh/hh/hh' where `h` are hexadecimal digits. * There may be multipe c ; spec elements present in the same instruction, e.g. 1;rgb:10/20/30;2;rgb:a0/b0/c0. */ - public setAnsiColor(data: string): void { + public setAnsiColor(data: string): boolean { const event = this._parseAnsiColorChange(data); if (event) { this._onAnsiColorChange.fire(event); @@ -2751,6 +2812,7 @@ export class InputHandler extends Disposable implements IInputHandler { else { this._logService.warn(`Expected format ;rgb:// but got data: ${data}`); } + return true; } /** @@ -2762,9 +2824,10 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y C1 NEL "Next Line" "\x85" "Move the cursor to the beginning of the next row." * @vt: #Y ESC NEL "Next Line" "ESC E" "Move the cursor to the beginning of the next row." */ - public nextLine(): void { + public nextLine(): boolean { this._bufferService.buffer.x = 0; this.index(); + return true; } /** @@ -2772,10 +2835,11 @@ export class InputHandler extends Disposable implements IInputHandler { * DEC mnemonic: DECKPAM (https://vt100.net/docs/vt510-rm/DECKPAM.html) * Enables the numeric keypad to send application sequences to the host. */ - public keypadApplicationMode(): void { + public keypadApplicationMode(): boolean { this._logService.debug('Serial port requested application keypad.'); this._coreService.decPrivateModes.applicationKeypad = true; this._onRequestSyncScrollBar.fire(); + return true; } /** @@ -2783,10 +2847,11 @@ export class InputHandler extends Disposable implements IInputHandler { * DEC mnemonic: DECKPNM (https://vt100.net/docs/vt510-rm/DECKPNM.html) * Enables the keypad to send numeric characters to the host. */ - public keypadNumericMode(): void { + public keypadNumericMode(): boolean { this._logService.debug('Switching back to normal keypad.'); this._coreService.decPrivateModes.applicationKeypad = false; this._onRequestSyncScrollBar.fire(); + return true; } /** @@ -2795,9 +2860,10 @@ export class InputHandler extends Disposable implements IInputHandler { * Select default character set. UTF-8 is not supported (string are unicode anyways) * therefore ESC % G does the same. */ - public selectDefaultCharset(): void { + public selectDefaultCharset(): boolean { this._charsetService.setgLevel(0); this._charsetService.setgCharset(0, DEFAULT_CHARSET); // US (default) + return true; } /** @@ -2816,16 +2882,16 @@ export class InputHandler extends Disposable implements IInputHandler { * ESC / C * Designate G3 Character Set (VT300). C = A -> ISO Latin-1 Supplemental. - Supported? */ - public selectCharset(collectAndFlag: string): void { + public selectCharset(collectAndFlag: string): boolean { if (collectAndFlag.length !== 2) { this.selectDefaultCharset(); - return; + return true; } if (collectAndFlag[0] === '/') { - return; // TODO: Is this supported? + return true; // TODO: Is this supported? } this._charsetService.setgCharset(GLEVEL[collectAndFlag[0]], CHARSETS[collectAndFlag[1]] || DEFAULT_CHARSET); - return; + return true; } /** @@ -2837,7 +2903,7 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y C1 IND "Index" "\x84" "Move the cursor one line down scrolling if needed." * @vt: #Y ESC IND "Index" "ESC D" "Move the cursor one line down scrolling if needed." */ - public index(): void { + public index(): boolean { this._restrictCursor(); const buffer = this._bufferService.buffer; this._bufferService.buffer.y++; @@ -2848,6 +2914,7 @@ export class InputHandler extends Disposable implements IInputHandler { buffer.y = this._bufferService.rows - 1; } this._restrictCursor(); + return true; } /** @@ -2860,8 +2927,9 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y C1 HTS "Horizontal Tabulation Set" "\x88" "Places a tab stop at the current cursor position." * @vt: #Y ESC HTS "Horizontal Tabulation Set" "ESC H" "Places a tab stop at the current cursor position." */ - public tabSet(): void { + public tabSet(): boolean { this._bufferService.buffer.tabs[this._bufferService.buffer.x] = true; + return true; } /** @@ -2873,7 +2941,7 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #Y ESC IR "Reverse Index" "ESC M" "Move the cursor one line up scrolling if needed." */ - public reverseIndex(): void { + public reverseIndex(): boolean { this._restrictCursor(); const buffer = this._bufferService.buffer; if (buffer.y === buffer.scrollTop) { @@ -2888,6 +2956,7 @@ export class InputHandler extends Disposable implements IInputHandler { buffer.y--; this._restrictCursor(); // quickfix to not run out of bounds } + return true; } /** @@ -2895,9 +2964,10 @@ export class InputHandler extends Disposable implements IInputHandler { * DEC mnemonic: RIS (https://vt100.net/docs/vt510-rm/RIS.html) * Reset to initial state. */ - public fullReset(): void { + public fullReset(): boolean { this._parser.reset(); this._onRequestReset.fire(); + return true; } public reset(): void { @@ -2924,8 +2994,9 @@ export class InputHandler extends Disposable implements IInputHandler { * When you use a locking shift, the character set remains in GL or GR until * you use another locking shift. (partly supported) */ - public setgLevel(level: number): void { + public setgLevel(level: number): boolean { this._charsetService.setgLevel(level); + return true; } /** @@ -2936,7 +3007,7 @@ export class InputHandler extends Disposable implements IInputHandler { * * @vt: #Y ESC DECALN "Screen Alignment Pattern" "ESC # 8" "Fill viewport with a test pattern (E)." */ - public screenAlignmentPattern(): void { + public screenAlignmentPattern(): boolean { // prepare cell data const cell = new CellData(); cell.content = 1 << Content.WIDTH_SHIFT | 'E'.charCodeAt(0); @@ -2956,5 +3027,6 @@ export class InputHandler extends Disposable implements IInputHandler { } this._dirtyRowService.markAllDirty(); this._setCursor(0, 0); + return true; } } diff --git a/src/common/parser/DcsParser.test.ts b/src/common/parser/DcsParser.test.ts index dbabb4fa..cf174139 100644 --- a/src/common/parser/DcsParser.test.ts +++ b/src/common/parser/DcsParser.test.ts @@ -61,11 +61,12 @@ class TestHandler implements IDcsHandler { public put(data: Uint32Array, start: number, end: number): void { this.output.push([this.msg, 'PUT', utf32ToString(data, start, end)]); } - public unhook(success: boolean): void | boolean { + public unhook(success: boolean): boolean { this.output.push([this.msg, 'UNHOOK', success]); if (this.returnFalse) { return false; } + return true; } } @@ -84,7 +85,7 @@ describe('DcsParser', () => { }); describe('handler registration', () => { it('setDcsHandler', () => { - parser.setHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 'th')); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 'th')); parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); let data = toUtf32('Here comes'); parser.put(data, 0, data.length); @@ -100,7 +101,7 @@ describe('DcsParser', () => { ]); }); it('clearDcsHandler', () => { - parser.setHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 'th')); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 'th')); parser.clearHandler(identifier({intermediates: '+', final: 'p'})); parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); let data = toUtf32('Here comes'); @@ -117,8 +118,8 @@ describe('DcsParser', () => { ]); }); it('addDcsHandler', () => { - parser.setHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 'th1')); - parser.addHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 'th2')); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 'th1')); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 'th2')); parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); let data = toUtf32('Here comes'); parser.put(data, 0, data.length); @@ -137,8 +138,8 @@ describe('DcsParser', () => { ]); }); it('addDcsHandler with return false', () => { - parser.setHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 'th1')); - parser.addHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 'th2', true)); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 'th1')); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 'th2', true)); parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); let data = toUtf32('Here comes'); parser.put(data, 0, data.length); @@ -157,8 +158,8 @@ describe('DcsParser', () => { ]); }); it('dispose handlers', () => { - parser.setHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 'th1')); - const dispo = parser.addHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 'th2', true)); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 'th1')); + const dispo = parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 'th2', true)); dispo.dispose(); parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); let data = toUtf32('Here comes'); @@ -176,7 +177,7 @@ describe('DcsParser', () => { }); describe('DcsHandlerFactory', () => { it('should be called once on end(true)', () => { - parser.setHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler((data, params) => reports.push([params.toArray(), data]))); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler((data, params) => { reports.push([params.toArray(), data]); return true; })); parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); let data = toUtf32('Here comes'); parser.put(data, 0, data.length); @@ -186,7 +187,7 @@ describe('DcsParser', () => { assert.deepEqual(reports, [[[1, 2, 3], 'Here comes the mouse!']]); }); it('should not be called on end(false)', () => { - parser.setHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler((data, params) => reports.push([params.toArray(), data]))); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler((data, params) => { reports.push([params.toArray(), data]); return true; })); parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); let data = toUtf32('Here comes'); parser.put(data, 0, data.length); @@ -196,8 +197,8 @@ describe('DcsParser', () => { assert.deepEqual(reports, []); }); it('should be disposable', () => { - parser.setHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler((data, params) => reports.push(['one', params.toArray(), data]))); - const dispo = parser.addHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler((data, params) => reports.push(['two', params.toArray(), data]))); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler((data, params) => { reports.push(['one', params.toArray(), data]); return true; })); + const dispo = parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler((data, params) => { reports.push(['two', params.toArray(), data]); return true; })); parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); let data = toUtf32('Here comes'); parser.put(data, 0, data.length); @@ -215,8 +216,8 @@ describe('DcsParser', () => { assert.deepEqual(reports, [['two', [1, 2, 3], 'Here comes the mouse!'], ['one', [1, 2, 3], 'some other data']]); }); it('should respect return false', () => { - parser.setHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler((data, params) => reports.push(['one', params.toArray(), data]))); - parser.addHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler((data, params) => { reports.push(['two', params.toArray(), data]); return false; })); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler((data, params) => { reports.push(['one', params.toArray(), data]); return true; })); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler((data, params) => { reports.push(['two', params.toArray(), data]); return false; })); parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); let data = toUtf32('Here comes'); parser.put(data, 0, data.length); @@ -227,7 +228,7 @@ describe('DcsParser', () => { }); it('should work up to payload limit', function(): void { this.timeout(10000); - parser.setHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler((data, params) => reports.push([params.toArray(), data]))); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler((data, params) => { reports.push([params.toArray(), data]); return true; })); parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); const data = toUtf32('A'.repeat(1000)); for (let i = 0; i < PAYLOAD_LIMIT; i += 1000) { @@ -238,7 +239,7 @@ describe('DcsParser', () => { }); it('should abort for payload limit +1', function(): void { this.timeout(10000); - parser.setHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler((data, params) => reports.push([params.toArray(), data]))); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler((data, params) => { reports.push([params.toArray(), data]); return true; })); parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); let data = toUtf32('A'.repeat(1000)); for (let i = 0; i < PAYLOAD_LIMIT; i += 1000) { diff --git a/src/common/parser/DcsParser.ts b/src/common/parser/DcsParser.ts index a09fd68c..8b934942 100644 --- a/src/common/parser/DcsParser.ts +++ b/src/common/parser/DcsParser.ts @@ -22,7 +22,7 @@ export class DcsParser implements IDcsParser { this._handlerFb = () => {}; } - public addHandler(ident: number, handler: IDcsHandler): IDisposable { + public registerHandler(ident: number, handler: IDcsHandler): IDisposable { if (this._handlers[ident] === undefined) { this._handlers[ident] = []; } @@ -38,10 +38,6 @@ export class DcsParser implements IDcsParser { }; } - public setHandler(ident: number, handler: IDcsHandler): void { - this._handlers[ident] = [handler]; - } - public clearHandler(ident: number): void { if (this._handlers[ident]) delete this._handlers[ident]; } @@ -112,7 +108,7 @@ export class DcsHandler implements IDcsHandler { private _params: IParams | undefined; private _hitLimit: boolean = false; - constructor(private _handler: (data: string, params: IParams) => any) {} + constructor(private _handler: (data: string, params: IParams) => boolean) {} public hook(params: IParams): void { this._params = params.clone(); @@ -131,8 +127,8 @@ export class DcsHandler implements IDcsHandler { } } - public unhook(success: boolean): any { - let ret; + public unhook(success: boolean): boolean { + let ret = false; if (this._hitLimit) { ret = false; } else if (success) { diff --git a/src/common/parser/EscapeSequenceParser.test.ts b/src/common/parser/EscapeSequenceParser.test.ts index 4934d346..468dc934 100644 --- a/src/common/parser/EscapeSequenceParser.test.ts +++ b/src/common/parser/EscapeSequenceParser.test.ts @@ -41,7 +41,7 @@ class MockOscPutParser implements IOscParser { this._fallback(id, 'END', this.data.slice(this.data.indexOf(';') + 1)); } } - public addHandler(ident: number, handler: IOscHandler): IDisposable { + public registerHandler(ident: number, handler: IOscHandler): IDisposable { throw new Error('not implemented'); } public setHandler(ident: number, handler: IOscHandler): void { @@ -1206,11 +1206,13 @@ describe('EscapeSequenceParser', function (): void { chai.expect(print).equal(''); }); it('ESC handler', function (): void { - parser2.setEscHandler({intermediates: '%', final: 'G'}, function (): void { + parser2.registerEscHandler({intermediates: '%', final: 'G'}, function (): boolean { esc.push('%G'); + return true; }); - parser2.setEscHandler({final: 'E'}, function (): void { + parser2.registerEscHandler({final: 'E'}, function (): boolean { esc.push('E'); + return true; }); parse(parser2, INPUT); chai.expect(esc).eql(['%G', 'E']); @@ -1226,49 +1228,49 @@ describe('EscapeSequenceParser', function (): void { }); describe('ESC custom handlers', () => { it('prevent fallback', () => { - parser2.setEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); }); - parser2.addEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return true; }); + parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); return true; }); + parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return true; }); parse(parser2, INPUT); chai.expect(esc).eql(['custom - %G']); }); it('allow fallback', () => { - parser2.setEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); }); - parser2.addEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return false; }); + parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); return true; }); + parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return false; }); parse(parser2, INPUT); chai.expect(esc).eql(['custom - %G', 'default - %G']); }); it('Multiple custom handlers fallback once', () => { - parser2.setEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); }); - parser2.addEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return true; }); - parser2.addEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom2 - %G'); return false; }); + parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); return true; }); + parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return true; }); + parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom2 - %G'); return false; }); parse(parser2, INPUT); chai.expect(esc).eql(['custom2 - %G', 'custom - %G']); }); it('Multiple custom handlers no fallback', () => { - parser2.setEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); }); - parser2.addEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return true; }); - parser2.addEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom2 - %G'); return true; }); + parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); return true; }); + parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return true; }); + parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom2 - %G'); return true; }); parse(parser2, INPUT); chai.expect(esc).eql(['custom2 - %G']); }); it('Execution order should go from latest handler down to the original', () => { const order: number[] = []; - parser2.setEscHandler({intermediates: '%', final: 'G'}, () => { order.push(1); }); - parser2.addEscHandler({intermediates: '%', final: 'G'}, () => { order.push(2); return false; }); - parser2.addEscHandler({intermediates: '%', final: 'G'}, () => { order.push(3); return false; }); + parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { order.push(1); return true; }); + parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { order.push(2); return false; }); + parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { order.push(3); return false; }); parse(parser2, '\x1b%G'); chai.expect(order).eql([3, 2, 1]); }); it('Dispose should work', () => { - parser2.setEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); }); - const dispo = parser2.addEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return true; }); + parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); return true; }); + const dispo = parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return true; }); dispo.dispose(); parse(parser2, INPUT); chai.expect(esc).eql(['default - %G']); }); it('Should not corrupt the parser when dispose is called twice', () => { - parser2.setEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); }); - const dispo = parser2.addEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return true; }); + parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); return true; }); + const dispo = parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return true; }); dispo.dispose(); dispo.dispose(); parse(parser2, INPUT); @@ -1276,8 +1278,9 @@ describe('EscapeSequenceParser', function (): void { }); }); it('CSI handler', function (): void { - parser2.setCsiHandler({final: 'm'}, function (params: IParams): void { + parser2.registerCsiHandler({final: 'm'}, function (params: IParams): boolean { csi.push(['m', params.toArray(), '']); + return true; }); parse(parser2, INPUT); chai.expect(csi).eql([['m', [1, 31], ''], ['m', [0], '']]); @@ -1290,16 +1293,16 @@ describe('EscapeSequenceParser', function (): void { describe('CSI custom handlers', () => { it('Prevent fallback', () => { const csiCustom: [string, ParamsArray, string][] = []; - parser2.setCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); }); - parser2.addCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); parse(parser2, INPUT); chai.expect(csi).eql([], 'Should not fallback to original handler'); chai.expect(csiCustom).eql([['m', [1, 31], ''], ['m', [0], '']]); }); it('Allow fallback', () => { const csiCustom: [string, ParamsArray, string][] = []; - parser2.setCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); }); - parser2.addCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return false; }); + parser2.registerCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return false; }); parse(parser2, INPUT); chai.expect(csi).eql([['m', [1, 31], ''], ['m', [0], '']], 'Should fallback to original handler'); chai.expect(csiCustom).eql([['m', [1, 31], ''], ['m', [0], '']]); @@ -1307,9 +1310,9 @@ describe('EscapeSequenceParser', function (): void { it('Multiple custom handlers fallback once', () => { const csiCustom: [string, ParamsArray, string][] = []; const csiCustom2: [string, ParamsArray, string][] = []; - parser2.setCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); }); - parser2.addCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); - parser2.addCsiHandler({final: 'm'}, params => { csiCustom2.push(['m', params.toArray(), '']); return false; }); + parser2.registerCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({final: 'm'}, params => { csiCustom2.push(['m', params.toArray(), '']); return false; }); parse(parser2, INPUT); chai.expect(csi).eql([], 'Should not fallback to original handler'); chai.expect(csiCustom).eql([['m', [1, 31], ''], ['m', [0], '']]); @@ -1318,9 +1321,9 @@ describe('EscapeSequenceParser', function (): void { it('Multiple custom handlers no fallback', () => { const csiCustom: [string, ParamsArray, string][] = []; const csiCustom2: [string, ParamsArray, string][] = []; - parser2.setCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); }); - parser2.addCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); - parser2.addCsiHandler({final: 'm'}, params => { csiCustom2.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({final: 'm'}, params => { csiCustom2.push(['m', params.toArray(), '']); return true; }); parse(parser2, INPUT); chai.expect(csi).eql([], 'Should not fallback to original handler'); chai.expect(csiCustom).eql([], 'Should not fallback once'); @@ -1328,16 +1331,16 @@ describe('EscapeSequenceParser', function (): void { }); it('Execution order should go from latest handler down to the original', () => { const order: number[] = []; - parser2.setCsiHandler({final: 'm'}, () => { order.push(1); }); - parser2.addCsiHandler({final: 'm'}, () => { order.push(2); return false; }); - parser2.addCsiHandler({final: 'm'}, () => { order.push(3); return false; }); + parser2.registerCsiHandler({final: 'm'}, () => { order.push(1); return true; }); + parser2.registerCsiHandler({final: 'm'}, () => { order.push(2); return false; }); + parser2.registerCsiHandler({final: 'm'}, () => { order.push(3); return false; }); parse(parser2, '\x1b[0m'); chai.expect(order).eql([3, 2, 1]); }); it('Dispose should work', () => { const csiCustom: [string, ParamsArray, string][] = []; - parser2.setCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); }); - const customHandler = parser2.addCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); return true; }); + const customHandler = parser2.registerCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); customHandler.dispose(); parse(parser2, INPUT); chai.expect(csi).eql([['m', [1, 31], ''], ['m', [0], '']]); @@ -1345,8 +1348,8 @@ describe('EscapeSequenceParser', function (): void { }); it('Should not corrupt the parser when dispose is called twice', () => { const csiCustom: [string, ParamsArray, string][] = []; - parser2.setCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); }); - const customHandler = parser2.addCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); return true; }); + const customHandler = parser2.registerCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); customHandler.dispose(); customHandler.dispose(); parse(parser2, INPUT); @@ -1355,11 +1358,13 @@ describe('EscapeSequenceParser', function (): void { }); }); it('EXECUTE handler', function (): void { - parser2.setExecuteHandler('\n', function (): void { + parser2.setExecuteHandler('\n', function (): boolean { exe.push('\n'); + return true; }); - parser2.setExecuteHandler('\r', function (): void { + parser2.setExecuteHandler('\r', function (): boolean { exe.push('\r'); + return true; }); parse(parser2, INPUT); chai.expect(exe).eql(['\r', '\n']); @@ -1370,8 +1375,9 @@ describe('EscapeSequenceParser', function (): void { chai.expect(exe).eql(['\n']); }); it('OSC handler', function (): void { - parser2.setOscHandler(1, new OscHandler(function (data: string): void { + parser2.registerOscHandler(1, new OscHandler(function (data: string): boolean { osc.push([1, data]); + return true; })); parse(parser2, INPUT); chai.expect(osc).eql([[1, 'foo=bar']]); @@ -1384,16 +1390,16 @@ describe('EscapeSequenceParser', function (): void { describe('OSC custom handlers', () => { it('Prevent fallback', () => { const oscCustom: [number, string][] = []; - parser2.setOscHandler(1, new OscHandler(data => osc.push([1, data]))); - parser2.addOscHandler(1, new OscHandler(data => { oscCustom.push([1, data]); return true; })); + parser2.registerOscHandler(1, new OscHandler(data => { osc.push([1, data]); return true; })); + parser2.registerOscHandler(1, new OscHandler(data => { oscCustom.push([1, data]); return true; })); parse(parser2, INPUT); chai.expect(osc).eql([], 'Should not fallback to original handler'); chai.expect(oscCustom).eql([[1, 'foo=bar']]); }); it('Allow fallback', () => { const oscCustom: [number, string][] = []; - parser2.setOscHandler(1, new OscHandler(data => osc.push([1, data]))); - parser2.addOscHandler(1, new OscHandler(data => { oscCustom.push([1, data]); return false; })); + parser2.registerOscHandler(1, new OscHandler(data => { osc.push([1, data]); return true; })); + parser2.registerOscHandler(1, new OscHandler(data => { oscCustom.push([1, data]); return false; })); parse(parser2, INPUT); chai.expect(osc).eql([[1, 'foo=bar']], 'Should fallback to original handler'); chai.expect(oscCustom).eql([[1, 'foo=bar']]); @@ -1401,9 +1407,9 @@ describe('EscapeSequenceParser', function (): void { it('Multiple custom handlers fallback once', () => { const oscCustom: [number, string][] = []; const oscCustom2: [number, string][] = []; - parser2.setOscHandler(1, new OscHandler(data => osc.push([1, data]))); - parser2.addOscHandler(1, new OscHandler(data => { oscCustom.push([1, data]); return true; })); - parser2.addOscHandler(1, new OscHandler(data => { oscCustom2.push([1, data]); return false; })); + parser2.registerOscHandler(1, new OscHandler(data => { osc.push([1, data]); return true; })); + parser2.registerOscHandler(1, new OscHandler(data => { oscCustom.push([1, data]); return true; })); + parser2.registerOscHandler(1, new OscHandler(data => { oscCustom2.push([1, data]); return false; })); parse(parser2, INPUT); chai.expect(osc).eql([], 'Should not fallback to original handler'); chai.expect(oscCustom).eql([[1, 'foo=bar']]); @@ -1412,9 +1418,9 @@ describe('EscapeSequenceParser', function (): void { it('Multiple custom handlers no fallback', () => { const oscCustom: [number, string][] = []; const oscCustom2: [number, string][] = []; - parser2.setOscHandler(1, new OscHandler(data => osc.push([1, data]))); - parser2.addOscHandler(1, new OscHandler(data => { oscCustom.push([1, data]); return true; })); - parser2.addOscHandler(1, new OscHandler(data => { oscCustom2.push([1, data]); return true; })); + parser2.registerOscHandler(1, new OscHandler(data => { osc.push([1, data]); return true; })); + parser2.registerOscHandler(1, new OscHandler(data => { oscCustom.push([1, data]); return true; })); + parser2.registerOscHandler(1, new OscHandler(data => { oscCustom2.push([1, data]); return true; })); parse(parser2, INPUT); chai.expect(osc).eql([], 'Should not fallback to original handler'); chai.expect(oscCustom).eql([], 'Should not fallback once'); @@ -1422,16 +1428,16 @@ describe('EscapeSequenceParser', function (): void { }); it('Execution order should go from latest handler down to the original', () => { const order: number[] = []; - parser2.setOscHandler(1, new OscHandler(() => order.push(1))); - parser2.addOscHandler(1, new OscHandler(() => { order.push(2); return false; })); - parser2.addOscHandler(1, new OscHandler(() => { order.push(3); return false; })); + parser2.registerOscHandler(1, new OscHandler(() => { order.push(1); return true; })); + parser2.registerOscHandler(1, new OscHandler(() => { order.push(2); return false; })); + parser2.registerOscHandler(1, new OscHandler(() => { order.push(3); return false; })); parse(parser2, '\x1b]1;foo=bar\x1b\\'); chai.expect(order).eql([3, 2, 1]); }); it('Dispose should work', () => { const oscCustom: [number, string][] = []; - parser2.setOscHandler(1, new OscHandler(data => osc.push([1, data]))); - const customHandler = parser2.addOscHandler(1, new OscHandler(data => { oscCustom.push([1, data]); return true; })); + parser2.registerOscHandler(1, new OscHandler(data => { osc.push([1, data]); return true; })); + const customHandler = parser2.registerOscHandler(1, new OscHandler(data => { oscCustom.push([1, data]); return true; })); customHandler.dispose(); parse(parser2, INPUT); chai.expect(osc).eql([[1, 'foo=bar']]); @@ -1439,8 +1445,8 @@ describe('EscapeSequenceParser', function (): void { }); it('Should not corrupt the parser when dispose is called twice', () => { const oscCustom: [number, string][] = []; - parser2.setOscHandler(1, new OscHandler(data => osc.push([1, data]))); - const customHandler = parser2.addOscHandler(1, new OscHandler(data => { oscCustom.push([1, data]); return true; })); + parser2.registerOscHandler(1, new OscHandler(data => { osc.push([1, data]); return true; })); + const customHandler = parser2.registerOscHandler(1, new OscHandler(data => { oscCustom.push([1, data]); return true; })); customHandler.dispose(); customHandler.dispose(); parse(parser2, INPUT); @@ -1449,7 +1455,7 @@ describe('EscapeSequenceParser', function (): void { }); }); it('DCS handler', function (): void { - parser2.setDcsHandler({intermediates: '+', final: 'p'}, { + parser2.registerDcsHandler({intermediates: '+', final: 'p'}, { hook: function (params: IParams): void { dcs.push(['hook', '', params.toArray(), 0]); }, @@ -1460,8 +1466,9 @@ describe('EscapeSequenceParser', function (): void { } dcs.push(['put', s]); }, - unhook: function (): void { + unhook: function (): boolean { dcs.push(['unhook']); + return true; } }); parse(parser2, '\x1bP1;2;3+pabc'); @@ -1482,54 +1489,54 @@ describe('EscapeSequenceParser', function (): void { const DCS_INPUT = '\x1bP1;2;3+pabc\x1b\\'; it('Prevent fallback', () => { const dcsCustom: [string, (number | number[])[], string][] = []; - parser2.setDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => dcsCustom.push(['A', params.toArray(), data]))); - parser2.addDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); parse(parser2, DCS_INPUT); chai.expect(dcsCustom).eql([['B', [1, 2, 3], 'abc']]); }); it('Allow fallback', () => { const dcsCustom: [string, (number | number[])[], string][] = []; - parser2.setDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => dcsCustom.push(['A', params.toArray(), data]))); - parser2.addDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return false; })); + parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return false; })); parse(parser2, DCS_INPUT); chai.expect(dcsCustom).eql([['B', [1, 2, 3], 'abc'], ['A', [1, 2, 3], 'abc']]); }); it('Multiple custom handlers fallback once', () => { const dcsCustom: [string, (number | number[])[], string][] = []; - parser2.setDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => dcsCustom.push(['A', params.toArray(), data]))); - parser2.addDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); - parser2.addDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['C', params.toArray(), data]); return false; })); + parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['C', params.toArray(), data]); return false; })); parse(parser2, DCS_INPUT); chai.expect(dcsCustom).eql([['C', [1, 2, 3], 'abc'], ['B', [1, 2, 3], 'abc']]); }); it('Multiple custom handlers no fallback', () => { const dcsCustom: [string, (number | number[])[], string][] = []; - parser2.setDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => dcsCustom.push(['A', params.toArray(), data]))); - parser2.addDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); - parser2.addDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['C', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['C', params.toArray(), data]); return true; })); parse(parser2, DCS_INPUT); chai.expect(dcsCustom).eql([['C', [1, 2, 3], 'abc']]); }); it('Execution order should go from latest handler down to the original', () => { const order: number[] = []; - parser2.setDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler(() => order.push(1))); - parser2.addDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler(() => { order.push(2); return false; })); - parser2.addDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler(() => { order.push(3); return false; })); + parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler(() => { order.push(1); return true; })); + parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler(() => { order.push(2); return false; })); + parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler(() => { order.push(3); return false; })); parse(parser2, DCS_INPUT); chai.expect(order).eql([3, 2, 1]); }); it('Dispose should work', () => { const dcsCustom: [string, (number | number[])[], string][] = []; - parser2.setDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => dcsCustom.push(['A', params.toArray(), data]))); - const dispo = parser2.addDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); + const dispo = parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); dispo.dispose(); parse(parser2, DCS_INPUT); chai.expect(dcsCustom).eql([['A', [1, 2, 3], 'abc']]); }); it('Should not corrupt the parser when dispose is called twice', () => { const dcsCustom: [string, (number | number[])[], string][] = []; - parser2.setDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => dcsCustom.push(['A', params.toArray(), data]))); - const dispo = parser2.addDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); + const dispo = parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); dispo.dispose(); dispo.dispose(); parse(parser2, DCS_INPUT); @@ -1591,11 +1598,11 @@ describe('EscapeSequenceParser', function (): void { for (let i = 0x30; i <= 0x7e; ++i) { const final = String.fromCharCode(i); let handler: IDisposable | undefined; - chai.assert.doesNotThrow(() => { handler = parser.addEscHandler({final}, () => {}); }, 'final must be in range 48 .. 126'); + chai.assert.doesNotThrow(() => { handler = parser.registerEscHandler({final}, () => true); }, 'final must be in range 48 .. 126'); if (handler) handler.dispose(); } - chai.assert.throws(() => { parser.addEscHandler({final: '\x2f'}, () => {}); }, 'final must be in range 48 .. 126'); - chai.assert.throws(() => { parser.addEscHandler({final: '\x7f'}, () => {}); }, 'final must be in range 48 .. 126'); + chai.assert.throws(() => { parser.registerEscHandler({final: '\x2f'}, () => true); }, 'final must be in range 48 .. 126'); + chai.assert.throws(() => { parser.registerEscHandler({final: '\x7f'}, () => true); }, 'final must be in range 48 .. 126'); }); it('id calculation - should stacking prefix -> intermediate -> final', () => { chai.expect(parser.identToString(parser.identifier({final: 'z'}))).eql('z'); @@ -1608,9 +1615,9 @@ describe('EscapeSequenceParser', function (): void { describe('identifier invocation', () => { it('ESC', () => { const callstack: string[] = []; - const h1 = parser.addEscHandler({final: 'z'}, () => { callstack.push('z'); }); - const h2 = parser.addEscHandler({intermediates: '!', final: 'z'}, () => { callstack.push('!z'); }); - const h3 = parser.addEscHandler({intermediates: '!!', final: 'z'}, () => { callstack.push('!!z'); }); + const h1 = parser.registerEscHandler({final: 'z'}, () => { callstack.push('z'); return true; }); + const h2 = parser.registerEscHandler({intermediates: '!', final: 'z'}, () => { callstack.push('!z'); return true; }); + const h3 = parser.registerEscHandler({intermediates: '!!', final: 'z'}, () => { callstack.push('!!z'); return true; }); parse(parser, '\x1bz\x1b!z\x1b!!z'); h1.dispose(); h2.dispose(); @@ -1620,12 +1627,12 @@ describe('EscapeSequenceParser', function (): void { }); it('CSI', () => { const callstack: any[] = []; - const h1 = parser.addCsiHandler({final: 'z'}, params => { callstack.push(['z', params.toArray()]); }); - const h2 = parser.addCsiHandler({intermediates: '!', final: 'z'}, params => { callstack.push(['!z', params.toArray()]); }); - const h3 = parser.addCsiHandler({intermediates: '!!', final: 'z'}, params => { callstack.push(['!!z', params.toArray()]); }); - const h4 = parser.addCsiHandler({prefix: '?', final: 'z'}, params => { callstack.push(['?z', params.toArray()]); }); - const h5 = parser.addCsiHandler({prefix: '?', intermediates: '!', final: 'z'}, params => { callstack.push(['?!z', params.toArray()]); }); - const h6 = parser.addCsiHandler({prefix: '?', intermediates: '!!', final: 'z'}, params => { callstack.push(['?!!z', params.toArray()]); }); + const h1 = parser.registerCsiHandler({final: 'z'}, params => { callstack.push(['z', params.toArray()]); return true; }); + const h2 = parser.registerCsiHandler({intermediates: '!', final: 'z'}, params => { callstack.push(['!z', params.toArray()]); return true; }); + const h3 = parser.registerCsiHandler({intermediates: '!!', final: 'z'}, params => { callstack.push(['!!z', params.toArray()]); return true; }); + const h4 = parser.registerCsiHandler({prefix: '?', final: 'z'}, params => { callstack.push(['?z', params.toArray()]); return true; }); + const h5 = parser.registerCsiHandler({prefix: '?', intermediates: '!', final: 'z'}, params => { callstack.push(['?!z', params.toArray()]); return true; }); + const h6 = parser.registerCsiHandler({prefix: '?', intermediates: '!!', final: 'z'}, params => { callstack.push(['?!!z', params.toArray()]); return true; }); parse(parser, '\x1b[1;z\x1b[1;!z\x1b[1;!!z\x1b[?1;z\x1b[?1;!z\x1b[?1;!!z'); h1.dispose(); h2.dispose(); @@ -1638,12 +1645,12 @@ describe('EscapeSequenceParser', function (): void { }); it('DCS', () => { const callstack: any[] = []; - const h1 = parser.addDcsHandler({final: 'z'}, new DcsHandler((data, params) => { callstack.push(['z', params.toArray(), data]); })); - const h2 = parser.addDcsHandler({intermediates: '!', final: 'z'}, new DcsHandler((data, params) => { callstack.push(['!z', params.toArray(), data]); })); - const h3 = parser.addDcsHandler({intermediates: '!!', final: 'z'}, new DcsHandler((data, params) => { callstack.push(['!!z', params.toArray(), data]); })); - const h4 = parser.addDcsHandler({prefix: '?', final: 'z'}, new DcsHandler((data, params) => { callstack.push(['?z', params.toArray(), data]); })); - const h5 = parser.addDcsHandler({prefix: '?', intermediates: '!', final: 'z'}, new DcsHandler((data, params) => { callstack.push(['?!z', params.toArray(), data]); })); - const h6 = parser.addDcsHandler({prefix: '?', intermediates: '!!', final: 'z'}, new DcsHandler((data, params) => { callstack.push(['?!!z', params.toArray(), data]); })); + const h1 = parser.registerDcsHandler({final: 'z'}, new DcsHandler((data, params) => { callstack.push(['z', params.toArray(), data]); return true; })); + const h2 = parser.registerDcsHandler({intermediates: '!', final: 'z'}, new DcsHandler((data, params) => { callstack.push(['!z', params.toArray(), data]); return true; })); + const h3 = parser.registerDcsHandler({intermediates: '!!', final: 'z'}, new DcsHandler((data, params) => { callstack.push(['!!z', params.toArray(), data]); return true; })); + const h4 = parser.registerDcsHandler({prefix: '?', final: 'z'}, new DcsHandler((data, params) => { callstack.push(['?z', params.toArray(), data]); return true; })); + const h5 = parser.registerDcsHandler({prefix: '?', intermediates: '!', final: 'z'}, new DcsHandler((data, params) => { callstack.push(['?!z', params.toArray(), data]); return true; })); + const h6 = parser.registerDcsHandler({prefix: '?', intermediates: '!!', final: 'z'}, new DcsHandler((data, params) => { callstack.push(['?!!z', params.toArray(), data]); return true; })); parse(parser, '\x1bP1;zAB\x1b\\\x1bP1;!zAB\x1b\\\x1bP1;!!zAB\x1b\\\x1bP?1;zAB\x1b\\\x1bP?1;!zAB\x1b\\\x1bP?1;!!zAB\x1b\\'); h1.dispose(); h2.dispose(); diff --git a/src/common/parser/EscapeSequenceParser.ts b/src/common/parser/EscapeSequenceParser.ts index 96d206b9..3ffcd2d5 100644 --- a/src/common/parser/EscapeSequenceParser.ts +++ b/src/common/parser/EscapeSequenceParser.ts @@ -280,7 +280,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP this._errorHandler = this._errorHandlerFb; // swallow 7bit ST (ESC+\) - this.setEscHandler({final: '\\'}, () => {}); + this.registerEscHandler({final: '\\'}, () => true); } protected _identifier(id: IFunctionIdentifier, finalRange: number[] = [0x40, 0x7e]): number { @@ -344,7 +344,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP this._printHandler = this._printHandlerFb; } - public addEscHandler(id: IFunctionIdentifier, handler: EscHandlerType): IDisposable { + public registerEscHandler(id: IFunctionIdentifier, handler: EscHandlerType): IDisposable { const ident = this._identifier(id, [0x30, 0x7e]); if (this._escHandlers[ident] === undefined) { this._escHandlers[ident] = []; @@ -360,9 +360,6 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP } }; } - public setEscHandler(id: IFunctionIdentifier, handler: EscHandlerType): void { - this._escHandlers[this._identifier(id, [0x30, 0x7e])] = [handler]; - } public clearEscHandler(id: IFunctionIdentifier): void { if (this._escHandlers[this._identifier(id, [0x30, 0x7e])]) delete this._escHandlers[this._identifier(id, [0x30, 0x7e])]; } @@ -380,7 +377,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP this._executeHandlerFb = handler; } - public addCsiHandler(id: IFunctionIdentifier, handler: CsiHandlerType): IDisposable { + public registerCsiHandler(id: IFunctionIdentifier, handler: CsiHandlerType): IDisposable { const ident = this._identifier(id); if (this._csiHandlers[ident] === undefined) { this._csiHandlers[ident] = []; @@ -396,9 +393,6 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP } }; } - public setCsiHandler(id: IFunctionIdentifier, handler: CsiHandlerType): void { - this._csiHandlers[this._identifier(id)] = [handler]; - } public clearCsiHandler(id: IFunctionIdentifier): void { if (this._csiHandlers[this._identifier(id)]) delete this._csiHandlers[this._identifier(id)]; } @@ -406,11 +400,8 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP this._csiHandlerFb = callback; } - public addDcsHandler(id: IFunctionIdentifier, handler: IDcsHandler): IDisposable { - return this._dcsParser.addHandler(this._identifier(id), handler); - } - public setDcsHandler(id: IFunctionIdentifier, handler: IDcsHandler): void { - this._dcsParser.setHandler(this._identifier(id), handler); + public registerDcsHandler(id: IFunctionIdentifier, handler: IDcsHandler): IDisposable { + return this._dcsParser.registerHandler(this._identifier(id), handler); } public clearDcsHandler(id: IFunctionIdentifier): void { this._dcsParser.clearHandler(this._identifier(id)); @@ -419,11 +410,8 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP this._dcsParser.setHandlerFallback(handler); } - public addOscHandler(ident: number, handler: IOscHandler): IDisposable { - return this._oscParser.addHandler(ident, handler); - } - public setOscHandler(ident: number, handler: IOscHandler): void { - this._oscParser.setHandler(ident, handler); + public registerOscHandler(ident: number, handler: IOscHandler): IDisposable { + return this._oscParser.registerHandler(ident, handler); } public clearOscHandler(ident: number): void { this._oscParser.clearHandler(ident); diff --git a/src/common/parser/OscParser.test.ts b/src/common/parser/OscParser.test.ts index 127bd83a..e2c8641c 100644 --- a/src/common/parser/OscParser.test.ts +++ b/src/common/parser/OscParser.test.ts @@ -23,11 +23,12 @@ class TestHandler implements IOscHandler { public put(data: Uint32Array, start: number, end: number): void { this.output.push([this.msg, this.id, 'PUT', utf32ToString(data, start, end)]); } - public end(success: boolean): void | boolean { + public end(success: boolean): boolean { this.output.push([this.msg, this.id, 'END', success]); if (this.returnFalse) { return false; } + return true; } } @@ -78,7 +79,7 @@ describe('OscParser', () => { }); describe('handler registration', () => { it('setOscHandler', () => { - parser.setHandler(1234, new TestHandler(1234, reports, 'th')); + parser.registerHandler(1234, new TestHandler(1234, reports, 'th')); parser.start(); let data = toUtf32('1234;Here comes'); parser.put(data, 0, data.length); @@ -94,7 +95,7 @@ describe('OscParser', () => { ]); }); it('clearOscHandler', () => { - parser.setHandler(1234, new TestHandler(1234, reports, 'th')); + parser.registerHandler(1234, new TestHandler(1234, reports, 'th')); parser.clearHandler(1234); parser.start(); let data = toUtf32('1234;Here comes'); @@ -111,8 +112,8 @@ describe('OscParser', () => { ]); }); it('addOscHandler', () => { - parser.setHandler(1234, new TestHandler(1234, reports, 'th1')); - parser.addHandler(1234, new TestHandler(1234, reports, 'th2')); + parser.registerHandler(1234, new TestHandler(1234, reports, 'th1')); + parser.registerHandler(1234, new TestHandler(1234, reports, 'th2')); parser.start(); let data = toUtf32('1234;Here comes'); parser.put(data, 0, data.length); @@ -131,8 +132,8 @@ describe('OscParser', () => { ]); }); it('addOscHandler with return false', () => { - parser.setHandler(1234, new TestHandler(1234, reports, 'th1')); - parser.addHandler(1234, new TestHandler(1234, reports, 'th2', true)); + parser.registerHandler(1234, new TestHandler(1234, reports, 'th1')); + parser.registerHandler(1234, new TestHandler(1234, reports, 'th2', true)); parser.start(); let data = toUtf32('1234;Here comes'); parser.put(data, 0, data.length); @@ -151,8 +152,8 @@ describe('OscParser', () => { ]); }); it('dispose handlers', () => { - parser.setHandler(1234, new TestHandler(1234, reports, 'th1')); - const dispo = parser.addHandler(1234, new TestHandler(1234, reports, 'th2', true)); + parser.registerHandler(1234, new TestHandler(1234, reports, 'th1')); + const dispo = parser.registerHandler(1234, new TestHandler(1234, reports, 'th2', true)); dispo.dispose(); parser.start(); let data = toUtf32('1234;Here comes'); @@ -170,7 +171,7 @@ describe('OscParser', () => { }); describe('OscHandlerFactory', () => { it('should be called once on end(true)', () => { - parser.setHandler(1234, new OscHandler(data => reports.push([1234, data]))); + parser.registerHandler(1234, new OscHandler(data => { reports.push([1234, data]); return true; })); parser.start(); let data = toUtf32('1234;Here comes'); parser.put(data, 0, data.length); @@ -180,7 +181,7 @@ describe('OscParser', () => { assert.deepEqual(reports, [[1234, 'Here comes the mouse!']]); }); it('should not be called on end(false)', () => { - parser.setHandler(1234, new OscHandler(data => reports.push([1234, data]))); + parser.registerHandler(1234, new OscHandler(data => { reports.push([1234, data]); return true; })); parser.start(); let data = toUtf32('1234;Here comes'); parser.put(data, 0, data.length); @@ -190,8 +191,8 @@ describe('OscParser', () => { assert.deepEqual(reports, []); }); it('should be disposable', () => { - parser.setHandler(1234, new OscHandler(data => reports.push(['one', data]))); - const dispo = parser.addHandler(1234, new OscHandler(data => reports.push(['two', data]))); + parser.registerHandler(1234, new OscHandler(data => { reports.push(['one', data]); return true; })); + const dispo = parser.registerHandler(1234, new OscHandler(data => { reports.push(['two', data]); return true; })); parser.start(); let data = toUtf32('1234;Here comes'); parser.put(data, 0, data.length); @@ -209,8 +210,8 @@ describe('OscParser', () => { assert.deepEqual(reports, [['two', 'Here comes the mouse!'], ['one', 'some other data']]); }); it('should respect return false', () => { - parser.setHandler(1234, new OscHandler(data => reports.push(['one', data]))); - parser.addHandler(1234, new OscHandler(data => { reports.push(['two', data]); return false; })); + parser.registerHandler(1234, new OscHandler(data => { reports.push(['one', data]); return true; })); + parser.registerHandler(1234, new OscHandler(data => { reports.push(['two', data]); return false; })); parser.start(); let data = toUtf32('1234;Here comes'); parser.put(data, 0, data.length); @@ -221,7 +222,7 @@ describe('OscParser', () => { }); it('should work up to payload limit', function(): void { this.timeout(10000); - parser.setHandler(1234, new OscHandler(data => reports.push([1234, data]))); + parser.registerHandler(1234, new OscHandler(data => { reports.push([1234, data]); return true; })); parser.start(); let data = toUtf32('1234;'); parser.put(data, 0, data.length); @@ -234,7 +235,7 @@ describe('OscParser', () => { }); it('should abort for payload limit +1', function(): void { this.timeout(10000); - parser.setHandler(1234, new OscHandler(data => reports.push([1234, data]))); + parser.registerHandler(1234, new OscHandler(data => { reports.push([1234, data]); return true; })); parser.start(); let data = toUtf32('1234;'); parser.put(data, 0, data.length); diff --git a/src/common/parser/OscParser.ts b/src/common/parser/OscParser.ts index e8c5a801..3a9ae19a 100644 --- a/src/common/parser/OscParser.ts +++ b/src/common/parser/OscParser.ts @@ -15,7 +15,7 @@ export class OscParser implements IOscParser { private _handlers: IHandlerCollection = Object.create(null); private _handlerFb: OscFallbackHandlerType = () => { }; - public addHandler(ident: number, handler: IOscHandler): IDisposable { + public registerHandler(ident: number, handler: IOscHandler): IDisposable { if (this._handlers[ident] === undefined) { this._handlers[ident] = []; } @@ -30,9 +30,6 @@ export class OscParser implements IOscParser { } }; } - public setHandler(ident: number, handler: IOscHandler): void { - this._handlers[ident] = [handler]; - } public clearHandler(ident: number): void { if (this._handlers[ident]) delete this._handlers[ident]; } @@ -171,7 +168,7 @@ export class OscHandler implements IOscHandler { private _data = ''; private _hitLimit: boolean = false; - constructor(private _handler: (data: string) => any) {} + constructor(private _handler: (data: string) => boolean) {} public start(): void { this._data = ''; @@ -189,8 +186,8 @@ export class OscHandler implements IOscHandler { } } - public end(success: boolean): any { - let ret; + public end(success: boolean): boolean { + let ret = false; if (this._hitLimit) { ret = false; } else if (success) { diff --git a/src/common/parser/Types.d.ts b/src/common/parser/Types.d.ts index e2fac89f..b325d025 100644 --- a/src/common/parser/Types.d.ts +++ b/src/common/parser/Types.d.ts @@ -69,7 +69,7 @@ export interface IParsingState { * CSI handler types. * Note: `params` is borrowed. */ -export type CsiHandlerType = (params: IParams) => boolean | void; +export type CsiHandlerType = (params: IParams) => boolean; export type CsiFallbackHandlerType = (ident: number, params: IParams) => void; /** @@ -93,20 +93,20 @@ export interface IDcsHandler { * execution of the command should depend on `success`. * To save memory also cleanup data structures here. */ - unhook(success: boolean): void | boolean; + unhook(success: boolean): boolean; } export type DcsFallbackHandlerType = (ident: number, action: 'HOOK' | 'PUT' | 'UNHOOK', payload?: any) => void; /** * ESC handler types. */ -export type EscHandlerType = () => boolean | void; +export type EscHandlerType = () => boolean; export type EscFallbackHandlerType = (identifier: number) => void; /** * EXECUTE handler types. */ -export type ExecuteHandlerType = () => boolean | void; +export type ExecuteHandlerType = () => boolean; export type ExecuteFallbackHandlerType = (ident: number) => void; /** @@ -129,7 +129,7 @@ export interface IOscHandler { * execution of the command should depend on `success`. * To save memory also cleanup data structures here. */ - end(success: boolean): void | boolean; + end(success: boolean): boolean; } export type OscFallbackHandlerType = (ident: number, action: 'START' | 'PUT' | 'END', payload?: any) => void; @@ -174,29 +174,25 @@ export interface IEscapeSequenceParser extends IDisposable { setPrintHandler(handler: PrintHandlerType): void; clearPrintHandler(): void; - setEscHandler(id: IFunctionIdentifier, handler: EscHandlerType): void; + registerEscHandler(id: IFunctionIdentifier, handler: EscHandlerType): IDisposable; clearEscHandler(id: IFunctionIdentifier): void; setEscHandlerFallback(handler: EscFallbackHandlerType): void; - addEscHandler(id: IFunctionIdentifier, handler: EscHandlerType): IDisposable; setExecuteHandler(flag: string, handler: ExecuteHandlerType): void; clearExecuteHandler(flag: string): void; setExecuteHandlerFallback(handler: ExecuteFallbackHandlerType): void; - setCsiHandler(id: IFunctionIdentifier, handler: CsiHandlerType): void; + registerCsiHandler(id: IFunctionIdentifier, handler: CsiHandlerType): IDisposable; clearCsiHandler(id: IFunctionIdentifier): void; setCsiHandlerFallback(callback: CsiFallbackHandlerType): void; - addCsiHandler(id: IFunctionIdentifier, handler: CsiHandlerType): IDisposable; - setDcsHandler(id: IFunctionIdentifier, handler: IDcsHandler): void; + registerDcsHandler(id: IFunctionIdentifier, handler: IDcsHandler): IDisposable; clearDcsHandler(id: IFunctionIdentifier): void; setDcsHandlerFallback(handler: DcsFallbackHandlerType): void; - addDcsHandler(id: IFunctionIdentifier, handler: IDcsHandler): IDisposable; - setOscHandler(ident: number, handler: IOscHandler): void; + registerOscHandler(ident: number, handler: IOscHandler): IDisposable; clearOscHandler(ident: number): void; setOscHandlerFallback(handler: OscFallbackHandlerType): void; - addOscHandler(ident: number, handler: IOscHandler): IDisposable; setErrorHandler(handler: (state: IParsingState) => IParsingState): void; clearErrorHandler(): void; @@ -209,8 +205,7 @@ export interface IEscapeSequenceParser extends IDisposable { */ export interface ISubParser extends IDisposable { reset(): void; - addHandler(ident: number, handler: T): IDisposable; - setHandler(ident: number, handler: T): void; + registerHandler(ident: number, handler: T): IDisposable; clearHandler(ident: number): void; setHandlerFallback(handler: U): void; put(data: Uint32Array, start: number, end: number): void; diff --git a/test/benchmark/EscapeSequenceParser.benchmark.ts b/test/benchmark/EscapeSequenceParser.benchmark.ts index e4591dde..88bfefe5 100644 --- a/test/benchmark/EscapeSequenceParser.benchmark.ts +++ b/test/benchmark/EscapeSequenceParser.benchmark.ts @@ -21,7 +21,7 @@ function toUtf32(s: string): Uint32Array { class DcsHandler implements IDcsHandler { public hook(params: IParams): void {} public put(data: Uint32Array, start: number, end: number): void {} - public unhook(): void {} + public unhook(): boolean { return true; } } @@ -32,73 +32,73 @@ perfContext('Parser throughput - 50MB data', () => { beforeEach(() => { parser = new EscapeSequenceParser(); parser.setPrintHandler((data, start, end) => {}); - parser.setCsiHandler({final: '@'}, params => {}); - parser.setCsiHandler({final: 'A'}, params => {}); - parser.setCsiHandler({final: 'B'}, params => {}); - parser.setCsiHandler({final: 'C'}, params => {}); - parser.setCsiHandler({final: 'D'}, params => {}); - parser.setCsiHandler({final: 'E'}, params => {}); - parser.setCsiHandler({final: 'F'}, params => {}); - parser.setCsiHandler({final: 'G'}, params => {}); - parser.setCsiHandler({final: 'H'}, params => {}); - parser.setCsiHandler({final: 'I'}, params => {}); - parser.setCsiHandler({final: 'J'}, params => {}); - parser.setCsiHandler({final: 'K'}, params => {}); - parser.setCsiHandler({final: 'L'}, params => {}); - parser.setCsiHandler({final: 'M'}, params => {}); - parser.setCsiHandler({final: 'P'}, params => {}); - parser.setCsiHandler({final: 'S'}, params => {}); - parser.setCsiHandler({final: 'T'}, params => {}); - parser.setCsiHandler({final: 'X'}, params => {}); - parser.setCsiHandler({final: 'Z'}, params => {}); - parser.setCsiHandler({final: '`'}, params => {}); - parser.setCsiHandler({final: 'a'}, params => {}); - parser.setCsiHandler({final: 'b'}, params => {}); - parser.setCsiHandler({final: 'c'}, params => {}); - parser.setCsiHandler({final: 'd'}, params => {}); - parser.setCsiHandler({final: 'e'}, params => {}); - parser.setCsiHandler({final: 'f'}, params => {}); - parser.setCsiHandler({final: 'g'}, params => {}); - parser.setCsiHandler({final: 'h'}, params => {}); - parser.setCsiHandler({final: 'l'}, params => {}); - parser.setCsiHandler({final: 'm'}, params => {}); - parser.setCsiHandler({final: 'n'}, params => {}); - parser.setCsiHandler({final: 'p'}, params => {}); - parser.setCsiHandler({final: 'q'}, params => {}); - parser.setCsiHandler({final: 'r'}, params => {}); - parser.setCsiHandler({final: 's'}, params => {}); - parser.setCsiHandler({final: 'u'}, params => {}); - parser.setExecuteHandler(C0.BEL, () => {}); - parser.setExecuteHandler(C0.LF, () => {}); - parser.setExecuteHandler(C0.VT, () => {}); - parser.setExecuteHandler(C0.FF, () => {}); - parser.setExecuteHandler(C0.CR, () => {}); - parser.setExecuteHandler(C0.BS, () => {}); - parser.setExecuteHandler(C0.HT, () => {}); - parser.setExecuteHandler(C0.SO, () => {}); - parser.setExecuteHandler(C0.SI, () => {}); - parser.setExecuteHandler(C1.IND, () => {}); - parser.setExecuteHandler(C1.NEL, () => {}); - parser.setExecuteHandler(C1.HTS, () => {}); - parser.setOscHandler(0, new OscHandler((data) => {})); - parser.setOscHandler(2, new OscHandler((data) => {})); - parser.setEscHandler({final: '7'}, () => {}); - parser.setEscHandler({final: '8'}, () => {}); - parser.setEscHandler({final: 'D'}, () => {}); - parser.setEscHandler({final: 'E'}, () => {}); - parser.setEscHandler({final: 'H'}, () => {}); - parser.setEscHandler({final: 'M'}, () => {}); - parser.setEscHandler({final: '='}, () => {}); - parser.setEscHandler({final: '>'}, () => {}); - parser.setEscHandler({final: 'c'}, () => {}); - parser.setEscHandler({final: 'n'}, () => {}); - parser.setEscHandler({final: 'o'}, () => {}); - parser.setEscHandler({final: '|'}, () => {}); - parser.setEscHandler({final: '}'}, () => {}); - parser.setEscHandler({final: '~'}, () => {}); - parser.setEscHandler({intermediates: '%', final: '@'}, () => {}); - parser.setEscHandler({intermediates: '%', final: 'G'}, () => {}); - parser.setDcsHandler({final: 'q'}, new DcsHandler()); + parser.registerCsiHandler({final: '@'}, params => true); + parser.registerCsiHandler({final: 'A'}, params => true); + parser.registerCsiHandler({final: 'B'}, params => true); + parser.registerCsiHandler({final: 'C'}, params => true); + parser.registerCsiHandler({final: 'D'}, params => true); + parser.registerCsiHandler({final: 'E'}, params => true); + parser.registerCsiHandler({final: 'F'}, params => true); + parser.registerCsiHandler({final: 'G'}, params => true); + parser.registerCsiHandler({final: 'H'}, params => true); + parser.registerCsiHandler({final: 'I'}, params => true); + parser.registerCsiHandler({final: 'J'}, params => true); + parser.registerCsiHandler({final: 'K'}, params => true); + parser.registerCsiHandler({final: 'L'}, params => true); + parser.registerCsiHandler({final: 'M'}, params => true); + parser.registerCsiHandler({final: 'P'}, params => true); + parser.registerCsiHandler({final: 'S'}, params => true); + parser.registerCsiHandler({final: 'T'}, params => true); + parser.registerCsiHandler({final: 'X'}, params => true); + parser.registerCsiHandler({final: 'Z'}, params => true); + parser.registerCsiHandler({final: '`'}, params => true); + parser.registerCsiHandler({final: 'a'}, params => true); + parser.registerCsiHandler({final: 'b'}, params => true); + parser.registerCsiHandler({final: 'c'}, params => true); + parser.registerCsiHandler({final: 'd'}, params => true); + parser.registerCsiHandler({final: 'e'}, params => true); + parser.registerCsiHandler({final: 'f'}, params => true); + parser.registerCsiHandler({final: 'g'}, params => true); + parser.registerCsiHandler({final: 'h'}, params => true); + parser.registerCsiHandler({final: 'l'}, params => true); + parser.registerCsiHandler({final: 'm'}, params => true); + parser.registerCsiHandler({final: 'n'}, params => true); + parser.registerCsiHandler({final: 'p'}, params => true); + parser.registerCsiHandler({final: 'q'}, params => true); + parser.registerCsiHandler({final: 'r'}, params => true); + parser.registerCsiHandler({final: 's'}, params => true); + parser.registerCsiHandler({final: 'u'}, params => true); + parser.setExecuteHandler(C0.BEL, () => true); + parser.setExecuteHandler(C0.LF, () => true); + parser.setExecuteHandler(C0.VT, () => true); + parser.setExecuteHandler(C0.FF, () => true); + parser.setExecuteHandler(C0.CR, () => true); + parser.setExecuteHandler(C0.BS, () => true); + parser.setExecuteHandler(C0.HT, () => true); + parser.setExecuteHandler(C0.SO, () => true); + parser.setExecuteHandler(C0.SI, () => true); + parser.setExecuteHandler(C1.IND, () => true); + parser.setExecuteHandler(C1.NEL, () => true); + parser.setExecuteHandler(C1.HTS, () => true); + parser.registerOscHandler(0, new OscHandler(data => true)); + parser.registerOscHandler(2, new OscHandler(data => true)); + parser.registerEscHandler({final: '7'}, () => true); + parser.registerEscHandler({final: '8'}, () => true); + parser.registerEscHandler({final: 'D'}, () => true); + parser.registerEscHandler({final: 'E'}, () => true); + parser.registerEscHandler({final: 'H'}, () => true); + parser.registerEscHandler({final: 'M'}, () => true); + parser.registerEscHandler({final: '='}, () => true); + parser.registerEscHandler({final: '>'}, () => true); + parser.registerEscHandler({final: 'c'}, () => true); + parser.registerEscHandler({final: 'n'}, () => true); + parser.registerEscHandler({final: 'o'}, () => true); + parser.registerEscHandler({final: '|'}, () => true); + parser.registerEscHandler({final: '}'}, () => true); + parser.registerEscHandler({final: '~'}, () => true); + parser.registerEscHandler({intermediates: '%', final: '@'}, () => true); + parser.registerEscHandler({intermediates: '%', final: 'G'}, () => true); + parser.registerDcsHandler({final: 'q'}, new DcsHandler()); }); perfContext('PRINT - a', () => { From d67faff92ac04aee5b9f6dcc7bcf84dce8e0bb3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Thu, 21 Jan 2021 11:38:47 +0100 Subject: [PATCH 062/377] simplify return eval --- src/common/parser/DcsParser.ts | 2 +- src/common/parser/EscapeSequenceParser.ts | 23 +++++++++++++++++++---- src/common/parser/OscParser.ts | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/common/parser/DcsParser.ts b/src/common/parser/DcsParser.ts index 8b934942..f501fe25 100644 --- a/src/common/parser/DcsParser.ts +++ b/src/common/parser/DcsParser.ts @@ -84,7 +84,7 @@ export class DcsParser implements IDcsParser { } else { let j = this._active.length - 1; for (; j >= 0; j--) { - if (this._active[j].unhook(success) !== false) { + if (this._active[j].unhook(success)) { break; } } diff --git a/src/common/parser/EscapeSequenceParser.ts b/src/common/parser/EscapeSequenceParser.ts index 3ffcd2d5..065cd1d9 100644 --- a/src/common/parser/EscapeSequenceParser.ts +++ b/src/common/parser/EscapeSequenceParser.ts @@ -521,8 +521,8 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP const handlers = this._csiHandlers[collect << 8 | code]; let j = handlers ? handlers.length - 1 : -1; for (; j >= 0; j--) { - // undefined or true means success and to stop bubbling - if (handlers[j](params) !== false) { + // true means success and to stop bubbling + if (handlers[j](params)) { break; } } @@ -555,8 +555,8 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP const handlersEsc = this._escHandlers[collect << 8 | code]; let jj = handlersEsc ? handlersEsc.length - 1 : -1; for (; jj >= 0; jj--) { - // undefined or true means success and to stop bubbling - if (handlersEsc[jj]() !== false) { + // true means success and to stop bubbling + if (handlersEsc[jj]()) { break; } } @@ -582,6 +582,21 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP i = j - 1; break; } + if (++j >= length || (code = data[j]) === 0x18 || code === 0x1a || code === 0x1b || (code > 0x7f && code < NON_ASCII_PRINTABLE)) { + dcs.put(data, i, j); + i = j - 1; + break; + } + if (++j >= length || (code = data[j]) === 0x18 || code === 0x1a || code === 0x1b || (code > 0x7f && code < NON_ASCII_PRINTABLE)) { + dcs.put(data, i, j); + i = j - 1; + break; + } + if (++j >= length || (code = data[j]) === 0x18 || code === 0x1a || code === 0x1b || (code > 0x7f && code < NON_ASCII_PRINTABLE)) { + dcs.put(data, i, j); + i = j - 1; + break; + } } break; case ParserAction.DCS_UNHOOK: diff --git a/src/common/parser/OscParser.ts b/src/common/parser/OscParser.ts index 3a9ae19a..ff5e7074 100644 --- a/src/common/parser/OscParser.ts +++ b/src/common/parser/OscParser.ts @@ -83,7 +83,7 @@ export class OscParser implements IOscParser { } else { let j = handlers.length - 1; for (; j >= 0; j--) { - if (handlers[j].end(success) !== false) { + if (handlers[j].end(success)) { break; } } From 9d0200252baffc87369964c6109adc91dd3546c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Thu, 21 Jan 2021 13:05:57 +0100 Subject: [PATCH 063/377] fix possible OSC handler bug skipping the fallback handler --- src/common/parser/OscParser.ts | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/common/parser/OscParser.ts b/src/common/parser/OscParser.ts index ff5e7074..e7edac66 100644 --- a/src/common/parser/OscParser.ts +++ b/src/common/parser/OscParser.ts @@ -8,9 +8,11 @@ import { OscState, PAYLOAD_LIMIT } from 'common/parser/Constants'; import { utf32ToString } from 'common/input/TextDecoder'; import { IDisposable } from 'common/Types'; +const EMPTY_HANDLERS: IOscHandler[] = []; export class OscParser implements IOscParser { private _state = OscState.START; + private _active = EMPTY_HANDLERS; private _id = -1; private _handlers: IHandlerCollection = Object.create(null); private _handlerFb: OscFallbackHandlerType = () => { }; @@ -40,6 +42,7 @@ export class OscParser implements IOscParser { public dispose(): void { this._handlers = Object.create(null); this._handlerFb = () => {}; + this._active = EMPTY_HANDLERS; } public reset(): void { @@ -47,28 +50,28 @@ export class OscParser implements IOscParser { if (this._state === OscState.PAYLOAD) { this.end(false); } + this._active = EMPTY_HANDLERS; this._id = -1; this._state = OscState.START; } private _start(): void { - const handlers = this._handlers[this._id]; - if (!handlers) { + this._active = this._handlers[this._id] || EMPTY_HANDLERS; + if (!this._active.length) { this._handlerFb(this._id, 'START'); } else { - for (let j = handlers.length - 1; j >= 0; j--) { - handlers[j].start(); + for (let j = this._active.length - 1; j >= 0; j--) { + this._active[j].start(); } } } private _put(data: Uint32Array, start: number, end: number): void { - const handlers = this._handlers[this._id]; - if (!handlers) { + if (!this._active.length) { this._handlerFb(this._id, 'PUT', utf32ToString(data, start, end)); } else { - for (let j = handlers.length - 1; j >= 0; j--) { - handlers[j].put(data, start, end); + for (let j = this._active.length - 1; j >= 0; j--) { + this._active[j].put(data, start, end); } } } @@ -77,20 +80,19 @@ export class OscParser implements IOscParser { // other than the old code we always have to call .end // to keep the bubbling we use `success` to indicate // whether a handler should execute - const handlers = this._handlers[this._id]; - if (!handlers) { + if (!this._active.length) { this._handlerFb(this._id, 'END', success); } else { - let j = handlers.length - 1; + let j = this._active.length - 1; for (; j >= 0; j--) { - if (handlers[j].end(success)) { + if (this._active[j].end(success)) { break; } } j--; // cleanup left over handlers for (; j >= 0; j--) { - handlers[j].end(false); + this._active[j].end(false); } } } @@ -98,7 +100,6 @@ export class OscParser implements IOscParser { public start(): void { // always reset leftover handlers this.reset(); - this._id = -1; this._state = OscState.ID; } @@ -155,6 +156,7 @@ export class OscParser implements IOscParser { } this._end(success); } + this._active = EMPTY_HANDLERS; this._id = -1; this._state = OscState.START; } From dd5b295219d9b788175a3da201d1982ded169ca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Thu, 21 Jan 2021 13:08:01 +0100 Subject: [PATCH 064/377] release active handler list on dispose in DcsHandler --- src/common/parser/DcsParser.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/parser/DcsParser.ts b/src/common/parser/DcsParser.ts index f501fe25..3a692ca0 100644 --- a/src/common/parser/DcsParser.ts +++ b/src/common/parser/DcsParser.ts @@ -20,6 +20,7 @@ export class DcsParser implements IDcsParser { public dispose(): void { this._handlers = Object.create(null); this._handlerFb = () => {}; + this._active = EMPTY_HANDLERS; } public registerHandler(ident: number, handler: IDcsHandler): IDisposable { From 3f659a15da246f1c19517829363cb7fb3d34f374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Thu, 21 Jan 2021 15:58:03 +0100 Subject: [PATCH 065/377] minor fixes: - better perf for short DCS without params (8 times faster) - test perf for class and string based interfaces of OSC and DCS separately - undo wrong commit on parser --- src/common/parser/DcsParser.ts | 16 ++- src/common/parser/EscapeSequenceParser.ts | 17 +-- .../EscapeSequenceParser.benchmark.ts | 115 ++++++++++++++---- 3 files changed, 105 insertions(+), 43 deletions(-) diff --git a/src/common/parser/DcsParser.ts b/src/common/parser/DcsParser.ts index 3a692ca0..2fa28992 100644 --- a/src/common/parser/DcsParser.ts +++ b/src/common/parser/DcsParser.ts @@ -100,19 +100,27 @@ export class DcsParser implements IDcsParser { } } +// predefine empty params as [0] (ZDM) +const EMPTY_PARAMS = new Params(); +EMPTY_PARAMS.addParam(0); + /** * Convenient class to create a DCS handler from a single callback function. * Note: The payload is currently limited to 50 MB (hardcoded). */ export class DcsHandler implements IDcsHandler { private _data = ''; - private _params: IParams | undefined; + private _params: IParams = EMPTY_PARAMS; private _hitLimit: boolean = false; constructor(private _handler: (data: string, params: IParams) => boolean) {} public hook(params: IParams): void { - this._params = params.clone(); + // since we need to preserve params until `unhook`, we have to clone it + // (only borrowed from parser and spans multiple parser states) + // perf optimization: + // clone only, if we have non empty params, otherwise stick with default + this._params = (params.length > 1 || params.params[0]) ? params.clone() : EMPTY_PARAMS; this._data = ''; this._hitLimit = false; } @@ -133,9 +141,9 @@ export class DcsHandler implements IDcsHandler { if (this._hitLimit) { ret = false; } else if (success) { - ret = this._handler(this._data, this._params || new Params()); + ret = this._handler(this._data, this._params); } - this._params = undefined; + this._params = EMPTY_PARAMS; this._data = ''; this._hitLimit = false; return ret; diff --git a/src/common/parser/EscapeSequenceParser.ts b/src/common/parser/EscapeSequenceParser.ts index 065cd1d9..9a403feb 100644 --- a/src/common/parser/EscapeSequenceParser.ts +++ b/src/common/parser/EscapeSequenceParser.ts @@ -582,21 +582,6 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP i = j - 1; break; } - if (++j >= length || (code = data[j]) === 0x18 || code === 0x1a || code === 0x1b || (code > 0x7f && code < NON_ASCII_PRINTABLE)) { - dcs.put(data, i, j); - i = j - 1; - break; - } - if (++j >= length || (code = data[j]) === 0x18 || code === 0x1a || code === 0x1b || (code > 0x7f && code < NON_ASCII_PRINTABLE)) { - dcs.put(data, i, j); - i = j - 1; - break; - } - if (++j >= length || (code = data[j]) === 0x18 || code === 0x1a || code === 0x1b || (code > 0x7f && code < NON_ASCII_PRINTABLE)) { - dcs.put(data, i, j); - i = j - 1; - break; - } } break; case ParserAction.DCS_UNHOOK: @@ -613,7 +598,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP case ParserAction.OSC_PUT: // inner loop: 0x20 (SP) included, 0x7F (DEL) included for (let j = i + 1; ; j++) { - if (j >= length || (code = data[j]) < 0x20 || (code > 0x7f && code <= 0x9f)) { + if (j >= length || (code = data[j]) < 0x20 || (code > 0x7f && code < NON_ASCII_PRINTABLE)) { osc.put(data, i, j); i = j - 1; break; diff --git a/test/benchmark/EscapeSequenceParser.benchmark.ts b/test/benchmark/EscapeSequenceParser.benchmark.ts index 88bfefe5..c2707f19 100644 --- a/test/benchmark/EscapeSequenceParser.benchmark.ts +++ b/test/benchmark/EscapeSequenceParser.benchmark.ts @@ -6,9 +6,11 @@ import { perfContext, before, beforeEach, ThroughputRuntimeCase } from 'xterm-be import { EscapeSequenceParser } from 'common/parser/EscapeSequenceParser'; import { C0, C1 } from 'common/data/EscapeSequences'; -import { IDcsHandler, IParams } from 'common/parser/Types'; +import { IDcsHandler, IOscHandler, IParams } from 'common/parser/Types'; import { OscHandler } from 'common/parser/OscParser'; +import { DcsHandler } from '../../out/common/parser/DcsParser'; +const SIZE = 5000000; function toUtf32(s: string): Uint32Array { const result = new Uint32Array(s.length); @@ -18,10 +20,16 @@ function toUtf32(s: string): Uint32Array { return result; } -class DcsHandler implements IDcsHandler { +class FastDcsHandler implements IDcsHandler { public hook(params: IParams): void {} public put(data: Uint32Array, start: number, end: number): void {} - public unhook(): boolean { return true; } + public unhook(success: boolean): boolean { return true; } +} + +class FastOscHandler implements IOscHandler { + public start(): void {} + public put(data: Uint32Array, start: number, end: number): void {} + public end(success: boolean): boolean { return true; } } @@ -81,7 +89,7 @@ perfContext('Parser throughput - 50MB data', () => { parser.setExecuteHandler(C1.NEL, () => true); parser.setExecuteHandler(C1.HTS, () => true); parser.registerOscHandler(0, new OscHandler(data => true)); - parser.registerOscHandler(2, new OscHandler(data => true)); + parser.registerOscHandler(1, new FastOscHandler()); parser.registerEscHandler({final: '7'}, () => true); parser.registerEscHandler({final: '8'}, () => true); parser.registerEscHandler({final: 'D'}, () => true); @@ -98,14 +106,15 @@ perfContext('Parser throughput - 50MB data', () => { parser.registerEscHandler({final: '~'}, () => true); parser.registerEscHandler({intermediates: '%', final: '@'}, () => true); parser.registerEscHandler({intermediates: '%', final: 'G'}, () => true); - parser.registerDcsHandler({final: 'q'}, new DcsHandler()); + parser.registerDcsHandler({final: 'p'}, new DcsHandler(data => true)); + parser.registerDcsHandler({final: 'q'}, new FastDcsHandler()); }); perfContext('PRINT - a', () => { before(() => { const data = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'; let content = ''; - while (content.length < 50000000) { + while (content.length < SIZE) { content += data; } parsed = toUtf32(content); @@ -120,7 +129,7 @@ perfContext('Parser throughput - 50MB data', () => { before(() => { const data = '\n\n\n\n\n\n\n'; let content = ''; - while (content.length < 50000000) { + while (content.length < SIZE) { content += data; } parsed = toUtf32(content); @@ -135,7 +144,7 @@ perfContext('Parser throughput - 50MB data', () => { before(() => { const data = '\x1bE\x1bE\x1bE\x1bE\x1bE\x1bE\x1bE\x1bE\x1bE\x1bE'; let content = ''; - while (content.length < 50000000) { + while (content.length < SIZE) { content += data; } parsed = toUtf32(content); @@ -150,7 +159,7 @@ perfContext('Parser throughput - 50MB data', () => { before(() => { const data = '\x1b%G\x1b%G\x1b%G\x1b%G\x1b%G\x1b%G\x1b%G\x1b%G\x1b%G\x1b%G'; let content = ''; - while (content.length < 50000000) { + while (content.length < SIZE) { content += data; } parsed = toUtf32(content); @@ -165,7 +174,7 @@ perfContext('Parser throughput - 50MB data', () => { before(() => { const data = '\x1b[A\x1b[A\x1b[A\x1b[A\x1b[A\x1b[A\x1b[A\x1b[A\x1b[A\x1b[A'; let content = ''; - while (content.length < 50000000) { + while (content.length < SIZE) { content += data; } parsed = toUtf32(content); @@ -180,7 +189,7 @@ perfContext('Parser throughput - 50MB data', () => { before(() => { const data = '\x1b[?p\x1b[?p\x1b[?p\x1b[?p\x1b[?p\x1b[?p\x1b[?p\x1b[?p\x1b[?p\x1b[?p'; let content = ''; - while (content.length < 50000000) { + while (content.length < SIZE) { content += data; } parsed = toUtf32(content); @@ -195,7 +204,7 @@ perfContext('Parser throughput - 50MB data', () => { before(() => { const data = '\x1b[1;2m\x1b[1;2m\x1b[1;2m\x1b[1;2m\x1b[1;2m\x1b[1;2m\x1b[1;2m\x1b[1;2m\x1b[1;2m\x1b[1;2m'; let content = ''; - while (content.length < 50000000) { + while (content.length < SIZE) { content += data; } parsed = toUtf32(content); @@ -210,7 +219,7 @@ perfContext('Parser throughput - 50MB data', () => { before(() => { const data = '\x1b[1;2;3;4;5;6;7;8;9;0m\x1b[1;2;3;4;5;6;7;8;9;0m\x1b[1;2;3;4;5;6;7;8;9;0m'; let content = ''; - while (content.length < 50000000) { + while (content.length < SIZE) { content += data; } parsed = toUtf32(content); @@ -221,11 +230,11 @@ perfContext('Parser throughput - 50MB data', () => { }, {fork: true}).showAverageThroughput(); }); - perfContext('OSC (short) - OSC 0;hi ST', () => { + perfContext('OSC string interface (short seq) - OSC 0;hi ST', () => { before(() => { const data = '\x1b]0;hi\x1b\\\x1b]0;hi\x1b\\\x1b]0;hi\x1b\\\x1b]0;hi\x1b\\x1b]0;hi\x1b\\'; let content = ''; - while (content.length < 50000000) { + while (content.length < SIZE) { content += data; } parsed = toUtf32(content); @@ -236,11 +245,11 @@ perfContext('Parser throughput - 50MB data', () => { }, {fork: true}).showAverageThroughput(); }); - perfContext('OSC (long) - OSC 0; ST', () => { + perfContext('OSC string interface (long seq) - OSC 0; ST', () => { before(() => { const data = '\x1b]0;Lorem ipsum dolor sit amet, consetetur sadipscing elitr.\x1b\\'; let content = ''; - while (content.length < 50000000) { + while (content.length < SIZE) { content += data; } parsed = toUtf32(content); @@ -251,11 +260,41 @@ perfContext('Parser throughput - 50MB data', () => { }, {fork: true}).showAverageThroughput(); }); - perfContext('DCS (short)', () => { + perfContext('OSC class interface (short seq) - OSC 0;hi ST', () => { before(() => { - const data = '\x1bPq~~\x1b\\'; + const data = '\x1b]1;hi\x1b\\\x1b]1;hi\x1b\\\x1b]1;hi\x1b\\\x1b]1;hi\x1b\\x1b]1;hi\x1b\\'; let content = ''; - while (content.length < 50000000) { + while (content.length < SIZE) { + content += data; + } + parsed = toUtf32(content); + }); + new ThroughputRuntimeCase('', () => { + parser.parse(parsed, parsed.length); + return {payloadSize: parsed.length}; + }, {fork: true}).showAverageThroughput(); + }); + + perfContext('OSC class interface (long seq) - OSC 0; ST', () => { + before(() => { + const data = '\x1b]1;Lorem ipsum dolor sit amet, consetetur sadipscing elitr.\x1b\\'; + let content = ''; + while (content.length < SIZE) { + content += data; + } + parsed = toUtf32(content); + }); + new ThroughputRuntimeCase('', () => { + parser.parse(parsed, parsed.length); + return {payloadSize: parsed.length}; + }, {fork: true}).showAverageThroughput(); + }); + + perfContext('DCS string interface (short seq)', () => { + before(() => { + const data = '\x1bPphi\x1b\\\x1bPphi\x1b\\\x1bPphi\x1b\\\x1bPphi\x1b\\\x1bPphi\x1b\\'; + let content = ''; + while (content.length < SIZE) { content += data; } parsed = toUtf32(content); @@ -266,11 +305,41 @@ perfContext('Parser throughput - 50MB data', () => { }, {fork: true}).showAverageThroughput(); }); - perfContext('DCS (long)', () => { + perfContext('DCS string interface (long seq)', () => { before(() => { - const data = '\x1bPq#0;2;0;0;0#1;2;100;100;0#2;2;0;100;0#1~~@@vv@@~~@@~~$#2??}}GG}}??}}??-#1!14@\x1b\\'; + const data = '\x1bPpLorem ipsum dolor sit amet, consetetur sadipscing elitr.\x1b\\'; let content = ''; - while (content.length < 50000000) { + while (content.length < SIZE) { + content += data; + } + parsed = toUtf32(content); + }); + new ThroughputRuntimeCase('', async () => { + parser.parse(parsed, parsed.length); + return {payloadSize: parsed.length}; + }, {fork: true}).showAverageThroughput(); + }); + + perfContext('DCS class interface (short seq)', () => { + before(() => { + const data = '\x1bPqhi\x1b\\\x1bPqhi\x1b\\\x1bPqhi\x1b\\\x1bPqhi\x1b\\\x1bPqhi\x1b\\'; + let content = ''; + while (content.length < SIZE) { + content += data; + } + parsed = toUtf32(content); + }); + new ThroughputRuntimeCase('', async () => { + parser.parse(parsed, parsed.length); + return {payloadSize: parsed.length}; + }, {fork: true}).showAverageThroughput(); + }); + + perfContext('DCS class interface (long seq)', () => { + before(() => { + const data = '\x1bPqLorem ipsum dolor sit amet, consetetur sadipscing elitr.\x1b\\'; + let content = ''; + while (content.length < SIZE) { content += data; } parsed = toUtf32(content); From 554b4a82240343c7e568daaa7587b7aafbc967ba Mon Sep 17 00:00:00 2001 From: Martin Sander Date: Thu, 21 Jan 2021 22:55:25 +0100 Subject: [PATCH 066/377] Store old selection when firing onSelectionChange --- src/browser/services/SelectionService.ts | 29 +++++++++++++----------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/browser/services/SelectionService.ts b/src/browser/services/SelectionService.ts index 7feaf9eb..3b993876 100644 --- a/src/browser/services/SelectionService.ts +++ b/src/browser/services/SelectionService.ts @@ -685,23 +685,22 @@ export class SelectionService extends Disposable implements ISelectionService { } } } else { - this._fireIfSelectionChanged(); + this._fireEventIfSelectionChanged(); } } - private _fireIfSelectionChanged(): void { - // Fire if there is no selection - const hasSelection = this.hasSelection; + private _fireEventIfSelectionChanged(): void { + const start = this._model.finalSelectionStart; + const end = this._model.finalSelectionEnd; + const hasSelection = !!start && !!end && (start[0] !== end[0] || start[1] !== end[1]); + if (!hasSelection) { if (this._oldHasSelection) { - this._onSelectionChange.fire(); + this._fireOnSelectionChange(start, end, hasSelection); } return; } - const start = this._model.finalSelectionStart; - const end = this._model.finalSelectionEnd; - // Sanity check, these should not be undefined as there is a selection if (!start || !end) { return; @@ -711,13 +710,17 @@ export class SelectionService extends Disposable implements ISelectionService { start[0] !== this._oldSelectionStart[0] || start[1] !== this._oldSelectionStart[1] || end[0] !== this._oldSelectionEnd[0] || end[1] !== this._oldSelectionEnd[1])) { - this._oldSelectionStart = start; - this._oldSelectionEnd = end; - this._oldHasSelection = hasSelection; - this._onSelectionChange.fire(); + this._fireOnSelectionChange(start, end, hasSelection); } } + private _fireOnSelectionChange(start: [number, number] | undefined, end: [number, number] | undefined, hasSelection: boolean): void { + this._oldSelectionStart = start; + this._oldSelectionEnd = end; + this._oldHasSelection = hasSelection; + this._onSelectionChange.fire(); + } + private _onBufferActivate(e: {activeBuffer: IBuffer, inactiveBuffer: IBuffer}): void { this.clearSelection(); // Only adjust the selection on trim, shiftElements is rarely used (only in @@ -762,7 +765,7 @@ export class SelectionService extends Disposable implements ISelectionService { public rightClickSelect(ev: MouseEvent): void { if (!this._isClickInSelection(ev)) { this._selectWordAtCursor(ev); - this._fireIfSelectionChanged(); + this._fireEventIfSelectionChanged(); } } From 4a1bdad7590e87e03653db15c8743a48be3cc6af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Fri, 22 Jan 2021 19:48:50 +0100 Subject: [PATCH 067/377] fix tests for async handlers in inputhandler --- src/common/InputHandler.test.ts | 1038 ++++++++++++++++--------------- 1 file changed, 526 insertions(+), 512 deletions(-) diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index 4c0d8559..ebc0df6a 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -41,6 +41,18 @@ class TestInputHandler extends InputHandler { public get windowTitleStack(): string[] { return this._windowTitleStack; } public get iconNameStack(): string[] { return this._iconNameStack; } public parseAnsiColorChange(data: string): IAnsiColorChangeEvent | null { return this._parseAnsiColorChange(data); } + + /** + * Promise based parse call to await the full resolve of given input data. + * This is useful to test async handlers in inputhandler directly. + */ + public async parseP(data: string | Uint8Array): Promise { + let result: Promise | void; + let prev: boolean | undefined; + while (result = this.parse(data, prev)) { + prev = await result; + } + } } describe('InputHandler', () => { @@ -118,7 +130,7 @@ describe('InputHandler', () => { describe('setMode', () => { it('should toggle bracketedPasteMode', () => { const coreService = new MockCoreService(); - const inputHandler = new InputHandler(new MockBufferService(80, 30), new MockCharsetService(), coreService, new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService()); + const inputHandler = new TestInputHandler(new MockBufferService(80, 30), new MockCharsetService(), coreService, new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService()); // Set bracketed paste mode inputHandler.setModePrivate(Params.fromArray([2004])); assert.equal(coreService.decPrivateModes.bracketedPasteMode, true); @@ -134,15 +146,15 @@ describe('InputHandler', () => { return result; } - it('insertChars', function(): void { + it('insertChars', async () => { const bufferService = new MockBufferService(80, 30); - const inputHandler = new InputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService()); + const inputHandler = new TestInputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService()); // insert some data in first and second line - inputHandler.parse(Array(bufferService.cols - 9).join('a')); - inputHandler.parse('1234567890'); - inputHandler.parse(Array(bufferService.cols - 9).join('a')); - inputHandler.parse('1234567890'); + await inputHandler.parseP(Array(bufferService.cols - 9).join('a')); + await inputHandler.parseP('1234567890'); + await inputHandler.parseP(Array(bufferService.cols - 9).join('a')); + await inputHandler.parseP('1234567890'); const line1: IBufferLine = bufferService.buffer.lines.get(0)!; expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + '1234567890'); @@ -171,15 +183,15 @@ describe('InputHandler', () => { expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + ' '); expect(line1.translateToString(true)).equals(Array(bufferService.cols - 9).join('a')); }); - it('deleteChars', function(): void { + it('deleteChars', async () => { const bufferService = new MockBufferService(80, 30); - const inputHandler = new InputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService()); + const inputHandler = new TestInputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService()); // insert some data in first and second line - inputHandler.parse(Array(bufferService.cols - 9).join('a')); - inputHandler.parse('1234567890'); - inputHandler.parse(Array(bufferService.cols - 9).join('a')); - inputHandler.parse('1234567890'); + await inputHandler.parseP(Array(bufferService.cols - 9).join('a')); + await inputHandler.parseP('1234567890'); + await inputHandler.parseP(Array(bufferService.cols - 9).join('a')); + await inputHandler.parseP('1234567890'); const line1: IBufferLine = bufferService.buffer.lines.get(0)!; expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + '1234567890'); @@ -211,14 +223,14 @@ describe('InputHandler', () => { expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + ' '); expect(line1.translateToString(true)).equals(Array(bufferService.cols - 9).join('a')); }); - it('eraseInLine', function(): void { + it('eraseInLine', async () => { const bufferService = new MockBufferService(80, 30); - const inputHandler = new InputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService()); + const inputHandler = new TestInputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService()); // fill 6 lines to test 3 different states - inputHandler.parse(Array(bufferService.cols + 1).join('a')); - inputHandler.parse(Array(bufferService.cols + 1).join('a')); - inputHandler.parse(Array(bufferService.cols + 1).join('a')); + await inputHandler.parseP(Array(bufferService.cols + 1).join('a')); + await inputHandler.parseP(Array(bufferService.cols + 1).join('a')); + await inputHandler.parseP(Array(bufferService.cols + 1).join('a')); // params[0] - right erase bufferService.buffer.y = 0; @@ -239,12 +251,12 @@ describe('InputHandler', () => { expect(bufferService.buffer.lines.get(2)!.translateToString(false)).equals(Array(bufferService.cols + 1).join(' ')); }); - it('eraseInDisplay', function(): void { + it('eraseInDisplay', async () => { const bufferService = new MockBufferService(80, 7); - const inputHandler = new InputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService()); + const inputHandler = new TestInputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService()); // fill display with a's - for (let i = 0; i < bufferService.rows; ++i) inputHandler.parse(Array(bufferService.cols + 1).join('a')); + for (let i = 0; i < bufferService.rows; ++i) await inputHandler.parseP(Array(bufferService.cols + 1).join('a')); // params [0] - right and below erase bufferService.buffer.y = 5; @@ -272,7 +284,7 @@ describe('InputHandler', () => { // reset bufferService.buffer.y = 0; bufferService.buffer.x = 0; - for (let i = 0; i < bufferService.rows; ++i) inputHandler.parse(Array(bufferService.cols + 1).join('a')); + for (let i = 0; i < bufferService.rows; ++i) await inputHandler.parseP(Array(bufferService.cols + 1).join('a')); // params [1] - left and above bufferService.buffer.y = 5; @@ -300,7 +312,7 @@ describe('InputHandler', () => { // reset bufferService.buffer.y = 0; bufferService.buffer.x = 0; - for (let i = 0; i < bufferService.rows; ++i) inputHandler.parse(Array(bufferService.cols + 1).join('a')); + for (let i = 0; i < bufferService.rows; ++i) await inputHandler.parseP(Array(bufferService.cols + 1).join('a')); // params [2] - whole screen bufferService.buffer.y = 5; @@ -328,9 +340,9 @@ describe('InputHandler', () => { // reset and add a wrapped line bufferService.buffer.y = 0; bufferService.buffer.x = 0; - inputHandler.parse(Array(bufferService.cols + 1).join('a')); // line 0 - inputHandler.parse(Array(bufferService.cols + 10).join('a')); // line 1 and 2 - for (let i = 3; i < bufferService.rows; ++i) inputHandler.parse(Array(bufferService.cols + 1).join('a')); + await inputHandler.parseP(Array(bufferService.cols + 1).join('a')); // line 0 + await inputHandler.parseP(Array(bufferService.cols + 10).join('a')); // line 1 and 2 + for (let i = 3; i < bufferService.rows; ++i) await inputHandler.parseP(Array(bufferService.cols + 1).join('a')); // params[1] left and above with wrap // confirm precondition that line 2 is wrapped @@ -343,9 +355,9 @@ describe('InputHandler', () => { // reset and add a wrapped line bufferService.buffer.y = 0; bufferService.buffer.x = 0; - inputHandler.parse(Array(bufferService.cols + 1).join('a')); // line 0 - inputHandler.parse(Array(bufferService.cols + 10).join('a')); // line 1 and 2 - for (let i = 3; i < bufferService.rows; ++i) inputHandler.parse(Array(bufferService.cols + 1).join('a')); + await inputHandler.parseP(Array(bufferService.cols + 1).join('a')); // line 0 + await inputHandler.parseP(Array(bufferService.cols + 10).join('a')); // line 1 and 2 + for (let i = 3; i < bufferService.rows; ++i) await inputHandler.parseP(Array(bufferService.cols + 1).join('a')); // params[1] left and above with wrap // confirm precondition that line 2 is wrapped @@ -358,45 +370,45 @@ describe('InputHandler', () => { }); describe('print', () => { it('should not cause an infinite loop (regression test)', () => { - const inputHandler = new InputHandler(new MockBufferService(80, 30), new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService()); + const inputHandler = new TestInputHandler(new MockBufferService(80, 30), new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService()); const container = new Uint32Array(10); container[0] = 0x200B; inputHandler.print(container, 0, 1); }); - it('should clear cells to the right on early wrap-around', () => { + it('should clear cells to the right on early wrap-around', async () => { bufferService.resize(5, 5); optionsService.options.scrollback = 1; - inputHandler.parse('12345'); + await inputHandler.parseP('12345'); bufferService.buffer.x = 0; - inputHandler.parse('¥¥¥'); + await inputHandler.parseP('¥¥¥'); assert.deepEqual(getLines(bufferService, 2), ['¥¥', '¥']); }); }); describe('alt screen', () => { let bufferService: IBufferService; - let handler: InputHandler; + let handler: TestInputHandler; beforeEach(() => { bufferService = new MockBufferService(80, 30); - handler = new InputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService()); + handler = new TestInputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService()); }); - it('should handle DECSET/DECRST 47 (alt screen buffer)', () => { - handler.parse('\x1b[?47h\r\n\x1b[31mJUNK\x1b[?47lTEST'); + it('should handle DECSET/DECRST 47 (alt screen buffer)', async () => { + await handler.parseP('\x1b[?47h\r\n\x1b[31mJUNK\x1b[?47lTEST'); expect(bufferService.buffer.translateBufferLineToString(0, true)).to.equal(''); expect(bufferService.buffer.translateBufferLineToString(1, true)).to.equal(' TEST'); // Text color of 'TEST' should be red expect((bufferService.buffer.lines.get(1)!.loadCell(4, new CellData()).getFgColor())).to.equal(1); }); - it('should handle DECSET/DECRST 1047 (alt screen buffer)', () => { - handler.parse('\x1b[?1047h\r\n\x1b[31mJUNK\x1b[?1047lTEST'); + it('should handle DECSET/DECRST 1047 (alt screen buffer)', async () => { + await handler.parseP('\x1b[?1047h\r\n\x1b[31mJUNK\x1b[?1047lTEST'); expect(bufferService.buffer.translateBufferLineToString(0, true)).to.equal(''); expect(bufferService.buffer.translateBufferLineToString(1, true)).to.equal(' TEST'); // Text color of 'TEST' should be red expect((bufferService.buffer.lines.get(1)!.loadCell(4, new CellData()).getFgColor())).to.equal(1); }); - it('should handle DECSET/DECRST 1048 (alt screen cursor)', () => { - handler.parse('\x1b[?1048h\r\n\x1b[31mJUNK\x1b[?1048lTEST'); + it('should handle DECSET/DECRST 1048 (alt screen cursor)', async () => { + await handler.parseP('\x1b[?1048h\r\n\x1b[31mJUNK\x1b[?1048lTEST'); expect(bufferService.buffer.translateBufferLineToString(0, true)).to.equal('TEST'); expect(bufferService.buffer.translateBufferLineToString(1, true)).to.equal('JUNK'); // Text color of 'TEST' should be default @@ -404,166 +416,166 @@ describe('InputHandler', () => { // Text color of 'JUNK' should be red expect((bufferService.buffer.lines.get(1)!.loadCell(0, new CellData()).getFgColor())).to.equal(1); }); - it('should handle DECSET/DECRST 1049 (alt screen buffer+cursor)', () => { - handler.parse('\x1b[?1049h\r\n\x1b[31mJUNK\x1b[?1049lTEST'); + it('should handle DECSET/DECRST 1049 (alt screen buffer+cursor)', async () => { + await handler.parseP('\x1b[?1049h\r\n\x1b[31mJUNK\x1b[?1049lTEST'); expect(bufferService.buffer.translateBufferLineToString(0, true)).to.equal('TEST'); expect(bufferService.buffer.translateBufferLineToString(1, true)).to.equal(''); // Text color of 'TEST' should be default expect(bufferService.buffer.lines.get(0)!.loadCell(0, new CellData()).fg).to.equal(DEFAULT_ATTR_DATA.fg); }); - it('should handle DECSET/DECRST 1049 - maintains saved cursor for alt buffer', () => { - handler.parse('\x1b[?1049h\r\n\x1b[31m\x1b[s\x1b[?1049lTEST'); + it('should handle DECSET/DECRST 1049 - maintains saved cursor for alt buffer', async () => { + await handler.parseP('\x1b[?1049h\r\n\x1b[31m\x1b[s\x1b[?1049lTEST'); expect(bufferService.buffer.translateBufferLineToString(0, true)).to.equal('TEST'); // Text color of 'TEST' should be default expect(bufferService.buffer.lines.get(0)!.loadCell(0, new CellData()).fg).to.equal(DEFAULT_ATTR_DATA.fg); - handler.parse('\x1b[?1049h\x1b[uTEST'); + await handler.parseP('\x1b[?1049h\x1b[uTEST'); expect(bufferService.buffer.translateBufferLineToString(1, true)).to.equal('TEST'); // Text color of 'TEST' should be red expect((bufferService.buffer.lines.get(1)!.loadCell(0, new CellData()).getFgColor())).to.equal(1); }); - it('should handle DECSET/DECRST 1049 - clears alt buffer with erase attributes', () => { - handler.parse('\x1b[42m\x1b[?1049h'); + it('should handle DECSET/DECRST 1049 - clears alt buffer with erase attributes', async () => { + await handler.parseP('\x1b[42m\x1b[?1049h'); // Buffer should be filled with green background expect(bufferService.buffer.lines.get(20)!.loadCell(10, new CellData()).getBgColor()).to.equal(2); }); }); describe('text attributes', () => { - it('bold', () => { - inputHandler.parse('\x1b[1m'); + it('bold', async () => { + await inputHandler.parseP('\x1b[1m'); assert.equal(!!inputHandler.curAttrData.isBold(), true); - inputHandler.parse('\x1b[22m'); + await inputHandler.parseP('\x1b[22m'); assert.equal(!!inputHandler.curAttrData.isBold(), false); }); - it('dim', () => { - inputHandler.parse('\x1b[2m'); + it('dim', async () => { + await inputHandler.parseP('\x1b[2m'); assert.equal(!!inputHandler.curAttrData.isDim(), true); - inputHandler.parse('\x1b[22m'); + await inputHandler.parseP('\x1b[22m'); assert.equal(!!inputHandler.curAttrData.isDim(), false); }); - it('italic', () => { - inputHandler.parse('\x1b[3m'); + it('italic', async () => { + await inputHandler.parseP('\x1b[3m'); assert.equal(!!inputHandler.curAttrData.isItalic(), true); - inputHandler.parse('\x1b[23m'); + await inputHandler.parseP('\x1b[23m'); assert.equal(!!inputHandler.curAttrData.isItalic(), false); }); - it('underline', () => { - inputHandler.parse('\x1b[4m'); + it('underline', async () => { + await inputHandler.parseP('\x1b[4m'); assert.equal(!!inputHandler.curAttrData.isUnderline(), true); - inputHandler.parse('\x1b[24m'); + await inputHandler.parseP('\x1b[24m'); assert.equal(!!inputHandler.curAttrData.isUnderline(), false); }); - it('blink', () => { - inputHandler.parse('\x1b[5m'); + it('blink', async () => { + await inputHandler.parseP('\x1b[5m'); assert.equal(!!inputHandler.curAttrData.isBlink(), true); - inputHandler.parse('\x1b[25m'); + await inputHandler.parseP('\x1b[25m'); assert.equal(!!inputHandler.curAttrData.isBlink(), false); }); - it('inverse', () => { - inputHandler.parse('\x1b[7m'); + it('inverse', async () => { + await inputHandler.parseP('\x1b[7m'); assert.equal(!!inputHandler.curAttrData.isInverse(), true); - inputHandler.parse('\x1b[27m'); + await inputHandler.parseP('\x1b[27m'); assert.equal(!!inputHandler.curAttrData.isInverse(), false); }); - it('invisible', () => { - inputHandler.parse('\x1b[8m'); + it('invisible', async () => { + await inputHandler.parseP('\x1b[8m'); assert.equal(!!inputHandler.curAttrData.isInvisible(), true); - inputHandler.parse('\x1b[28m'); + await inputHandler.parseP('\x1b[28m'); assert.equal(!!inputHandler.curAttrData.isInvisible(), false); }); - it('colormode palette 16', () => { + it('colormode palette 16', async () => { assert.equal(inputHandler.curAttrData.getFgColorMode(), 0); // DEFAULT assert.equal(inputHandler.curAttrData.getBgColorMode(), 0); // DEFAULT // lower 8 colors for (let i = 0; i < 8; ++i) { - inputHandler.parse(`\x1b[${i + 30};${i + 40}m`); + await inputHandler.parseP(`\x1b[${i + 30};${i + 40}m`); assert.equal(inputHandler.curAttrData.getFgColorMode(), Attributes.CM_P16); assert.equal(inputHandler.curAttrData.getFgColor(), i); assert.equal(inputHandler.curAttrData.getBgColorMode(), Attributes.CM_P16); assert.equal(inputHandler.curAttrData.getBgColor(), i); } // reset to DEFAULT - inputHandler.parse(`\x1b[39;49m`); + await inputHandler.parseP(`\x1b[39;49m`); assert.equal(inputHandler.curAttrData.getFgColorMode(), 0); assert.equal(inputHandler.curAttrData.getBgColorMode(), 0); }); - it('colormode palette 256', () => { + it('colormode palette 256', async () => { assert.equal(inputHandler.curAttrData.getFgColorMode(), 0); // DEFAULT assert.equal(inputHandler.curAttrData.getBgColorMode(), 0); // DEFAULT // lower 8 colors for (let i = 0; i < 256; ++i) { - inputHandler.parse(`\x1b[38;5;${i};48;5;${i}m`); + await inputHandler.parseP(`\x1b[38;5;${i};48;5;${i}m`); assert.equal(inputHandler.curAttrData.getFgColorMode(), Attributes.CM_P256); assert.equal(inputHandler.curAttrData.getFgColor(), i); assert.equal(inputHandler.curAttrData.getBgColorMode(), Attributes.CM_P256); assert.equal(inputHandler.curAttrData.getBgColor(), i); } // reset to DEFAULT - inputHandler.parse(`\x1b[39;49m`); + await inputHandler.parseP(`\x1b[39;49m`); assert.equal(inputHandler.curAttrData.getFgColorMode(), 0); assert.equal(inputHandler.curAttrData.getFgColor(), -1); assert.equal(inputHandler.curAttrData.getBgColorMode(), 0); assert.equal(inputHandler.curAttrData.getBgColor(), -1); }); - it('colormode RGB', () => { + it('colormode RGB', async () => { assert.equal(inputHandler.curAttrData.getFgColorMode(), 0); // DEFAULT assert.equal(inputHandler.curAttrData.getBgColorMode(), 0); // DEFAULT - inputHandler.parse(`\x1b[38;2;1;2;3;48;2;4;5;6m`); + await inputHandler.parseP(`\x1b[38;2;1;2;3;48;2;4;5;6m`); assert.equal(inputHandler.curAttrData.getFgColorMode(), Attributes.CM_RGB); assert.equal(inputHandler.curAttrData.getFgColor(), 1 << 16 | 2 << 8 | 3); assert.deepEqual(AttributeData.toColorRGB(inputHandler.curAttrData.getFgColor()), [1, 2, 3]); assert.equal(inputHandler.curAttrData.getBgColorMode(), Attributes.CM_RGB); assert.deepEqual(AttributeData.toColorRGB(inputHandler.curAttrData.getBgColor()), [4, 5, 6]); // reset to DEFAULT - inputHandler.parse(`\x1b[39;49m`); + await inputHandler.parseP(`\x1b[39;49m`); assert.equal(inputHandler.curAttrData.getFgColorMode(), 0); assert.equal(inputHandler.curAttrData.getFgColor(), -1); assert.equal(inputHandler.curAttrData.getBgColorMode(), 0); assert.equal(inputHandler.curAttrData.getBgColor(), -1); }); - it('colormode transition RGB to 256', () => { + it('colormode transition RGB to 256', async () => { // enter RGB for FG and BG - inputHandler.parse(`\x1b[38;2;1;2;3;48;2;4;5;6m`); + await inputHandler.parseP(`\x1b[38;2;1;2;3;48;2;4;5;6m`); // enter 256 for FG and BG - inputHandler.parse(`\x1b[38;5;255;48;5;255m`); + await inputHandler.parseP(`\x1b[38;5;255;48;5;255m`); assert.equal(inputHandler.curAttrData.getFgColorMode(), Attributes.CM_P256); assert.equal(inputHandler.curAttrData.getFgColor(), 255); assert.equal(inputHandler.curAttrData.getBgColorMode(), Attributes.CM_P256); assert.equal(inputHandler.curAttrData.getBgColor(), 255); }); - it('colormode transition RGB to 16', () => { + it('colormode transition RGB to 16', async () => { // enter RGB for FG and BG - inputHandler.parse(`\x1b[38;2;1;2;3;48;2;4;5;6m`); + await inputHandler.parseP(`\x1b[38;2;1;2;3;48;2;4;5;6m`); // enter 16 for FG and BG - inputHandler.parse(`\x1b[37;47m`); + await inputHandler.parseP(`\x1b[37;47m`); assert.equal(inputHandler.curAttrData.getFgColorMode(), Attributes.CM_P16); assert.equal(inputHandler.curAttrData.getFgColor(), 7); assert.equal(inputHandler.curAttrData.getBgColorMode(), Attributes.CM_P16); assert.equal(inputHandler.curAttrData.getBgColor(), 7); }); - it('colormode transition 16 to 256', () => { + it('colormode transition 16 to 256', async () => { // enter 16 for FG and BG - inputHandler.parse(`\x1b[37;47m`); + await inputHandler.parseP(`\x1b[37;47m`); // enter 256 for FG and BG - inputHandler.parse(`\x1b[38;5;255;48;5;255m`); + await inputHandler.parseP(`\x1b[38;5;255;48;5;255m`); assert.equal(inputHandler.curAttrData.getFgColorMode(), Attributes.CM_P256); assert.equal(inputHandler.curAttrData.getFgColor(), 255); assert.equal(inputHandler.curAttrData.getBgColorMode(), Attributes.CM_P256); assert.equal(inputHandler.curAttrData.getBgColor(), 255); }); - it('colormode transition 256 to 16', () => { + it('colormode transition 256 to 16', async () => { // enter 256 for FG and BG - inputHandler.parse(`\x1b[38;5;255;48;5;255m`); + await inputHandler.parseP(`\x1b[38;5;255;48;5;255m`); // enter 16 for FG and BG - inputHandler.parse(`\x1b[37;47m`); + await inputHandler.parseP(`\x1b[37;47m`); assert.equal(inputHandler.curAttrData.getFgColorMode(), Attributes.CM_P16); assert.equal(inputHandler.curAttrData.getFgColor(), 7); assert.equal(inputHandler.curAttrData.getBgColorMode(), Attributes.CM_P16); assert.equal(inputHandler.curAttrData.getBgColor(), 7); }); - it('should zero missing RGB values', () => { - inputHandler.parse(`\x1b[38;2;1;2;3m`); - inputHandler.parse(`\x1b[38;2;5m`); + it('should zero missing RGB values', async () => { + await inputHandler.parseP(`\x1b[38;2;1;2;3m`); + await inputHandler.parseP(`\x1b[38;2;5m`); assert.deepEqual(AttributeData.toColorRGB(inputHandler.curAttrData.getFgColor()), [5, 0, 0]); }); }); @@ -573,141 +585,141 @@ describe('InputHandler', () => { inputHandler2 = new TestInputHandler(bufferService, new MockCharsetService(), coreService, new MockDirtyRowService(), new MockLogService(), optionsService, new MockCoreMouseService(), new MockUnicodeService()); }); describe('should equal to semicolon', () => { - it('CSI 38:2::50:100:150 m', () => { + it('CSI 38:2::50:100:150 m', async () => { inputHandler.curAttrData.fg = 0xFFFFFFFF; inputHandler2.curAttrData.fg = 0xFFFFFFFF; - inputHandler2.parse('\x1b[38;2;50;100;150m'); - inputHandler.parse('\x1b[38:2::50:100:150m'); + await inputHandler2.parseP('\x1b[38;2;50;100;150m'); + await inputHandler.parseP('\x1b[38:2::50:100:150m'); assert.equal(inputHandler2.curAttrData.fg & 0xFFFFFF, 50 << 16 | 100 << 8 | 150); assert.equal(inputHandler.curAttrData.fg, inputHandler2.curAttrData.fg); }); - it('CSI 38:2::50:100: m', () => { + it('CSI 38:2::50:100: m', async () => { inputHandler.curAttrData.fg = 0xFFFFFFFF; inputHandler2.curAttrData.fg = 0xFFFFFFFF; - inputHandler2.parse('\x1b[38;2;50;100;m'); - inputHandler.parse('\x1b[38:2::50:100:m'); + await inputHandler2.parseP('\x1b[38;2;50;100;m'); + await inputHandler.parseP('\x1b[38:2::50:100:m'); assert.equal(inputHandler2.curAttrData.fg & 0xFFFFFF, 50 << 16 | 100 << 8 | 0); assert.equal(inputHandler.curAttrData.fg, inputHandler2.curAttrData.fg); }); - it('CSI 38:2::50:: m', () => { + it('CSI 38:2::50:: m', async () => { inputHandler.curAttrData.fg = 0xFFFFFFFF; inputHandler2.curAttrData.fg = 0xFFFFFFFF; - inputHandler2.parse('\x1b[38;2;50;;m'); - inputHandler.parse('\x1b[38:2::50::m'); + await inputHandler2.parseP('\x1b[38;2;50;;m'); + await inputHandler.parseP('\x1b[38:2::50::m'); assert.equal(inputHandler2.curAttrData.fg & 0xFFFFFF, 50 << 16 | 0 << 8 | 0); assert.equal(inputHandler.curAttrData.fg, inputHandler2.curAttrData.fg); }); - it('CSI 38:2:::: m', () => { + it('CSI 38:2:::: m', async () => { inputHandler.curAttrData.fg = 0xFFFFFFFF; inputHandler2.curAttrData.fg = 0xFFFFFFFF; - inputHandler2.parse('\x1b[38;2;;;m'); - inputHandler.parse('\x1b[38:2::::m'); + await inputHandler2.parseP('\x1b[38;2;;;m'); + await inputHandler.parseP('\x1b[38:2::::m'); assert.equal(inputHandler2.curAttrData.fg & 0xFFFFFF, 0 << 16 | 0 << 8 | 0); assert.equal(inputHandler.curAttrData.fg, inputHandler2.curAttrData.fg); }); - it('CSI 38;2::50:100:150 m', () => { + it('CSI 38;2::50:100:150 m', async () => { inputHandler.curAttrData.fg = 0xFFFFFFFF; inputHandler2.curAttrData.fg = 0xFFFFFFFF; - inputHandler2.parse('\x1b[38;2;50;100;150m'); - inputHandler.parse('\x1b[38;2::50:100:150m'); + await inputHandler2.parseP('\x1b[38;2;50;100;150m'); + await inputHandler.parseP('\x1b[38;2::50:100:150m'); assert.equal(inputHandler2.curAttrData.fg & 0xFFFFFF, 50 << 16 | 100 << 8 | 150); assert.equal(inputHandler.curAttrData.fg, inputHandler2.curAttrData.fg); }); - it('CSI 38;2;50:100:150 m', () => { + it('CSI 38;2;50:100:150 m', async () => { inputHandler.curAttrData.fg = 0xFFFFFFFF; inputHandler2.curAttrData.fg = 0xFFFFFFFF; - inputHandler2.parse('\x1b[38;2;50;100;150m'); - inputHandler.parse('\x1b[38;2;50:100:150m'); + await inputHandler2.parseP('\x1b[38;2;50;100;150m'); + await inputHandler.parseP('\x1b[38;2;50:100:150m'); assert.equal(inputHandler2.curAttrData.fg & 0xFFFFFF, 50 << 16 | 100 << 8 | 150); assert.equal(inputHandler.curAttrData.fg, inputHandler2.curAttrData.fg); }); - it('CSI 38;2;50;100:150 m', () => { + it('CSI 38;2;50;100:150 m', async () => { inputHandler.curAttrData.fg = 0xFFFFFFFF; inputHandler2.curAttrData.fg = 0xFFFFFFFF; - inputHandler2.parse('\x1b[38;2;50;100;150m'); - inputHandler.parse('\x1b[38;2;50;100:150m'); + await inputHandler2.parseP('\x1b[38;2;50;100;150m'); + await inputHandler.parseP('\x1b[38;2;50;100:150m'); assert.equal(inputHandler2.curAttrData.fg & 0xFFFFFF, 50 << 16 | 100 << 8 | 150); assert.equal(inputHandler.curAttrData.fg, inputHandler2.curAttrData.fg); }); - it('CSI 38:5:50 m', () => { + it('CSI 38:5:50 m', async () => { inputHandler.curAttrData.fg = 0xFFFFFFFF; inputHandler2.curAttrData.fg = 0xFFFFFFFF; - inputHandler2.parse('\x1b[38;5;50m'); - inputHandler.parse('\x1b[38:5:50m'); + await inputHandler2.parseP('\x1b[38;5;50m'); + await inputHandler.parseP('\x1b[38:5:50m'); assert.equal(inputHandler2.curAttrData.fg & 0xFF, 50); assert.equal(inputHandler.curAttrData.fg, inputHandler2.curAttrData.fg); }); - it('CSI 38:5: m', () => { + it('CSI 38:5: m', async () => { inputHandler.curAttrData.fg = 0xFFFFFFFF; inputHandler2.curAttrData.fg = 0xFFFFFFFF; - inputHandler2.parse('\x1b[38;5;m'); - inputHandler.parse('\x1b[38:5:m'); + await inputHandler2.parseP('\x1b[38;5;m'); + await inputHandler.parseP('\x1b[38:5:m'); assert.equal(inputHandler2.curAttrData.fg & 0xFF, 0); assert.equal(inputHandler.curAttrData.fg, inputHandler2.curAttrData.fg); }); - it('CSI 38;5:50 m', () => { + it('CSI 38;5:50 m', async () => { inputHandler.curAttrData.fg = 0xFFFFFFFF; inputHandler2.curAttrData.fg = 0xFFFFFFFF; - inputHandler2.parse('\x1b[38;5;50m'); - inputHandler.parse('\x1b[38;5:50m'); + await inputHandler2.parseP('\x1b[38;5;50m'); + await inputHandler.parseP('\x1b[38;5:50m'); assert.equal(inputHandler2.curAttrData.fg & 0xFF, 50); assert.equal(inputHandler.curAttrData.fg, inputHandler2.curAttrData.fg); }); }); describe('should fill early sequence end with default of 0', () => { - it('CSI 38:2 m', () => { + it('CSI 38:2 m', async () => { inputHandler.curAttrData.fg = 0xFFFFFFFF; inputHandler2.curAttrData.fg = 0xFFFFFFFF; - inputHandler2.parse('\x1b[38;2m'); - inputHandler.parse('\x1b[38:2m'); + await inputHandler2.parseP('\x1b[38;2m'); + await inputHandler.parseP('\x1b[38:2m'); assert.equal(inputHandler2.curAttrData.fg & 0xFFFFFF, 0 << 16 | 0 << 8 | 0); assert.equal(inputHandler.curAttrData.fg, inputHandler2.curAttrData.fg); }); - it('CSI 38:5 m', () => { + it('CSI 38:5 m', async () => { inputHandler.curAttrData.fg = 0xFFFFFFFF; inputHandler2.curAttrData.fg = 0xFFFFFFFF; - inputHandler2.parse('\x1b[38;5m'); - inputHandler.parse('\x1b[38:5m'); + await inputHandler2.parseP('\x1b[38;5m'); + await inputHandler.parseP('\x1b[38:5m'); assert.equal(inputHandler2.curAttrData.fg & 0xFF, 0); assert.equal(inputHandler.curAttrData.fg, inputHandler2.curAttrData.fg); }); }); describe('should not interfere with leading/following SGR attrs', () => { - it('CSI 1 ; 38:2::50:100:150 ; 4 m', () => { - inputHandler2.parse('\x1b[1;38;2;50;100;150;4m'); - inputHandler.parse('\x1b[1;38:2::50:100:150;4m'); + it('CSI 1 ; 38:2::50:100:150 ; 4 m', async () => { + await inputHandler2.parseP('\x1b[1;38;2;50;100;150;4m'); + await inputHandler.parseP('\x1b[1;38:2::50:100:150;4m'); assert.equal(!!inputHandler2.curAttrData.isBold(), true); assert.equal(!!inputHandler2.curAttrData.isUnderline(), true); assert.equal(inputHandler2.curAttrData.fg & 0xFFFFFF, 50 << 16 | 100 << 8 | 150); assert.equal(inputHandler.curAttrData.fg, inputHandler2.curAttrData.fg); }); - it('CSI 1 ; 38:2::50:100: ; 4 m', () => { - inputHandler2.parse('\x1b[1;38;2;50;100;;4m'); - inputHandler.parse('\x1b[1;38:2::50:100:;4m'); + it('CSI 1 ; 38:2::50:100: ; 4 m', async () => { + await inputHandler2.parseP('\x1b[1;38;2;50;100;;4m'); + await inputHandler.parseP('\x1b[1;38:2::50:100:;4m'); assert.equal(!!inputHandler2.curAttrData.isBold(), true); assert.equal(!!inputHandler2.curAttrData.isUnderline(), true); assert.equal(inputHandler2.curAttrData.fg & 0xFFFFFF, 50 << 16 | 100 << 8 | 0); assert.equal(inputHandler.curAttrData.fg, inputHandler2.curAttrData.fg); }); - it('CSI 1 ; 38:2::50:100 ; 4 m', () => { - inputHandler2.parse('\x1b[1;38;2;50;100;;4m'); - inputHandler.parse('\x1b[1;38:2::50:100;4m'); + it('CSI 1 ; 38:2::50:100 ; 4 m', async () => { + await inputHandler2.parseP('\x1b[1;38;2;50;100;;4m'); + await inputHandler.parseP('\x1b[1;38:2::50:100;4m'); assert.equal(!!inputHandler2.curAttrData.isBold(), true); assert.equal(!!inputHandler2.curAttrData.isUnderline(), true); assert.equal(inputHandler2.curAttrData.fg & 0xFFFFFF, 50 << 16 | 100 << 8 | 0); assert.equal(inputHandler.curAttrData.fg, inputHandler2.curAttrData.fg); }); - it('CSI 1 ; 38:2:: ; 4 m', () => { - inputHandler2.parse('\x1b[1;38;2;;;;4m'); - inputHandler.parse('\x1b[1;38:2::;4m'); + it('CSI 1 ; 38:2:: ; 4 m', async () => { + await inputHandler2.parseP('\x1b[1;38;2;;;;4m'); + await inputHandler.parseP('\x1b[1;38:2::;4m'); assert.equal(!!inputHandler2.curAttrData.isBold(), true); assert.equal(!!inputHandler2.curAttrData.isUnderline(), true); assert.equal(inputHandler2.curAttrData.fg & 0xFFFFFF, 0); assert.equal(inputHandler.curAttrData.fg, inputHandler2.curAttrData.fg); }); - it('CSI 1 ; 38;2:: ; 4 m', () => { - inputHandler2.parse('\x1b[1;38;2;;;;4m'); - inputHandler.parse('\x1b[1;38;2::;4m'); + it('CSI 1 ; 38;2:: ; 4 m', async () => { + await inputHandler2.parseP('\x1b[1;38;2;;;;4m'); + await inputHandler.parseP('\x1b[1;38;2::;4m'); assert.equal(!!inputHandler2.curAttrData.isBold(), true); assert.equal(!!inputHandler2.curAttrData.isUnderline(), true); assert.equal(inputHandler2.curAttrData.fg & 0xFFFFFF, 0); @@ -719,372 +731,372 @@ describe('InputHandler', () => { beforeEach(() => { bufferService.resize(10, 10); }); - it('cursor forward (CUF)', () => { - inputHandler.parse('\x1b[C'); + it('cursor forward (CUF)', async () => { + await inputHandler.parseP('\x1b[C'); assert.deepEqual(getCursor(bufferService), [1, 0]); - inputHandler.parse('\x1b[1C'); + await inputHandler.parseP('\x1b[1C'); assert.deepEqual(getCursor(bufferService), [2, 0]); - inputHandler.parse('\x1b[4C'); + await inputHandler.parseP('\x1b[4C'); assert.deepEqual(getCursor(bufferService), [6, 0]); - inputHandler.parse('\x1b[100C'); + await inputHandler.parseP('\x1b[100C'); assert.deepEqual(getCursor(bufferService), [9, 0]); // should not change y bufferService.buffer.x = 8; bufferService.buffer.y = 4; - inputHandler.parse('\x1b[C'); + await inputHandler.parseP('\x1b[C'); assert.deepEqual(getCursor(bufferService), [9, 4]); }); - it('cursor backward (CUB)', () => { - inputHandler.parse('\x1b[D'); + it('cursor backward (CUB)', async () => { + await inputHandler.parseP('\x1b[D'); assert.deepEqual(getCursor(bufferService), [0, 0]); - inputHandler.parse('\x1b[1D'); + await inputHandler.parseP('\x1b[1D'); assert.deepEqual(getCursor(bufferService), [0, 0]); // place cursor at end of first line - inputHandler.parse('\x1b[100C'); - inputHandler.parse('\x1b[D'); + await inputHandler.parseP('\x1b[100C'); + await inputHandler.parseP('\x1b[D'); assert.deepEqual(getCursor(bufferService), [8, 0]); - inputHandler.parse('\x1b[1D'); + await inputHandler.parseP('\x1b[1D'); assert.deepEqual(getCursor(bufferService), [7, 0]); - inputHandler.parse('\x1b[4D'); + await inputHandler.parseP('\x1b[4D'); assert.deepEqual(getCursor(bufferService), [3, 0]); - inputHandler.parse('\x1b[100D'); + await inputHandler.parseP('\x1b[100D'); assert.deepEqual(getCursor(bufferService), [0, 0]); // should not change y bufferService.buffer.x = 4; bufferService.buffer.y = 4; - inputHandler.parse('\x1b[D'); + await inputHandler.parseP('\x1b[D'); assert.deepEqual(getCursor(bufferService), [3, 4]); }); - it('cursor down (CUD)', () => { - inputHandler.parse('\x1b[B'); + it('cursor down (CUD)', async () => { + await inputHandler.parseP('\x1b[B'); assert.deepEqual(getCursor(bufferService), [0, 1]); - inputHandler.parse('\x1b[1B'); + await inputHandler.parseP('\x1b[1B'); assert.deepEqual(getCursor(bufferService), [0, 2]); - inputHandler.parse('\x1b[4B'); + await inputHandler.parseP('\x1b[4B'); assert.deepEqual(getCursor(bufferService), [0, 6]); - inputHandler.parse('\x1b[100B'); + await inputHandler.parseP('\x1b[100B'); assert.deepEqual(getCursor(bufferService), [0, 9]); // should not change x bufferService.buffer.x = 8; bufferService.buffer.y = 0; - inputHandler.parse('\x1b[B'); + await inputHandler.parseP('\x1b[B'); assert.deepEqual(getCursor(bufferService), [8, 1]); }); - it('cursor up (CUU)', () => { - inputHandler.parse('\x1b[A'); + it('cursor up (CUU)', async () => { + await inputHandler.parseP('\x1b[A'); assert.deepEqual(getCursor(bufferService), [0, 0]); - inputHandler.parse('\x1b[1A'); + await inputHandler.parseP('\x1b[1A'); assert.deepEqual(getCursor(bufferService), [0, 0]); // place cursor at beginning of last row - inputHandler.parse('\x1b[100B'); - inputHandler.parse('\x1b[A'); + await inputHandler.parseP('\x1b[100B'); + await inputHandler.parseP('\x1b[A'); assert.deepEqual(getCursor(bufferService), [0, 8]); - inputHandler.parse('\x1b[1A'); + await inputHandler.parseP('\x1b[1A'); assert.deepEqual(getCursor(bufferService), [0, 7]); - inputHandler.parse('\x1b[4A'); + await inputHandler.parseP('\x1b[4A'); assert.deepEqual(getCursor(bufferService), [0, 3]); - inputHandler.parse('\x1b[100A'); + await inputHandler.parseP('\x1b[100A'); assert.deepEqual(getCursor(bufferService), [0, 0]); // should not change x bufferService.buffer.x = 8; bufferService.buffer.y = 9; - inputHandler.parse('\x1b[A'); + await inputHandler.parseP('\x1b[A'); assert.deepEqual(getCursor(bufferService), [8, 8]); }); - it('cursor next line (CNL)', () => { - inputHandler.parse('\x1b[E'); + it('cursor next line (CNL)', async () => { + await inputHandler.parseP('\x1b[E'); assert.deepEqual(getCursor(bufferService), [0, 1]); - inputHandler.parse('\x1b[1E'); + await inputHandler.parseP('\x1b[1E'); assert.deepEqual(getCursor(bufferService), [0, 2]); - inputHandler.parse('\x1b[4E'); + await inputHandler.parseP('\x1b[4E'); assert.deepEqual(getCursor(bufferService), [0, 6]); - inputHandler.parse('\x1b[100E'); + await inputHandler.parseP('\x1b[100E'); assert.deepEqual(getCursor(bufferService), [0, 9]); // should reset x to zero bufferService.buffer.x = 8; bufferService.buffer.y = 0; - inputHandler.parse('\x1b[E'); + await inputHandler.parseP('\x1b[E'); assert.deepEqual(getCursor(bufferService), [0, 1]); }); - it('cursor previous line (CPL)', () => { - inputHandler.parse('\x1b[F'); + it('cursor previous line (CPL)', async () => { + await inputHandler.parseP('\x1b[F'); assert.deepEqual(getCursor(bufferService), [0, 0]); - inputHandler.parse('\x1b[1F'); + await inputHandler.parseP('\x1b[1F'); assert.deepEqual(getCursor(bufferService), [0, 0]); // place cursor at beginning of last row - inputHandler.parse('\x1b[100E'); - inputHandler.parse('\x1b[F'); + await inputHandler.parseP('\x1b[100E'); + await inputHandler.parseP('\x1b[F'); assert.deepEqual(getCursor(bufferService), [0, 8]); - inputHandler.parse('\x1b[1F'); + await inputHandler.parseP('\x1b[1F'); assert.deepEqual(getCursor(bufferService), [0, 7]); - inputHandler.parse('\x1b[4F'); + await inputHandler.parseP('\x1b[4F'); assert.deepEqual(getCursor(bufferService), [0, 3]); - inputHandler.parse('\x1b[100F'); + await inputHandler.parseP('\x1b[100F'); assert.deepEqual(getCursor(bufferService), [0, 0]); // should reset x to zero bufferService.buffer.x = 8; bufferService.buffer.y = 9; - inputHandler.parse('\x1b[F'); + await inputHandler.parseP('\x1b[F'); assert.deepEqual(getCursor(bufferService), [0, 8]); }); - it('cursor character absolute (CHA)', () => { - inputHandler.parse('\x1b[G'); + it('cursor character absolute (CHA)', async () => { + await inputHandler.parseP('\x1b[G'); assert.deepEqual(getCursor(bufferService), [0, 0]); - inputHandler.parse('\x1b[1G'); + await inputHandler.parseP('\x1b[1G'); assert.deepEqual(getCursor(bufferService), [0, 0]); - inputHandler.parse('\x1b[2G'); + await inputHandler.parseP('\x1b[2G'); assert.deepEqual(getCursor(bufferService), [1, 0]); - inputHandler.parse('\x1b[5G'); + await inputHandler.parseP('\x1b[5G'); assert.deepEqual(getCursor(bufferService), [4, 0]); - inputHandler.parse('\x1b[100G'); + await inputHandler.parseP('\x1b[100G'); assert.deepEqual(getCursor(bufferService), [9, 0]); }); - it('cursor position (CUP)', () => { + it('cursor position (CUP)', async () => { bufferService.buffer.x = 5; bufferService.buffer.y = 5; - inputHandler.parse('\x1b[H'); + await inputHandler.parseP('\x1b[H'); assert.deepEqual(getCursor(bufferService), [0, 0]); bufferService.buffer.x = 5; bufferService.buffer.y = 5; - inputHandler.parse('\x1b[1H'); + await inputHandler.parseP('\x1b[1H'); assert.deepEqual(getCursor(bufferService), [0, 0]); bufferService.buffer.x = 5; bufferService.buffer.y = 5; - inputHandler.parse('\x1b[1;1H'); + await inputHandler.parseP('\x1b[1;1H'); assert.deepEqual(getCursor(bufferService), [0, 0]); bufferService.buffer.x = 5; bufferService.buffer.y = 5; - inputHandler.parse('\x1b[8H'); + await inputHandler.parseP('\x1b[8H'); assert.deepEqual(getCursor(bufferService), [0, 7]); bufferService.buffer.x = 5; bufferService.buffer.y = 5; - inputHandler.parse('\x1b[;8H'); + await inputHandler.parseP('\x1b[;8H'); assert.deepEqual(getCursor(bufferService), [7, 0]); bufferService.buffer.x = 5; bufferService.buffer.y = 5; - inputHandler.parse('\x1b[100;100H'); + await inputHandler.parseP('\x1b[100;100H'); assert.deepEqual(getCursor(bufferService), [9, 9]); }); - it('horizontal position absolute (HPA)', () => { - inputHandler.parse('\x1b[`'); + it('horizontal position absolute (HPA)', async () => { + await inputHandler.parseP('\x1b[`'); assert.deepEqual(getCursor(bufferService), [0, 0]); - inputHandler.parse('\x1b[1`'); + await inputHandler.parseP('\x1b[1`'); assert.deepEqual(getCursor(bufferService), [0, 0]); - inputHandler.parse('\x1b[2`'); + await inputHandler.parseP('\x1b[2`'); assert.deepEqual(getCursor(bufferService), [1, 0]); - inputHandler.parse('\x1b[5`'); + await inputHandler.parseP('\x1b[5`'); assert.deepEqual(getCursor(bufferService), [4, 0]); - inputHandler.parse('\x1b[100`'); + await inputHandler.parseP('\x1b[100`'); assert.deepEqual(getCursor(bufferService), [9, 0]); }); - it('horizontal position relative (HPR)', () => { - inputHandler.parse('\x1b[a'); + it('horizontal position relative (HPR)', async () => { + await inputHandler.parseP('\x1b[a'); assert.deepEqual(getCursor(bufferService), [1, 0]); - inputHandler.parse('\x1b[1a'); + await inputHandler.parseP('\x1b[1a'); assert.deepEqual(getCursor(bufferService), [2, 0]); - inputHandler.parse('\x1b[4a'); + await inputHandler.parseP('\x1b[4a'); assert.deepEqual(getCursor(bufferService), [6, 0]); - inputHandler.parse('\x1b[100a'); + await inputHandler.parseP('\x1b[100a'); assert.deepEqual(getCursor(bufferService), [9, 0]); // should not change y bufferService.buffer.x = 8; bufferService.buffer.y = 4; - inputHandler.parse('\x1b[a'); + await inputHandler.parseP('\x1b[a'); assert.deepEqual(getCursor(bufferService), [9, 4]); }); - it('vertical position absolute (VPA)', () => { - inputHandler.parse('\x1b[d'); + it('vertical position absolute (VPA)', async () => { + await inputHandler.parseP('\x1b[d'); assert.deepEqual(getCursor(bufferService), [0, 0]); - inputHandler.parse('\x1b[1d'); + await inputHandler.parseP('\x1b[1d'); assert.deepEqual(getCursor(bufferService), [0, 0]); - inputHandler.parse('\x1b[2d'); + await inputHandler.parseP('\x1b[2d'); assert.deepEqual(getCursor(bufferService), [0, 1]); - inputHandler.parse('\x1b[5d'); + await inputHandler.parseP('\x1b[5d'); assert.deepEqual(getCursor(bufferService), [0, 4]); - inputHandler.parse('\x1b[100d'); + await inputHandler.parseP('\x1b[100d'); assert.deepEqual(getCursor(bufferService), [0, 9]); // should not change x bufferService.buffer.x = 8; bufferService.buffer.y = 4; - inputHandler.parse('\x1b[d'); + await inputHandler.parseP('\x1b[d'); assert.deepEqual(getCursor(bufferService), [8, 0]); }); - it('vertical position relative (VPR)', () => { - inputHandler.parse('\x1b[e'); + it('vertical position relative (VPR)', async () => { + await inputHandler.parseP('\x1b[e'); assert.deepEqual(getCursor(bufferService), [0, 1]); - inputHandler.parse('\x1b[1e'); + await inputHandler.parseP('\x1b[1e'); assert.deepEqual(getCursor(bufferService), [0, 2]); - inputHandler.parse('\x1b[4e'); + await inputHandler.parseP('\x1b[4e'); assert.deepEqual(getCursor(bufferService), [0, 6]); - inputHandler.parse('\x1b[100e'); + await inputHandler.parseP('\x1b[100e'); assert.deepEqual(getCursor(bufferService), [0, 9]); // should not change x bufferService.buffer.x = 8; bufferService.buffer.y = 4; - inputHandler.parse('\x1b[e'); + await inputHandler.parseP('\x1b[e'); assert.deepEqual(getCursor(bufferService), [8, 5]); }); describe('should clamp cursor into addressible range', () => { - it('CUF', () => { + it('CUF', async () => { bufferService.buffer.x = 10000; bufferService.buffer.y = 10000; - inputHandler.parse('\x1b[C'); + await inputHandler.parseP('\x1b[C'); assert.deepEqual(getCursor(bufferService), [9, 9]); bufferService.buffer.x = -10000; bufferService.buffer.y = -10000; - inputHandler.parse('\x1b[C'); + await inputHandler.parseP('\x1b[C'); assert.deepEqual(getCursor(bufferService), [1, 0]); }); - it('CUB', () => { + it('CUB', async () => { bufferService.buffer.x = 10000; bufferService.buffer.y = 10000; - inputHandler.parse('\x1b[D'); + await inputHandler.parseP('\x1b[D'); assert.deepEqual(getCursor(bufferService), [8, 9]); bufferService.buffer.x = -10000; bufferService.buffer.y = -10000; - inputHandler.parse('\x1b[D'); + await inputHandler.parseP('\x1b[D'); assert.deepEqual(getCursor(bufferService), [0, 0]); }); - it('CUD', () => { + it('CUD', async () => { bufferService.buffer.x = 10000; bufferService.buffer.y = 10000; - inputHandler.parse('\x1b[B'); + await inputHandler.parseP('\x1b[B'); assert.deepEqual(getCursor(bufferService), [9, 9]); bufferService.buffer.x = -10000; bufferService.buffer.y = -10000; - inputHandler.parse('\x1b[B'); + await inputHandler.parseP('\x1b[B'); assert.deepEqual(getCursor(bufferService), [0, 1]); }); - it('CUU', () => { + it('CUU', async () => { bufferService.buffer.x = 10000; bufferService.buffer.y = 10000; - inputHandler.parse('\x1b[A'); + await inputHandler.parseP('\x1b[A'); assert.deepEqual(getCursor(bufferService), [9, 8]); bufferService.buffer.x = -10000; bufferService.buffer.y = -10000; - inputHandler.parse('\x1b[A'); + await inputHandler.parseP('\x1b[A'); assert.deepEqual(getCursor(bufferService), [0, 0]); }); - it('CNL', () => { + it('CNL', async () => { bufferService.buffer.x = 10000; bufferService.buffer.y = 10000; - inputHandler.parse('\x1b[E'); + await inputHandler.parseP('\x1b[E'); assert.deepEqual(getCursor(bufferService), [0, 9]); bufferService.buffer.x = -10000; bufferService.buffer.y = -10000; - inputHandler.parse('\x1b[E'); + await inputHandler.parseP('\x1b[E'); assert.deepEqual(getCursor(bufferService), [0, 1]); }); - it('CPL', () => { + it('CPL', async () => { bufferService.buffer.x = 10000; bufferService.buffer.y = 10000; - inputHandler.parse('\x1b[F'); + await inputHandler.parseP('\x1b[F'); assert.deepEqual(getCursor(bufferService), [0, 8]); bufferService.buffer.x = -10000; bufferService.buffer.y = -10000; - inputHandler.parse('\x1b[F'); + await inputHandler.parseP('\x1b[F'); assert.deepEqual(getCursor(bufferService), [0, 0]); }); - it('CHA', () => { + it('CHA', async () => { bufferService.buffer.x = 10000; bufferService.buffer.y = 10000; - inputHandler.parse('\x1b[5G'); + await inputHandler.parseP('\x1b[5G'); assert.deepEqual(getCursor(bufferService), [4, 9]); bufferService.buffer.x = -10000; bufferService.buffer.y = -10000; - inputHandler.parse('\x1b[5G'); + await inputHandler.parseP('\x1b[5G'); assert.deepEqual(getCursor(bufferService), [4, 0]); }); - it('CUP', () => { + it('CUP', async () => { bufferService.buffer.x = 10000; bufferService.buffer.y = 10000; - inputHandler.parse('\x1b[5;5H'); + await inputHandler.parseP('\x1b[5;5H'); assert.deepEqual(getCursor(bufferService), [4, 4]); bufferService.buffer.x = -10000; bufferService.buffer.y = -10000; - inputHandler.parse('\x1b[5;5H'); + await inputHandler.parseP('\x1b[5;5H'); assert.deepEqual(getCursor(bufferService), [4, 4]); }); - it('HPA', () => { + it('HPA', async () => { bufferService.buffer.x = 10000; bufferService.buffer.y = 10000; - inputHandler.parse('\x1b[5`'); + await inputHandler.parseP('\x1b[5`'); assert.deepEqual(getCursor(bufferService), [4, 9]); bufferService.buffer.x = -10000; bufferService.buffer.y = -10000; - inputHandler.parse('\x1b[5`'); + await inputHandler.parseP('\x1b[5`'); assert.deepEqual(getCursor(bufferService), [4, 0]); }); - it('HPR', () => { + it('HPR', async () => { bufferService.buffer.x = 10000; bufferService.buffer.y = 10000; - inputHandler.parse('\x1b[a'); + await inputHandler.parseP('\x1b[a'); assert.deepEqual(getCursor(bufferService), [9, 9]); bufferService.buffer.x = -10000; bufferService.buffer.y = -10000; - inputHandler.parse('\x1b[a'); + await inputHandler.parseP('\x1b[a'); assert.deepEqual(getCursor(bufferService), [1, 0]); }); - it('VPA', () => { + it('VPA', async () => { bufferService.buffer.x = 10000; bufferService.buffer.y = 10000; - inputHandler.parse('\x1b[5d'); + await inputHandler.parseP('\x1b[5d'); assert.deepEqual(getCursor(bufferService), [9, 4]); bufferService.buffer.x = -10000; bufferService.buffer.y = -10000; - inputHandler.parse('\x1b[5d'); + await inputHandler.parseP('\x1b[5d'); assert.deepEqual(getCursor(bufferService), [0, 4]); }); - it('VPR', () => { + it('VPR', async () => { bufferService.buffer.x = 10000; bufferService.buffer.y = 10000; - inputHandler.parse('\x1b[e'); + await inputHandler.parseP('\x1b[e'); assert.deepEqual(getCursor(bufferService), [9, 9]); bufferService.buffer.x = -10000; bufferService.buffer.y = -10000; - inputHandler.parse('\x1b[e'); + await inputHandler.parseP('\x1b[e'); assert.deepEqual(getCursor(bufferService), [0, 1]); }); - it('DCH', () => { + it('DCH', async () => { bufferService.buffer.x = 10000; bufferService.buffer.y = 10000; - inputHandler.parse('\x1b[P'); + await inputHandler.parseP('\x1b[P'); assert.deepEqual(getCursor(bufferService), [9, 9]); bufferService.buffer.x = -10000; bufferService.buffer.y = -10000; - inputHandler.parse('\x1b[P'); + await inputHandler.parseP('\x1b[P'); assert.deepEqual(getCursor(bufferService), [0, 0]); }); - it('DCH - should delete last cell', () => { - inputHandler.parse('0123456789\x1b[P'); + it('DCH - should delete last cell', async () => { + await inputHandler.parseP('0123456789\x1b[P'); assert.equal(bufferService.buffer.lines.get(0)!.translateToString(false), '012345678 '); }); - it('ECH', () => { + it('ECH', async () => { bufferService.buffer.x = 10000; bufferService.buffer.y = 10000; - inputHandler.parse('\x1b[X'); + await inputHandler.parseP('\x1b[X'); assert.deepEqual(getCursor(bufferService), [9, 9]); bufferService.buffer.x = -10000; bufferService.buffer.y = -10000; - inputHandler.parse('\x1b[X'); + await inputHandler.parseP('\x1b[X'); assert.deepEqual(getCursor(bufferService), [0, 0]); }); - it('ECH - should delete last cell', () => { - inputHandler.parse('0123456789\x1b[X'); + it('ECH - should delete last cell', async () => { + await inputHandler.parseP('0123456789\x1b[X'); assert.equal(bufferService.buffer.lines.get(0)!.translateToString(false), '012345678 '); }); - it('ICH', () => { + it('ICH', async () => { bufferService.buffer.x = 10000; bufferService.buffer.y = 10000; - inputHandler.parse('\x1b[@'); + await inputHandler.parseP('\x1b[@'); assert.deepEqual(getCursor(bufferService), [9, 9]); bufferService.buffer.x = -10000; bufferService.buffer.y = -10000; - inputHandler.parse('\x1b[@'); + await inputHandler.parseP('\x1b[@'); assert.deepEqual(getCursor(bufferService), [0, 0]); }); - it('ICH - should delete last cell', () => { - inputHandler.parse('0123456789\x1b[@'); + it('ICH - should delete last cell', async () => { + await inputHandler.parseP('0123456789\x1b[@'); assert.equal(bufferService.buffer.lines.get(0)!.translateToString(false), '012345678 '); }); }); @@ -1093,31 +1105,31 @@ describe('InputHandler', () => { beforeEach(() => { bufferService.resize(10, 10); }); - it('should default to whole viewport', () => { - inputHandler.parse('\x1b[r'); + it('should default to whole viewport', async () => { + await inputHandler.parseP('\x1b[r'); assert.equal(bufferService.buffer.scrollTop, 0); assert.equal(bufferService.buffer.scrollBottom, 9); - inputHandler.parse('\x1b[3;7r'); + await inputHandler.parseP('\x1b[3;7r'); assert.equal(bufferService.buffer.scrollTop, 2); assert.equal(bufferService.buffer.scrollBottom, 6); - inputHandler.parse('\x1b[0;0r'); + await inputHandler.parseP('\x1b[0;0r'); assert.equal(bufferService.buffer.scrollTop, 0); assert.equal(bufferService.buffer.scrollBottom, 9); }); - it('should clamp bottom', () => { - inputHandler.parse('\x1b[3;1000r'); + it('should clamp bottom', async () => { + await inputHandler.parseP('\x1b[3;1000r'); assert.equal(bufferService.buffer.scrollTop, 2); assert.equal(bufferService.buffer.scrollBottom, 9); }); - it('should only apply for top < bottom', () => { - inputHandler.parse('\x1b[7;2r'); + it('should only apply for top < bottom', async () => { + await inputHandler.parseP('\x1b[7;2r'); assert.equal(bufferService.buffer.scrollTop, 0); assert.equal(bufferService.buffer.scrollBottom, 9); }); - it('should home cursor', () => { + it('should home cursor', async () => { bufferService.buffer.x = 10000; bufferService.buffer.y = 10000; - inputHandler.parse('\x1b[2;7r'); + await inputHandler.parseP('\x1b[2;7r'); assert.deepEqual(getCursor(bufferService), [0, 0]); }); }); @@ -1125,76 +1137,76 @@ describe('InputHandler', () => { beforeEach(() => { bufferService.resize(10, 10); }); - it('scrollUp', () => { - inputHandler.parse('0\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\x1b[2;4r\x1b[2Sm'); + it('scrollUp', async () => { + await inputHandler.parseP('0\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\x1b[2;4r\x1b[2Sm'); assert.deepEqual(getLines(bufferService), ['m', '3', '', '', '4', '5', '6', '7', '8', '9']); }); - it('scrollDown', () => { - inputHandler.parse('0\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\x1b[2;4r\x1b[2Tm'); + it('scrollDown', async () => { + await inputHandler.parseP('0\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\x1b[2;4r\x1b[2Tm'); assert.deepEqual(getLines(bufferService), ['m', '', '', '1', '4', '5', '6', '7', '8', '9']); }); - it('insertLines - out of margins', () => { - inputHandler.parse('0\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\x1b[3;6r'); + it('insertLines - out of margins', async () => { + await inputHandler.parseP('0\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\x1b[3;6r'); assert.equal(bufferService.buffer.scrollTop, 2); assert.equal(bufferService.buffer.scrollBottom, 5); - inputHandler.parse('\x1b[2Lm'); + await inputHandler.parseP('\x1b[2Lm'); assert.deepEqual(getLines(bufferService), ['m', '1', '2', '3', '4', '5', '6', '7', '8', '9']); - inputHandler.parse('\x1b[2H\x1b[2Ln'); + await inputHandler.parseP('\x1b[2H\x1b[2Ln'); assert.deepEqual(getLines(bufferService), ['m', 'n', '2', '3', '4', '5', '6', '7', '8', '9']); // skip below scrollbottom - inputHandler.parse('\x1b[7H\x1b[2Lo'); + await inputHandler.parseP('\x1b[7H\x1b[2Lo'); assert.deepEqual(getLines(bufferService), ['m', 'n', '2', '3', '4', '5', 'o', '7', '8', '9']); - inputHandler.parse('\x1b[8H\x1b[2Lp'); + await inputHandler.parseP('\x1b[8H\x1b[2Lp'); assert.deepEqual(getLines(bufferService), ['m', 'n', '2', '3', '4', '5', 'o', 'p', '8', '9']); - inputHandler.parse('\x1b[100H\x1b[2Lq'); + await inputHandler.parseP('\x1b[100H\x1b[2Lq'); assert.deepEqual(getLines(bufferService), ['m', 'n', '2', '3', '4', '5', 'o', 'p', '8', 'q']); }); - it('insertLines - within margins', () => { - inputHandler.parse('0\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\x1b[3;6r'); + it('insertLines - within margins', async () => { + await inputHandler.parseP('0\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\x1b[3;6r'); assert.equal(bufferService.buffer.scrollTop, 2); assert.equal(bufferService.buffer.scrollBottom, 5); - inputHandler.parse('\x1b[3H\x1b[2Lm'); + await inputHandler.parseP('\x1b[3H\x1b[2Lm'); assert.deepEqual(getLines(bufferService), ['0', '1', 'm', '', '2', '3', '6', '7', '8', '9']); - inputHandler.parse('\x1b[6H\x1b[2Ln'); + await inputHandler.parseP('\x1b[6H\x1b[2Ln'); assert.deepEqual(getLines(bufferService), ['0', '1', 'm', '', '2', 'n', '6', '7', '8', '9']); }); - it('deleteLines - out of margins', () => { - inputHandler.parse('0\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\x1b[3;6r'); + it('deleteLines - out of margins', async () => { + await inputHandler.parseP('0\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\x1b[3;6r'); assert.equal(bufferService.buffer.scrollTop, 2); assert.equal(bufferService.buffer.scrollBottom, 5); - inputHandler.parse('\x1b[2Mm'); + await inputHandler.parseP('\x1b[2Mm'); assert.deepEqual(getLines(bufferService), ['m', '1', '2', '3', '4', '5', '6', '7', '8', '9']); - inputHandler.parse('\x1b[2H\x1b[2Mn'); + await inputHandler.parseP('\x1b[2H\x1b[2Mn'); assert.deepEqual(getLines(bufferService), ['m', 'n', '2', '3', '4', '5', '6', '7', '8', '9']); // skip below scrollbottom - inputHandler.parse('\x1b[7H\x1b[2Mo'); + await inputHandler.parseP('\x1b[7H\x1b[2Mo'); assert.deepEqual(getLines(bufferService), ['m', 'n', '2', '3', '4', '5', 'o', '7', '8', '9']); - inputHandler.parse('\x1b[8H\x1b[2Mp'); + await inputHandler.parseP('\x1b[8H\x1b[2Mp'); assert.deepEqual(getLines(bufferService), ['m', 'n', '2', '3', '4', '5', 'o', 'p', '8', '9']); - inputHandler.parse('\x1b[100H\x1b[2Mq'); + await inputHandler.parseP('\x1b[100H\x1b[2Mq'); assert.deepEqual(getLines(bufferService), ['m', 'n', '2', '3', '4', '5', 'o', 'p', '8', 'q']); }); - it('deleteLines - within margins', () => { - inputHandler.parse('0\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\x1b[3;6r'); + it('deleteLines - within margins', async () => { + await inputHandler.parseP('0\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\x1b[3;6r'); assert.equal(bufferService.buffer.scrollTop, 2); assert.equal(bufferService.buffer.scrollBottom, 5); - inputHandler.parse('\x1b[6H\x1b[2Mm'); + await inputHandler.parseP('\x1b[6H\x1b[2Mm'); assert.deepEqual(getLines(bufferService), ['0', '1', '2', '3', '4', 'm', '6', '7', '8', '9']); - inputHandler.parse('\x1b[3H\x1b[2Mn'); + await inputHandler.parseP('\x1b[3H\x1b[2Mn'); assert.deepEqual(getLines(bufferService), ['0', '1', 'n', 'm', '', '', '6', '7', '8', '9']); }); }); - it('should parse big chunks in smaller subchunks', () => { + it('should parse big chunks in smaller subchunks', async () => { // max single chunk size is hardcoded as 131072 const calls: any[] = []; bufferService.resize(10, 10); (inputHandler as any)._parser.parse = (data: Uint32Array, length: number) => { calls.push([data.length, length]); }; - inputHandler.parse('12345'); - inputHandler.parse('a'.repeat(10000)); - inputHandler.parse('a'.repeat(200000)); - inputHandler.parse('a'.repeat(300000)); + await inputHandler.parseP('12345'); + await inputHandler.parseP('a'.repeat(10000)); + await inputHandler.parseP('a'.repeat(200000)); + await inputHandler.parseP('a'.repeat(300000)); assert.deepEqual(calls, [ [4096, 5], [10000, 10000], @@ -1203,187 +1215,187 @@ describe('InputHandler', () => { ]); }); describe('windowOptions', () => { - it('all should be disabled by default and not report', () => { + it('all should be disabled by default and not report', async () => { bufferService.resize(10, 10); const stack: string[] = []; coreService.onData(data => stack.push(data)); - inputHandler.parse('\x1b[14t'); - inputHandler.parse('\x1b[16t'); - inputHandler.parse('\x1b[18t'); - inputHandler.parse('\x1b[20t'); - inputHandler.parse('\x1b[21t'); + await inputHandler.parseP('\x1b[14t'); + await inputHandler.parseP('\x1b[16t'); + await inputHandler.parseP('\x1b[18t'); + await inputHandler.parseP('\x1b[20t'); + await inputHandler.parseP('\x1b[21t'); assert.deepEqual(stack, []); }); - it('14 - GetWinSizePixels', () => { + it('14 - GetWinSizePixels', async () => { bufferService.resize(10, 10); optionsService.options.windowOptions.getWinSizePixels = true; const stack: string[] = []; coreService.onData(data => stack.push(data)); - inputHandler.parse('\x1b[14t'); + await inputHandler.parseP('\x1b[14t'); // does not report in test terminal due to missing renderer assert.deepEqual(stack, []); }); - it('16 - GetCellSizePixels', () => { + it('16 - GetCellSizePixels', async () => { bufferService.resize(10, 10); optionsService.options.windowOptions.getCellSizePixels = true; const stack: string[] = []; coreService.onData(data => stack.push(data)); - inputHandler.parse('\x1b[16t'); + await inputHandler.parseP('\x1b[16t'); // does not report in test terminal due to missing renderer assert.deepEqual(stack, []); }); - it('18 - GetWinSizeChars', () => { + it('18 - GetWinSizeChars', async () => { bufferService.resize(10, 10); optionsService.options.windowOptions.getWinSizeChars = true; const stack: string[] = []; coreService.onData(data => stack.push(data)); - inputHandler.parse('\x1b[18t'); + await inputHandler.parseP('\x1b[18t'); assert.deepEqual(stack, ['\x1b[8;10;10t']); bufferService.resize(50, 20); - inputHandler.parse('\x1b[18t'); + await inputHandler.parseP('\x1b[18t'); assert.deepEqual(stack, ['\x1b[8;10;10t', '\x1b[8;20;50t']); }); - it('22/23 - PushTitle/PopTitle', () => { + it('22/23 - PushTitle/PopTitle', async () => { bufferService.resize(10, 10); optionsService.options.windowOptions.pushTitle = true; optionsService.options.windowOptions.popTitle = true; const stack: string[] = []; inputHandler.onTitleChange(data => stack.push(data)); - inputHandler.parse('\x1b]0;1\x07'); - inputHandler.parse('\x1b[22t'); - inputHandler.parse('\x1b]0;2\x07'); - inputHandler.parse('\x1b[22t'); - inputHandler.parse('\x1b]0;3\x07'); - inputHandler.parse('\x1b[22t'); + await inputHandler.parseP('\x1b]0;1\x07'); + await inputHandler.parseP('\x1b[22t'); + await inputHandler.parseP('\x1b]0;2\x07'); + await inputHandler.parseP('\x1b[22t'); + await inputHandler.parseP('\x1b]0;3\x07'); + await inputHandler.parseP('\x1b[22t'); assert.deepEqual(inputHandler.windowTitleStack, ['1', '2', '3']); assert.deepEqual(inputHandler.iconNameStack, ['1', '2', '3']); assert.deepEqual(stack, ['1', '2', '3']); - inputHandler.parse('\x1b[23t'); - inputHandler.parse('\x1b[23t'); - inputHandler.parse('\x1b[23t'); - inputHandler.parse('\x1b[23t'); // one more to test "overflow" + await inputHandler.parseP('\x1b[23t'); + await inputHandler.parseP('\x1b[23t'); + await inputHandler.parseP('\x1b[23t'); + await inputHandler.parseP('\x1b[23t'); // one more to test "overflow" assert.deepEqual(inputHandler.windowTitleStack, []); assert.deepEqual(inputHandler.iconNameStack, []); assert.deepEqual(stack, ['1', '2', '3', '3', '2', '1']); }); - it('22/23 - PushTitle/PopTitle with ;1', () => { + it('22/23 - PushTitle/PopTitle with ;1', async () => { bufferService.resize(10, 10); optionsService.options.windowOptions.pushTitle = true; optionsService.options.windowOptions.popTitle = true; const stack: string[] = []; inputHandler.onTitleChange(data => stack.push(data)); - inputHandler.parse('\x1b]0;1\x07'); - inputHandler.parse('\x1b[22;1t'); - inputHandler.parse('\x1b]0;2\x07'); - inputHandler.parse('\x1b[22;1t'); - inputHandler.parse('\x1b]0;3\x07'); - inputHandler.parse('\x1b[22;1t'); + await inputHandler.parseP('\x1b]0;1\x07'); + await inputHandler.parseP('\x1b[22;1t'); + await inputHandler.parseP('\x1b]0;2\x07'); + await inputHandler.parseP('\x1b[22;1t'); + await inputHandler.parseP('\x1b]0;3\x07'); + await inputHandler.parseP('\x1b[22;1t'); assert.deepEqual(inputHandler.windowTitleStack, []); assert.deepEqual(inputHandler.iconNameStack, ['1', '2', '3']); assert.deepEqual(stack, ['1', '2', '3']); - inputHandler.parse('\x1b[23;1t'); - inputHandler.parse('\x1b[23;1t'); - inputHandler.parse('\x1b[23;1t'); - inputHandler.parse('\x1b[23;1t'); // one more to test "overflow" + await inputHandler.parseP('\x1b[23;1t'); + await inputHandler.parseP('\x1b[23;1t'); + await inputHandler.parseP('\x1b[23;1t'); + await inputHandler.parseP('\x1b[23;1t'); // one more to test "overflow" assert.deepEqual(inputHandler.windowTitleStack, []); assert.deepEqual(inputHandler.iconNameStack, []); assert.deepEqual(stack, ['1', '2', '3']); }); - it('22/23 - PushTitle/PopTitle with ;2', () => { + it('22/23 - PushTitle/PopTitle with ;2', async () => { bufferService.resize(10, 10); optionsService.options.windowOptions.pushTitle = true; optionsService.options.windowOptions.popTitle = true; const stack: string[] = []; inputHandler.onTitleChange(data => stack.push(data)); - inputHandler.parse('\x1b]0;1\x07'); - inputHandler.parse('\x1b[22;2t'); - inputHandler.parse('\x1b]0;2\x07'); - inputHandler.parse('\x1b[22;2t'); - inputHandler.parse('\x1b]0;3\x07'); - inputHandler.parse('\x1b[22;2t'); + await inputHandler.parseP('\x1b]0;1\x07'); + await inputHandler.parseP('\x1b[22;2t'); + await inputHandler.parseP('\x1b]0;2\x07'); + await inputHandler.parseP('\x1b[22;2t'); + await inputHandler.parseP('\x1b]0;3\x07'); + await inputHandler.parseP('\x1b[22;2t'); assert.deepEqual(inputHandler.windowTitleStack, ['1', '2', '3']); assert.deepEqual(inputHandler.iconNameStack, []); assert.deepEqual(stack, ['1', '2', '3']); - inputHandler.parse('\x1b[23;2t'); - inputHandler.parse('\x1b[23;2t'); - inputHandler.parse('\x1b[23;2t'); - inputHandler.parse('\x1b[23;2t'); // one more to test "overflow" + await inputHandler.parseP('\x1b[23;2t'); + await inputHandler.parseP('\x1b[23;2t'); + await inputHandler.parseP('\x1b[23;2t'); + await inputHandler.parseP('\x1b[23;2t'); // one more to test "overflow" assert.deepEqual(inputHandler.windowTitleStack, []); assert.deepEqual(inputHandler.iconNameStack, []); assert.deepEqual(stack, ['1', '2', '3', '3', '2', '1']); }); - it('DECCOLM - should only work with "SetWinLines" (24) enabled', () => { + it('DECCOLM - should only work with "SetWinLines" (24) enabled', async () => { // disabled bufferService.resize(10, 10); - inputHandler.parse('\x1b[?3l'); + await inputHandler.parseP('\x1b[?3l'); assert.equal(bufferService.cols, 10); - inputHandler.parse('\x1b[?3h'); + await inputHandler.parseP('\x1b[?3h'); assert.equal(bufferService.cols, 10); // enabled inputHandler.reset(); optionsService.options.windowOptions.setWinLines = true; - inputHandler.parse('\x1b[?3l'); + await inputHandler.parseP('\x1b[?3l'); assert.equal(bufferService.cols, 80); - inputHandler.parse('\x1b[?3h'); + await inputHandler.parseP('\x1b[?3h'); assert.equal(bufferService.cols, 132); }); }); describe('should correctly reset cells taken by wide chars', () => { - beforeEach(() => { + beforeEach(async () => { bufferService.resize(10, 5); optionsService.options.scrollback = 1; - inputHandler.parse('¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥'); + await inputHandler.parseP('¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥'); }); - it('print', () => { - inputHandler.parse('\x1b[H#'); + it('print', async () => { + await inputHandler.parseP('\x1b[H#'); assert.deepEqual(getLines(bufferService), ['# ¥¥¥¥', '¥¥¥¥¥', '¥¥¥¥¥', '¥¥¥¥¥', '']); - inputHandler.parse('\x1b[1;6H######'); + await inputHandler.parseP('\x1b[1;6H######'); assert.deepEqual(getLines(bufferService), ['# ¥ #####', '# ¥¥¥¥', '¥¥¥¥¥', '¥¥¥¥¥', '']); - inputHandler.parse('#'); + await inputHandler.parseP('#'); assert.deepEqual(getLines(bufferService), ['# ¥ #####', '##¥¥¥¥', '¥¥¥¥¥', '¥¥¥¥¥', '']); - inputHandler.parse('#'); + await inputHandler.parseP('#'); assert.deepEqual(getLines(bufferService), ['# ¥ #####', '### ¥¥¥', '¥¥¥¥¥', '¥¥¥¥¥', '']); - inputHandler.parse('\x1b[3;9H#'); + await inputHandler.parseP('\x1b[3;9H#'); assert.deepEqual(getLines(bufferService), ['# ¥ #####', '### ¥¥¥', '¥¥¥¥#', '¥¥¥¥¥', '']); - inputHandler.parse('#'); + await inputHandler.parseP('#'); assert.deepEqual(getLines(bufferService), ['# ¥ #####', '### ¥¥¥', '¥¥¥¥##', '¥¥¥¥¥', '']); - inputHandler.parse('#'); + await inputHandler.parseP('#'); assert.deepEqual(getLines(bufferService), ['# ¥ #####', '### ¥¥¥', '¥¥¥¥##', '# ¥¥¥¥', '']); - inputHandler.parse('\x1b[4;10H#'); + await inputHandler.parseP('\x1b[4;10H#'); assert.deepEqual(getLines(bufferService), ['# ¥ #####', '### ¥¥¥', '¥¥¥¥##', '# ¥¥¥ #', '']); }); - it('EL', () => { - inputHandler.parse('\x1b[1;6H\x1b[K#'); + it('EL', async () => { + await inputHandler.parseP('\x1b[1;6H\x1b[K#'); assert.deepEqual(getLines(bufferService), ['¥¥ #', '¥¥¥¥¥', '¥¥¥¥¥', '¥¥¥¥¥', '']); - inputHandler.parse('\x1b[2;5H\x1b[1K'); + await inputHandler.parseP('\x1b[2;5H\x1b[1K'); assert.deepEqual(getLines(bufferService), ['¥¥ #', ' ¥¥', '¥¥¥¥¥', '¥¥¥¥¥', '']); - inputHandler.parse('\x1b[3;6H\x1b[1K'); + await inputHandler.parseP('\x1b[3;6H\x1b[1K'); assert.deepEqual(getLines(bufferService), ['¥¥ #', ' ¥¥', ' ¥¥', '¥¥¥¥¥', '']); }); - it('ICH', () => { - inputHandler.parse('\x1b[1;6H\x1b[@'); + it('ICH', async () => { + await inputHandler.parseP('\x1b[1;6H\x1b[@'); assert.deepEqual(getLines(bufferService), ['¥¥ ¥', '¥¥¥¥¥', '¥¥¥¥¥', '¥¥¥¥¥', '']); - inputHandler.parse('\x1b[2;4H\x1b[2@'); + await inputHandler.parseP('\x1b[2;4H\x1b[2@'); assert.deepEqual(getLines(bufferService), ['¥¥ ¥', '¥ ¥¥', '¥¥¥¥¥', '¥¥¥¥¥', '']); - inputHandler.parse('\x1b[3;4H\x1b[3@'); + await inputHandler.parseP('\x1b[3;4H\x1b[3@'); assert.deepEqual(getLines(bufferService), ['¥¥ ¥', '¥ ¥¥', '¥ ¥', '¥¥¥¥¥', '']); - inputHandler.parse('\x1b[4;4H\x1b[4@'); + await inputHandler.parseP('\x1b[4;4H\x1b[4@'); assert.deepEqual(getLines(bufferService), ['¥¥ ¥', '¥ ¥¥', '¥ ¥', '¥ ¥', '']); }); - it('DCH', () => { - inputHandler.parse('\x1b[1;6H\x1b[P'); + it('DCH', async () => { + await inputHandler.parseP('\x1b[1;6H\x1b[P'); assert.deepEqual(getLines(bufferService), ['¥¥ ¥¥', '¥¥¥¥¥', '¥¥¥¥¥', '¥¥¥¥¥', '']); - inputHandler.parse('\x1b[2;6H\x1b[2P'); + await inputHandler.parseP('\x1b[2;6H\x1b[2P'); assert.deepEqual(getLines(bufferService), ['¥¥ ¥¥', '¥¥ ¥', '¥¥¥¥¥', '¥¥¥¥¥', '']); - inputHandler.parse('\x1b[3;6H\x1b[3P'); + await inputHandler.parseP('\x1b[3;6H\x1b[3P'); assert.deepEqual(getLines(bufferService), ['¥¥ ¥¥', '¥¥ ¥', '¥¥ ¥', '¥¥¥¥¥', '']); }); - it('ECH', () => { - inputHandler.parse('\x1b[1;6H\x1b[X'); + it('ECH', async () => { + await inputHandler.parseP('\x1b[1;6H\x1b[X'); assert.deepEqual(getLines(bufferService), ['¥¥ ¥¥', '¥¥¥¥¥', '¥¥¥¥¥', '¥¥¥¥¥', '']); - inputHandler.parse('\x1b[2;6H\x1b[2X'); + await inputHandler.parseP('\x1b[2;6H\x1b[2X'); assert.deepEqual(getLines(bufferService), ['¥¥ ¥¥', '¥¥ ¥', '¥¥¥¥¥', '¥¥¥¥¥', '']); - inputHandler.parse('\x1b[3;6H\x1b[3X'); + await inputHandler.parseP('\x1b[3;6H\x1b[3X'); assert.deepEqual(getLines(bufferService), ['¥¥ ¥¥', '¥¥ ¥', '¥¥ ¥', '¥¥¥¥¥', '']); }); }); @@ -1395,74 +1407,74 @@ describe('InputHandler', () => { optionsService.options.scrollback = 1; }); describe('reverseWraparound unset (default)', () => { - it('cannot delete last cell', () => { - inputHandler.parse('12345'); - inputHandler.parse(ttyBS); + it('cannot delete last cell', async () => { + await inputHandler.parseP('12345'); + await inputHandler.parseP(ttyBS); assert.deepEqual(getLines(bufferService, 1), ['123 5']); - inputHandler.parse(ttyBS.repeat(10)); + await inputHandler.parseP(ttyBS.repeat(10)); assert.deepEqual(getLines(bufferService, 1), [' 5']); }); - it('cannot access prev line', () => { - inputHandler.parse('12345'.repeat(2)); - inputHandler.parse(ttyBS); + it('cannot access prev line', async () => { + await inputHandler.parseP('12345'.repeat(2)); + await inputHandler.parseP(ttyBS); assert.deepEqual(getLines(bufferService, 2), ['12345', '123 5']); - inputHandler.parse(ttyBS.repeat(10)); + await inputHandler.parseP(ttyBS.repeat(10)); assert.deepEqual(getLines(bufferService, 2), ['12345', ' 5']); }); }); describe('reverseWraparound set', () => { - it('can delete last cell', () => { - inputHandler.parse('\x1b[?45h'); - inputHandler.parse('12345'); - inputHandler.parse(ttyBS); + it('can delete last cell', async () => { + await inputHandler.parseP('\x1b[?45h'); + await inputHandler.parseP('12345'); + await inputHandler.parseP(ttyBS); assert.deepEqual(getLines(bufferService, 1), ['1234 ']); - inputHandler.parse(ttyBS.repeat(7)); + await inputHandler.parseP(ttyBS.repeat(7)); assert.deepEqual(getLines(bufferService, 1), [' ']); }); - it('can access prev line if wrapped', () => { - inputHandler.parse('\x1b[?45h'); - inputHandler.parse('12345'.repeat(2)); - inputHandler.parse(ttyBS); + it('can access prev line if wrapped', async () => { + await inputHandler.parseP('\x1b[?45h'); + await inputHandler.parseP('12345'.repeat(2)); + await inputHandler.parseP(ttyBS); assert.deepEqual(getLines(bufferService, 2), ['12345', '1234 ']); - inputHandler.parse(ttyBS.repeat(7)); + await inputHandler.parseP(ttyBS.repeat(7)); assert.deepEqual(getLines(bufferService, 2), ['12 ', ' ']); }); - it('should lift isWrapped', () => { - inputHandler.parse('\x1b[?45h'); - inputHandler.parse('12345'.repeat(2)); + it('should lift isWrapped', async () => { + await inputHandler.parseP('\x1b[?45h'); + await inputHandler.parseP('12345'.repeat(2)); assert.equal(bufferService.buffer.lines.get(1)?.isWrapped, true); - inputHandler.parse(ttyBS.repeat(7)); + await inputHandler.parseP(ttyBS.repeat(7)); assert.equal(bufferService.buffer.lines.get(1)?.isWrapped, false); }); - it('stops at hard NLs', () => { - inputHandler.parse('\x1b[?45h'); - inputHandler.parse('12345\r\n'); - inputHandler.parse('12345'.repeat(2)); - inputHandler.parse(ttyBS.repeat(50)); + it('stops at hard NLs', async () => { + await inputHandler.parseP('\x1b[?45h'); + await inputHandler.parseP('12345\r\n'); + await inputHandler.parseP('12345'.repeat(2)); + await inputHandler.parseP(ttyBS.repeat(50)); assert.deepEqual(getLines(bufferService, 3), ['12345', ' ', ' ']); assert.equal(bufferService.buffer.x, 0); assert.equal(bufferService.buffer.y, 1); }); - it('handles wide chars correctly', () => { - inputHandler.parse('\x1b[?45h'); - inputHandler.parse('¥¥¥'); + it('handles wide chars correctly', async () => { + await inputHandler.parseP('\x1b[?45h'); + await inputHandler.parseP('¥¥¥'); assert.deepEqual(getLines(bufferService, 2), ['¥¥', '¥']); - inputHandler.parse(ttyBS); + await inputHandler.parseP(ttyBS); assert.deepEqual(getLines(bufferService, 2), ['¥¥', ' ']); assert.equal(bufferService.buffer.x, 1); - inputHandler.parse(ttyBS); + await inputHandler.parseP(ttyBS); assert.deepEqual(getLines(bufferService, 2), ['¥¥', ' ']); assert.equal(bufferService.buffer.x, 0); - inputHandler.parse(ttyBS); + await inputHandler.parseP(ttyBS); assert.deepEqual(getLines(bufferService, 2), ['¥ ', ' ']); assert.equal(bufferService.buffer.x, 3); // x=4 skipped due to early wrap-around - inputHandler.parse(ttyBS); + await inputHandler.parseP(ttyBS); assert.deepEqual(getLines(bufferService, 2), ['¥ ', ' ']); assert.equal(bufferService.buffer.x, 2); - inputHandler.parse(ttyBS); + await inputHandler.parseP(ttyBS); assert.deepEqual(getLines(bufferService, 2), [' ', ' ']); assert.equal(bufferService.buffer.x, 1); - inputHandler.parse(ttyBS); + await inputHandler.parseP(ttyBS); assert.deepEqual(getLines(bufferService, 2), [' ', ' ']); assert.equal(bufferService.buffer.x, 0); }); @@ -1473,72 +1485,72 @@ describe('InputHandler', () => { beforeEach(() => { bufferService.resize(10, 5); }); - it('4 | 24', () => { - inputHandler.parse('\x1b[4m'); + it('4 | 24', async () => { + await inputHandler.parseP('\x1b[4m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.SINGLE); - inputHandler.parse('\x1b[24m'); + await inputHandler.parseP('\x1b[24m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.NONE); }); - it('21 | 24', () => { - inputHandler.parse('\x1b[21m'); + it('21 | 24', async () => { + await inputHandler.parseP('\x1b[21m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.DOUBLE); - inputHandler.parse('\x1b[24m'); + await inputHandler.parseP('\x1b[24m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.NONE); }); - it('4:1 | 4:0', () => { - inputHandler.parse('\x1b[4:1m'); + it('4:1 | 4:0', async () => { + await inputHandler.parseP('\x1b[4:1m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.SINGLE); - inputHandler.parse('\x1b[4:0m'); + await inputHandler.parseP('\x1b[4:0m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.NONE); - inputHandler.parse('\x1b[4:1m'); + await inputHandler.parseP('\x1b[4:1m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.SINGLE); - inputHandler.parse('\x1b[24m'); + await inputHandler.parseP('\x1b[24m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.NONE); }); - it('4:2 | 4:0', () => { - inputHandler.parse('\x1b[4:2m'); + it('4:2 | 4:0', async () => { + await inputHandler.parseP('\x1b[4:2m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.DOUBLE); - inputHandler.parse('\x1b[4:0m'); + await inputHandler.parseP('\x1b[4:0m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.NONE); - inputHandler.parse('\x1b[4:2m'); + await inputHandler.parseP('\x1b[4:2m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.DOUBLE); - inputHandler.parse('\x1b[24m'); + await inputHandler.parseP('\x1b[24m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.NONE); }); - it('4:3 | 4:0', () => { - inputHandler.parse('\x1b[4:3m'); + it('4:3 | 4:0', async () => { + await inputHandler.parseP('\x1b[4:3m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.CURLY); - inputHandler.parse('\x1b[4:0m'); + await inputHandler.parseP('\x1b[4:0m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.NONE); - inputHandler.parse('\x1b[4:3m'); + await inputHandler.parseP('\x1b[4:3m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.CURLY); - inputHandler.parse('\x1b[24m'); + await inputHandler.parseP('\x1b[24m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.NONE); }); - it('4:4 | 4:0', () => { - inputHandler.parse('\x1b[4:4m'); + it('4:4 | 4:0', async () => { + await inputHandler.parseP('\x1b[4:4m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.DOTTED); - inputHandler.parse('\x1b[4:0m'); + await inputHandler.parseP('\x1b[4:0m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.NONE); - inputHandler.parse('\x1b[4:4m'); + await inputHandler.parseP('\x1b[4:4m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.DOTTED); - inputHandler.parse('\x1b[24m'); + await inputHandler.parseP('\x1b[24m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.NONE); }); - it('4:5 | 4:0', () => { - inputHandler.parse('\x1b[4:5m'); + it('4:5 | 4:0', async () => { + await inputHandler.parseP('\x1b[4:5m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.DASHED); - inputHandler.parse('\x1b[4:0m'); + await inputHandler.parseP('\x1b[4:0m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.NONE); - inputHandler.parse('\x1b[4:5m'); + await inputHandler.parseP('\x1b[4:5m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.DASHED); - inputHandler.parse('\x1b[24m'); + await inputHandler.parseP('\x1b[24m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.NONE); }); - it('4:x --> 4 should revert to single underline', () => { - inputHandler.parse('\x1b[4:5m'); + it('4:x --> 4 should revert to single underline', async () => { + await inputHandler.parseP('\x1b[4:5m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.DASHED); - inputHandler.parse('\x1b[4m'); + await inputHandler.parseP('\x1b[4m'); assert.equal(inputHandler.curAttrData.getUnderlineStyle(), UnderlineStyle.SINGLE); }); }); @@ -1546,9 +1558,9 @@ describe('InputHandler', () => { beforeEach(() => { bufferService.resize(10, 5); }); - it('defaults to FG color', () => { + it('defaults to FG color', async () => { for (const s of ['', '\x1b[30m', '\x1b[38;510m', '\x1b[38;2;1;2;3m']) { - inputHandler.parse(s); + await inputHandler.parseP(s); assert.equal(inputHandler.curAttrData.getUnderlineColor(), inputHandler.curAttrData.getFgColor()); assert.equal(inputHandler.curAttrData.getUnderlineColorMode(), inputHandler.curAttrData.getFgColorMode()); assert.equal(inputHandler.curAttrData.isUnderlineColorRGB(), inputHandler.curAttrData.isFgRGB()); @@ -1556,31 +1568,31 @@ describe('InputHandler', () => { assert.equal(inputHandler.curAttrData.isUnderlineColorDefault(), inputHandler.curAttrData.isFgDefault()); } }); - it('correctly sets P256/RGB colors', () => { - inputHandler.parse('\x1b[4m'); - inputHandler.parse('\x1b[58;5;123m'); + it('correctly sets P256/RGB colors', async () => { + await inputHandler.parseP('\x1b[4m'); + await inputHandler.parseP('\x1b[58;5;123m'); assert.equal(inputHandler.curAttrData.getUnderlineColor(), 123); assert.equal(inputHandler.curAttrData.getUnderlineColorMode(), Attributes.CM_P256); assert.equal(inputHandler.curAttrData.isUnderlineColorRGB(), false); assert.equal(inputHandler.curAttrData.isUnderlineColorPalette(), true); assert.equal(inputHandler.curAttrData.isUnderlineColorDefault(), false); - inputHandler.parse('\x1b[58;2::1:2:3m'); + await inputHandler.parseP('\x1b[58;2::1:2:3m'); assert.equal(inputHandler.curAttrData.getUnderlineColor(), (1 << 16) | (2 << 8) | 3); assert.equal(inputHandler.curAttrData.getUnderlineColorMode(), Attributes.CM_RGB); assert.equal(inputHandler.curAttrData.isUnderlineColorRGB(), true); assert.equal(inputHandler.curAttrData.isUnderlineColorPalette(), false); assert.equal(inputHandler.curAttrData.isUnderlineColorDefault(), false); }); - it('P256/RGB persistence', () => { + it('P256/RGB persistence', async () => { const cell = new CellData(); - inputHandler.parse('\x1b[4m'); - inputHandler.parse('\x1b[58;5;123m'); + await inputHandler.parseP('\x1b[4m'); + await inputHandler.parseP('\x1b[58;5;123m'); assert.equal(inputHandler.curAttrData.getUnderlineColor(), 123); assert.equal(inputHandler.curAttrData.getUnderlineColorMode(), Attributes.CM_P256); assert.equal(inputHandler.curAttrData.isUnderlineColorRGB(), false); assert.equal(inputHandler.curAttrData.isUnderlineColorPalette(), true); assert.equal(inputHandler.curAttrData.isUnderlineColorDefault(), false); - inputHandler.parse('ab'); + await inputHandler.parseP('ab'); bufferService.buffer!.lines.get(0)!.loadCell(1, cell); assert.equal(cell.getUnderlineColor(), 123); assert.equal(cell.getUnderlineColorMode(), Attributes.CM_P256); @@ -1588,13 +1600,13 @@ describe('InputHandler', () => { assert.equal(cell.isUnderlineColorPalette(), true); assert.equal(cell.isUnderlineColorDefault(), false); - inputHandler.parse('\x1b[4:0m'); + await inputHandler.parseP('\x1b[4:0m'); assert.equal(inputHandler.curAttrData.getUnderlineColor(), inputHandler.curAttrData.getFgColor()); assert.equal(inputHandler.curAttrData.getUnderlineColorMode(), inputHandler.curAttrData.getFgColorMode()); assert.equal(inputHandler.curAttrData.isUnderlineColorRGB(), inputHandler.curAttrData.isFgRGB()); assert.equal(inputHandler.curAttrData.isUnderlineColorPalette(), inputHandler.curAttrData.isFgPalette()); assert.equal(inputHandler.curAttrData.isUnderlineColorDefault(), inputHandler.curAttrData.isFgDefault()); - inputHandler.parse('a'); + await inputHandler.parseP('a'); bufferService.buffer!.lines.get(0)!.loadCell(1, cell); assert.equal(cell.getUnderlineColor(), 123); assert.equal(cell.getUnderlineColorMode(), Attributes.CM_P256); @@ -1608,15 +1620,15 @@ describe('InputHandler', () => { assert.equal(cell.isUnderlineColorPalette(), inputHandler.curAttrData.isFgPalette()); assert.equal(cell.isUnderlineColorDefault(), inputHandler.curAttrData.isFgDefault()); - inputHandler.parse('\x1b[4m'); - inputHandler.parse('\x1b[58;2::1:2:3m'); + await inputHandler.parseP('\x1b[4m'); + await inputHandler.parseP('\x1b[58;2::1:2:3m'); assert.equal(inputHandler.curAttrData.getUnderlineColor(), (1 << 16) | (2 << 8) | 3); assert.equal(inputHandler.curAttrData.getUnderlineColorMode(), Attributes.CM_RGB); assert.equal(inputHandler.curAttrData.isUnderlineColorRGB(), true); assert.equal(inputHandler.curAttrData.isUnderlineColorPalette(), false); assert.equal(inputHandler.curAttrData.isUnderlineColorDefault(), false); - inputHandler.parse('a'); - inputHandler.parse('\x1b[24m'); + await inputHandler.parseP('a'); + await inputHandler.parseP('\x1b[24m'); bufferService.buffer!.lines.get(0)!.loadCell(1, cell); assert.equal(cell.getUnderlineColor(), 123); assert.equal(cell.getUnderlineColorMode(), Attributes.CM_P256); @@ -1645,51 +1657,51 @@ describe('InputHandler', () => { }); }); describe('DECSTR', () => { - beforeEach(() => { + beforeEach(async () => { bufferService.resize(10, 5); optionsService.options.scrollback = 1; - inputHandler.parse('01234567890123'); + await inputHandler.parseP('01234567890123'); }); - it('should reset IRM', () => { - inputHandler.parse('\x1b[4h'); + it('should reset IRM', async () => { + await inputHandler.parseP('\x1b[4h'); assert.equal(coreService.modes.insertMode, true); - inputHandler.parse('\x1b[!p'); + await inputHandler.parseP('\x1b[!p'); assert.equal(coreService.modes.insertMode, false); }); - it('should reset cursor visibility', () => { - inputHandler.parse('\x1b[?25l'); + it('should reset cursor visibility', async () => { + await inputHandler.parseP('\x1b[?25l'); assert.equal(coreService.isCursorHidden, true); - inputHandler.parse('\x1b[!p'); + await inputHandler.parseP('\x1b[!p'); assert.equal(coreService.isCursorHidden, false); }); - it('should reset scroll margins', () => { - inputHandler.parse('\x1b[2;4r'); + it('should reset scroll margins', async () => { + await inputHandler.parseP('\x1b[2;4r'); assert.equal(bufferService.buffer.scrollTop, 1); assert.equal(bufferService.buffer.scrollBottom, 3); - inputHandler.parse('\x1b[!p'); + await inputHandler.parseP('\x1b[!p'); assert.equal(bufferService.buffer.scrollTop, 0); assert.equal(bufferService.buffer.scrollBottom, bufferService.rows - 1); }); - it('should reset text attributes', () => { - inputHandler.parse('\x1b[1;2;32;43m'); + it('should reset text attributes', async () => { + await inputHandler.parseP('\x1b[1;2;32;43m'); assert.equal(!!inputHandler.curAttrData.isBold(), true); - inputHandler.parse('\x1b[!p'); + await inputHandler.parseP('\x1b[!p'); assert.equal(!!inputHandler.curAttrData.isBold(), false); assert.equal(inputHandler.curAttrData.fg, 0); assert.equal(inputHandler.curAttrData.bg, 0); }); - it('should reset DECSC data', () => { - inputHandler.parse('\x1b7'); + it('should reset DECSC data', async () => { + await inputHandler.parseP('\x1b7'); assert.equal(bufferService.buffer.savedX, 4); assert.equal(bufferService.buffer.savedY, 1); - inputHandler.parse('\x1b[!p'); + await inputHandler.parseP('\x1b[!p'); assert.equal(bufferService.buffer.savedX, 0); assert.equal(bufferService.buffer.savedY, 0); }); - it('should reset DECOM', () => { - inputHandler.parse('\x1b[?6h'); + it('should reset DECOM', async () => { + await inputHandler.parseP('\x1b[?6h'); assert.equal(coreService.decPrivateModes.origin, true); - inputHandler.parse('\x1b[!p'); + await inputHandler.parseP('\x1b[!p'); assert.equal(coreService.decPrivateModes.origin, false); }); }); @@ -1733,15 +1745,17 @@ describe('InputHandler', () => { assert.equal(event!.colors.length, 1); assert.deepEqual(event!.colors[0], { colorIndex: 19, red: 0xa1, green: 0xb2, blue: 0xc3 }); }); - it('4: should fire event on Ansi color change', (done) => { - inputHandler.onAnsiColorChange(e => { - assert.isNotNull(e); - assert.isNotNull(e!.colors); - assert.deepEqual(e!.colors[0], { colorIndex: 17, red: 0x1a, green: 0x2b, blue: 0x3c }); - assert.deepEqual(e!.colors[1], { colorIndex: 12, red: 0x11, green: 0x22, blue: 0x33 }); - done(); + it('4: should fire event on Ansi color change', async () => { + return new Promise(async r => { + inputHandler.onAnsiColorChange(e => { + assert.isNotNull(e); + assert.isNotNull(e!.colors); + assert.deepEqual(e!.colors[0], { colorIndex: 17, red: 0x1a, green: 0x2b, blue: 0x3c }); + assert.deepEqual(e!.colors[1], { colorIndex: 12, red: 0x11, green: 0x22, blue: 0x33 }); + r(); + }); + await inputHandler.parseP('\x1b]4;17;rgb:1a/2b/3c;12;rgb:11/22/33\x1b\\'); }); - inputHandler.parse('\x1b]4;17;rgb:1a/2b/3c;12;rgb:11/22/33\x1b\\'); }); }); }); From adfeffec764caffe4bfcca15014350f6ea650573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Fri, 22 Jan 2021 21:17:34 +0100 Subject: [PATCH 068/377] deprecate writeSync --- src/browser/Terminal.test.ts | 471 +++++++++++++++++----------------- src/browser/TestUtils.test.ts | 3 + src/common/CoreTerminal.ts | 10 + 3 files changed, 254 insertions(+), 230 deletions(-) diff --git a/src/browser/Terminal.test.ts b/src/browser/Terminal.test.ts index 8626be09..2e09f719 100644 --- a/src/browser/Terminal.test.ts +++ b/src/browser/Terminal.test.ts @@ -55,22 +55,30 @@ describe('Terminal', () => { // term.onData(() => done()); // term.handler('fake'); // }); - it('should fire the onCursorMove event', (done) => { - term.onCursorMove(() => done()); - term.writeSync('foo'); + it('should fire the onCursorMove event', () => { + return new Promise(async r => { + term.onCursorMove(() => r()); + await term.writeP('foo'); + }); }); - it('should fire the onLineFeed event', (done) => { - term.onLineFeed(() => done()); - term.writeSync('\n'); + it('should fire the onLineFeed event', () => { + return new Promise(async r => { + term.onLineFeed(() => r()); + await term.writeP('\n'); + }); }); - it('should fire a scroll event when scrollback is created', (done) => { - term.onScroll(() => done()); - term.writeSync('\n'.repeat(INIT_ROWS)); + it('should fire a scroll event when scrollback is created', () => { + return new Promise(async r => { + term.onScroll(() => r()); + await term.writeP('\n'.repeat(INIT_ROWS)); + }); }); - it('should fire a scroll event when scrollback is cleared', (done) => { - term.writeSync('\n'.repeat(INIT_ROWS)); - term.onScroll(() => done()); - term.clear(); + it('should fire a scroll event when scrollback is cleared', () => { + return new Promise(async r => { + await term.writeP('\n'.repeat(INIT_ROWS)); + term.onScroll(() => r()); + term.clear(); + }); }); it('should fire a key event after a keypress DOM event', (done) => { term.onKey(e => { @@ -178,10 +186,10 @@ describe('Terminal', () => { assert.deepEqual(term.buffer.lines.get(i), term.buffer.getBlankLine(DEFAULT_ATTR_DATA)); } }); - it('should clear a buffer larger than rows', () => { + it('should clear a buffer larger than rows', async () => { // Fill the buffer with dummy rows for (let i = 0; i < term.rows * 2; i++) { - term.writeSync('test\n'); + await term.writeP('test\n'); } const promptLine = term.buffer.lines.get(term.buffer.ybase + term.buffer.y); @@ -225,22 +233,24 @@ describe('Terminal', () => { }); term.paste('\r\nfoo\nbar\r'); }); - it('should respect bracketed paste mode', done => { - term.onData(e => { - assert.equal(e, '\x1b[200~foo\x1b[201~'); - done(); + it('should respect bracketed paste mode', () => { + return new Promise(async r => { + term.onData(e => { + assert.equal(e, '\x1b[200~foo\x1b[201~'); + r(); + }); + await term.writeP('\x1b[?2004h'); + term.paste('foo'); }); - term.writeSync('\x1b[?2004h'); - term.paste('foo'); }); }); describe('scroll', () => { describe('scrollLines', () => { let startYDisp: number; - beforeEach(() => { + beforeEach(async () => { for (let i = 0; i < INIT_ROWS * 2; i++) { - term.writeSync('test\r\n'); + await term.writeP('test\r\n'); } startYDisp = INIT_ROWS + 1; }); @@ -273,9 +283,9 @@ describe('Terminal', () => { describe('scrollPages', () => { let startYDisp: number; - beforeEach(() => { + beforeEach(async () => { for (let i = 0; i < term.rows * 3; i++) { - term.writeSync('test\r\n'); + await term.writeP('test\r\n'); } startYDisp = (term.rows * 2) + 1; }); @@ -296,9 +306,9 @@ describe('Terminal', () => { }); describe('scrollToTop', () => { - beforeEach(() => { + beforeEach(async () => { for (let i = 0; i < term.rows * 3; i++) { - term.writeSync('test\r\n'); + await term.writeP('test\r\n'); } }); it('should scroll to the top', () => { @@ -310,9 +320,9 @@ describe('Terminal', () => { describe('scrollToBottom', () => { let startYDisp: number; - beforeEach(() => { + beforeEach(async () => { for (let i = 0; i < term.rows * 3; i++) { - term.writeSync('test\r\n'); + await term.writeP('test\r\n'); } startYDisp = (term.rows * 2) + 1; }); @@ -331,9 +341,9 @@ describe('Terminal', () => { describe('scrollToLine', () => { let startYDisp: number; - beforeEach(() => { + beforeEach(async () => { for (let i = 0; i < term.rows * 3; i++) { - term.writeSync('test\r\n'); + await term.writeP('test\r\n'); } startYDisp = (term.rows * 2) + 1; }); @@ -375,10 +385,10 @@ describe('Terminal', () => { assert.equal(term.buffer.ydisp, term.buffer.ybase); }); - it('should not scroll down, when a custom keydown handler prevents the event', () => { + it('should not scroll down, when a custom keydown handler prevents the event', async () => { // Add some output to the terminal for (let i = 0; i < term.rows * 3; i++) { - term.writeSync('test\r\n'); + await term.writeP('test\r\n'); } const startYDisp = (term.rows * 2) + 1; term.attachCustomKeyEventHandler(() => { @@ -717,12 +727,12 @@ describe('Terminal', () => { }); describe('unicode - surrogates', () => { - it('2 characters per cell', function (): void { + it('2 characters per cell', async function (): Promise { this.timeout(10000); // This is needed because istanbul patches code and slows it down const high = String.fromCharCode(0xD800); const cell = new CellData(); for (let i = 0xDC00; i <= 0xDCFF; ++i) { - term.writeSync(high + String.fromCharCode(i)); + await term.writeP(high + String.fromCharCode(i)); const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); expect(tchar.getChars()).eql(high + String.fromCharCode(i)); expect(tchar.getChars().length).eql(2); @@ -731,25 +741,25 @@ describe('Terminal', () => { term.reset(); } }); - it('2 characters at last cell', () => { + it('2 characters at last cell', async () => { const high = String.fromCharCode(0xD800); const cell = new CellData(); for (let i = 0xDC00; i <= 0xDCFF; ++i) { term.buffer.x = term.cols - 1; - term.writeSync(high + String.fromCharCode(i)); + await term.writeP(high + String.fromCharCode(i)); expect(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars()).eql(high + String.fromCharCode(i)); expect(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars().length).eql(2); expect(term.buffer.lines.get(1)!.loadCell(0, cell).getChars()).eql(''); term.reset(); } }); - it('2 characters per cell over line end with autowrap', () => { + it('2 characters per cell over line end with autowrap', async () => { const high = String.fromCharCode(0xD800); const cell = new CellData(); for (let i = 0xDC00; i <= 0xDCFF; ++i) { term.buffer.x = term.cols - 1; - term.writeSync('a' + high + String.fromCharCode(i)); + await term.writeP('a' + high + String.fromCharCode(i)); expect(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars()).eql('a'); expect(term.buffer.lines.get(1)!.loadCell(0, cell).getChars()).eql(high + String.fromCharCode(i)); expect(term.buffer.lines.get(1)!.loadCell(0, cell).getChars().length).eql(2); @@ -757,17 +767,17 @@ describe('Terminal', () => { term.reset(); } }); - it('2 characters per cell over line end without autowrap', () => { + it('2 characters per cell over line end without autowrap', async () => { const high = String.fromCharCode(0xD800); const cell = new CellData(); for (let i = 0xDC00; i <= 0xDCFF; ++i) { term.buffer.x = term.cols - 1; - term.writeSync('\x1b[?7l'); // Disable wraparound mode + await term.writeP('\x1b[?7l'); // Disable wraparound mode const width = wcwidth((0xD800 - 0xD800) * 0x400 + i - 0xDC00 + 0x10000); if (width !== 1) { continue; } - term.writeSync('a' + high + String.fromCharCode(i)); + await term.writeP('a' + high + String.fromCharCode(i)); // auto wraparound mode should cut off the rest of the line expect(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars()).eql(high + String.fromCharCode(i)); expect(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars().length).eql(2); @@ -775,12 +785,11 @@ describe('Terminal', () => { term.reset(); } }); - it('splitted surrogates', () => { + it('splitted surrogates', async () => { const high = String.fromCharCode(0xD800); const cell = new CellData(); for (let i = 0xDC00; i <= 0xDCFF; ++i) { - term.writeSync(high); - term.writeSync(String.fromCharCode(i)); + await term.writeP(high + String.fromCharCode(i)); const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); expect(tchar.getChars()).eql(high + String.fromCharCode(i)); expect(tchar.getChars().length).eql(2); @@ -793,16 +802,16 @@ describe('Terminal', () => { describe('unicode - combining characters', () => { const cell = new CellData(); - it('café', () => { - term.writeSync('cafe\u0301'); + it('café', async () => { + await term.writeP('cafe\u0301'); term.buffer.lines.get(0)!.loadCell(3, cell); expect(cell.getChars()).eql('e\u0301'); expect(cell.getChars().length).eql(2); expect(cell.getWidth()).eql(1); }); - it('café - end of line', () => { + it('café - end of line', async () => { term.buffer.x = term.cols - 1 - 3; - term.writeSync('cafe\u0301'); + await term.writeP('cafe\u0301'); term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); expect(cell.getChars()).eql('e\u0301'); expect(cell.getChars().length).eql(2); @@ -812,8 +821,8 @@ describe('Terminal', () => { expect(cell.getChars().length).eql(0); expect(cell.getWidth()).eql(1); }); - it('multiple combined é', () => { - term.writeSync(Array(100).join('e\u0301')); + it('multiple combined é', async () => { + await term.writeP(Array(100).join('e\u0301')); for (let i = 0; i < term.cols; ++i) { term.buffer.lines.get(0)!.loadCell(i, cell); expect(cell.getChars()).eql('e\u0301'); @@ -825,8 +834,8 @@ describe('Terminal', () => { expect(cell.getChars().length).eql(2); expect(cell.getWidth()).eql(1); }); - it('multiple surrogate with combined', () => { - term.writeSync(Array(100).join('\uD800\uDC00\u0301')); + it('multiple surrogate with combined', async () => { + await term.writeP(Array(100).join('\uD800\uDC00\u0301')); for (let i = 0; i < term.cols; ++i) { term.buffer.lines.get(0)!.loadCell(i, cell); expect(cell.getChars()).eql('\uD800\uDC00\u0301'); @@ -842,19 +851,19 @@ describe('Terminal', () => { describe('unicode - fullwidth characters', () => { const cell = new CellData(); - it('cursor movement even', () => { + it('cursor movement even', async () => { expect(term.buffer.x).eql(0); - term.writeSync('¥'); + await term.writeP('¥'); expect(term.buffer.x).eql(2); }); - it('cursor movement odd', () => { + it('cursor movement odd', async () => { term.buffer.x = 1; expect(term.buffer.x).eql(1); - term.writeSync('¥'); + await term.writeP('¥'); expect(term.buffer.x).eql(3); }); - it('line of ¥ even', () => { - term.writeSync(Array(50).join('¥')); + it('line of ¥ even', async () => { + await term.writeP(Array(50).join('¥')); for (let i = 0; i < term.cols; ++i) { term.buffer.lines.get(0)!.loadCell(i, cell); if (i % 2) { @@ -872,9 +881,9 @@ describe('Terminal', () => { expect(cell.getChars().length).eql(1); expect(cell.getWidth()).eql(2); }); - it('line of ¥ odd', () => { + it('line of ¥ odd', async () => { term.buffer.x = 1; - term.writeSync(Array(50).join('¥')); + await term.writeP(Array(50).join('¥')); for (let i = 1; i < term.cols - 1; ++i) { term.buffer.lines.get(0)!.loadCell(i, cell); if (!(i % 2)) { @@ -896,9 +905,9 @@ describe('Terminal', () => { expect(cell.getChars().length).eql(1); expect(cell.getWidth()).eql(2); }); - it('line of ¥ with combining odd', () => { + it('line of ¥ with combining odd', async () => { term.buffer.x = 1; - term.writeSync(Array(50).join('¥\u0301')); + await term.writeP(Array(50).join('¥\u0301')); for (let i = 1; i < term.cols - 1; ++i) { term.buffer.lines.get(0)!.loadCell(i, cell); if (!(i % 2)) { @@ -920,8 +929,8 @@ describe('Terminal', () => { expect(cell.getChars().length).eql(2); expect(cell.getWidth()).eql(2); }); - it('line of ¥ with combining even', () => { - term.writeSync(Array(50).join('¥\u0301')); + it('line of ¥ with combining even', async () => { + await term.writeP(Array(50).join('¥\u0301')); for (let i = 0; i < term.cols; ++i) { term.buffer.lines.get(0)!.loadCell(i, cell); if (i % 2) { @@ -939,9 +948,9 @@ describe('Terminal', () => { expect(cell.getChars().length).eql(2); expect(cell.getWidth()).eql(2); }); - it('line of surrogate fullwidth with combining odd', () => { + it('line of surrogate fullwidth with combining odd', async () => { term.buffer.x = 1; - term.writeSync(Array(50).join('\ud843\ude6d\u0301')); + await term.writeP(Array(50).join('\ud843\ude6d\u0301')); for (let i = 1; i < term.cols - 1; ++i) { term.buffer.lines.get(0)!.loadCell(i, cell); if (!(i % 2)) { @@ -963,8 +972,8 @@ describe('Terminal', () => { expect(cell.getChars().length).eql(3); expect(cell.getWidth()).eql(2); }); - it('line of surrogate fullwidth with combining even', () => { - term.writeSync(Array(50).join('\ud843\ude6d\u0301')); + it('line of surrogate fullwidth with combining even', async () => { + await term.writeP(Array(50).join('\ud843\ude6d\u0301')); for (let i = 0; i < term.cols; ++i) { term.buffer.lines.get(0)!.loadCell(i, cell); if (i % 2) { @@ -986,24 +995,24 @@ describe('Terminal', () => { describe('insert mode', () => { const cell = new CellData(); - it('halfwidth - all', () => { - term.writeSync(Array(9).join('0123456789').slice(-80)); + it('halfwidth - all', async () => { + await term.writeP(Array(9).join('0123456789').slice(-80)); term.buffer.x = 10; term.buffer.y = 0; term.write('\x1b[4h'); - term.writeSync('abcde'); + await term.writeP('abcde'); expect(term.buffer.lines.get(0)!.length).eql(term.cols); expect(term.buffer.lines.get(0)!.loadCell(10, cell).getChars()).eql('a'); expect(term.buffer.lines.get(0)!.loadCell(14, cell).getChars()).eql('e'); expect(term.buffer.lines.get(0)!.loadCell(15, cell).getChars()).eql('0'); expect(term.buffer.lines.get(0)!.loadCell(79, cell).getChars()).eql('4'); }); - it('fullwidth - insert', () => { - term.writeSync(Array(9).join('0123456789').slice(-80)); + it('fullwidth - insert', async () => { + await term.writeP(Array(9).join('0123456789').slice(-80)); term.buffer.x = 10; term.buffer.y = 0; term.write('\x1b[4h'); - term.writeSync('¥¥¥'); + await term.writeP('¥¥¥'); expect(term.buffer.lines.get(0)!.length).eql(term.cols); expect(term.buffer.lines.get(0)!.loadCell(10, cell).getChars()).eql('¥'); expect(term.buffer.lines.get(0)!.loadCell(11, cell).getChars()).eql(''); @@ -1011,17 +1020,17 @@ describe('Terminal', () => { expect(term.buffer.lines.get(0)!.loadCell(15, cell).getChars()).eql(''); expect(term.buffer.lines.get(0)!.loadCell(79, cell).getChars()).eql('3'); }); - it('fullwidth - right border', () => { - term.writeSync(Array(41).join('¥')); + it('fullwidth - right border', async () => { + await term.writeP(Array(41).join('¥')); term.buffer.x = 10; term.buffer.y = 0; term.write('\x1b[4h'); - term.writeSync('a'); + await term.writeP('a'); expect(term.buffer.lines.get(0)!.length).eql(term.cols); expect(term.buffer.lines.get(0)!.loadCell(10, cell).getChars()).eql('a'); expect(term.buffer.lines.get(0)!.loadCell(11, cell).getChars()).eql('¥'); expect(term.buffer.lines.get(0)!.loadCell(79, cell).getChars()).eql(''); // fullwidth char got replaced - term.writeSync('b'); + await term.writeP('b'); expect(term.buffer.lines.get(0)!.length).eql(term.cols); expect(term.buffer.lines.get(0)!.loadCell(11, cell).getChars()).eql('b'); expect(term.buffer.lines.get(0)!.loadCell(12, cell).getChars()).eql('¥'); @@ -1043,85 +1052,87 @@ describe('Terminal', () => { linkifier.attachToDom({} as any, mouseZoneManager); }); - function assertLinkifiesInTerminal(rowText: string, linkMatcherRegex: RegExp, links: {x1: number, y1: number, x2: number, y2: number}[], done: Mocha.Done): void { - terminal.writeSync(rowText); - linkifier.registerLinkMatcher(linkMatcherRegex, () => {}); - linkifier.linkifyRows(); - // Allow linkify to happen - setTimeout(() => { - assert.equal(mouseZoneManager.zones.length, links.length); - links.forEach((l, i) => { - assert.equal(mouseZoneManager.zones[i].x1, l.x1 + 1); - assert.equal(mouseZoneManager.zones[i].x2, l.x2 + 1); - assert.equal(mouseZoneManager.zones[i].y1, l.y1 + 1); - assert.equal(mouseZoneManager.zones[i].y2, l.y2 + 1); - }); - done(); - }, 0); + function assertLinkifiesInTerminal(rowText: string, linkMatcherRegex: RegExp, links: {x1: number, y1: number, x2: number, y2: number}[]): Promise { + return new Promise(async r => { + await terminal.writeP(rowText); + linkifier.registerLinkMatcher(linkMatcherRegex, () => {}); + linkifier.linkifyRows(); + // Allow linkify to happen + setTimeout(() => { + assert.equal(mouseZoneManager.zones.length, links.length); + links.forEach((l, i) => { + assert.equal(mouseZoneManager.zones[i].x1, l.x1 + 1); + assert.equal(mouseZoneManager.zones[i].x2, l.x2 + 1); + assert.equal(mouseZoneManager.zones[i].y1, l.y1 + 1); + assert.equal(mouseZoneManager.zones[i].y2, l.y2 + 1); + }); + r(); + }, 0); + }); } describe('unicode before the match', () => { - it('combining - match within one line', function(done: () => void): void { - assertLinkifiesInTerminal('e\u0301e\u0301e\u0301 foo', /foo/, [{x1: 4, x2: 7, y1: 0, y2: 0}], done); + it('combining - match within one line', () => { + return assertLinkifiesInTerminal('e\u0301e\u0301e\u0301 foo', /foo/, [{x1: 4, x2: 7, y1: 0, y2: 0}]); }); - it('combining - match over two lines', function(done: () => void): void { - assertLinkifiesInTerminal('e\u0301e\u0301e\u0301 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}], done); + it('combining - match over two lines', () => { + return assertLinkifiesInTerminal('e\u0301e\u0301e\u0301 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}]); }); - it('surrogate - match within one line', function(done: () => void): void { - assertLinkifiesInTerminal('𝄞𝄞𝄞 foo', /foo/, [{x1: 4, x2: 7, y1: 0, y2: 0}], done); + it('surrogate - match within one line', () => { + return assertLinkifiesInTerminal('𝄞𝄞𝄞 foo', /foo/, [{x1: 4, x2: 7, y1: 0, y2: 0}]); }); - it('surrogate - match over two lines', function(done: () => void): void { - assertLinkifiesInTerminal('𝄞𝄞𝄞 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}], done); + it('surrogate - match over two lines', () => { + return assertLinkifiesInTerminal('𝄞𝄞𝄞 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}]); }); - it('combining surrogate - match within one line', function(done: () => void): void { - assertLinkifiesInTerminal('𓂀\u0301𓂀\u0301𓂀\u0301 foo', /foo/, [{x1: 4, x2: 7, y1: 0, y2: 0}], done); + it('combining surrogate - match within one line', () => { + return assertLinkifiesInTerminal('𓂀\u0301𓂀\u0301𓂀\u0301 foo', /foo/, [{x1: 4, x2: 7, y1: 0, y2: 0}]); }); - it('combining surrogate - match over two lines', function(done: () => void): void { - assertLinkifiesInTerminal('𓂀\u0301𓂀\u0301𓂀\u0301 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}], done); + it('combining surrogate - match over two lines', () => { + return assertLinkifiesInTerminal('𓂀\u0301𓂀\u0301𓂀\u0301 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}]); }); - it('fullwidth - match within one line', function(done: () => void): void { - assertLinkifiesInTerminal('12 foo', /foo/, [{x1: 5, x2: 8, y1: 0, y2: 0}], done); + it('fullwidth - match within one line', () => { + return assertLinkifiesInTerminal('12 foo', /foo/, [{x1: 5, x2: 8, y1: 0, y2: 0}]); }); - it('fullwidth - match over two lines', function(done: () => void): void { - assertLinkifiesInTerminal('12 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}], done); + it('fullwidth - match over two lines', () => { + return assertLinkifiesInTerminal('12 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}]); }); - it('combining fullwidth - match within one line', function(done: () => void): void { - assertLinkifiesInTerminal('¥\u0301¥\u0301 foo', /foo/, [{x1: 5, x2: 8, y1: 0, y2: 0}], done); + it('combining fullwidth - match within one line', () => { + return assertLinkifiesInTerminal('¥\u0301¥\u0301 foo', /foo/, [{x1: 5, x2: 8, y1: 0, y2: 0}]); }); - it('combining fullwidth - match over two lines', function(done: () => void): void { - assertLinkifiesInTerminal('¥\u0301¥\u0301 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}], done); + it('combining fullwidth - match over two lines', () => { + return assertLinkifiesInTerminal('¥\u0301¥\u0301 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}]); }); }); describe('unicode within the match', () => { - it('combining - match within one line', function(done: () => void): void { - assertLinkifiesInTerminal('test cafe\u0301', /cafe\u0301/, [{x1: 5, x2: 9, y1: 0, y2: 0}], done); + it('combining - match within one line', () => { + return assertLinkifiesInTerminal('test cafe\u0301', /cafe\u0301/, [{x1: 5, x2: 9, y1: 0, y2: 0}]); }); - it('combining - match over two lines', function(done: () => void): void { - assertLinkifiesInTerminal('testtest cafe\u0301', /cafe\u0301/, [{x1: 9, x2: 3, y1: 0, y2: 1}], done); + it('combining - match over two lines', () => { + return assertLinkifiesInTerminal('testtest cafe\u0301', /cafe\u0301/, [{x1: 9, x2: 3, y1: 0, y2: 1}]); }); - it('surrogate - match within one line', function(done: () => void): void { - assertLinkifiesInTerminal('test a𝄞b', /a𝄞b/, [{x1: 5, x2: 8, y1: 0, y2: 0}], done); + it('surrogate - match within one line', () => { + return assertLinkifiesInTerminal('test a𝄞b', /a𝄞b/, [{x1: 5, x2: 8, y1: 0, y2: 0}]); }); - it('surrogate - match over two lines', function(done: () => void): void { - assertLinkifiesInTerminal('testtest a𝄞b', /a𝄞b/, [{x1: 9, x2: 2, y1: 0, y2: 1}], done); + it('surrogate - match over two lines', () => { + return assertLinkifiesInTerminal('testtest a𝄞b', /a𝄞b/, [{x1: 9, x2: 2, y1: 0, y2: 1}]); }); - it('combining surrogate - match within one line', function(done: () => void): void { - assertLinkifiesInTerminal('test a𓂀\u0301b', /a𓂀\u0301b/, [{x1: 5, x2: 8, y1: 0, y2: 0}], done); + it('combining surrogate - match within one line', () => { + return assertLinkifiesInTerminal('test a𓂀\u0301b', /a𓂀\u0301b/, [{x1: 5, x2: 8, y1: 0, y2: 0}]); }); - it('combining surrogate - match over two lines', function(done: () => void): void { - assertLinkifiesInTerminal('testtest a𓂀\u0301b', /a𓂀\u0301b/, [{x1: 9, x2: 2, y1: 0, y2: 1}], done); + it('combining surrogate - match over two lines', () => { + return assertLinkifiesInTerminal('testtest a𓂀\u0301b', /a𓂀\u0301b/, [{x1: 9, x2: 2, y1: 0, y2: 1}]); }); - it('fullwidth - match within one line', function(done: () => void): void { - assertLinkifiesInTerminal('test a1b', /a1b/, [{x1: 5, x2: 9, y1: 0, y2: 0}], done); + it('fullwidth - match within one line', () => { + return assertLinkifiesInTerminal('test a1b', /a1b/, [{x1: 5, x2: 9, y1: 0, y2: 0}]); }); - it('fullwidth - match over two lines', function(done: () => void): void { - assertLinkifiesInTerminal('testtest a1b', /a1b/, [{x1: 9, x2: 3, y1: 0, y2: 1}], done); + it('fullwidth - match over two lines', () => { + return assertLinkifiesInTerminal('testtest a1b', /a1b/, [{x1: 9, x2: 3, y1: 0, y2: 1}]); }); - it('combining fullwidth - match within one line', function(done: () => void): void { - assertLinkifiesInTerminal('test a¥\u0301b', /a¥\u0301b/, [{x1: 5, x2: 9, y1: 0, y2: 0}], done); + it('combining fullwidth - match within one line', () => { + return assertLinkifiesInTerminal('test a¥\u0301b', /a¥\u0301b/, [{x1: 5, x2: 9, y1: 0, y2: 0}]); }); - it('combining fullwidth - match over two lines', function(done: () => void): void { - assertLinkifiesInTerminal('testtest a¥\u0301b', /a¥\u0301b/, [{x1: 9, x2: 3, y1: 0, y2: 1}], done); + it('combining fullwidth - match over two lines', () => { + return assertLinkifiesInTerminal('testtest a¥\u0301b', /a¥\u0301b/, [{x1: 9, x2: 3, y1: 0, y2: 1}]); }); }); }); @@ -1133,9 +1144,9 @@ describe('Terminal', () => { terminal = new TestTerminal({rows: 5, cols: 10, scrollback: 5}); }); - it('multiline ascii', () => { + it('multiline ascii', async () => { const input = 'This is ASCII text spanning multiple lines.'; - terminal.writeSync(input); + await terminal.writeP(input); const s = terminal.buffer.iterator(true).next().content; assert.equal(input, s); for (let i = 0; i < input.length; ++i) { @@ -1144,9 +1155,9 @@ describe('Terminal', () => { } }); - it('combining e\u0301 in a sentence', () => { + it('combining e\u0301 in a sentence', async () => { const input = 'Sitting in the cafe\u0301 drinking coffee.'; - terminal.writeSync(input); + await terminal.writeP(input); const s = terminal.buffer.iterator(true).next().content; assert.equal(input, s); for (let i = 0; i < 19; ++i) { @@ -1164,9 +1175,9 @@ describe('Terminal', () => { } }); - it('multiline combining e\u0301', () => { + it('multiline combining e\u0301', async () => { const input = 'e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301'; - terminal.writeSync(input); + await terminal.writeP(input); const s = terminal.buffer.iterator(true).next().content; assert.equal(input, s); // every buffer cell index contains 2 string indices @@ -1176,9 +1187,9 @@ describe('Terminal', () => { } }); - it('surrogate char in a sentence', () => { + it('surrogate char in a sentence', async () => { const input = 'The 𝄞 is a clef widely used in modern notation.'; - terminal.writeSync(input); + await terminal.writeP(input); const s = terminal.buffer.iterator(true).next().content; assert.equal(input, s); for (let i = 0; i < 5; ++i) { @@ -1196,9 +1207,9 @@ describe('Terminal', () => { } }); - it('multiline surrogate char', () => { + it('multiline surrogate char', async () => { const input = '𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞'; - terminal.writeSync(input); + await terminal.writeP(input); const s = terminal.buffer.iterator(true).next().content; assert.equal(input, s); // every buffer cell index contains 2 string indices @@ -1208,10 +1219,10 @@ describe('Terminal', () => { } }); - it('surrogate char with combining', () => { + it('surrogate char with combining', async () => { // eye of Ra with acute accent - string length of 3 const input = '𓂀\u0301 - the eye hiroglyph with an acute accent.'; - terminal.writeSync(input); + await terminal.writeP(input); const s = terminal.buffer.iterator(true).next().content; assert.equal(input, s); // index 0..2 should map to 0 @@ -1223,9 +1234,9 @@ describe('Terminal', () => { } }); - it('multiline surrogate with combining', () => { + it('multiline surrogate with combining', async () => { const input = '𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301'; - terminal.writeSync(input); + await terminal.writeP(input); const s = terminal.buffer.iterator(true).next().content; assert.equal(input, s); // every buffer cell index contains 3 string indices @@ -1235,9 +1246,9 @@ describe('Terminal', () => { } }); - it('fullwidth chars', () => { + it('fullwidth chars', async () => { const input = 'These 123 are some fat numbers.'; - terminal.writeSync(input); + await terminal.writeP(input); const s = terminal.buffer.iterator(true).next().content; assert.equal(input, s); for (let i = 0; i < 6; ++i) { @@ -1254,9 +1265,9 @@ describe('Terminal', () => { } }); - it('multiline fullwidth chars', () => { + it('multiline fullwidth chars', async () => { const input = '12345678901234567890'; - terminal.writeSync(input); + await terminal.writeP(input); const s = terminal.buffer.iterator(true).next().content; assert.equal(input, s); for (let i = 9; i < input.length; ++i) { @@ -1265,9 +1276,9 @@ describe('Terminal', () => { } }); - it('fullwidth combining with emoji - match emoji cell', () => { + it('fullwidth combining with emoji - match emoji cell', async () => { const input = 'Lots of ¥\u0301 make me 😃.'; - terminal.writeSync(input); + await terminal.writeP(input); const s = terminal.buffer.iterator(true).next().content; assert.equal(input, s); const stringIndex = s.match(/😃/)!.index!; @@ -1275,14 +1286,14 @@ describe('Terminal', () => { assert(terminal.buffer.lines.get(bufferIndex[0])!.loadCell(bufferIndex[1], new CellData()).getChars(), '😃'); }); - it('multiline fullwidth chars with offset 1 (currently tests for broken behavior)', () => { + it('multiline fullwidth chars with offset 1 (currently tests for broken behavior)', async () => { const input = 'a12345678901234567890'; // the 'a' at the beginning moves all fullwidth chars one to the right // now the end of the line contains a dangling empty cell since // the next fullwidth char has to wrap early // the dangling last cell is wrongly added in the string // --> fixable after resolving #1685 - terminal.writeSync(input); + await terminal.writeP(input); const s = terminal.buffer.iterator(true).next().content; assert.equal(input, s); for (let i = 10; i < input.length; ++i) { @@ -1292,9 +1303,9 @@ describe('Terminal', () => { } }); - it('test fully wrapped buffer up to last char', () => { + it('test fully wrapped buffer up to last char', async () => { const input = Array(6).join('1234567890'); - terminal.writeSync(input); + await terminal.writeP(input); const s = terminal.buffer.iterator(true).next().content; assert.equal(input, s); for (let i = 0; i < input.length; ++i) { @@ -1303,10 +1314,10 @@ describe('Terminal', () => { } }); - it('test fully wrapped buffer up to last char with full width odd', () => { + it('test fully wrapped buffer up to last char with full width odd', async () => { const input = 'a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301' + 'a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301'; - terminal.writeSync(input); + await terminal.writeP(input); const s = terminal.buffer.iterator(true).next().content; assert.equal(input, s); for (let i = 0; i < input.length; ++i) { @@ -1321,16 +1332,16 @@ describe('Terminal', () => { } }); - it('should handle \t in lines correctly', () => { + it('should handle \t in lines correctly', async () => { const input = '\thttps://google.de'; - terminal.writeSync(input); + await terminal.writeP(input); const s = terminal.buffer.iterator(true).next().content; assert.equal(s, Array(terminal.optionsService.options.tabStopWidth + 1).join(' ') + 'https://google.de'); }); }); describe('BufferStringIterator', function(): void { - it('iterator does not overflow buffer limits', function(): void { + it('iterator does not overflow buffer limits', async () => { const terminal = new TestTerminal({rows: 5, cols: 10, scrollback: 5}); const data = [ 'aaaaaaaaaa', @@ -1344,7 +1355,7 @@ describe('Terminal', () => { 'aaaaaaaaaa', 'aaaaaaaaaa' ]; - terminal.writeSync(data.join('')); + await terminal.writeP(data.join('')); // brute force test with insane values expect(() => { for (let overscan = 0; overscan < 20; ++overscan) { @@ -1362,7 +1373,7 @@ describe('Terminal', () => { }); describe('Windows Mode', () => { - it('should mark lines as wrapped when the line ends in a non-null character after a LF', () => { + it('should mark lines as wrapped when the line ends in a non-null character after a LF', async () => { const data = [ 'aaaaaaaaaa\n\r', // cannot wrap as it's the first 'aaaaaaaaa\n\r', // wrapped (windows mode only) @@ -1370,19 +1381,19 @@ describe('Terminal', () => { ]; const normalTerminal = new TestTerminal({rows: 5, cols: 10, windowsMode: false}); - normalTerminal.writeSync(data.join('')); + await normalTerminal.writeP(data.join('')); assert.equal(normalTerminal.buffer.lines.get(0)!.isWrapped, false); assert.equal(normalTerminal.buffer.lines.get(1)!.isWrapped, false); assert.equal(normalTerminal.buffer.lines.get(2)!.isWrapped, false); const windowsModeTerminal = new TestTerminal({rows: 5, cols: 10, windowsMode: true}); - windowsModeTerminal.writeSync(data.join('')); + await windowsModeTerminal.writeP(data.join('')); assert.equal(windowsModeTerminal.buffer.lines.get(0)!.isWrapped, false); assert.equal(windowsModeTerminal.buffer.lines.get(1)!.isWrapped, true, 'This line should wrap in Windows mode as the previous line ends in a non-null character'); assert.equal(windowsModeTerminal.buffer.lines.get(2)!.isWrapped, false); }); - it('should mark lines as wrapped when the line ends in a non-null character after a CUP', () => { + it('should mark lines as wrapped when the line ends in a non-null character after a CUP', async () => { const data = [ 'aaaaaaaaaa\x1b[2;1H', // cannot wrap as it's the first 'aaaaaaaaa\x1b[3;1H', // wrapped (windows mode only) @@ -1390,22 +1401,22 @@ describe('Terminal', () => { ]; const normalTerminal = new TestTerminal({rows: 5, cols: 10, windowsMode: false}); - normalTerminal.writeSync(data.join('')); + await normalTerminal.writeP(data.join('')); assert.equal(normalTerminal.buffer.lines.get(0)!.isWrapped, false); assert.equal(normalTerminal.buffer.lines.get(1)!.isWrapped, false); assert.equal(normalTerminal.buffer.lines.get(2)!.isWrapped, false); const windowsModeTerminal = new TestTerminal({rows: 5, cols: 10, windowsMode: true}); - windowsModeTerminal.writeSync(data.join('')); + await windowsModeTerminal.writeP(data.join('')); assert.equal(windowsModeTerminal.buffer.lines.get(0)!.isWrapped, false); assert.equal(windowsModeTerminal.buffer.lines.get(1)!.isWrapped, true, 'This line should wrap in Windows mode as the previous line ends in a non-null character'); assert.equal(windowsModeTerminal.buffer.lines.get(2)!.isWrapped, false); }); }); - it('convertEol setting', function(): void { + it('convertEol setting', async () => { // not converting const termNotConverting = new TestTerminal({cols: 15, rows: 10}); - termNotConverting.writeSync('Hello\nWorld'); + await termNotConverting.writeP('Hello\nWorld'); expect(termNotConverting.buffer.lines.get(0)!.translateToString(false)).equals('Hello '); expect(termNotConverting.buffer.lines.get(1)!.translateToString(false)).equals(' World '); expect(termNotConverting.buffer.lines.get(0)!.translateToString(true)).equals('Hello'); @@ -1413,7 +1424,7 @@ describe('Terminal', () => { // converting const termConverting = new TestTerminal({cols: 15, rows: 10, convertEol: true}); - termConverting.writeSync('Hello\nWorld'); + await termConverting.writeP('Hello\nWorld'); expect(termConverting.buffer.lines.get(0)!.translateToString(false)).equals('Hello '); expect(termConverting.buffer.lines.get(1)!.translateToString(false)).equals('World '); expect(termConverting.buffer.lines.get(0)!.translateToString(true)).equals('Hello'); @@ -1434,54 +1445,54 @@ describe('Terminal', () => { beforeEach(() => { term = new TestTerminal({cols: 5, rows: 5, scrollback: 1}); }); - it('SL (scrollLeft)', () => { - term.writeSync('12345'.repeat(6)); - term.writeSync('\x1b[ @'); + it('SL (scrollLeft)', async () => { + await term.writeP('12345'.repeat(6)); + await term.writeP('\x1b[ @'); assert.deepEqual(getLines(term, term.rows + 1), ['12345', '2345', '2345', '2345', '2345', '2345']); - term.writeSync('\x1b[0 @'); + await term.writeP('\x1b[0 @'); assert.deepEqual(getLines(term, term.rows + 1), ['12345', '345', '345', '345', '345', '345']); - term.writeSync('\x1b[2 @'); + await term.writeP('\x1b[2 @'); assert.deepEqual(getLines(term, term.rows + 1), ['12345', '5', '5', '5', '5', '5']); }); - it('SR (scrollRight)', () => { - term.writeSync('12345'.repeat(6)); - term.writeSync('\x1b[ A'); + it('SR (scrollRight)', async () => { + await term.writeP('12345'.repeat(6)); + await term.writeP('\x1b[ A'); assert.deepEqual(getLines(term, term.rows + 1), ['12345', ' 1234', ' 1234', ' 1234', ' 1234', ' 1234']); - term.writeSync('\x1b[0 A'); + await term.writeP('\x1b[0 A'); assert.deepEqual(getLines(term, term.rows + 1), ['12345', ' 123', ' 123', ' 123', ' 123', ' 123']); - term.writeSync('\x1b[2 A'); + await term.writeP('\x1b[2 A'); assert.deepEqual(getLines(term, term.rows + 1), ['12345', ' 1', ' 1', ' 1', ' 1', ' 1']); }); - it('insertColumns (DECIC)', () => { - term.writeSync('12345'.repeat(6)); - term.writeSync('\x1b[3;3H'); - term.writeSync('\x1b[\'}'); + it('insertColumns (DECIC)', async () => { + await term.writeP('12345'.repeat(6)); + await term.writeP('\x1b[3;3H'); + await term.writeP('\x1b[\'}'); assert.deepEqual(getLines(term, term.rows + 1), ['12345', '12 34', '12 34', '12 34', '12 34', '12 34']); term.reset(); - term.writeSync('12345'.repeat(6)); - term.writeSync('\x1b[3;3H'); - term.writeSync('\x1b[1\'}'); + await term.writeP('12345'.repeat(6)); + await term.writeP('\x1b[3;3H'); + await term.writeP('\x1b[1\'}'); assert.deepEqual(getLines(term, term.rows + 1), ['12345', '12 34', '12 34', '12 34', '12 34', '12 34']); term.reset(); - term.writeSync('12345'.repeat(6)); - term.writeSync('\x1b[3;3H'); - term.writeSync('\x1b[2\'}'); + await term.writeP('12345'.repeat(6)); + await term.writeP('\x1b[3;3H'); + await term.writeP('\x1b[2\'}'); assert.deepEqual(getLines(term, term.rows + 1), ['12345', '12 3', '12 3', '12 3', '12 3', '12 3']); }); - it('deleteColumns (DECDC)', () => { - term.writeSync('12345'.repeat(6)); - term.writeSync('\x1b[3;3H'); - term.writeSync('\x1b[\'~'); + it('deleteColumns (DECDC)', async () => { + await term.writeP('12345'.repeat(6)); + await term.writeP('\x1b[3;3H'); + await term.writeP('\x1b[\'~'); assert.deepEqual(getLines(term, term.rows + 1), ['12345', '1245', '1245', '1245', '1245', '1245']); term.reset(); - term.writeSync('12345'.repeat(6)); - term.writeSync('\x1b[3;3H'); - term.writeSync('\x1b[1\'~'); + await term.writeP('12345'.repeat(6)); + await term.writeP('\x1b[3;3H'); + await term.writeP('\x1b[1\'~'); assert.deepEqual(getLines(term, term.rows + 1), ['12345', '1245', '1245', '1245', '1245', '1245']); term.reset(); - term.writeSync('12345'.repeat(6)); - term.writeSync('\x1b[3;3H'); - term.writeSync('\x1b[2\'~'); + await term.writeP('12345'.repeat(6)); + await term.writeP('\x1b[3;3H'); + await term.writeP('\x1b[2\'~'); assert.deepEqual(getLines(term, term.rows + 1), ['12345', '125', '125', '125', '125', '125']); }); }); @@ -1494,41 +1505,41 @@ describe('Terminal', () => { }); describe('reverseWraparound set', () => { - it('should not reverse outside of scroll margins', () => { + it('should not reverse outside of scroll margins', async () => { // prepare buffer content - term.writeSync('#####abcdefghijklmnopqrstuvwxy'); + await term.writeP('#####abcdefghijklmnopqrstuvwxy'); assert.deepEqual(getLines(term, 6), ['#####', 'abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy']); assert.equal(term.buffer.ydisp, 1); assert.equal(term.buffer.x, 5); assert.equal(term.buffer.y, 4); - term.writeSync(ttyBS.repeat(100)); + await term.writeP(ttyBS.repeat(100)); assert.deepEqual(getLines(term, 6), ['#####', 'abcde', 'fghij', 'klmno', 'pqrst', ' y']); - term.writeSync('\x1b[?45h'); - term.writeSync('uvwxy'); + await term.writeP('\x1b[?45h'); + await term.writeP('uvwxy'); // set top/bottom to 1/3 (0-based) - term.writeSync('\x1b[2;4r'); + await term.writeP('\x1b[2;4r'); // place cursor below scroll bottom term.buffer.x = 5; term.buffer.y = 4; - term.writeSync(ttyBS.repeat(100)); + await term.writeP(ttyBS.repeat(100)); assert.deepEqual(getLines(term, 6), ['#####', 'abcde', 'fghij', 'klmno', 'pqrst', ' ']); - term.writeSync('uvwxy'); + await term.writeP('uvwxy'); // place cursor within scroll margins term.buffer.x = 5; term.buffer.y = 3; - term.writeSync(ttyBS.repeat(100)); + await term.writeP(ttyBS.repeat(100)); assert.deepEqual(getLines(term, 6), ['#####', 'abcde', ' ', ' ', ' ', 'uvwxy']); assert.equal(term.buffer.x, 0); assert.equal(term.buffer.y, term.buffer.scrollTop); // stops at 0, scrollTop - term.writeSync('fghijklmnopqrst'); + await term.writeP('fghijklmnopqrst'); // place cursor above scroll top term.buffer.x = 5; term.buffer.y = 0; - term.writeSync(ttyBS.repeat(100)); + await term.writeP(ttyBS.repeat(100)); assert.deepEqual(getLines(term, 6), ['#####', ' ', 'fghij', 'klmno', 'pqrst', 'uvwxy']); }); }); @@ -1542,22 +1553,22 @@ describe('Terminal', () => { let markers: IMarker[]; let disposeStack: IMarker[]; let term: TestTerminal; - beforeEach(() => { + beforeEach(async () => { term = new TestTerminal({}); markers = []; disposeStack = []; term.optionsService.setOption('scrollback', 1); term.resize(10, 5); markers.push(term.buffers.active.addMarker(term.buffers.active.y)); - term.writeSync('\x1b[r0\r\n'); + await term.writeP('\x1b[r0\r\n'); markers.push(term.buffers.active.addMarker(term.buffers.active.y)); - term.writeSync('1\r\n'); + await term.writeP('1\r\n'); markers.push(term.buffers.active.addMarker(term.buffers.active.y)); - term.writeSync('2\r\n'); + await term.writeP('2\r\n'); markers.push(term.buffers.active.addMarker(term.buffers.active.y)); - term.writeSync('3\r\n'); + await term.writeP('3\r\n'); markers.push(term.buffers.active.addMarker(term.buffers.active.y)); - term.writeSync('4'); + await term.writeP('4'); for (let i = 0; i < markers.length; ++i) { const marker = markers[i]; marker.onDispose(() => disposeStack.push(marker)); @@ -1566,15 +1577,15 @@ describe('Terminal', () => { it('initial', () => { assert.deepEqual(markers.map(m => m.line), [0, 1, 2, 3, 4]); }); - it('should dispose on normal trim off the top', () => { + it('should dispose on normal trim off the top', async () => { // moves top line into scrollback - term.writeSync('\n'); + await term.writeP('\n'); assert.deepEqual(disposeStack, []); // trims first marker - term.writeSync('\n'); + await term.writeP('\n'); assert.deepEqual(disposeStack, [markers[0]]); // trims second marker - term.writeSync('\n'); + await term.writeP('\n'); assert.deepEqual(disposeStack, [markers[0], markers[1]]); // trimmed marker objs should be disposed assert.deepEqual(disposeStack.map(el => el.isDisposed), [true, true]); @@ -1582,14 +1593,14 @@ describe('Terminal', () => { // trimmed markers should contain line -1 assert.deepEqual(disposeStack.map(el => el.line), [-1, -1]); }); - it('should dispose on DL', () => { - term.writeSync('\x1b[3;1H'); // move cursor to 0, 2 - term.writeSync('\x1b[2M'); // delete 2 lines + it('should dispose on DL', async () => { + await term.writeP('\x1b[3;1H'); // move cursor to 0, 2 + await term.writeP('\x1b[2M'); // delete 2 lines assert.deepEqual(disposeStack, [markers[2], markers[3]]); }); - it('should dispose on IL', () => { - term.writeSync('\x1b[3;1H'); // move cursor to 0, 2 - term.writeSync('\x1b[2L'); // insert 2 lines + it('should dispose on IL', async () => { + await term.writeP('\x1b[3;1H'); // move cursor to 0, 2 + await term.writeP('\x1b[2L'); // insert 2 lines assert.deepEqual(disposeStack, [markers[4], markers[3]]); assert.deepEqual(markers.map(el => el.line), [0, 1, 4, -1, -1]); }); diff --git a/src/browser/TestUtils.test.ts b/src/browser/TestUtils.test.ts index 6a4b4a0d..38f9c8f1 100644 --- a/src/browser/TestUtils.test.ts +++ b/src/browser/TestUtils.test.ts @@ -21,6 +21,9 @@ export class TestTerminal extends Terminal { public get curAttrData(): IAttributeData { return (this as any)._inputHandler._curAttrData; } public keyDown(ev: any): boolean | undefined { return this._keyDown(ev); } public keyPress(ev: any): boolean { return this._keyPress(ev); } + public writeP(data: string | Uint8Array): Promise { + return new Promise(r => this.write(data, r)); + } } export class MockTerminal implements ITerminal { diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 11e71bad..e67a1f26 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -125,7 +125,17 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this._writeBuffer.write(data, callback); } + /** + * Write data to terminal synchonously. + * + * This method is unreliable with async parser handlers, thus should not + * be used anymore. If you need blocking semantics on data input consider + * `write` with a callback instead. + * + * @deprecated Unreliable, will be removed soon. + */ public writeSync(data: string | Uint8Array): void { + console.error('writeSync is unreliable and will be removed soon.'); this._writeBuffer.writeSync(data); } From 22d777c9f96c263377003cce82244a19a21f7209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Fri, 22 Jan 2021 21:24:54 +0100 Subject: [PATCH 069/377] make linter happy --- src/common/CoreTerminal.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index e67a1f26..7b45a172 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -127,11 +127,11 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { /** * Write data to terminal synchonously. - * + * * This method is unreliable with async parser handlers, thus should not * be used anymore. If you need blocking semantics on data input consider * `write` with a callback instead. - * + * * @deprecated Unreliable, will be removed soon. */ public writeSync(data: string | Uint8Array): void { From b07ca8bb2422d6ea5d4fb45527e5f715626bdf4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Fri, 22 Jan 2021 21:34:12 +0100 Subject: [PATCH 070/377] fix timeout issue on macos --- src/browser/Terminal.test.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/browser/Terminal.test.ts b/src/browser/Terminal.test.ts index 2e09f719..fe5b0bd5 100644 --- a/src/browser/Terminal.test.ts +++ b/src/browser/Terminal.test.ts @@ -753,7 +753,8 @@ describe('Terminal', () => { term.reset(); } }); - it('2 characters per cell over line end with autowrap', async () => { + it('2 characters per cell over line end with autowrap', async function (): Promise { + this.timeout(10000); const high = String.fromCharCode(0xD800); const cell = new CellData(); for (let i = 0xDC00; i <= 0xDCFF; ++i) { @@ -767,7 +768,8 @@ describe('Terminal', () => { term.reset(); } }); - it('2 characters per cell over line end without autowrap', async () => { + it('2 characters per cell over line end without autowrap', async function (): Promise { + this.timeout(10000); const high = String.fromCharCode(0xD800); const cell = new CellData(); for (let i = 0xDC00; i <= 0xDCFF; ++i) { @@ -785,7 +787,8 @@ describe('Terminal', () => { term.reset(); } }); - it('splitted surrogates', async () => { + it('splitted surrogates', async function (): Promise { + this.timeout(10000); const high = String.fromCharCode(0xD800); const cell = new CellData(); for (let i = 0xDC00; i <= 0xDCFF; ++i) { From 354f3e03a2bb3aa364bef6346971b50dcd63b7ea Mon Sep 17 00:00:00 2001 From: mmis1000 Date: Sat, 23 Jan 2021 10:19:03 +0800 Subject: [PATCH 071/377] Fix: inconsistent styles Co-authored-by: Daniel Imms --- addons/xterm-addon-serialize/src/SerializeAddon.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index ec8c6d0d..9641dc20 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -95,7 +95,7 @@ class StringSerializeHandler extends BaseSerializeHandler { private _lastContentCursorRow: number = 0; private _lastContentCursorCol: number = 0; - constructor(private _buffer1: IBuffer,private _terminal: Terminal) { + constructor(private _buffer1: IBuffer, private _terminal: Terminal) { super(_buffer1); } @@ -201,7 +201,7 @@ class StringSerializeHandler extends BaseSerializeHandler { this._nullCellCount = 0; } - private _diffStyle (cell: IBufferCell, oldCell: IBufferCell): number[] { + private _diffStyle(cell: IBufferCell, oldCell: IBufferCell): number[] { const sgrSeq: number[] = []; const fgChanged = !equalFg(cell, oldCell); const bgChanged = !equalBg(cell, oldCell); @@ -337,7 +337,7 @@ class StringSerializeHandler extends BaseSerializeHandler { const realCursorRow = this._buffer1.baseY + this._buffer1.cursorY; const realCursorCol = this._buffer1.cursorX; - const cursorMoved = (realCursorRow !== this._lastCursorRow || realCursorCol !== this._lastCursorCol); + const cursorMoved = (realCursorRow !== this._lastCursorRow || realCursorCol !== this._lastCursorCol); const moveRight = (offset: number): void => { if (offset > 0) { From cd501f9dcc445737160b982876146de0c67cb1ba Mon Sep 17 00:00:00 2001 From: mmis1000 Date: Sat, 23 Jan 2021 10:20:03 +0800 Subject: [PATCH 072/377] Update addons/xterm-addon-serialize/src/MyBufferCell.ts Co-authored-by: Daniel Imms --- addons/xterm-addon-serialize/src/MyBufferCell.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/xterm-addon-serialize/src/MyBufferCell.ts b/addons/xterm-addon-serialize/src/MyBufferCell.ts index 56efcb3c..d635a424 100644 --- a/addons/xterm-addon-serialize/src/MyBufferCell.ts +++ b/addons/xterm-addon-serialize/src/MyBufferCell.ts @@ -4,7 +4,7 @@ import { IBufferCell } from 'xterm'; * This is a dummy buffer cell to hold data from real buffer cell */ export class MyBufferCell implements IBufferCell { - constructor (private _cell: IBufferCell) {} + constructor(private _cell: IBufferCell) {} private _width: number = this._cell.getWidth(); private _chars: string = this._cell.getChars(); private _code: number = this._cell.getCode(); From a2480bae51b86a368cea3784b4bcb07e9e139caa Mon Sep 17 00:00:00 2001 From: Mmis1000 Date: Sat, 23 Jan 2021 11:57:08 +0800 Subject: [PATCH 073/377] Remove dummy buffer cell in favor of just remember the location --- .../xterm-addon-serialize/src/MyBufferCell.ts | 96 ------------------- .../src/SerializeAddon.ts | 18 +++- 2 files changed, 14 insertions(+), 100 deletions(-) delete mode 100644 addons/xterm-addon-serialize/src/MyBufferCell.ts diff --git a/addons/xterm-addon-serialize/src/MyBufferCell.ts b/addons/xterm-addon-serialize/src/MyBufferCell.ts deleted file mode 100644 index d635a424..00000000 --- a/addons/xterm-addon-serialize/src/MyBufferCell.ts +++ /dev/null @@ -1,96 +0,0 @@ -import { IBufferCell } from 'xterm'; - -/** - * This is a dummy buffer cell to hold data from real buffer cell - */ -export class MyBufferCell implements IBufferCell { - constructor(private _cell: IBufferCell) {} - private _width: number = this._cell.getWidth(); - private _chars: string = this._cell.getChars(); - private _code: number = this._cell.getCode(); - private _fgColorMode: number = this._cell.getFgColorMode(); - private _bgColorMode: number = this._cell.getBgColorMode(); - private _fgColor: number = this._cell.getFgColor(); - private _bgColor: number = this._cell.getBgColor(); - private _bold: number = this._cell.isBold(); - private _italic: number = this._cell.isItalic(); - private _dim: number = this._cell.isDim(); - private _underline: number = this._cell.isUnderline(); - private _blink: number = this._cell.isBlink(); - private _inverse: number = this._cell.isInverse(); - private _invisible: number = this._cell.isInvisible(); - private _fgRGB: boolean = this._cell.isFgRGB(); - private _bgRGB: boolean = this._cell.isBgRGB(); - private _fgPalette: boolean = this._cell.isFgPalette(); - private _bgPallette: boolean = this._cell.isBgPalette(); - private _fgDefault: boolean = this._cell.isFgDefault(); - private _bgDefault: boolean = this._cell.isBgDefault(); - private _attributeDefault: boolean = this._cell.isAttributeDefault(); - public getWidth(): number { - return this._width; - } - public getChars(): string { - return this._chars; - } - public getCode(): number { - return this._code; - } - public getFgColorMode(): number { - return this._fgColorMode; - } - public getBgColorMode(): number { - return this._bgColorMode; - } - public getFgColor(): number { - return this._fgColor; - } - public getBgColor(): number { - return this._bgColor; - } - public isBold(): number { - return this._bold; - } - public isItalic(): number { - return this._italic; - } - public isDim(): number { - return this._dim; - } - public isUnderline(): number { - return this._underline; - } - public isBlink(): number { - return this._blink; - } - public isInverse(): number { - return this._inverse; - } - public isInvisible(): number { - return this._invisible; - } - public isFgRGB(): boolean { - return this._fgRGB; - } - public isBgRGB(): boolean { - return this._bgRGB; - } - public isFgPalette(): boolean { - return this._fgPalette; - } - public isBgPalette(): boolean { - return this._bgPallette; - } - public isFgDefault(): boolean { - return this._fgDefault; - } - public isBgDefault(): boolean { - return this._bgDefault; - } - public isAttributeDefault(): boolean { - return this._attributeDefault; - } - - public static from(cell: IBufferCell): MyBufferCell { - return new MyBufferCell(cell); - } -} diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index 9641dc20..60fe9624 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -6,7 +6,6 @@ */ import { Terminal, ITerminalAddon, IBuffer, IBufferCell } from 'xterm'; -import { MyBufferCell } from './MyBufferCell'; function constrain(value: number, low: number, high: number): number { return Math.max(low, Math.min(value, high)); @@ -86,8 +85,14 @@ class StringSerializeHandler extends BaseSerializeHandler { // so wee need to record it when required. private _cursorStyle: IBufferCell = this._buffer1.getNullCell(); + // where exact the cursor styles comes from + // because we can't copy the cell directly + // so we remember where the content comes from instead + private _cursorStyleRow: number = 0; + private _cursorStyleCol: number = 0; + // this is a null cell for reference for checking whether background is empty or not - private _backgroundCell: MyBufferCell = MyBufferCell.from(this._cursorStyle); + private _backgroundCell: IBufferCell = this._buffer1.getNullCell(); private _firstRow: number = 0; private _lastCursorRow: number = 0; @@ -122,7 +127,7 @@ class StringSerializeHandler extends BaseSerializeHandler { if (!isLastRow) { // Enable BCE if (row - this._firstRow >= this._terminal.rows) { - this._backgroundCell = MyBufferCell.from(this._cursorStyle); + this._buffer1.getLine(this._cursorStyleRow)?.getCell(this._cursorStyleCol, this._backgroundCell); } // Fetch current line @@ -283,7 +288,12 @@ class StringSerializeHandler extends BaseSerializeHandler { this._currentRow += `\x1b[${sgrSeq.join(';')}m`; // update the last cursor style - this._buffer1.getLine(row)?.getCell(col, this._cursorStyle); + const line = this._buffer1.getLine(row); + if (line !== undefined) { + line.getCell(col, this._cursorStyle); + this._cursorStyleRow = row; + this._cursorStyleCol = col; + } } /** From db8e449a8a47b18b6ab9d2d439f550664918f17a Mon Sep 17 00:00:00 2001 From: nishant-d <58689354+nishant-d@users.noreply.github.com> Date: Sat, 23 Jan 2021 09:35:43 +0530 Subject: [PATCH 074/377] added Devtron's usages --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0e7df5ac..b46b7e93 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,7 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**Intervue**](https://www.intervue.io): Pair programming for interviews. Multiple programming languages supported, with results displayed by xterm.js. - [**TRASA**](https://trasa.io): Zero trust access to Web, SSH, RDP and Database services. - [**Commas**](https://github.com/CyanSalt/commas): Commas is a hackable terminal and command runner. +- [**Devtron**](https://github.com/devtron-labs/devtron): Software Delivery Workflow For Kubernetes. [And much more...](https://github.com/xtermjs/xterm.js/network/dependents) Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it in our list. Note: Please add any new contributions to the end of the list only. From 079702282cb048a23d5d861f1a40336b1ace8e40 Mon Sep 17 00:00:00 2001 From: Mmis1000 Date: Sat, 23 Jan 2021 12:26:30 +0800 Subject: [PATCH 075/377] SerializeAddon: move test util into seperate file --- .../src/SerializeAddon.ts | 20 -------------- .../test/SerializeAddon.api.ts | 12 ++++----- .../test/SerializeAddonTestUtil.ts | 27 +++++++++++++++++++ demo/client.ts | 3 +++ 4 files changed, 36 insertions(+), 26 deletions(-) create mode 100644 addons/xterm-addon-serialize/test/SerializeAddonTestUtil.ts diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index 60fe9624..25fa9ad2 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -412,25 +412,5 @@ export class SerializeAddon implements ITerminalAddon { + alternativeScreenContent; } - // this is a util used only for test - private static _inspectBuffer(buffer: IBuffer): { x: number, y: number, data: any[][] } { - const lines: any[] = []; - - for (let i = 0; i < buffer.length; i++) { - /** - * Do this intentionally to get content of underlining source - */ - const bufferLine = (buffer.getLine(i)! as any)._line; - - lines.push(JSON.stringify(bufferLine)); - } - - return { - x: buffer.cursorX, - y: buffer.cursorY, - data: lines - }; - } - public dispose(): void { } } diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index 5dc29d0d..339ac162 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -18,12 +18,12 @@ const writeRawSync = (page: any, str: string): Promise => writeSync(page, const testNormalScreenEqual = async (page: any, str: string): Promise => { await writeRawSync(page, str); - const originalBuffer = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); + const originalBuffer = await page.evaluate(`SerializeAddonTestUtil.inspectBuffer(term.buffer.normal);`); const result = await page.evaluate(`serializeAddon.serialize();`) as string; await page.evaluate(`term.reset();`); await writeRawSync(page, result); - const newBuffer = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); + const newBuffer = await page.evaluate(`SerializeAddonTestUtil.inspectBuffer(term.buffer.normal);`); // chai decides -0 and 0 are different number... // and firefox have a bug that output -0 for unknown reason @@ -51,11 +51,11 @@ describe('SerializeAddon', () => { it('produce different output when we call test util with different text', async function(): Promise { await writeRawSync(page, '12345'); - const buffer1 = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); + const buffer1 = await page.evaluate(`SerializeAddonTestUtil.inspectBuffer(term.buffer.normal);`); await page.evaluate(`term.reset();`); await writeRawSync(page, '67890'); - const buffer2 = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); + const buffer2 = await page.evaluate(`SerializeAddonTestUtil.inspectBuffer(term.buffer.normal);`); assert.throw(() => { assert.equal(JSON.stringify(buffer1), JSON.stringify(buffer2)); @@ -64,11 +64,11 @@ describe('SerializeAddon', () => { it('produce different output when we call test util with different line wrap', async function(): Promise { await writeRawSync(page, '1234567890\r\n12345'); - const buffer3 = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); + const buffer3 = await page.evaluate(`SerializeAddonTestUtil.inspectBuffer(term.buffer.normal);`); await page.evaluate(`term.reset();`); await writeRawSync(page, '1234567890n12345'); - const buffer4 = await page.evaluate(`SerializeAddon._inspectBuffer(term.buffer.normal);`); + const buffer4 = await page.evaluate(`SerializeAddonTestUtil.inspectBuffer(term.buffer.normal);`); assert.throw(() => { assert.equal(JSON.stringify(buffer3), JSON.stringify(buffer4)); diff --git a/addons/xterm-addon-serialize/test/SerializeAddonTestUtil.ts b/addons/xterm-addon-serialize/test/SerializeAddonTestUtil.ts new file mode 100644 index 00000000..23ac2237 --- /dev/null +++ b/addons/xterm-addon-serialize/test/SerializeAddonTestUtil.ts @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2021 The xterm.js authors. All rights reserved. + * @license MIT + */ + +import { IBuffer } from 'xterm'; +export class SerializeAddonTestUtil { + // this is a util used only for test + public static inspectBuffer(buffer: IBuffer): { x: number, y: number, data: any[][] } { + const lines: any[] = []; + + for (let i = 0; i < buffer.length; i++) { + /** + * Do this intentionally to get content of underlining source + */ + const bufferLine = (buffer.getLine(i)! as any)._line; + + lines.push(JSON.stringify(bufferLine)); + } + + return { + x: buffer.cursorX, + y: buffer.cursorY, + data: lines + }; + } +} diff --git a/demo/client.ts b/demo/client.ts index 93b7c26c..27d1c297 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -13,6 +13,7 @@ import { AttachAddon } from '../addons/xterm-addon-attach/out/AttachAddon'; import { FitAddon } from '../addons/xterm-addon-fit/out/FitAddon'; import { SearchAddon, ISearchOptions } from '../addons/xterm-addon-search/out/SearchAddon'; import { SerializeAddon } from '../addons/xterm-addon-serialize/out/SerializeAddon'; +import { SerializeAddonTestUtil } from '../addons/xterm-addon-serialize/out-test/SerializeAddonTestUtil'; import { WebLinksAddon } from '../addons/xterm-addon-web-links/out/WebLinksAddon'; import { WebglAddon } from '../addons/xterm-addon-webgl/out/WebglAddon'; import { Unicode11Addon } from '../addons/xterm-addon-unicode11/out/Unicode11Addon'; @@ -38,6 +39,7 @@ export interface IWindowWithTerminal extends Window { FitAddon?: typeof FitAddon; SearchAddon?: typeof SearchAddon; SerializeAddon?: typeof SerializeAddon; + SerializeAddonTestUtil?: typeof SerializeAddonTestUtil; WebLinksAddon?: typeof WebLinksAddon; WebglAddon?: typeof WebglAddon; Unicode11Addon?: typeof Unicode11Addon; @@ -132,6 +134,7 @@ if (document.location.pathname === '/test') { window.FitAddon = FitAddon; window.SearchAddon = SearchAddon; window.SerializeAddon = SerializeAddon; + window.SerializeAddonTestUtil = SerializeAddonTestUtil; window.Unicode11Addon = Unicode11Addon; window.WebLinksAddon = WebLinksAddon; window.WebglAddon = WebglAddon; From 93aab95f7bd19e3b1d2fe65f6108aa92cfc75cda Mon Sep 17 00:00:00 2001 From: Ken Aoki Date: Sat, 23 Jan 2021 04:39:57 +0000 Subject: [PATCH 076/377] filter U+FEFF (BOM) when decoding input data --- src/common/input/TextDecoder.test.ts | 25 +++++++++++++++++++++---- src/common/input/TextDecoder.ts | 8 ++++++-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/common/input/TextDecoder.test.ts b/src/common/input/TextDecoder.test.ts index 92b0e03a..e9299021 100644 --- a/src/common/input/TextDecoder.test.ts +++ b/src/common/input/TextDecoder.test.ts @@ -58,8 +58,8 @@ describe('text encodings', () => { const decoder = new StringToUtf32(); const target = new Uint32Array(5); for (let i = 0; i < 65536; ++i) { - // skip surrogate pairs - if (i >= 0xD800 && i <= 0xDFFF) { + // skip surrogate pairs and a BOM + if ((i >= 0xD800 && i <= 0xDFFF) || i === 0xFEFF) { continue; } const length = decoder.decode(String.fromCharCode(i), target); @@ -84,6 +84,14 @@ describe('text encodings', () => { decoder.clear(); } }); + + it('0xFEFF(BOM)', () => { + const decoder = new StringToUtf32(); + const target = new Uint32Array(5); + const length = decoder.decode(String.fromCharCode(0xFEFF), target); + assert.equal(length, 0); + decoder.clear(); + }); }); it('test strings', () => { @@ -118,8 +126,8 @@ describe('text encodings', () => { const decoder = new Utf8ToUtf32(); const target = new Uint32Array(5); for (let i = 0; i < 65536; ++i) { - // skip surrogate pairs - if (i >= 0xD800 && i <= 0xDFFF) { + // skip surrogate pairs and a BOM + if ((i >= 0xD800 && i <= 0xDFFF) || i === 0xFEFF) { continue; } const utf8Data = fromByteString(encode(String.fromCharCode(i))); @@ -142,6 +150,15 @@ describe('text encodings', () => { decoder.clear(); } }); + + it('0xFEFF(BOM)', () => { + const decoder = new Utf8ToUtf32(); + const target = new Uint32Array(5); + const utf8Data = fromByteString(encode(String.fromCharCode(0xFEFF))); + const length = decoder.decode(utf8Data, target); + assert.equal(length, 0); + decoder.clear(); + }); }); it('test strings', () => { diff --git a/src/common/input/TextDecoder.ts b/src/common/input/TextDecoder.ts index 6ecab011..9df26f59 100644 --- a/src/common/input/TextDecoder.ts +++ b/src/common/input/TextDecoder.ts @@ -105,6 +105,10 @@ export class StringToUtf32 { } continue; } + if (code === 0xFEFF) { + // BOM + continue; + } target[size++] = code; } return size; @@ -286,8 +290,8 @@ export class Utf8ToUtf32 { continue; } codepoint = (byte1 & 0x0F) << 12 | (byte2 & 0x3F) << 6 | (byte3 & 0x3F); - if (codepoint < 0x0800 || (codepoint >= 0xD800 && codepoint <= 0xDFFF)) { - // illegal codepoint, no i-- here + if (codepoint < 0x0800 || (codepoint >= 0xD800 && codepoint <= 0xDFFF) || codepoint === 0xFEFF) { + // illegal codepoint or BOM, no i-- here continue; } target[size++] = codepoint; From 3d941f2fdf08190aa347f9015a737d83718b747b Mon Sep 17 00:00:00 2001 From: Ken Aoki Date: Sat, 23 Jan 2021 11:42:16 +0000 Subject: [PATCH 077/377] add BOM skip logic --- src/common/input/TextDecoder.test.ts | 13 +++++++++++++ src/common/input/TextDecoder.ts | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/common/input/TextDecoder.test.ts b/src/common/input/TextDecoder.test.ts index e9299021..da1760a2 100644 --- a/src/common/input/TextDecoder.test.ts +++ b/src/common/input/TextDecoder.test.ts @@ -232,6 +232,19 @@ describe('text encodings', () => { } assert(decoded, 'Ä€𝄞Ö𝄞€Ü𝄞€'); }); + + it('BOMs (3 byte sequences) - advance by 2', () => { + const decoder = new Utf8ToUtf32(); + const target = new Uint32Array(5); + const utf8Data = fromByteString('\xef\xbb\xbf\xef\xbb\xbf'); + let decoded = ''; + for (let i = 0; i < utf8Data.length; i += 2) { + const written = decoder.decode(utf8Data.slice(i, i + 2), target); + decoded += toString(target, written); + } + assert.equal(decoded, ''); + }); + it('test break after 3 bytes - issue #2495', () => { const decoder = new Utf8ToUtf32(); const target = new Uint32Array(5); diff --git a/src/common/input/TextDecoder.ts b/src/common/input/TextDecoder.ts index 9df26f59..715e9197 100644 --- a/src/common/input/TextDecoder.ts +++ b/src/common/input/TextDecoder.ts @@ -192,8 +192,8 @@ export class Utf8ToUtf32 { target[size++] = cp; } } else if (type === 3) { - if (cp < 0x0800 || (cp >= 0xD800 && cp <= 0xDFFF)) { - // illegal codepoint + if (cp < 0x0800 || (cp >= 0xD800 && cp <= 0xDFFF) || cp === 0xFEFF) { + // illegal codepoint or BOM } else { target[size++] = cp; } From 2f07ed997605d9c289c8a6cc5c3a2a8bd86e11c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sat, 23 Jan 2021 13:05:57 +0100 Subject: [PATCH 078/377] simplify stack save in parser --- src/common/InputHandler.ts | 18 ++- src/common/parser/EscapeSequenceParser.ts | 173 +++++++++------------- src/common/parser/Types.d.ts | 20 +++ 3 files changed, 108 insertions(+), 103 deletions(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 001c9995..099cdff7 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -460,7 +460,9 @@ export class InputHandler extends Disposable implements IInputHandler { super.dispose(); } - // FIXME: cleanup async handling + /** + * Async parse support. + */ private _parseStack = { paused: false, cursorStartX: 0, @@ -468,7 +470,6 @@ export class InputHandler extends Disposable implements IInputHandler { decodedLength: 0, position: 0 }; - private _preserveStack(cursorStartX: number, cursorStartY: number, decodedLength: number, position: number): void { this._parseStack.paused = true; this._parseStack.cursorStartX = cursorStartX; @@ -477,6 +478,19 @@ export class InputHandler extends Disposable implements IInputHandler { this._parseStack.position = position; } + /** + * Parse call with async handler support. + * + * Whether the stack state got preserved for the next call, is indicated by the return value: + * - undefined (void): + * all handlers were sync, no stack save, continue normally with next chunk + * - Promise\: + * execution stopped at async handler, stack saved, continue with + * same chunk and the promise resolve value as `promiseResult` until the method returns `undefined` + * + * Note: Never call this directly for a running terminal instance in production. + * Always use `Terminal.write`, which provides in-band blocking and correct exection order. + */ public parse(data: string | Uint8Array, promiseResult?: boolean): void | Promise { let result: void | Promise; let buffer = this._bufferService.buffer; diff --git a/src/common/parser/EscapeSequenceParser.ts b/src/common/parser/EscapeSequenceParser.ts index 3635ca78..e56655ae 100644 --- a/src/common/parser/EscapeSequenceParser.ts +++ b/src/common/parser/EscapeSequenceParser.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { IParsingState, IDcsHandler, IEscapeSequenceParser, IParams, IOscHandler, IHandlerCollection, CsiHandlerType, OscFallbackHandlerType, IOscParser, EscHandlerType, IDcsParser, DcsFallbackHandlerType, IFunctionIdentifier, ExecuteFallbackHandlerType, CsiFallbackHandlerType, EscFallbackHandlerType, PrintHandlerType, PrintFallbackHandlerType, ExecuteHandlerType } from 'common/parser/Types'; +import { IParsingState, IDcsHandler, IEscapeSequenceParser, IParams, IOscHandler, IHandlerCollection, CsiHandlerType, OscFallbackHandlerType, IOscParser, EscHandlerType, IDcsParser, DcsFallbackHandlerType, IFunctionIdentifier, ExecuteFallbackHandlerType, CsiFallbackHandlerType, EscFallbackHandlerType, PrintHandlerType, PrintFallbackHandlerType, ExecuteHandlerType, IParserStackState, ParserStackType, ResumableHandlersType } from 'common/parser/Types'; import { ParserState, ParserAction } from 'common/parser/Constants'; import { Disposable } from 'common/Lifecycle'; import { IDisposable } from 'common/Types'; @@ -437,44 +437,28 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP this.precedingCodepoint = 0; } - // FIXME: cleanup async handling - private _parseStack: { - paused: boolean; - type: 'ESC' | 'CSI'; // FIXME: support for DCS and OSC - handlers: CsiHandlerType[] | EscHandlerType[]; - handlerPos: number; - transition: number; - currentState: ParserState; - collect: number; - pos: number; - } = { - paused: false, - type: 'ESC', + /** + * Async parse support. + */ + private _parseStack: IParserStackState = { + state: ParserStackType.NONE, handlers: [], handlerPos: 0, transition: 0, - currentState: 0, - collect: 0, - pos: 0 + chunkPos: 0 }; - private _preserveStack( - type: 'ESC' | 'CSI', - handlers: CsiHandlerType[] | EscHandlerType[], + state: ParserStackType, + handlers: ResumableHandlersType, handlerPos: number, transition: number, - currentState: ParserState, - collect: number, - pos: number - ): void { - this._parseStack.paused = true; - this._parseStack.type = type; + chunkPos: number): void + { + this._parseStack.state = state; this._parseStack.handlers = handlers; this._parseStack.handlerPos = handlerPos; this._parseStack.transition = transition; - this._parseStack.currentState = currentState; - this._parseStack.collect = collect; - this._parseStack.pos = pos; + this._parseStack.chunkPos = chunkPos; } /** @@ -494,22 +478,12 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP public parse(data: Uint32Array, length: number, promiseResult?: boolean): void | Promise { let code = 0; let transition = 0; - let currentState = this.currentState; - const osc = this._oscParser; - const dcs = this._dcsParser; - let collect = this._collect; - const params = this._params; - const table: Uint8Array = this._transitions.table; - - let res: any; let start = 0; - if (this._parseStack.paused) { - const handlers = this._parseStack.handlers; + let handlerResult: any; + + // resume from async handler + if (this._parseStack.state) { let handlerPos = this._parseStack.handlerPos - 1; - transition = this._parseStack.transition; - currentState = this._parseStack.currentState; - collect = this._parseStack.collect; - start = this._parseStack.pos; // we have to resume the old handler loop if: // - return value of the promise was `false` @@ -517,24 +491,25 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP // FIXME: removing handlers from within a handler of the same sequence // is not supported atm (also true for sync handlers)!! if (promiseResult === false && handlerPos > -1) { - switch (this._parseStack.type) { - case 'CSI': + const handlers = this._parseStack.handlers; + switch (this._parseStack.state) { + case ParserStackType.CSI: for (; handlerPos >= 0; handlerPos--) { - if ((res = (handlers as CsiHandlerType[])[handlerPos](params)) !== false) { - if (res instanceof Promise) { + if ((handlerResult = (handlers as CsiHandlerType[])[handlerPos](this._params)) !== false) { + if (handlerResult instanceof Promise) { this._parseStack.handlerPos = handlerPos; - return res; + return handlerResult; } break; } } break; - case 'ESC': + case ParserStackType.ESC: for (; handlerPos >= 0; handlerPos--) { - if ((res = (handlers as EscHandlerType[])[handlerPos]()) !== false) { - if (res instanceof Promise) { + if ((handlerResult = (handlers as EscHandlerType[])[handlerPos]()) !== false) { + if (handlerResult instanceof Promise) { this._parseStack.handlerPos = handlerPos; - return res; + return handlerResult; } break; } @@ -543,20 +518,20 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP } } // cleanup before continuing with the main loop + this._parseStack.state = ParserStackType.NONE; + start = this._parseStack.chunkPos + 1; this.precedingCodepoint = 0; - this._parseStack.paused = false; - start++; - currentState = transition & TableAccess.TRANSITION_STATE_MASK; + this.currentState = this._parseStack.transition & TableAccess.TRANSITION_STATE_MASK; } - // console.log('startPos', start, length); + // continue with main sync loop // process input string for (let i = start; i < length; ++i) { code = data[i]; // normal transition & action lookup - transition = table[currentState << TableAccess.INDEX_STATE_SHIFT | (code < 0xa0 ? code : NON_ASCII_PRINTABLE)]; + transition = this._transitions.table[this.currentState << TableAccess.INDEX_STATE_SHIFT | (code < 0xa0 ? code : NON_ASCII_PRINTABLE)]; switch (transition >> TableAccess.TRANSITION_ACTION_SHIFT) { case ParserAction.PRINT: // read ahead with loop unrolling @@ -596,9 +571,9 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP { position: i, code, - currentState, - collect, - params, + currentState: this.currentState, + collect: this._collect, + params: this._params, abort: false }); if (inject.abort) return; @@ -606,19 +581,20 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP break; case ParserAction.CSI_DISPATCH: // Trigger CSI Handler - const handlers = this._csiHandlers[collect << 8 | code]; + const handlers = this._csiHandlers[this._collect << 8 | code]; let j = handlers ? handlers.length - 1 : -1; for (; j >= 0; j--) { - // undefined or true means success and to stop bubbling - if ((res = handlers[j](params)) === true) { + // true means success and to stop bubbling + // a promise indicates an async handler that needs to finish before progressing + if ((handlerResult = handlers[j](this._params)) === true) { break; - } else if (res instanceof Promise) { - this._preserveStack('CSI', handlers, j, transition, currentState, collect, i); - return res; + } else if (handlerResult instanceof Promise) { + this._preserveStack(ParserStackType.CSI, handlers, j, transition, i); + return handlerResult; } } if (j < 0) { - this._csiHandlerFb(collect << 8 | code, params); + this._csiHandlerFb(this._collect << 8 | code, this._params); } this.precedingCodepoint = 0; break; @@ -627,94 +603,89 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP do { switch (code) { case 0x3b: - params.addParam(0); // ZDM + this._params.addParam(0); // ZDM break; case 0x3a: - params.addSubParam(-1); + this._params.addSubParam(-1); break; default: // 0x30 - 0x39 - params.addDigit(code - 48); + this._params.addDigit(code - 48); } } while (++i < length && (code = data[i]) > 0x2f && code < 0x3c); i--; break; case ParserAction.COLLECT: - collect <<= 8; - collect |= code; + this._collect <<= 8; + this._collect |= code; break; case ParserAction.ESC_DISPATCH: - const handlersEsc = this._escHandlers[collect << 8 | code]; + const handlersEsc = this._escHandlers[this._collect << 8 | code]; let jj = handlersEsc ? handlersEsc.length - 1 : -1; for (; jj >= 0; jj--) { - // undefined or true means success and to stop bubbling - if ((res = handlersEsc[jj]()) === true) { + // true means success and to stop bubbling + // a promise indicates an async handler that needs to finish before progressing + if ((handlerResult = handlersEsc[jj]()) === true) { break; - } else if (res instanceof Promise) { - this._preserveStack('ESC', handlersEsc, jj, transition, currentState, collect, i); - return res; + } else if (handlerResult instanceof Promise) { + this._preserveStack(ParserStackType.ESC, handlersEsc, jj, transition, i); + return handlerResult; } } if (jj < 0) { - this._escHandlerFb(collect << 8 | code); + this._escHandlerFb(this._collect << 8 | code); } this.precedingCodepoint = 0; break; case ParserAction.CLEAR: - params.reset(); - params.addParam(0); // ZDM - collect = 0; + this._params.reset(); + this._params.addParam(0); // ZDM + this._collect = 0; break; case ParserAction.DCS_HOOK: - dcs.hook(collect << 8 | code, params); + this._dcsParser.hook(this._collect << 8 | code, this._params); break; case ParserAction.DCS_PUT: // inner loop - exit DCS_PUT: 0x18, 0x1a, 0x1b, 0x7f, 0x80 - 0x9f // unhook triggered by: 0x1b, 0x9c (success) and 0x18, 0x1a (abort) for (let j = i + 1; ; ++j) { if (j >= length || (code = data[j]) === 0x18 || code === 0x1a || code === 0x1b || (code > 0x7f && code < NON_ASCII_PRINTABLE)) { - dcs.put(data, i, j); + this._dcsParser.put(data, i, j); i = j - 1; break; } } break; case ParserAction.DCS_UNHOOK: - dcs.unhook(code !== 0x18 && code !== 0x1a); + this._dcsParser.unhook(code !== 0x18 && code !== 0x1a); if (code === 0x1b) transition |= ParserState.ESCAPE; - params.reset(); - params.addParam(0); // ZDM - collect = 0; + this._params.reset(); + this._params.addParam(0); // ZDM + this._collect = 0; this.precedingCodepoint = 0; break; case ParserAction.OSC_START: - osc.start(); + this._oscParser.start(); break; case ParserAction.OSC_PUT: // inner loop: 0x20 (SP) included, 0x7F (DEL) included for (let j = i + 1; ; j++) { if (j >= length || (code = data[j]) < 0x20 || (code > 0x7f && code < NON_ASCII_PRINTABLE)) { - osc.put(data, i, j); + this._oscParser.put(data, i, j); i = j - 1; break; } } break; case ParserAction.OSC_END: - osc.end(code !== 0x18 && code !== 0x1a); + this._oscParser.end(code !== 0x18 && code !== 0x1a); if (code === 0x1b) transition |= ParserState.ESCAPE; - params.reset(); - params.addParam(0); // ZDM - collect = 0; + this._params.reset(); + this._params.addParam(0); // ZDM + this._collect = 0; this.precedingCodepoint = 0; break; } - currentState = transition & TableAccess.TRANSITION_STATE_MASK; + this.currentState = transition & TableAccess.TRANSITION_STATE_MASK; } - - // save collected intermediates - this._collect = collect; - - // save state - this.currentState = currentState; } } diff --git a/src/common/parser/Types.d.ts b/src/common/parser/Types.d.ts index 9db38fbd..002fc8ed 100644 --- a/src/common/parser/Types.d.ts +++ b/src/common/parser/Types.d.ts @@ -5,6 +5,7 @@ import { IDisposable } from 'common/Types'; import { ParserState } from 'common/parser/Constants'; +import { OscParser } from 'common/parser/OscParser'; /** sequence params serialized to js arrays */ export type ParamsArray = (number | number[])[]; @@ -237,3 +238,22 @@ export interface IFunctionIdentifier { export interface IHandlerCollection { [key: string]: T[]; } + +/** + * Types for async parser support. + */ +export const enum ParserStackType { + NONE = 0, + CSI, + ESC, + OSC, + DCS +} +export type ResumableHandlersType = CsiHandlerType[] | EscHandlerType[]; +export interface IParserStackState { + state: ParserStackType; + handlers: ResumableHandlersType; + handlerPos: number; + transition: number; + chunkPos: number; +} From d3c9f70bec852b0abf54c177afb80bcef44af30b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sat, 23 Jan 2021 17:09:43 +0100 Subject: [PATCH 079/377] replace expect testing with assert --- src/browser/Terminal.test.ts | 277 ++++---- src/common/Clone.test.ts | 4 +- src/common/InputHandler.test.ts | 150 +++-- src/common/buffer/BufferLine.test.ts | 168 ++--- .../parser/EscapeSequenceParser.test.ts | 620 +++++++++--------- 5 files changed, 635 insertions(+), 584 deletions(-) diff --git a/src/browser/Terminal.test.ts b/src/browser/Terminal.test.ts index 8626be09..8f919302 100644 --- a/src/browser/Terminal.test.ts +++ b/src/browser/Terminal.test.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { assert, expect } from 'chai'; +import { assert } from 'chai'; import { MockViewport, MockCompositionHelper, MockRenderer, TestTerminal } from 'browser/TestUtils.test'; import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; import { CellData } from 'common/buffer/CellData'; @@ -75,7 +75,7 @@ describe('Terminal', () => { it('should fire a key event after a keypress DOM event', (done) => { term.onKey(e => { assert.equal(typeof e.key, 'string'); - expect(e.domEvent).to.be.an.instanceof(Object); + assert.equal(e.domEvent instanceof Object, true); done(); }); const evKeyPress = { @@ -89,7 +89,7 @@ describe('Terminal', () => { it('should fire a key event after a keydown DOM event', (done) => { term.onKey(e => { assert.equal(typeof e.key, 'string'); - expect(e.domEvent).to.be.an.instanceof(Object); + assert.equal(e.domEvent instanceof Object, true); done(); }); (term).textarea = { value: '' }; @@ -103,7 +103,6 @@ describe('Terminal', () => { }); it('should fire the onResize event', (done) => { term.onResize(e => { - expect(e).to.have.keys(['cols', 'rows']); assert.equal(typeof e.cols, 'number'); assert.equal(typeof e.rows, 'number'); done(); @@ -724,10 +723,10 @@ describe('Terminal', () => { for (let i = 0xDC00; i <= 0xDCFF; ++i) { term.writeSync(high + String.fromCharCode(i)); const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); - expect(tchar.getChars()).eql(high + String.fromCharCode(i)); - expect(tchar.getChars().length).eql(2); - expect(tchar.getWidth()).eql(1); - expect(term.buffer.lines.get(0)!.loadCell(1, cell).getChars()).eql(''); + assert.equal(tchar.getChars(), high + String.fromCharCode(i)); + assert.equal(tchar.getChars().length, 2); + assert.equal(tchar.getWidth(), 1); + assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), ''); term.reset(); } }); @@ -737,9 +736,9 @@ describe('Terminal', () => { for (let i = 0xDC00; i <= 0xDCFF; ++i) { term.buffer.x = term.cols - 1; term.writeSync(high + String.fromCharCode(i)); - expect(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars()).eql(high + String.fromCharCode(i)); - expect(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars().length).eql(2); - expect(term.buffer.lines.get(1)!.loadCell(0, cell).getChars()).eql(''); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars(), high + String.fromCharCode(i)); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars().length, 2); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), ''); term.reset(); } }); @@ -750,10 +749,10 @@ describe('Terminal', () => { term.buffer.x = term.cols - 1; term.writeSync('a' + high + String.fromCharCode(i)); - expect(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars()).eql('a'); - expect(term.buffer.lines.get(1)!.loadCell(0, cell).getChars()).eql(high + String.fromCharCode(i)); - expect(term.buffer.lines.get(1)!.loadCell(0, cell).getChars().length).eql(2); - expect(term.buffer.lines.get(1)!.loadCell(1, cell).getChars()).eql(''); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), 'a'); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), high + String.fromCharCode(i)); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars().length, 2); + assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), ''); term.reset(); } }); @@ -769,9 +768,9 @@ describe('Terminal', () => { } term.writeSync('a' + high + String.fromCharCode(i)); // auto wraparound mode should cut off the rest of the line - expect(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars()).eql(high + String.fromCharCode(i)); - expect(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars().length).eql(2); - expect(term.buffer.lines.get(1)!.loadCell(1, cell).getChars()).eql(''); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), high + String.fromCharCode(i)); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars().length, 2); + assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), ''); term.reset(); } }); @@ -782,10 +781,10 @@ describe('Terminal', () => { term.writeSync(high); term.writeSync(String.fromCharCode(i)); const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); - expect(tchar.getChars()).eql(high + String.fromCharCode(i)); - expect(tchar.getChars().length).eql(2); - expect(tchar.getWidth()).eql(1); - expect(term.buffer.lines.get(0)!.loadCell(1, cell).getChars()).eql(''); + assert.equal(tchar.getChars(), high + String.fromCharCode(i)); + assert.equal(tchar.getChars().length, 2); + assert.equal(tchar.getWidth(), 1); + assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), ''); term.reset(); } }); @@ -796,81 +795,81 @@ describe('Terminal', () => { it('café', () => { term.writeSync('cafe\u0301'); term.buffer.lines.get(0)!.loadCell(3, cell); - expect(cell.getChars()).eql('e\u0301'); - expect(cell.getChars().length).eql(2); - expect(cell.getWidth()).eql(1); + assert.equal(cell.getChars(), 'e\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 1); }); it('café - end of line', () => { term.buffer.x = term.cols - 1 - 3; term.writeSync('cafe\u0301'); term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); - expect(cell.getChars()).eql('e\u0301'); - expect(cell.getChars().length).eql(2); - expect(cell.getWidth()).eql(1); + assert.equal(cell.getChars(), 'e\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 1); term.buffer.lines.get(0)!.loadCell(1, cell); - expect(cell.getChars()).eql(''); - expect(cell.getChars().length).eql(0); - expect(cell.getWidth()).eql(1); + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 1); }); it('multiple combined é', () => { term.writeSync(Array(100).join('e\u0301')); for (let i = 0; i < term.cols; ++i) { term.buffer.lines.get(0)!.loadCell(i, cell); - expect(cell.getChars()).eql('e\u0301'); - expect(cell.getChars().length).eql(2); - expect(cell.getWidth()).eql(1); + assert.equal(cell.getChars(), 'e\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 1); } term.buffer.lines.get(1)!.loadCell(0, cell); - expect(cell.getChars()).eql('e\u0301'); - expect(cell.getChars().length).eql(2); - expect(cell.getWidth()).eql(1); + assert.equal(cell.getChars(), 'e\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 1); }); it('multiple surrogate with combined', () => { term.writeSync(Array(100).join('\uD800\uDC00\u0301')); for (let i = 0; i < term.cols; ++i) { term.buffer.lines.get(0)!.loadCell(i, cell); - expect(cell.getChars()).eql('\uD800\uDC00\u0301'); - expect(cell.getChars().length).eql(3); - expect(cell.getWidth()).eql(1); + assert.equal(cell.getChars(), '\uD800\uDC00\u0301'); + assert.equal(cell.getChars().length, 3); + assert.equal(cell.getWidth(), 1); } term.buffer.lines.get(1)!.loadCell(0, cell); - expect(cell.getChars()).eql('\uD800\uDC00\u0301'); - expect(cell.getChars().length).eql(3); - expect(cell.getWidth()).eql(1); + assert.equal(cell.getChars(), '\uD800\uDC00\u0301'); + assert.equal(cell.getChars().length, 3); + assert.equal(cell.getWidth(), 1); }); }); describe('unicode - fullwidth characters', () => { const cell = new CellData(); it('cursor movement even', () => { - expect(term.buffer.x).eql(0); + assert.equal(term.buffer.x, 0); term.writeSync('¥'); - expect(term.buffer.x).eql(2); + assert.equal(term.buffer.x, 2); }); it('cursor movement odd', () => { term.buffer.x = 1; - expect(term.buffer.x).eql(1); + assert.equal(term.buffer.x, 1); term.writeSync('¥'); - expect(term.buffer.x).eql(3); + assert.equal(term.buffer.x, 3); }); it('line of ¥ even', () => { term.writeSync(Array(50).join('¥')); for (let i = 0; i < term.cols; ++i) { term.buffer.lines.get(0)!.loadCell(i, cell); if (i % 2) { - expect(cell.getChars()).eql(''); - expect(cell.getChars().length).eql(0); - expect(cell.getWidth()).eql(0); + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 0); } else { - expect(cell.getChars()).eql('¥'); - expect(cell.getChars().length).eql(1); - expect(cell.getWidth()).eql(2); + assert.equal(cell.getChars(), '¥'); + assert.equal(cell.getChars().length, 1); + assert.equal(cell.getWidth(), 2); } } term.buffer.lines.get(1)!.loadCell(0, cell); - expect(cell.getChars()).eql('¥'); - expect(cell.getChars().length).eql(1); - expect(cell.getWidth()).eql(2); + assert.equal(cell.getChars(), '¥'); + assert.equal(cell.getChars().length, 1); + assert.equal(cell.getWidth(), 2); }); it('line of ¥ odd', () => { term.buffer.x = 1; @@ -878,23 +877,23 @@ describe('Terminal', () => { for (let i = 1; i < term.cols - 1; ++i) { term.buffer.lines.get(0)!.loadCell(i, cell); if (!(i % 2)) { - expect(cell.getChars()).eql(''); - expect(cell.getChars().length).eql(0); - expect(cell.getWidth()).eql(0); + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 0); } else { - expect(cell.getChars()).eql('¥'); - expect(cell.getChars().length).eql(1); - expect(cell.getWidth()).eql(2); + assert.equal(cell.getChars(), '¥'); + assert.equal(cell.getChars().length, 1); + assert.equal(cell.getWidth(), 2); } } term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); - expect(cell.getChars()).eql(''); - expect(cell.getChars().length).eql(0); - expect(cell.getWidth()).eql(1); + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 1); term.buffer.lines.get(1)!.loadCell(0, cell); - expect(cell.getChars()).eql('¥'); - expect(cell.getChars().length).eql(1); - expect(cell.getWidth()).eql(2); + assert.equal(cell.getChars(), '¥'); + assert.equal(cell.getChars().length, 1); + assert.equal(cell.getWidth(), 2); }); it('line of ¥ with combining odd', () => { term.buffer.x = 1; @@ -902,42 +901,42 @@ describe('Terminal', () => { for (let i = 1; i < term.cols - 1; ++i) { term.buffer.lines.get(0)!.loadCell(i, cell); if (!(i % 2)) { - expect(cell.getChars()).eql(''); - expect(cell.getChars().length).eql(0); - expect(cell.getWidth()).eql(0); + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 0); } else { - expect(cell.getChars()).eql('¥\u0301'); - expect(cell.getChars().length).eql(2); - expect(cell.getWidth()).eql(2); + assert.equal(cell.getChars(), '¥\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 2); } } term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); - expect(cell.getChars()).eql(''); - expect(cell.getChars().length).eql(0); - expect(cell.getWidth()).eql(1); + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 1); term.buffer.lines.get(1)!.loadCell(0, cell); - expect(cell.getChars()).eql('¥\u0301'); - expect(cell.getChars().length).eql(2); - expect(cell.getWidth()).eql(2); + assert.equal(cell.getChars(), '¥\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 2); }); it('line of ¥ with combining even', () => { term.writeSync(Array(50).join('¥\u0301')); for (let i = 0; i < term.cols; ++i) { term.buffer.lines.get(0)!.loadCell(i, cell); if (i % 2) { - expect(cell.getChars()).eql(''); - expect(cell.getChars().length).eql(0); - expect(cell.getWidth()).eql(0); + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 0); } else { - expect(cell.getChars()).eql('¥\u0301'); - expect(cell.getChars().length).eql(2); - expect(cell.getWidth()).eql(2); + assert.equal(cell.getChars(), '¥\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 2); } } term.buffer.lines.get(1)!.loadCell(0, cell); - expect(cell.getChars()).eql('¥\u0301'); - expect(cell.getChars().length).eql(2); - expect(cell.getWidth()).eql(2); + assert.equal(cell.getChars(), '¥\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 2); }); it('line of surrogate fullwidth with combining odd', () => { term.buffer.x = 1; @@ -945,42 +944,42 @@ describe('Terminal', () => { for (let i = 1; i < term.cols - 1; ++i) { term.buffer.lines.get(0)!.loadCell(i, cell); if (!(i % 2)) { - expect(cell.getChars()).eql(''); - expect(cell.getChars().length).eql(0); - expect(cell.getWidth()).eql(0); + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 0); } else { - expect(cell.getChars()).eql('\ud843\ude6d\u0301'); - expect(cell.getChars().length).eql(3); - expect(cell.getWidth()).eql(2); + assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); + assert.equal(cell.getChars().length, 3); + assert.equal(cell.getWidth(), 2); } } term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); - expect(cell.getChars()).eql(''); - expect(cell.getChars().length).eql(0); - expect(cell.getWidth()).eql(1); + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 1); term.buffer.lines.get(1)!.loadCell(0, cell); - expect(cell.getChars()).eql('\ud843\ude6d\u0301'); - expect(cell.getChars().length).eql(3); - expect(cell.getWidth()).eql(2); + assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); + assert.equal(cell.getChars().length, 3); + assert.equal(cell.getWidth(), 2); }); it('line of surrogate fullwidth with combining even', () => { term.writeSync(Array(50).join('\ud843\ude6d\u0301')); for (let i = 0; i < term.cols; ++i) { term.buffer.lines.get(0)!.loadCell(i, cell); if (i % 2) { - expect(cell.getChars()).eql(''); - expect(cell.getChars().length).eql(0); - expect(cell.getWidth()).eql(0); + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 0); } else { - expect(cell.getChars()).eql('\ud843\ude6d\u0301'); - expect(cell.getChars().length).eql(3); - expect(cell.getWidth()).eql(2); + assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); + assert.equal(cell.getChars().length, 3); + assert.equal(cell.getWidth(), 2); } } term.buffer.lines.get(1)!.loadCell(0, cell); - expect(cell.getChars()).eql('\ud843\ude6d\u0301'); - expect(cell.getChars().length).eql(3); - expect(cell.getWidth()).eql(2); + assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); + assert.equal(cell.getChars().length, 3); + assert.equal(cell.getWidth(), 2); }); }); @@ -992,11 +991,11 @@ describe('Terminal', () => { term.buffer.y = 0; term.write('\x1b[4h'); term.writeSync('abcde'); - expect(term.buffer.lines.get(0)!.length).eql(term.cols); - expect(term.buffer.lines.get(0)!.loadCell(10, cell).getChars()).eql('a'); - expect(term.buffer.lines.get(0)!.loadCell(14, cell).getChars()).eql('e'); - expect(term.buffer.lines.get(0)!.loadCell(15, cell).getChars()).eql('0'); - expect(term.buffer.lines.get(0)!.loadCell(79, cell).getChars()).eql('4'); + assert.equal(term.buffer.lines.get(0)!.length, term.cols); + assert.equal(term.buffer.lines.get(0)!.loadCell(10, cell).getChars(), 'a'); + assert.equal(term.buffer.lines.get(0)!.loadCell(14, cell).getChars(), 'e'); + assert.equal(term.buffer.lines.get(0)!.loadCell(15, cell).getChars(), '0'); + assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), '4'); }); it('fullwidth - insert', () => { term.writeSync(Array(9).join('0123456789').slice(-80)); @@ -1004,12 +1003,12 @@ describe('Terminal', () => { term.buffer.y = 0; term.write('\x1b[4h'); term.writeSync('¥¥¥'); - expect(term.buffer.lines.get(0)!.length).eql(term.cols); - expect(term.buffer.lines.get(0)!.loadCell(10, cell).getChars()).eql('¥'); - expect(term.buffer.lines.get(0)!.loadCell(11, cell).getChars()).eql(''); - expect(term.buffer.lines.get(0)!.loadCell(14, cell).getChars()).eql('¥'); - expect(term.buffer.lines.get(0)!.loadCell(15, cell).getChars()).eql(''); - expect(term.buffer.lines.get(0)!.loadCell(79, cell).getChars()).eql('3'); + assert.equal(term.buffer.lines.get(0)!.length, term.cols); + assert.equal(term.buffer.lines.get(0)!.loadCell(10, cell).getChars(), '¥'); + assert.equal(term.buffer.lines.get(0)!.loadCell(11, cell).getChars(), ''); + assert.equal(term.buffer.lines.get(0)!.loadCell(14, cell).getChars(), '¥'); + assert.equal(term.buffer.lines.get(0)!.loadCell(15, cell).getChars(), ''); + assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), '3'); }); it('fullwidth - right border', () => { term.writeSync(Array(41).join('¥')); @@ -1017,15 +1016,15 @@ describe('Terminal', () => { term.buffer.y = 0; term.write('\x1b[4h'); term.writeSync('a'); - expect(term.buffer.lines.get(0)!.length).eql(term.cols); - expect(term.buffer.lines.get(0)!.loadCell(10, cell).getChars()).eql('a'); - expect(term.buffer.lines.get(0)!.loadCell(11, cell).getChars()).eql('¥'); - expect(term.buffer.lines.get(0)!.loadCell(79, cell).getChars()).eql(''); // fullwidth char got replaced + assert.equal(term.buffer.lines.get(0)!.length, term.cols); + assert.equal(term.buffer.lines.get(0)!.loadCell(10, cell).getChars(), 'a'); + assert.equal(term.buffer.lines.get(0)!.loadCell(11, cell).getChars(), '¥'); + assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), ''); // fullwidth char got replaced term.writeSync('b'); - expect(term.buffer.lines.get(0)!.length).eql(term.cols); - expect(term.buffer.lines.get(0)!.loadCell(11, cell).getChars()).eql('b'); - expect(term.buffer.lines.get(0)!.loadCell(12, cell).getChars()).eql('¥'); - expect(term.buffer.lines.get(0)!.loadCell(79, cell).getChars()).eql(''); // empty cell after fullwidth + assert.equal(term.buffer.lines.get(0)!.length, term.cols); + assert.equal(term.buffer.lines.get(0)!.loadCell(11, cell).getChars(), 'b'); + assert.equal(term.buffer.lines.get(0)!.loadCell(12, cell).getChars(), '¥'); + assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), ''); // empty cell after fullwidth }); }); @@ -1346,7 +1345,7 @@ describe('Terminal', () => { ]; terminal.writeSync(data.join('')); // brute force test with insane values - expect(() => { + assert.doesNotThrow(() => { for (let overscan = 0; overscan < 20; ++overscan) { for (let start = -10; start < 20; ++start) { for (let end = -10; end < 20; ++end) { @@ -1357,7 +1356,7 @@ describe('Terminal', () => { } } } - }).to.not.throw(); + }); }); }); @@ -1406,18 +1405,18 @@ describe('Terminal', () => { // not converting const termNotConverting = new TestTerminal({cols: 15, rows: 10}); termNotConverting.writeSync('Hello\nWorld'); - expect(termNotConverting.buffer.lines.get(0)!.translateToString(false)).equals('Hello '); - expect(termNotConverting.buffer.lines.get(1)!.translateToString(false)).equals(' World '); - expect(termNotConverting.buffer.lines.get(0)!.translateToString(true)).equals('Hello'); - expect(termNotConverting.buffer.lines.get(1)!.translateToString(true)).equals(' World'); + assert.equal(termNotConverting.buffer.lines.get(0)!.translateToString(false), 'Hello '); + assert.equal(termNotConverting.buffer.lines.get(1)!.translateToString(false), ' World '); + assert.equal(termNotConverting.buffer.lines.get(0)!.translateToString(true), 'Hello'); + assert.equal(termNotConverting.buffer.lines.get(1)!.translateToString(true), ' World'); // converting const termConverting = new TestTerminal({cols: 15, rows: 10, convertEol: true}); termConverting.writeSync('Hello\nWorld'); - expect(termConverting.buffer.lines.get(0)!.translateToString(false)).equals('Hello '); - expect(termConverting.buffer.lines.get(1)!.translateToString(false)).equals('World '); - expect(termConverting.buffer.lines.get(0)!.translateToString(true)).equals('Hello'); - expect(termConverting.buffer.lines.get(1)!.translateToString(true)).equals('World'); + assert.equal(termConverting.buffer.lines.get(0)!.translateToString(false), 'Hello '); + assert.equal(termConverting.buffer.lines.get(1)!.translateToString(false), 'World '); + assert.equal(termConverting.buffer.lines.get(0)!.translateToString(true), 'Hello'); + assert.equal(termConverting.buffer.lines.get(1)!.translateToString(true), 'World'); }); describe('Terminal InputHandler integration', () => { function getLines(term: TestTerminal, limit: number = term.rows): string[] { diff --git a/src/common/Clone.test.ts b/src/common/Clone.test.ts index 370538ea..5fbe4bf9 100644 --- a/src/common/Clone.test.ts +++ b/src/common/Clone.test.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { assert, expect } from 'chai'; +import { assert } from 'chai'; import { clone } from 'common/Clone'; describe('clone', () => { @@ -124,6 +124,6 @@ describe('clone', () => { test.a.b.c = test; - expect(() => clone(test)).to.not.throw(); + assert.doesNotThrow(() => clone(test)); }); }); diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index 4c0d8559..e1fcd727 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { assert, expect } from 'chai'; +import { assert } from 'chai'; import { InputHandler } from 'common/InputHandler'; import { IBufferLine, IAttributeData, IAnsiColorChangeEvent } from 'common/Types'; import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; @@ -136,7 +136,16 @@ describe('InputHandler', () => { it('insertChars', function(): void { const bufferService = new MockBufferService(80, 30); - const inputHandler = new InputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService()); + const inputHandler = new TestInputHandler( + bufferService, + new MockCharsetService(), + new MockCoreService(), + new MockDirtyRowService(), + new MockLogService(), + new MockOptionsService(), + new MockCoreMouseService(), + new MockUnicodeService() + ); // insert some data in first and second line inputHandler.parse(Array(bufferService.cols - 9).join('a')); @@ -144,36 +153,45 @@ describe('InputHandler', () => { inputHandler.parse(Array(bufferService.cols - 9).join('a')); inputHandler.parse('1234567890'); const line1: IBufferLine = bufferService.buffer.lines.get(0)!; - expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + '1234567890'); + assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + '1234567890'); // insert one char from params = [0] bufferService.buffer.y = 0; bufferService.buffer.x = 70; inputHandler.insertChars(Params.fromArray([0])); - expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + ' 123456789'); + assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + ' 123456789'); // insert one char from params = [1] bufferService.buffer.y = 0; bufferService.buffer.x = 70; inputHandler.insertChars(Params.fromArray([1])); - expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + ' 12345678'); + assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + ' 12345678'); // insert two chars from params = [2] bufferService.buffer.y = 0; bufferService.buffer.x = 70; inputHandler.insertChars(Params.fromArray([2])); - expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + ' 123456'); + assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + ' 123456'); // insert 10 chars from params = [10] bufferService.buffer.y = 0; bufferService.buffer.x = 70; inputHandler.insertChars(Params.fromArray([10])); - expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + ' '); - expect(line1.translateToString(true)).equals(Array(bufferService.cols - 9).join('a')); + assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + ' '); + assert.equal(line1.translateToString(true), Array(bufferService.cols - 9).join('a')); }); it('deleteChars', function(): void { const bufferService = new MockBufferService(80, 30); - const inputHandler = new InputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService()); + const inputHandler = new TestInputHandler( + bufferService, + new MockCharsetService(), + new MockCoreService(), + new MockDirtyRowService(), + new MockLogService(), + new MockOptionsService(), + new MockCoreMouseService(), + new MockUnicodeService() + ); // insert some data in first and second line inputHandler.parse(Array(bufferService.cols - 9).join('a')); @@ -181,39 +199,49 @@ describe('InputHandler', () => { inputHandler.parse(Array(bufferService.cols - 9).join('a')); inputHandler.parse('1234567890'); const line1: IBufferLine = bufferService.buffer.lines.get(0)!; - expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + '1234567890'); + assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + '1234567890'); // delete one char from params = [0] bufferService.buffer.y = 0; bufferService.buffer.x = 70; inputHandler.deleteChars(Params.fromArray([0])); - expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + '234567890 '); - expect(line1.translateToString(true)).equals(Array(bufferService.cols - 9).join('a') + '234567890'); + assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + '234567890 '); + assert.equal(line1.translateToString(true), Array(bufferService.cols - 9).join('a') + '234567890'); // insert one char from params = [1] bufferService.buffer.y = 0; bufferService.buffer.x = 70; inputHandler.deleteChars(Params.fromArray([1])); - expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + '34567890 '); - expect(line1.translateToString(true)).equals(Array(bufferService.cols - 9).join('a') + '34567890'); + assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + '34567890 '); + assert.equal(line1.translateToString(true), Array(bufferService.cols - 9).join('a') + '34567890'); // insert two chars from params = [2] bufferService.buffer.y = 0; bufferService.buffer.x = 70; inputHandler.deleteChars(Params.fromArray([2])); - expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + '567890 '); - expect(line1.translateToString(true)).equals(Array(bufferService.cols - 9).join('a') + '567890'); + assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + '567890 '); + assert.equal(line1.translateToString(true), Array(bufferService.cols - 9).join('a') + '567890'); + // insert 10 chars from params = [10] bufferService.buffer.y = 0; bufferService.buffer.x = 70; inputHandler.deleteChars(Params.fromArray([10])); - expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + ' '); - expect(line1.translateToString(true)).equals(Array(bufferService.cols - 9).join('a')); + assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + ' '); + assert.equal(line1.translateToString(true), Array(bufferService.cols - 9).join('a')); }); it('eraseInLine', function(): void { const bufferService = new MockBufferService(80, 30); - const inputHandler = new InputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService()); + const inputHandler = new TestInputHandler( + bufferService, + new MockCharsetService(), + new MockCoreService(), + new MockDirtyRowService(), + new MockLogService(), + new MockOptionsService(), + new MockCoreMouseService(), + new MockUnicodeService() + ); // fill 6 lines to test 3 different states inputHandler.parse(Array(bufferService.cols + 1).join('a')); @@ -224,24 +252,33 @@ describe('InputHandler', () => { bufferService.buffer.y = 0; bufferService.buffer.x = 70; inputHandler.eraseInLine(Params.fromArray([0])); - expect(bufferService.buffer.lines.get(0)!.translateToString(false)).equals(Array(71).join('a') + ' '); + assert.equal(bufferService.buffer.lines.get(0)!.translateToString(false), Array(71).join('a') + ' '); // params[1] - left erase bufferService.buffer.y = 1; bufferService.buffer.x = 70; inputHandler.eraseInLine(Params.fromArray([1])); - expect(bufferService.buffer.lines.get(1)!.translateToString(false)).equals(Array(71).join(' ') + ' aaaaaaaaa'); + assert.equal(bufferService.buffer.lines.get(1)!.translateToString(false), Array(71).join(' ') + ' aaaaaaaaa'); // params[1] - left erase bufferService.buffer.y = 2; bufferService.buffer.x = 70; inputHandler.eraseInLine(Params.fromArray([2])); - expect(bufferService.buffer.lines.get(2)!.translateToString(false)).equals(Array(bufferService.cols + 1).join(' ')); + assert.equal(bufferService.buffer.lines.get(2)!.translateToString(false), Array(bufferService.cols + 1).join(' ')); }); it('eraseInDisplay', function(): void { const bufferService = new MockBufferService(80, 7); - const inputHandler = new InputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService()); + const inputHandler = new TestInputHandler( + bufferService, + new MockCharsetService(), + new MockCoreService(), + new MockDirtyRowService(), + new MockLogService(), + new MockOptionsService(), + new MockCoreMouseService(), + new MockUnicodeService() + ); // fill display with a's for (let i = 0; i < bufferService.rows; ++i) inputHandler.parse(Array(bufferService.cols + 1).join('a')); @@ -250,7 +287,7 @@ describe('InputHandler', () => { bufferService.buffer.y = 5; bufferService.buffer.x = 40; inputHandler.eraseInDisplay(Params.fromArray([0])); - expect(termContent(bufferService, false)).eql([ + assert.deepEqual(termContent(bufferService, false), [ Array(bufferService.cols + 1).join('a'), Array(bufferService.cols + 1).join('a'), Array(bufferService.cols + 1).join('a'), @@ -259,7 +296,7 @@ describe('InputHandler', () => { Array(40 + 1).join('a') + Array(bufferService.cols - 40 + 1).join(' '), Array(bufferService.cols + 1).join(' ') ]); - expect(termContent(bufferService, true)).eql([ + assert.deepEqual(termContent(bufferService, true), [ Array(bufferService.cols + 1).join('a'), Array(bufferService.cols + 1).join('a'), Array(bufferService.cols + 1).join('a'), @@ -278,7 +315,7 @@ describe('InputHandler', () => { bufferService.buffer.y = 5; bufferService.buffer.x = 40; inputHandler.eraseInDisplay(Params.fromArray([1])); - expect(termContent(bufferService, false)).eql([ + assert.deepEqual(termContent(bufferService, false), [ Array(bufferService.cols + 1).join(' '), Array(bufferService.cols + 1).join(' '), Array(bufferService.cols + 1).join(' '), @@ -287,7 +324,7 @@ describe('InputHandler', () => { Array(41 + 1).join(' ') + Array(bufferService.cols - 41 + 1).join('a'), Array(bufferService.cols + 1).join('a') ]); - expect(termContent(bufferService, true)).eql([ + assert.deepEqual(termContent(bufferService, true), [ '', '', '', @@ -306,7 +343,7 @@ describe('InputHandler', () => { bufferService.buffer.y = 5; bufferService.buffer.x = 40; inputHandler.eraseInDisplay(Params.fromArray([2])); - expect(termContent(bufferService, false)).eql([ + assert.deepEqual(termContent(bufferService, false), [ Array(bufferService.cols + 1).join(' '), Array(bufferService.cols + 1).join(' '), Array(bufferService.cols + 1).join(' '), @@ -315,7 +352,7 @@ describe('InputHandler', () => { Array(bufferService.cols + 1).join(' '), Array(bufferService.cols + 1).join(' ') ]); - expect(termContent(bufferService, true)).eql([ + assert.deepEqual(termContent(bufferService, true), [ '', '', '', @@ -334,11 +371,11 @@ describe('InputHandler', () => { // params[1] left and above with wrap // confirm precondition that line 2 is wrapped - expect(bufferService.buffer.lines.get(2)!.isWrapped).true; + assert.equal(bufferService.buffer.lines.get(2)!.isWrapped, true); bufferService.buffer.y = 2; bufferService.buffer.x = 40; inputHandler.eraseInDisplay(Params.fromArray([1])); - expect(bufferService.buffer.lines.get(2)!.isWrapped).false; + assert.equal(bufferService.buffer.lines.get(2)!.isWrapped, false); // reset and add a wrapped line bufferService.buffer.y = 0; @@ -349,16 +386,25 @@ describe('InputHandler', () => { // params[1] left and above with wrap // confirm precondition that line 2 is wrapped - expect(bufferService.buffer.lines.get(2)!.isWrapped).true; + assert.equal(bufferService.buffer.lines.get(2)!.isWrapped, true); bufferService.buffer.y = 1; bufferService.buffer.x = 90; // Cursor is beyond last column inputHandler.eraseInDisplay(Params.fromArray([1])); - expect(bufferService.buffer.lines.get(2)!.isWrapped).false; + assert.equal(bufferService.buffer.lines.get(2)!.isWrapped, false); }); }); describe('print', () => { it('should not cause an infinite loop (regression test)', () => { - const inputHandler = new InputHandler(new MockBufferService(80, 30), new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService()); + const inputHandler = new TestInputHandler( + new MockBufferService(80, 30), + new MockCharsetService(), + new MockCoreService(), + new MockDirtyRowService(), + new MockLogService(), + new MockOptionsService(), + new MockCoreMouseService(), + new MockUnicodeService() + ); const container = new Uint32Array(10); container[0] = 0x200B; inputHandler.print(container, 0, 1); @@ -383,48 +429,48 @@ describe('InputHandler', () => { }); it('should handle DECSET/DECRST 47 (alt screen buffer)', () => { handler.parse('\x1b[?47h\r\n\x1b[31mJUNK\x1b[?47lTEST'); - expect(bufferService.buffer.translateBufferLineToString(0, true)).to.equal(''); - expect(bufferService.buffer.translateBufferLineToString(1, true)).to.equal(' TEST'); + assert.equal(bufferService.buffer.translateBufferLineToString(0, true), ''); + assert.equal(bufferService.buffer.translateBufferLineToString(1, true), ' TEST'); // Text color of 'TEST' should be red - expect((bufferService.buffer.lines.get(1)!.loadCell(4, new CellData()).getFgColor())).to.equal(1); + assert.equal((bufferService.buffer.lines.get(1)!.loadCell(4, new CellData()).getFgColor()), 1); }); it('should handle DECSET/DECRST 1047 (alt screen buffer)', () => { handler.parse('\x1b[?1047h\r\n\x1b[31mJUNK\x1b[?1047lTEST'); - expect(bufferService.buffer.translateBufferLineToString(0, true)).to.equal(''); - expect(bufferService.buffer.translateBufferLineToString(1, true)).to.equal(' TEST'); + assert.equal(bufferService.buffer.translateBufferLineToString(0, true), ''); + assert.equal(bufferService.buffer.translateBufferLineToString(1, true), ' TEST'); // Text color of 'TEST' should be red - expect((bufferService.buffer.lines.get(1)!.loadCell(4, new CellData()).getFgColor())).to.equal(1); + assert.equal((bufferService.buffer.lines.get(1)!.loadCell(4, new CellData()).getFgColor()), 1); }); it('should handle DECSET/DECRST 1048 (alt screen cursor)', () => { handler.parse('\x1b[?1048h\r\n\x1b[31mJUNK\x1b[?1048lTEST'); - expect(bufferService.buffer.translateBufferLineToString(0, true)).to.equal('TEST'); - expect(bufferService.buffer.translateBufferLineToString(1, true)).to.equal('JUNK'); + assert.equal(bufferService.buffer.translateBufferLineToString(0, true), 'TEST'); + assert.equal(bufferService.buffer.translateBufferLineToString(1, true), 'JUNK'); // Text color of 'TEST' should be default - expect(bufferService.buffer.lines.get(0)!.loadCell(0, new CellData()).fg).to.equal(DEFAULT_ATTR_DATA.fg); + assert.equal(bufferService.buffer.lines.get(0)!.loadCell(0, new CellData()).fg, DEFAULT_ATTR_DATA.fg); // Text color of 'JUNK' should be red - expect((bufferService.buffer.lines.get(1)!.loadCell(0, new CellData()).getFgColor())).to.equal(1); + assert.equal((bufferService.buffer.lines.get(1)!.loadCell(0, new CellData()).getFgColor()), 1); }); it('should handle DECSET/DECRST 1049 (alt screen buffer+cursor)', () => { handler.parse('\x1b[?1049h\r\n\x1b[31mJUNK\x1b[?1049lTEST'); - expect(bufferService.buffer.translateBufferLineToString(0, true)).to.equal('TEST'); - expect(bufferService.buffer.translateBufferLineToString(1, true)).to.equal(''); + assert.equal(bufferService.buffer.translateBufferLineToString(0, true), 'TEST'); + assert.equal(bufferService.buffer.translateBufferLineToString(1, true), ''); // Text color of 'TEST' should be default - expect(bufferService.buffer.lines.get(0)!.loadCell(0, new CellData()).fg).to.equal(DEFAULT_ATTR_DATA.fg); + assert.equal(bufferService.buffer.lines.get(0)!.loadCell(0, new CellData()).fg, DEFAULT_ATTR_DATA.fg); }); it('should handle DECSET/DECRST 1049 - maintains saved cursor for alt buffer', () => { handler.parse('\x1b[?1049h\r\n\x1b[31m\x1b[s\x1b[?1049lTEST'); - expect(bufferService.buffer.translateBufferLineToString(0, true)).to.equal('TEST'); + assert.equal(bufferService.buffer.translateBufferLineToString(0, true), 'TEST'); // Text color of 'TEST' should be default - expect(bufferService.buffer.lines.get(0)!.loadCell(0, new CellData()).fg).to.equal(DEFAULT_ATTR_DATA.fg); + assert.equal(bufferService.buffer.lines.get(0)!.loadCell(0, new CellData()).fg, DEFAULT_ATTR_DATA.fg); handler.parse('\x1b[?1049h\x1b[uTEST'); - expect(bufferService.buffer.translateBufferLineToString(1, true)).to.equal('TEST'); + assert.equal(bufferService.buffer.translateBufferLineToString(1, true), 'TEST'); // Text color of 'TEST' should be red - expect((bufferService.buffer.lines.get(1)!.loadCell(0, new CellData()).getFgColor())).to.equal(1); + assert.equal((bufferService.buffer.lines.get(1)!.loadCell(0, new CellData()).getFgColor()), 1); }); it('should handle DECSET/DECRST 1049 - clears alt buffer with erase attributes', () => { handler.parse('\x1b[42m\x1b[?1049h'); // Buffer should be filled with green background - expect(bufferService.buffer.lines.get(20)!.loadCell(10, new CellData()).getBgColor()).to.equal(2); + assert.equal(bufferService.buffer.lines.get(20)!.loadCell(10, new CellData()).getBgColor(), 2); }); }); diff --git a/src/common/buffer/BufferLine.test.ts b/src/common/buffer/BufferLine.test.ts index 4c5fc3a4..fa15a854 100644 --- a/src/common/buffer/BufferLine.test.ts +++ b/src/common/buffer/BufferLine.test.ts @@ -6,7 +6,7 @@ import { NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, DEFAULT_ATTR, Content, import { BufferLine } from 'common/buffer//BufferLine'; import { CellData } from 'common/buffer/CellData'; import { CharData, IBufferLine } from '../Types'; -import { assert, expect } from 'chai'; +import { assert } from 'chai'; import { AttributeData } from 'common/buffer/AttributeData'; @@ -151,20 +151,20 @@ describe('CellData', () => { describe('BufferLine', function(): void { it('ctor', function(): void { let line: IBufferLine = new TestBufferLine(0); - expect(line.length).equals(0); - expect(line.isWrapped).equals(false); + assert.equal(line.length, 0); + assert.equal(line.isWrapped, false); line = new TestBufferLine(10); - expect(line.length).equals(10); - expect(line.loadCell(0, new CellData()).getAsCharData()).eql([0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]); - expect(line.isWrapped).equals(false); + assert.equal(line.length, 10); + assert.deepEqual(line.loadCell(0, new CellData()).getAsCharData(), [0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]); + assert.equal(line.isWrapped, false); line = new TestBufferLine(10, undefined, true); - expect(line.length).equals(10); - expect(line.loadCell(0, new CellData()).getAsCharData()).eql([0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]); - expect(line.isWrapped).equals(true); + assert.equal(line.length, 10); + assert.deepEqual(line.loadCell(0, new CellData()).getAsCharData(), [0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]); + assert.equal(line.isWrapped, true); line = new TestBufferLine(10, CellData.fromCharData([123, 'a', 456, 'a'.charCodeAt(0)]), true); - expect(line.length).equals(10); - expect(line.loadCell(0, new CellData()).getAsCharData()).eql([123, 'a', 456, 'a'.charCodeAt(0)]); - expect(line.isWrapped).equals(true); + assert.equal(line.length, 10); + assert.deepEqual(line.loadCell(0, new CellData()).getAsCharData(), [123, 'a', 456, 'a'.charCodeAt(0)]); + assert.equal(line.isWrapped, true); }); it('insertCells', function(): void { const line = new TestBufferLine(3); @@ -172,7 +172,7 @@ describe('BufferLine', function(): void { line.setCell(1, CellData.fromCharData([2, 'b', 0, 'b'.charCodeAt(0)])); line.setCell(2, CellData.fromCharData([3, 'c', 0, 'c'.charCodeAt(0)])); line.insertCells(1, 3, CellData.fromCharData([4, 'd', 0, 'd'.charCodeAt(0)])); - expect(line.toArray()).eql([ + assert.deepEqual(line.toArray(), [ [1, 'a', 0, 'a'.charCodeAt(0)], [4, 'd', 0, 'd'.charCodeAt(0)], [4, 'd', 0, 'd'.charCodeAt(0)] @@ -186,7 +186,7 @@ describe('BufferLine', function(): void { line.setCell(3, CellData.fromCharData([4, 'd', 0, 'd'.charCodeAt(0)])); line.setCell(4, CellData.fromCharData([5, 'e', 0, 'e'.charCodeAt(0)])); line.deleteCells(1, 2, CellData.fromCharData([6, 'f', 0, 'f'.charCodeAt(0)])); - expect(line.toArray()).eql([ + assert.deepEqual(line.toArray(), [ [1, 'a', 0, 'a'.charCodeAt(0)], [4, 'd', 0, 'd'.charCodeAt(0)], [5, 'e', 0, 'e'.charCodeAt(0)], @@ -202,7 +202,7 @@ describe('BufferLine', function(): void { line.setCell(3, CellData.fromCharData([4, 'd', 0, 'd'.charCodeAt(0)])); line.setCell(4, CellData.fromCharData([5, 'e', 0, 'e'.charCodeAt(0)])); line.replaceCells(2, 4, CellData.fromCharData([6, 'f', 0, 'f'.charCodeAt(0)])); - expect(line.toArray()).eql([ + assert.deepEqual(line.toArray(), [ [1, 'a', 0, 'a'.charCodeAt(0)], [2, 'b', 0, 'b'.charCodeAt(0)], [6, 'f', 0, 'f'.charCodeAt(0)], @@ -218,7 +218,7 @@ describe('BufferLine', function(): void { line.setCell(3, CellData.fromCharData([4, 'd', 0, 'd'.charCodeAt(0)])); line.setCell(4, CellData.fromCharData([5, 'e', 0, 'e'.charCodeAt(0)])); line.fill(CellData.fromCharData([123, 'z', 0, 'z'.charCodeAt(0)])); - expect(line.toArray()).eql([ + assert.deepEqual(line.toArray(), [ [123, 'z', 0, 'z'.charCodeAt(0)], [123, 'z', 0, 'z'.charCodeAt(0)], [123, 'z', 0, 'z'.charCodeAt(0)], @@ -234,9 +234,9 @@ describe('BufferLine', function(): void { line.setCell(3, CellData.fromCharData([4, 'd', 0, 'd'.charCodeAt(0)])); line.setCell(4, CellData.fromCharData([5, 'e', 0, 'e'.charCodeAt(0)])); const line2 = line.clone(); - expect(TestBufferLine.prototype.toArray.apply(line2)).eql(line.toArray()); - expect(line2.length).equals(line.length); - expect(line2.isWrapped).equals(line.isWrapped); + assert.deepEqual(TestBufferLine.prototype.toArray.apply(line2), line.toArray()); + assert.equal(line2.length, line.length); + assert.equal(line2.isWrapped, line.isWrapped); }); it('copyFrom', function(): void { const line = new TestBufferLine(5); @@ -247,92 +247,92 @@ describe('BufferLine', function(): void { line.setCell(4, CellData.fromCharData([5, 'e', 0, 'e'.charCodeAt(0)])); const line2 = new TestBufferLine(5, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)]), true); line2.copyFrom(line); - expect(line2.toArray()).eql(line.toArray()); - expect(line2.length).equals(line.length); - expect(line2.isWrapped).equals(line.isWrapped); + assert.deepEqual(line2.toArray(), line.toArray()); + assert.equal(line2.length, line.length); + assert.equal(line2.isWrapped, line.isWrapped); }); it('should support combining chars', function(): void { // CHAR_DATA_CODE_INDEX resembles current behavior in InputHandler.print // --> set code to the last charCodeAt value of the string // Note: needs to be fixed once the string pointer is in place const line = new TestBufferLine(2, CellData.fromCharData([1, 'e\u0301', 0, '\u0301'.charCodeAt(0)])); - expect(line.toArray()).eql([[1, 'e\u0301', 0, '\u0301'.charCodeAt(0)], [1, 'e\u0301', 0, '\u0301'.charCodeAt(0)]]); + assert.deepEqual(line.toArray(), [[1, 'e\u0301', 0, '\u0301'.charCodeAt(0)], [1, 'e\u0301', 0, '\u0301'.charCodeAt(0)]]); const line2 = new TestBufferLine(5, CellData.fromCharData([1, 'a', 0, '\u0301'.charCodeAt(0)]), true); line2.copyFrom(line); - expect(line2.toArray()).eql(line.toArray()); + assert.deepEqual(line2.toArray(), line.toArray()); const line3 = line.clone(); - expect(TestBufferLine.prototype.toArray.apply(line3)).eql(line.toArray()); + assert.deepEqual(TestBufferLine.prototype.toArray.apply(line3), line.toArray()); }); describe('resize', function(): void { it('enlarge(false)', function(): void { const line = new TestBufferLine(5, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)]), false); line.resize(10, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)])); - expect(line.toArray()).eql((Array(10) as any).fill([1, 'a', 0, 'a'.charCodeAt(0)])); + assert.deepEqual(line.toArray(), (Array(10) as any).fill([1, 'a', 0, 'a'.charCodeAt(0)])); }); it('enlarge(true)', function(): void { const line = new TestBufferLine(5, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)]), false); line.resize(10, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)])); - expect(line.toArray()).eql((Array(10) as any).fill([1, 'a', 0, 'a'.charCodeAt(0)])); + assert.deepEqual(line.toArray(), (Array(10) as any).fill([1, 'a', 0, 'a'.charCodeAt(0)])); }); it('shrink(true) - should apply new size', function(): void { const line = new TestBufferLine(10, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)]), false); line.resize(5, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)])); - expect(line.toArray()).eql((Array(5) as any).fill([1, 'a', 0, 'a'.charCodeAt(0)])); + assert.deepEqual(line.toArray(), (Array(5) as any).fill([1, 'a', 0, 'a'.charCodeAt(0)])); }); it('shrink to 0 length', function(): void { const line = new TestBufferLine(10, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)]), false); line.resize(0, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)])); - expect(line.toArray()).eql((Array(0) as any).fill([1, 'a', 0, 'a'.charCodeAt(0)])); + assert.deepEqual(line.toArray(), (Array(0) as any).fill([1, 'a', 0, 'a'.charCodeAt(0)])); }); it('should remove combining data on replaced cells after shrinking then enlarging', () => { const line = new TestBufferLine(10, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)]), false); line.set(2, [ 0, '😁', 1, '😁'.charCodeAt(0) ]); line.set(9, [ 0, '😁', 1, '😁'.charCodeAt(0) ]); - expect(line.translateToString()).eql('aa😁aaaaaa😁'); - expect(Object.keys(line.combined).length).eql(2); + assert.equal(line.translateToString(), 'aa😁aaaaaa😁'); + assert.equal(Object.keys(line.combined).length, 2); line.resize(5, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)])); - expect(line.translateToString()).eql('aa😁aa'); + assert.equal(line.translateToString(), 'aa😁aa'); line.resize(10, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)])); - expect(line.translateToString()).eql('aa😁aaaaaaa'); - expect(Object.keys(line.combined).length).eql(1); + assert.equal(line.translateToString(), 'aa😁aaaaaaa'); + assert.equal(Object.keys(line.combined).length, 1); }); }); describe('getTrimLength', function(): void { it('empty line', function(): void { const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false); - expect(line.getTrimmedLength()).equal(0); + assert.equal(line.getTrimmedLength(), 0); }); it('ASCII', function(): void { const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false); line.setCell(0, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)])); line.setCell(2, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)])); - expect(line.getTrimmedLength()).equal(3); + assert.equal(line.getTrimmedLength(), 3); }); it('surrogate', function(): void { const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false); line.setCell(0, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)])); line.setCell(2, CellData.fromCharData([1, '𝄞', 1, '𝄞'.charCodeAt(0)])); - expect(line.getTrimmedLength()).equal(3); + assert.equal(line.getTrimmedLength(), 3); }); it('combining', function(): void { const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false); line.setCell(0, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)])); line.setCell(2, CellData.fromCharData([1, 'e\u0301', 1, '\u0301'.charCodeAt(0)])); - expect(line.getTrimmedLength()).equal(3); + assert.equal(line.getTrimmedLength(), 3); }); it('fullwidth', function(): void { const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false); line.setCell(0, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)])); line.setCell(2, CellData.fromCharData([1, '1', 2, '1'.charCodeAt(0)])); line.setCell(3, CellData.fromCharData([0, '', 0, 0])); - expect(line.getTrimmedLength()).equal(4); // also counts null cell after fullwidth + assert.equal(line.getTrimmedLength(), 4); // also counts null cell after fullwidth }); }); describe('translateToString with and w\'o trimming', function(): void { it('empty line', function(): void { const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false); - expect(line.translateToString(false)).equal(' '); - expect(line.translateToString(true)).equal(''); + assert.equal(line.translateToString(false), ' '); + assert.equal(line.translateToString(true), ''); }); it('ASCII', function(): void { const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false); @@ -340,14 +340,14 @@ describe('BufferLine', function(): void { line.setCell(2, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)])); line.setCell(4, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)])); line.setCell(5, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)])); - expect(line.translateToString(false)).equal('a a aa '); - expect(line.translateToString(true)).equal('a a aa'); - expect(line.translateToString(false, 0, 5)).equal('a a a'); - expect(line.translateToString(false, 0, 4)).equal('a a '); - expect(line.translateToString(false, 0, 3)).equal('a a'); - expect(line.translateToString(true, 0, 5)).equal('a a a'); - expect(line.translateToString(true, 0, 4)).equal('a a '); - expect(line.translateToString(true, 0, 3)).equal('a a'); + assert.equal(line.translateToString(false), 'a a aa '); + assert.equal(line.translateToString(true), 'a a aa'); + assert.equal(line.translateToString(false, 0, 5), 'a a a'); + assert.equal(line.translateToString(false, 0, 4), 'a a '); + assert.equal(line.translateToString(false, 0, 3), 'a a'); + assert.equal(line.translateToString(true, 0, 5), 'a a a'); + assert.equal(line.translateToString(true, 0, 4), 'a a '); + assert.equal(line.translateToString(true, 0, 3), 'a a'); }); it('surrogate', function(): void { @@ -356,14 +356,14 @@ describe('BufferLine', function(): void { line.setCell(2, CellData.fromCharData([1, '𝄞', 1, '𝄞'.charCodeAt(0)])); line.setCell(4, CellData.fromCharData([1, '𝄞', 1, '𝄞'.charCodeAt(0)])); line.setCell(5, CellData.fromCharData([1, '𝄞', 1, '𝄞'.charCodeAt(0)])); - expect(line.translateToString(false)).equal('a 𝄞 𝄞𝄞 '); - expect(line.translateToString(true)).equal('a 𝄞 𝄞𝄞'); - expect(line.translateToString(false, 0, 5)).equal('a 𝄞 𝄞'); - expect(line.translateToString(false, 0, 4)).equal('a 𝄞 '); - expect(line.translateToString(false, 0, 3)).equal('a 𝄞'); - expect(line.translateToString(true, 0, 5)).equal('a 𝄞 𝄞'); - expect(line.translateToString(true, 0, 4)).equal('a 𝄞 '); - expect(line.translateToString(true, 0, 3)).equal('a 𝄞'); + assert.equal(line.translateToString(false), 'a 𝄞 𝄞𝄞 '); + assert.equal(line.translateToString(true), 'a 𝄞 𝄞𝄞'); + assert.equal(line.translateToString(false, 0, 5), 'a 𝄞 𝄞'); + assert.equal(line.translateToString(false, 0, 4), 'a 𝄞 '); + assert.equal(line.translateToString(false, 0, 3), 'a 𝄞'); + assert.equal(line.translateToString(true, 0, 5), 'a 𝄞 𝄞'); + assert.equal(line.translateToString(true, 0, 4), 'a 𝄞 '); + assert.equal(line.translateToString(true, 0, 3), 'a 𝄞'); }); it('combining', function(): void { const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false); @@ -371,14 +371,14 @@ describe('BufferLine', function(): void { line.setCell(2, CellData.fromCharData([1, 'e\u0301', 1, '\u0301'.charCodeAt(0)])); line.setCell(4, CellData.fromCharData([1, 'e\u0301', 1, '\u0301'.charCodeAt(0)])); line.setCell(5, CellData.fromCharData([1, 'e\u0301', 1, '\u0301'.charCodeAt(0)])); - expect(line.translateToString(false)).equal('a e\u0301 e\u0301e\u0301 '); - expect(line.translateToString(true)).equal('a e\u0301 e\u0301e\u0301'); - expect(line.translateToString(false, 0, 5)).equal('a e\u0301 e\u0301'); - expect(line.translateToString(false, 0, 4)).equal('a e\u0301 '); - expect(line.translateToString(false, 0, 3)).equal('a e\u0301'); - expect(line.translateToString(true, 0, 5)).equal('a e\u0301 e\u0301'); - expect(line.translateToString(true, 0, 4)).equal('a e\u0301 '); - expect(line.translateToString(true, 0, 3)).equal('a e\u0301'); + assert.equal(line.translateToString(false), 'a e\u0301 e\u0301e\u0301 '); + assert.equal(line.translateToString(true), 'a e\u0301 e\u0301e\u0301'); + assert.equal(line.translateToString(false, 0, 5), 'a e\u0301 e\u0301'); + assert.equal(line.translateToString(false, 0, 4), 'a e\u0301 '); + assert.equal(line.translateToString(false, 0, 3), 'a e\u0301'); + assert.equal(line.translateToString(true, 0, 5), 'a e\u0301 e\u0301'); + assert.equal(line.translateToString(true, 0, 4), 'a e\u0301 '); + assert.equal(line.translateToString(true, 0, 3), 'a e\u0301'); }); it('fullwidth', function(): void { const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false); @@ -389,20 +389,20 @@ describe('BufferLine', function(): void { line.setCell(6, CellData.fromCharData([0, '', 0, 0])); line.setCell(7, CellData.fromCharData([1, '1', 2, '1'.charCodeAt(0)])); line.setCell(8, CellData.fromCharData([0, '', 0, 0])); - expect(line.translateToString(false)).equal('a 1 11 '); - expect(line.translateToString(true)).equal('a 1 11'); - expect(line.translateToString(false, 0, 7)).equal('a 1 1'); - expect(line.translateToString(false, 0, 6)).equal('a 1 1'); - expect(line.translateToString(false, 0, 5)).equal('a 1 '); - expect(line.translateToString(false, 0, 4)).equal('a 1'); - expect(line.translateToString(false, 0, 3)).equal('a 1'); - expect(line.translateToString(false, 0, 2)).equal('a '); - expect(line.translateToString(true, 0, 7)).equal('a 1 1'); - expect(line.translateToString(true, 0, 6)).equal('a 1 1'); - expect(line.translateToString(true, 0, 5)).equal('a 1 '); - expect(line.translateToString(true, 0, 4)).equal('a 1'); - expect(line.translateToString(true, 0, 3)).equal('a 1'); - expect(line.translateToString(true, 0, 2)).equal('a '); + assert.equal(line.translateToString(false), 'a 1 11 '); + assert.equal(line.translateToString(true), 'a 1 11'); + assert.equal(line.translateToString(false, 0, 7), 'a 1 1'); + assert.equal(line.translateToString(false, 0, 6), 'a 1 1'); + assert.equal(line.translateToString(false, 0, 5), 'a 1 '); + assert.equal(line.translateToString(false, 0, 4), 'a 1'); + assert.equal(line.translateToString(false, 0, 3), 'a 1'); + assert.equal(line.translateToString(false, 0, 2), 'a '); + assert.equal(line.translateToString(true, 0, 7), 'a 1 1'); + assert.equal(line.translateToString(true, 0, 6), 'a 1 1'); + assert.equal(line.translateToString(true, 0, 5), 'a 1 '); + assert.equal(line.translateToString(true, 0, 4), 'a 1'); + assert.equal(line.translateToString(true, 0, 3), 'a 1'); + assert.equal(line.translateToString(true, 0, 2), 'a '); }); it('space at end', function(): void { const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false); @@ -411,21 +411,21 @@ describe('BufferLine', function(): void { line.setCell(4, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)])); line.setCell(5, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)])); line.setCell(6, CellData.fromCharData([1, ' ', 1, ' '.charCodeAt(0)])); - expect(line.translateToString(false)).equal('a a aa '); - expect(line.translateToString(true)).equal('a a aa '); + assert.equal(line.translateToString(false), 'a a aa '); + assert.equal(line.translateToString(true), 'a a aa '); }); it('should always return some sane value', function(): void { // sanity check - broken line with invalid out of bound null width cells // this can atm happen with deleting/inserting chars in inputhandler by "breaking" // fullwidth pairs --> needs to be fixed after settling BufferLine impl const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, 0, NULL_CELL_CODE]), false); - expect(line.translateToString(false)).equal(' '); - expect(line.translateToString(true)).equal(''); + assert.equal(line.translateToString(false), ' '); + assert.equal(line.translateToString(true), ''); }); it('should work with endCol=0', () => { const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, 0, NULL_CELL_CODE]), false); line.setCell(0, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)])); - expect(line.translateToString(true, 0, 0)).equal(''); + assert.equal(line.translateToString(true, 0, 0), ''); }); }); describe('addCharToCell', () => { diff --git a/src/common/parser/EscapeSequenceParser.test.ts b/src/common/parser/EscapeSequenceParser.test.ts index 468dc934..f4ec5025 100644 --- a/src/common/parser/EscapeSequenceParser.test.ts +++ b/src/common/parser/EscapeSequenceParser.test.ts @@ -5,7 +5,7 @@ import { IParsingState, IParams, ParamsArray, IOscParser, IOscHandler, OscFallbackHandlerType, IFunctionIdentifier } from 'common/parser/Types'; import { EscapeSequenceParser, TransitionTable, VT500_TRANSITION_TABLE } from 'common/parser/EscapeSequenceParser'; -import * as chai from 'chai'; +import { assert } from 'chai'; import { StringToUtf32, stringFromCodePoint, utf32ToString } from 'common/input/TextDecoder'; import { ParserState } from 'common/parser/Constants'; import { Params } from 'common/parser/Params'; @@ -97,38 +97,38 @@ class TestEscapeSequenceParser extends EscapeSequenceParser { // test object to collect parser actions and compare them with expected values const testTerminal: any = { calls: [], - clear: function (): void { + clear(): void { this.calls = []; }, - compare: function (value: any): void { - chai.expect(this.calls.slice()).eql(value); // weird bug w'o slicing here + compare(value: any): void { + assert.deepEqual(this.calls, value); }, - print: function (data: Uint32Array, start: number, end: number): void { + print(data: Uint32Array, start: number, end: number): void { let s = ''; for (let i = start; i < end; ++i) { s += stringFromCodePoint(data[i]); } this.calls.push(['print', s]); }, - actionOSC: function (s: string): void { + actionOSC(s: string): void { this.calls.push(['osc', s]); }, - actionExecute: function (flag: string): void { + actionExecute(flag: string): void { this.calls.push(['exe', flag]); }, - actionCSI: function (collect: string, params: IParams, flag: string): void { + actionCSI(collect: string, params: IParams, flag: string): void { this.calls.push(['csi', collect, params.toArray(), flag]); }, - actionESC: function (collect: string, flag: string): void { + actionESC(collect: string, flag: string): void { this.calls.push(['esc', collect, flag]); }, - actionDCSHook: function (params: IParams): void { + actionDCSHook(params: IParams): void { this.calls.push(['dcs hook', params.toArray()]); }, - actionDCSPrint: function (s: string): void { + actionDCSPrint(s: string): void { this.calls.push(['dcs put', s]); }, - actionDCSUnhook: function (success: boolean): void { + actionDCSUnhook(success: boolean): void { this.calls.push(['dcs unhook', success]); } }; @@ -191,40 +191,40 @@ function parse(parser: TestEscapeSequenceParser, data: string): void { parser.parse(container, decoder.decode(data, container)); } -describe('EscapeSequenceParser', function (): void { +describe('EscapeSequenceParser', () => { const parser = testParser; - describe('Parser init and methods', function (): void { - it('constructor', function (): void { + describe('Parser init and methods', () => { + it('constructor', () => { let p = new TestEscapeSequenceParser(); - chai.expect(p.transitions).equal(VT500_TRANSITION_TABLE); + assert.deepEqual(p.transitions, VT500_TRANSITION_TABLE); p = new TestEscapeSequenceParser(VT500_TRANSITION_TABLE); - chai.expect(p.transitions).equal(VT500_TRANSITION_TABLE); + assert.deepEqual(p.transitions, VT500_TRANSITION_TABLE); const tansitions: TransitionTable = new TransitionTable(10); p = new TestEscapeSequenceParser(tansitions); - chai.expect(p.transitions).equal(tansitions); + assert.deepEqual(p.transitions, tansitions); }); - it('inital states', function (): void { - chai.expect(parser.initialState).equal(ParserState.GROUND); - chai.expect(parser.currentState).equal(ParserState.GROUND); - chai.expect(parser.osc).equal(''); - chai.expect(parser.params).eql([0]); - chai.expect(parser.collect).equal(''); + it('inital states', () => { + assert.equal(parser.initialState, ParserState.GROUND); + assert.equal(parser.currentState, ParserState.GROUND); + assert.equal(parser.osc, ''); + assert.deepEqual(parser.params, [0]); + assert.equal(parser.collect, ''); }); - it('reset states', function (): void { + it('reset states', () => { parser.currentState = 124; parser.osc = '#'; parser.params = [123]; parser.collect = '#'; parser.reset(); - chai.expect(parser.currentState).equal(ParserState.GROUND); - chai.expect(parser.osc).equal(''); - chai.expect(parser.params).eql([0]); - chai.expect(parser.collect).equal(''); + assert.equal(parser.currentState, ParserState.GROUND); + assert.equal(parser.osc, ''); + assert.deepEqual(parser.params, [0]); + assert.equal(parser.collect, ''); }); }); - describe('state transitions and actions', function (): void { - it('state GROUND execute action', function (): void { + describe('state transitions and actions', () => { + it('state GROUND execute action', () => { parser.reset(); testTerminal.clear(); let exes = r(0x00, 0x18); @@ -233,26 +233,26 @@ describe('EscapeSequenceParser', function (): void { for (let i = 0; i < exes.length; ++i) { parser.currentState = ParserState.GROUND; parse(parser, exes[i]); - chai.expect(parser.currentState).equal(ParserState.GROUND); + assert.equal(parser.currentState, ParserState.GROUND); testTerminal.compare([['exe', exes[i]]]); parser.reset(); testTerminal.clear(); } }); - it('state GROUND print action', function (): void { + it('state GROUND print action', () => { parser.reset(); testTerminal.clear(); const printables = r(0x20, 0x7f); // NOTE: DEL excluded for (let i = 0; i < printables.length; ++i) { parser.currentState = ParserState.GROUND; parse(parser, printables[i]); - chai.expect(parser.currentState).equal(ParserState.GROUND); + assert.equal(parser.currentState, ParserState.GROUND); testTerminal.compare([['print', printables[i]]]); parser.reset(); testTerminal.clear(); } }); - it('trans ANYWHERE --> GROUND with actions', function (): void { + it('trans ANYWHERE --> GROUND with actions', () => { const exes = [ '\x18', '\x1a', '\x80', '\x81', '\x82', '\x83', '\x84', '\x85', '\x86', '\x87', '\x88', @@ -269,32 +269,32 @@ describe('EscapeSequenceParser', function (): void { for (let i = 0; i < exes.length; ++i) { parser.currentState = state; parse(parser, exes[i]); - chai.expect(parser.currentState).equal(ParserState.GROUND); + assert.equal(parser.currentState, ParserState.GROUND); testTerminal.compare((state in exceptions ? exceptions[state][exes[i]] : 0) || [['exe', exes[i]]]); parser.reset(); testTerminal.clear(); } parse(parser, '\x9c'); - chai.expect(parser.currentState).equal(ParserState.GROUND); + assert.equal(parser.currentState, ParserState.GROUND); testTerminal.compare([]); parser.reset(); testTerminal.clear(); } }); - it('trans ANYWHERE --> ESCAPE with clear', function (): void { + it('trans ANYWHERE --> ESCAPE with clear', () => { parser.reset(); for (state in states) { parser.currentState = state; parser.params = [23]; parser.collect = '#'; parse(parser, '\x1b'); - chai.expect(parser.currentState).equal(ParserState.ESCAPE); - chai.expect(parser.params).eql([0]); - chai.expect(parser.collect).equal(''); + assert.equal(parser.currentState, ParserState.ESCAPE); + assert.deepEqual(parser.params, [0]); + assert.equal(parser.collect, ''); parser.reset(); } }); - it('state ESCAPE execute rules', function (): void { + it('state ESCAPE execute rules', () => { parser.reset(); testTerminal.clear(); let exes = r(0x00, 0x18); @@ -303,23 +303,23 @@ describe('EscapeSequenceParser', function (): void { for (let i = 0; i < exes.length; ++i) { parser.currentState = ParserState.ESCAPE; parse(parser, exes[i]); - chai.expect(parser.currentState).equal(ParserState.ESCAPE); + assert.equal(parser.currentState, ParserState.ESCAPE); testTerminal.compare([['exe', exes[i]]]); parser.reset(); testTerminal.clear(); } }); - it('state ESCAPE ignore', function (): void { + it('state ESCAPE ignore', () => { parser.reset(); testTerminal.clear(); parser.currentState = ParserState.ESCAPE; parse(parser, '\x7f'); - chai.expect(parser.currentState).equal(ParserState.ESCAPE); + assert.equal(parser.currentState, ParserState.ESCAPE); testTerminal.compare([]); parser.reset(); testTerminal.clear(); }); - it('trans ESCAPE --> GROUND with ecs_dispatch action', function (): void { + it('trans ESCAPE --> GROUND with ecs_dispatch action', () => { parser.reset(); testTerminal.clear(); let dispatches = r(0x30, 0x50); @@ -329,24 +329,24 @@ describe('EscapeSequenceParser', function (): void { for (let i = 0; i < dispatches.length; ++i) { parser.currentState = ParserState.ESCAPE; parse(parser, dispatches[i]); - chai.expect(parser.currentState).equal(ParserState.GROUND); + assert.equal(parser.currentState, ParserState.GROUND); testTerminal.compare([['esc', '', dispatches[i]]]); parser.reset(); testTerminal.clear(); } }); - it('trans ESCAPE --> ESCAPE_INTERMEDIATE with collect action', function (): void { + it('trans ESCAPE --> ESCAPE_INTERMEDIATE with collect action', () => { parser.reset(); const collect = r(0x20, 0x30); for (let i = 0; i < collect.length; ++i) { parser.currentState = ParserState.ESCAPE; parse(parser, collect[i]); - chai.expect(parser.currentState).equal(ParserState.ESCAPE_INTERMEDIATE); - chai.expect(parser.collect).equal(collect[i]); + assert.equal(parser.currentState, ParserState.ESCAPE_INTERMEDIATE); + assert.equal(parser.collect, collect[i]); parser.reset(); } }); - it('state ESCAPE_INTERMEDIATE execute rules', function (): void { + it('state ESCAPE_INTERMEDIATE execute rules', () => { parser.reset(); testTerminal.clear(); let exes = r(0x00, 0x18); @@ -355,57 +355,57 @@ describe('EscapeSequenceParser', function (): void { for (let i = 0; i < exes.length; ++i) { parser.currentState = ParserState.ESCAPE_INTERMEDIATE; parse(parser, exes[i]); - chai.expect(parser.currentState).equal(ParserState.ESCAPE_INTERMEDIATE); + assert.equal(parser.currentState, ParserState.ESCAPE_INTERMEDIATE); testTerminal.compare([['exe', exes[i]]]); parser.reset(); testTerminal.clear(); } }); - it('state ESCAPE_INTERMEDIATE ignore', function (): void { + it('state ESCAPE_INTERMEDIATE ignore', () => { parser.reset(); testTerminal.clear(); parser.currentState = ParserState.ESCAPE_INTERMEDIATE; parse(parser, '\x7f'); - chai.expect(parser.currentState).equal(ParserState.ESCAPE_INTERMEDIATE); + assert.equal(parser.currentState, ParserState.ESCAPE_INTERMEDIATE); testTerminal.compare([]); parser.reset(); testTerminal.clear(); }); - it('state ESCAPE_INTERMEDIATE collect action', function (): void { + it('state ESCAPE_INTERMEDIATE collect action', () => { parser.reset(); const collect = r(0x20, 0x30); for (let i = 0; i < collect.length; ++i) { parser.currentState = ParserState.ESCAPE_INTERMEDIATE; parse(parser, collect[i]); - chai.expect(parser.currentState).equal(ParserState.ESCAPE_INTERMEDIATE); - chai.expect(parser.collect).equal(collect[i]); + assert.equal(parser.currentState, ParserState.ESCAPE_INTERMEDIATE); + assert.equal(parser.collect, collect[i]); parser.reset(); } }); - it('trans ESCAPE_INTERMEDIATE --> GROUND with esc_dispatch action', function (): void { + it('trans ESCAPE_INTERMEDIATE --> GROUND with esc_dispatch action', () => { parser.reset(); testTerminal.clear(); const collect = r(0x30, 0x7f); for (let i = 0; i < collect.length; ++i) { parser.currentState = ParserState.ESCAPE_INTERMEDIATE; parse(parser, collect[i]); - chai.expect(parser.currentState).equal(ParserState.GROUND); + assert.equal(parser.currentState, ParserState.GROUND); // '\x5c' --> ESC + \ (7bit ST) parser does not expose this as it already got handled testTerminal.compare((collect[i] === '\x5c') ? [] : [['esc', '', collect[i]]]); parser.reset(); testTerminal.clear(); } }); - it('trans ANYWHERE/ESCAPE --> CSI_ENTRY with clear', function (): void { + it('trans ANYWHERE/ESCAPE --> CSI_ENTRY with clear', () => { parser.reset(); // C0 parser.currentState = ParserState.ESCAPE; parser.params = [123]; parser.collect = '#'; parse(parser, '['); - chai.expect(parser.currentState).equal(ParserState.CSI_ENTRY); - chai.expect(parser.params).eql([0]); - chai.expect(parser.collect).equal(''); + assert.equal(parser.currentState, ParserState.CSI_ENTRY); + assert.deepEqual(parser.params, [0]); + assert.equal(parser.collect, ''); parser.reset(); // C1 for (state in states) { @@ -413,13 +413,13 @@ describe('EscapeSequenceParser', function (): void { parser.params = [123]; parser.collect = '#'; parse(parser, '\x9b'); - chai.expect(parser.currentState).equal(ParserState.CSI_ENTRY); - chai.expect(parser.params).eql([0]); - chai.expect(parser.collect).equal(''); + assert.equal(parser.currentState, ParserState.CSI_ENTRY); + assert.deepEqual(parser.params, [0]); + assert.equal(parser.collect, ''); parser.reset(); } }); - it('state CSI_ENTRY execute rules', function (): void { + it('state CSI_ENTRY execute rules', () => { parser.reset(); testTerminal.clear(); let exes = r(0x00, 0x18); @@ -428,59 +428,59 @@ describe('EscapeSequenceParser', function (): void { for (let i = 0; i < exes.length; ++i) { parser.currentState = ParserState.CSI_ENTRY; parse(parser, exes[i]); - chai.expect(parser.currentState).equal(ParserState.CSI_ENTRY); + assert.equal(parser.currentState, ParserState.CSI_ENTRY); testTerminal.compare([['exe', exes[i]]]); parser.reset(); testTerminal.clear(); } }); - it('state CSI_ENTRY ignore', function (): void { + it('state CSI_ENTRY ignore', () => { parser.reset(); testTerminal.clear(); parser.currentState = ParserState.CSI_ENTRY; parse(parser, '\x7f'); - chai.expect(parser.currentState).equal(ParserState.CSI_ENTRY); + assert.equal(parser.currentState, ParserState.CSI_ENTRY); testTerminal.compare([]); parser.reset(); testTerminal.clear(); }); - it('trans CSI_ENTRY --> GROUND with csi_dispatch action', function (): void { + it('trans CSI_ENTRY --> GROUND with csi_dispatch action', () => { parser.reset(); const dispatches = r(0x40, 0x7f); for (let i = 0; i < dispatches.length; ++i) { parser.currentState = ParserState.CSI_ENTRY; parse(parser, dispatches[i]); - chai.expect(parser.currentState).equal(ParserState.GROUND); + assert.equal(parser.currentState, ParserState.GROUND); testTerminal.compare([['csi', '', [0], dispatches[i]]]); parser.reset(); testTerminal.clear(); } }); - it('trans CSI_ENTRY --> CSI_PARAM with param/collect actions', function (): void { + it('trans CSI_ENTRY --> CSI_PARAM with param/collect actions', () => { parser.reset(); const params = ['\x30', '\x31', '\x32', '\x33', '\x34', '\x35', '\x36', '\x37', '\x38', '\x39']; const collect = ['\x3c', '\x3d', '\x3e', '\x3f']; for (let i = 0; i < params.length; ++i) { parser.currentState = ParserState.CSI_ENTRY; parse(parser, params[i]); - chai.expect(parser.currentState).equal(ParserState.CSI_PARAM); - chai.expect(parser.params).eql([params[i].charCodeAt(0) - 48]); + assert.equal(parser.currentState, ParserState.CSI_PARAM); + assert.deepEqual(parser.params, [params[i].charCodeAt(0) - 48]); parser.reset(); } parser.currentState = ParserState.CSI_ENTRY; parse(parser, '\x3b'); - chai.expect(parser.currentState).equal(ParserState.CSI_PARAM); - chai.expect(parser.params).eql([0, 0]); + assert.equal(parser.currentState, ParserState.CSI_PARAM); + assert.deepEqual(parser.params, [0, 0]); parser.reset(); for (let i = 0; i < collect.length; ++i) { parser.currentState = ParserState.CSI_ENTRY; parse(parser, collect[i]); - chai.expect(parser.currentState).equal(ParserState.CSI_PARAM); - chai.expect(parser.collect).equal(collect[i]); + assert.equal(parser.currentState, ParserState.CSI_PARAM); + assert.equal(parser.collect, collect[i]); parser.reset(); } }); - it('state CSI_PARAM execute rules', function (): void { + it('state CSI_PARAM execute rules', () => { parser.reset(); testTerminal.clear(); let exes = r(0x00, 0x18); @@ -489,74 +489,74 @@ describe('EscapeSequenceParser', function (): void { for (let i = 0; i < exes.length; ++i) { parser.currentState = ParserState.CSI_PARAM; parse(parser, exes[i]); - chai.expect(parser.currentState).equal(ParserState.CSI_PARAM); + assert.equal(parser.currentState, ParserState.CSI_PARAM); testTerminal.compare([['exe', exes[i]]]); parser.reset(); testTerminal.clear(); } }); - it('state CSI_PARAM param action', function (): void { + it('state CSI_PARAM param action', () => { parser.reset(); const params = ['\x30', '\x31', '\x32', '\x33', '\x34', '\x35', '\x36', '\x37', '\x38', '\x39']; for (let i = 0; i < params.length; ++i) { parser.currentState = ParserState.CSI_PARAM; parse(parser, params[i]); - chai.expect(parser.currentState).equal(ParserState.CSI_PARAM); - chai.expect(parser.params).eql([params[i].charCodeAt(0) - 48]); + assert.equal(parser.currentState, ParserState.CSI_PARAM); + assert.deepEqual(parser.params, [params[i].charCodeAt(0) - 48]); parser.reset(); } parser.currentState = ParserState.CSI_PARAM; parse(parser, '\x3b'); - chai.expect(parser.currentState).equal(ParserState.CSI_PARAM); - chai.expect(parser.params).eql([0, 0]); + assert.equal(parser.currentState, ParserState.CSI_PARAM); + assert.deepEqual(parser.params, [0, 0]); parser.reset(); }); - it('state CSI_PARAM ignore', function (): void { + it('state CSI_PARAM ignore', () => { parser.reset(); testTerminal.clear(); parser.currentState = ParserState.CSI_PARAM; parse(parser, '\x7f'); - chai.expect(parser.currentState).equal(ParserState.CSI_PARAM); + assert.equal(parser.currentState, ParserState.CSI_PARAM); testTerminal.compare([]); parser.reset(); testTerminal.clear(); }); - it('trans CSI_PARAM --> GROUND with csi_dispatch action', function (): void { + it('trans CSI_PARAM --> GROUND with csi_dispatch action', () => { parser.reset(); const dispatches = r(0x40, 0x7f); for (let i = 0; i < dispatches.length; ++i) { parser.currentState = ParserState.CSI_PARAM; parser.params = [0, 1]; parse(parser, dispatches[i]); - chai.expect(parser.currentState).equal(ParserState.GROUND); + assert.equal(parser.currentState, ParserState.GROUND); testTerminal.compare([['csi', '', [0, 1], dispatches[i]]]); parser.reset(); testTerminal.clear(); } }); - it('trans CSI_ENTRY --> CSI_INTERMEDIATE with collect action', function (): void { + it('trans CSI_ENTRY --> CSI_INTERMEDIATE with collect action', () => { parser.reset(); const collect = r(0x20, 0x30); for (let i = 0; i < collect.length; ++i) { parser.currentState = ParserState.CSI_ENTRY; parse(parser, collect[i]); - chai.expect(parser.currentState).equal(ParserState.CSI_INTERMEDIATE); - chai.expect(parser.collect).equal(collect[i]); + assert.equal(parser.currentState, ParserState.CSI_INTERMEDIATE); + assert.equal(parser.collect, collect[i]); parser.reset(); } }); - it('trans CSI_PARAM --> CSI_INTERMEDIATE with collect action', function (): void { + it('trans CSI_PARAM --> CSI_INTERMEDIATE with collect action', () => { parser.reset(); const collect = r(0x20, 0x30); for (let i = 0; i < collect.length; ++i) { parser.currentState = ParserState.CSI_PARAM; parse(parser, collect[i]); - chai.expect(parser.currentState).equal(ParserState.CSI_INTERMEDIATE); - chai.expect(parser.collect).equal(collect[i]); + assert.equal(parser.currentState, ParserState.CSI_INTERMEDIATE); + assert.equal(parser.collect, collect[i]); parser.reset(); } }); - it('state CSI_INTERMEDIATE execute rules', function (): void { + it('state CSI_INTERMEDIATE execute rules', () => { parser.reset(); testTerminal.clear(); let exes = r(0x00, 0x18); @@ -565,88 +565,88 @@ describe('EscapeSequenceParser', function (): void { for (let i = 0; i < exes.length; ++i) { parser.currentState = ParserState.CSI_INTERMEDIATE; parse(parser, exes[i]); - chai.expect(parser.currentState).equal(ParserState.CSI_INTERMEDIATE); + assert.equal(parser.currentState, ParserState.CSI_INTERMEDIATE); testTerminal.compare([['exe', exes[i]]]); parser.reset(); testTerminal.clear(); } }); - it('state CSI_INTERMEDIATE collect', function (): void { + it('state CSI_INTERMEDIATE collect', () => { parser.reset(); const collect = r(0x20, 0x30); for (let i = 0; i < collect.length; ++i) { parser.currentState = ParserState.CSI_INTERMEDIATE; parse(parser, collect[i]); - chai.expect(parser.currentState).equal(ParserState.CSI_INTERMEDIATE); - chai.expect(parser.collect).equal(collect[i]); + assert.equal(parser.currentState, ParserState.CSI_INTERMEDIATE); + assert.equal(parser.collect, collect[i]); parser.reset(); } }); - it('state CSI_INTERMEDIATE ignore', function (): void { + it('state CSI_INTERMEDIATE ignore', () => { parser.reset(); testTerminal.clear(); parser.currentState = ParserState.CSI_INTERMEDIATE; parse(parser, '\x7f'); - chai.expect(parser.currentState).equal(ParserState.CSI_INTERMEDIATE); + assert.equal(parser.currentState, ParserState.CSI_INTERMEDIATE); testTerminal.compare([]); parser.reset(); testTerminal.clear(); }); - it('trans CSI_INTERMEDIATE --> GROUND with csi_dispatch action', function (): void { + it('trans CSI_INTERMEDIATE --> GROUND with csi_dispatch action', () => { parser.reset(); const dispatches = r(0x40, 0x7f); for (let i = 0; i < dispatches.length; ++i) { parser.currentState = ParserState.CSI_INTERMEDIATE; parser.params = [0, 1]; parse(parser, dispatches[i]); - chai.expect(parser.currentState).equal(ParserState.GROUND); + assert.equal(parser.currentState, ParserState.GROUND); testTerminal.compare([['csi', '', [0, 1], dispatches[i]]]); parser.reset(); testTerminal.clear(); } }); - it('trans CSI_ENTRY --> CSI_PARAM for ":" (0x3a)', function (): void { + it('trans CSI_ENTRY --> CSI_PARAM for ":" (0x3a)', () => { parser.reset(); parser.currentState = ParserState.CSI_ENTRY; parse(parser, '\x3a'); - chai.expect(parser.currentState).equal(ParserState.CSI_PARAM); + assert.equal(parser.currentState, ParserState.CSI_PARAM); parser.reset(); }); - it('trans CSI_PARAM --> CSI_IGNORE', function (): void { + it('trans CSI_PARAM --> CSI_IGNORE', () => { parser.reset(); const chars = ['\x3c', '\x3d', '\x3e', '\x3f']; for (let i = 0; i < chars.length; ++i) { parser.currentState = ParserState.CSI_PARAM; parse(parser, '\x3b' + chars[i]); - chai.expect(parser.currentState).equal(ParserState.CSI_IGNORE); - chai.expect(parser.params).eql([0, 0]); + assert.equal(parser.currentState, ParserState.CSI_IGNORE); + assert.deepEqual(parser.params, [0, 0]); parser.reset(); } }); - it('trans CSI_PARAM --> CSI_IGNORE', function (): void { + it('trans CSI_PARAM --> CSI_IGNORE', () => { parser.reset(); const chars = ['\x3c', '\x3d', '\x3e', '\x3f']; for (let i = 0; i < chars.length; ++i) { - chai.expect(parser.params).eql([0]); + assert.deepEqual(parser.params, [0]); parser.currentState = ParserState.CSI_PARAM; parse(parser, '\x3b' + chars[i]); - chai.expect(parser.currentState).equal(ParserState.CSI_IGNORE); - chai.expect(parser.params).eql([0, 0]); + assert.equal(parser.currentState, ParserState.CSI_IGNORE); + assert.deepEqual(parser.params, [0, 0]); parser.reset(); } }); - it('trans CSI_INTERMEDIATE --> CSI_IGNORE', function (): void { + it('trans CSI_INTERMEDIATE --> CSI_IGNORE', () => { parser.reset(); const chars = r(0x30, 0x40); for (let i = 0; i < chars.length; ++i) { parser.currentState = ParserState.CSI_INTERMEDIATE; parse(parser, chars[i]); - chai.expect(parser.currentState).equal(ParserState.CSI_IGNORE); - chai.expect(parser.params).eql([0]); + assert.equal(parser.currentState, ParserState.CSI_IGNORE); + assert.deepEqual(parser.params, [0]); parser.reset(); } }); - it('state CSI_IGNORE execute rules', function (): void { + it('state CSI_IGNORE execute rules', () => { parser.reset(); testTerminal.clear(); let exes = r(0x00, 0x18); @@ -655,13 +655,13 @@ describe('EscapeSequenceParser', function (): void { for (let i = 0; i < exes.length; ++i) { parser.currentState = ParserState.CSI_IGNORE; parse(parser, exes[i]); - chai.expect(parser.currentState).equal(ParserState.CSI_IGNORE); + assert.equal(parser.currentState, ParserState.CSI_IGNORE); testTerminal.compare([['exe', exes[i]]]); parser.reset(); testTerminal.clear(); } }); - it('state CSI_IGNORE ignore', function (): void { + it('state CSI_IGNORE ignore', () => { parser.reset(); testTerminal.clear(); let ignored = r(0x20, 0x40); @@ -669,32 +669,32 @@ describe('EscapeSequenceParser', function (): void { for (let i = 0; i < ignored.length; ++i) { parser.currentState = ParserState.CSI_IGNORE; parse(parser, ignored[i]); - chai.expect(parser.currentState).equal(ParserState.CSI_IGNORE); + assert.equal(parser.currentState, ParserState.CSI_IGNORE); testTerminal.compare([]); parser.reset(); testTerminal.clear(); } }); - it('trans CSI_IGNORE --> GROUND', function (): void { + it('trans CSI_IGNORE --> GROUND', () => { parser.reset(); const dispatches = r(0x40, 0x7f); for (let i = 0; i < dispatches.length; ++i) { parser.currentState = ParserState.CSI_IGNORE; parser.params = [0, 1]; parse(parser, dispatches[i]); - chai.expect(parser.currentState).equal(ParserState.GROUND); + assert.equal(parser.currentState, ParserState.GROUND); testTerminal.compare([]); parser.reset(); testTerminal.clear(); } }); - it('trans ANYWHERE/ESCAPE --> SOS_PM_APC_STRING', function (): void { + it('trans ANYWHERE/ESCAPE --> SOS_PM_APC_STRING', () => { parser.reset(); // C0 let initializers = ['\x58', '\x5e', '\x5f']; for (let i = 0; i < initializers.length; ++i) { parse(parser, '\x1b' + initializers[i]); - chai.expect(parser.currentState).equal(ParserState.SOS_PM_APC_STRING); + assert.equal(parser.currentState, ParserState.SOS_PM_APC_STRING); parser.reset(); } // C1 @@ -703,12 +703,12 @@ describe('EscapeSequenceParser', function (): void { initializers = ['\x98', '\x9e', '\x9f']; for (let i = 0; i < initializers.length; ++i) { parse(parser, initializers[i]); - chai.expect(parser.currentState).equal(ParserState.SOS_PM_APC_STRING); + assert.equal(parser.currentState, ParserState.SOS_PM_APC_STRING); parser.reset(); } } }); - it('state SOS_PM_APC_STRING ignore rules', function (): void { + it('state SOS_PM_APC_STRING ignore rules', () => { parser.reset(); let ignored = r(0x00, 0x18); ignored = ignored.concat(['\x19']); @@ -717,25 +717,25 @@ describe('EscapeSequenceParser', function (): void { for (let i = 0; i < ignored.length; ++i) { parser.currentState = ParserState.SOS_PM_APC_STRING; parse(parser, ignored[i]); - chai.expect(parser.currentState).equal(ParserState.SOS_PM_APC_STRING); + assert.equal(parser.currentState, ParserState.SOS_PM_APC_STRING); parser.reset(); } }); - it('trans ANYWHERE/ESCAPE --> OSC_STRING', function (): void { + it('trans ANYWHERE/ESCAPE --> OSC_STRING', () => { parser.reset(); // C0 parse(parser, '\x1b]'); - chai.expect(parser.currentState).equal(ParserState.OSC_STRING); + assert.equal(parser.currentState, ParserState.OSC_STRING); parser.reset(); // C1 for (state in states) { parser.currentState = state; parse(parser, '\x9d'); - chai.expect(parser.currentState).equal(ParserState.OSC_STRING); + assert.equal(parser.currentState, ParserState.OSC_STRING); parser.reset(); } }); - it('state OSC_STRING ignore rules', function (): void { + it('state OSC_STRING ignore rules', () => { parser.reset(); const ignored = [ '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', /* '\x07', */ '\x08', @@ -744,37 +744,37 @@ describe('EscapeSequenceParser', function (): void { for (let i = 0; i < ignored.length; ++i) { parser.currentState = ParserState.OSC_STRING; parse(parser, ignored[i]); - chai.expect(parser.currentState).equal(ParserState.OSC_STRING); - chai.expect(parser.osc).equal(''); + assert.equal(parser.currentState, ParserState.OSC_STRING); + assert.equal(parser.osc, ''); parser.reset(); } }); - it('state OSC_STRING put action', function (): void { + it('state OSC_STRING put action', () => { parser.reset(); const puts = r(0x20, 0x80); for (let i = 0; i < puts.length; ++i) { parser.currentState = ParserState.OSC_STRING; parse(parser, puts[i]); - chai.expect(parser.currentState).equal(ParserState.OSC_STRING); - chai.expect(parser.osc).equal(puts[i]); + assert.equal(parser.currentState, ParserState.OSC_STRING); + assert.equal(parser.osc, puts[i]); parser.reset(); } }); - it('state DCS_ENTRY', function (): void { + it('state DCS_ENTRY', () => { parser.reset(); // C0 parse(parser, '\x1bP'); - chai.expect(parser.currentState).equal(ParserState.DCS_ENTRY); + assert.equal(parser.currentState, ParserState.DCS_ENTRY); parser.reset(); // C1 for (state in states) { parser.currentState = state; parse(parser, '\x90'); - chai.expect(parser.currentState).equal(ParserState.DCS_ENTRY); + assert.equal(parser.currentState, ParserState.DCS_ENTRY); parser.reset(); } }); - it('state DCS_ENTRY ignore rules', function (): void { + it('state DCS_ENTRY ignore rules', () => { parser.reset(); const ignored = [ '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', @@ -783,35 +783,35 @@ describe('EscapeSequenceParser', function (): void { for (let i = 0; i < ignored.length; ++i) { parser.currentState = ParserState.DCS_ENTRY; parse(parser, ignored[i]); - chai.expect(parser.currentState).equal(ParserState.DCS_ENTRY); + assert.equal(parser.currentState, ParserState.DCS_ENTRY); parser.reset(); } }); - it('state DCS_ENTRY --> DCS_PARAM with param/collect actions', function (): void { + it('state DCS_ENTRY --> DCS_PARAM with param/collect actions', () => { parser.reset(); const params = ['\x30', '\x31', '\x32', '\x33', '\x34', '\x35', '\x36', '\x37', '\x38', '\x39']; const collect = ['\x3c', '\x3d', '\x3e', '\x3f']; for (let i = 0; i < params.length; ++i) { parser.currentState = ParserState.DCS_ENTRY; parse(parser, params[i]); - chai.expect(parser.currentState).equal(ParserState.DCS_PARAM); - chai.expect(parser.params).eql([params[i].charCodeAt(0) - 48]); + assert.equal(parser.currentState, ParserState.DCS_PARAM); + assert.deepEqual(parser.params, [params[i].charCodeAt(0) - 48]); parser.reset(); } parser.currentState = ParserState.DCS_ENTRY; parse(parser, '\x3b'); - chai.expect(parser.currentState).equal(ParserState.DCS_PARAM); - chai.expect(parser.params).eql([0, 0]); + assert.equal(parser.currentState, ParserState.DCS_PARAM); + assert.deepEqual(parser.params, [0, 0]); parser.reset(); for (let i = 0; i < collect.length; ++i) { parser.currentState = ParserState.DCS_ENTRY; parse(parser, collect[i]); - chai.expect(parser.currentState).equal(ParserState.DCS_PARAM); - chai.expect(parser.collect).equal(collect[i]); + assert.equal(parser.currentState, ParserState.DCS_PARAM); + assert.equal(parser.collect, collect[i]); parser.reset(); } }); - it('state DCS_PARAM ignore rules', function (): void { + it('state DCS_PARAM ignore rules', () => { parser.reset(); const ignored = [ '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', @@ -820,55 +820,55 @@ describe('EscapeSequenceParser', function (): void { for (let i = 0; i < ignored.length; ++i) { parser.currentState = ParserState.DCS_PARAM; parse(parser, ignored[i]); - chai.expect(parser.currentState).equal(ParserState.DCS_PARAM); + assert.equal(parser.currentState, ParserState.DCS_PARAM); parser.reset(); } }); - it('state DCS_PARAM param action', function (): void { + it('state DCS_PARAM param action', () => { parser.reset(); const params = ['\x30', '\x31', '\x32', '\x33', '\x34', '\x35', '\x36', '\x37', '\x38', '\x39']; for (let i = 0; i < params.length; ++i) { parser.currentState = ParserState.DCS_PARAM; parse(parser, params[i]); - chai.expect(parser.currentState).equal(ParserState.DCS_PARAM); - chai.expect(parser.params).eql([params[i].charCodeAt(0) - 48]); + assert.equal(parser.currentState, ParserState.DCS_PARAM); + assert.deepEqual(parser.params, [params[i].charCodeAt(0) - 48]); parser.reset(); } parser.currentState = ParserState.DCS_PARAM; parse(parser, '\x3b'); - chai.expect(parser.currentState).equal(ParserState.DCS_PARAM); - chai.expect(parser.params).eql([0, 0]); + assert.equal(parser.currentState, ParserState.DCS_PARAM); + assert.deepEqual(parser.params, [0, 0]); parser.reset(); }); - it('trans DCS_ENTRY --> DCS_PARAM for ":" (0x3a)', function (): void { + it('trans DCS_ENTRY --> DCS_PARAM for ":" (0x3a)', () => { parser.reset(); parser.currentState = ParserState.DCS_ENTRY; parse(parser, '\x3a'); - chai.expect(parser.currentState).equal(ParserState.DCS_PARAM); + assert.equal(parser.currentState, ParserState.DCS_PARAM); parser.reset(); }); - it('trans DCS_PARAM --> DCS_IGNORE', function (): void { + it('trans DCS_PARAM --> DCS_IGNORE', () => { parser.reset(); const chars = ['\x3c', '\x3d', '\x3e', '\x3f']; for (let i = 0; i < chars.length; ++i) { parser.currentState = ParserState.DCS_PARAM; parse(parser, '\x3b' + chars[i]); - chai.expect(parser.currentState).equal(ParserState.DCS_IGNORE); - chai.expect(parser.params).eql([0, 0]); + assert.equal(parser.currentState, ParserState.DCS_IGNORE); + assert.deepEqual(parser.params, [0, 0]); parser.reset(); } }); - it('trans DCS_INTERMEDIATE --> DCS_IGNORE', function (): void { + it('trans DCS_INTERMEDIATE --> DCS_IGNORE', () => { parser.reset(); const chars = r(0x30, 0x40); for (let i = 0; i < chars.length; ++i) { parser.currentState = ParserState.DCS_INTERMEDIATE; parse(parser, chars[i]); - chai.expect(parser.currentState).equal(ParserState.DCS_IGNORE); + assert.equal(parser.currentState, ParserState.DCS_IGNORE); parser.reset(); } }); - it('state DCS_IGNORE ignore rules', function (): void { + it('state DCS_IGNORE ignore rules', () => { parser.reset(); let ignored = [ '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', @@ -878,33 +878,33 @@ describe('EscapeSequenceParser', function (): void { for (let i = 0; i < ignored.length; ++i) { parser.currentState = ParserState.DCS_IGNORE; parse(parser, ignored[i]); - chai.expect(parser.currentState).equal(ParserState.DCS_IGNORE); + assert.equal(parser.currentState, ParserState.DCS_IGNORE); parser.reset(); } }); - it('trans DCS_ENTRY --> DCS_INTERMEDIATE with collect action', function (): void { + it('trans DCS_ENTRY --> DCS_INTERMEDIATE with collect action', () => { parser.reset(); const collect = r(0x20, 0x30); for (let i = 0; i < collect.length; ++i) { parser.currentState = ParserState.DCS_ENTRY; parse(parser, collect[i]); - chai.expect(parser.currentState).equal(ParserState.DCS_INTERMEDIATE); - chai.expect(parser.collect).equal(collect[i]); + assert.equal(parser.currentState, ParserState.DCS_INTERMEDIATE); + assert.equal(parser.collect, collect[i]); parser.reset(); } }); - it('trans DCS_PARAM --> DCS_INTERMEDIATE with collect action', function (): void { + it('trans DCS_PARAM --> DCS_INTERMEDIATE with collect action', () => { parser.reset(); const collect = r(0x20, 0x30); for (let i = 0; i < collect.length; ++i) { parser.currentState = ParserState.DCS_PARAM; parse(parser, collect[i]); - chai.expect(parser.currentState).equal(ParserState.DCS_INTERMEDIATE); - chai.expect(parser.collect).equal(collect[i]); + assert.equal(parser.currentState, ParserState.DCS_INTERMEDIATE); + assert.equal(parser.collect, collect[i]); parser.reset(); } }); - it('state DCS_INTERMEDIATE ignore rules', function (): void { + it('state DCS_INTERMEDIATE ignore rules', () => { parser.reset(); const ignored = [ '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', @@ -913,72 +913,72 @@ describe('EscapeSequenceParser', function (): void { for (let i = 0; i < ignored.length; ++i) { parser.currentState = ParserState.DCS_INTERMEDIATE; parse(parser, ignored[i]); - chai.expect(parser.currentState).equal(ParserState.DCS_INTERMEDIATE); + assert.equal(parser.currentState, ParserState.DCS_INTERMEDIATE); parser.reset(); } }); - it('state DCS_INTERMEDIATE collect action', function (): void { + it('state DCS_INTERMEDIATE collect action', () => { parser.reset(); const collect = r(0x20, 0x30); for (let i = 0; i < collect.length; ++i) { parser.currentState = ParserState.DCS_INTERMEDIATE; parse(parser, collect[i]); - chai.expect(parser.currentState).equal(ParserState.DCS_INTERMEDIATE); - chai.expect(parser.collect).equal(collect[i]); + assert.equal(parser.currentState, ParserState.DCS_INTERMEDIATE); + assert.equal(parser.collect, collect[i]); parser.reset(); } }); - it('trans DCS_INTERMEDIATE --> DCS_IGNORE', function (): void { + it('trans DCS_INTERMEDIATE --> DCS_IGNORE', () => { parser.reset(); const chars = r(0x30, 0x40); for (let i = 0; i < chars.length; ++i) { parser.currentState = ParserState.DCS_INTERMEDIATE; parse(parser, '\x20' + chars[i]); - chai.expect(parser.currentState).equal(ParserState.DCS_IGNORE); - chai.expect(parser.collect).equal('\x20'); + assert.equal(parser.currentState, ParserState.DCS_IGNORE); + assert.equal(parser.collect, '\x20'); parser.reset(); } }); - it('trans DCS_ENTRY --> DCS_PASSTHROUGH with hook', function (): void { + it('trans DCS_ENTRY --> DCS_PASSTHROUGH with hook', () => { parser.reset(); testTerminal.clear(); const collect = r(0x40, 0x7f); for (let i = 0; i < collect.length; ++i) { parser.currentState = ParserState.DCS_ENTRY; parse(parser, collect[i]); - chai.expect(parser.currentState).equal(ParserState.DCS_PASSTHROUGH); + assert.equal(parser.currentState, ParserState.DCS_PASSTHROUGH); testTerminal.compare([['dcs hook', [0]]]); parser.reset(); testTerminal.clear(); } }); - it('trans DCS_PARAM --> DCS_PASSTHROUGH with hook', function (): void { + it('trans DCS_PARAM --> DCS_PASSTHROUGH with hook', () => { parser.reset(); testTerminal.clear(); const collect = r(0x40, 0x7f); for (let i = 0; i < collect.length; ++i) { parser.currentState = ParserState.DCS_PARAM; parse(parser, collect[i]); - chai.expect(parser.currentState).equal(ParserState.DCS_PASSTHROUGH); + assert.equal(parser.currentState, ParserState.DCS_PASSTHROUGH); testTerminal.compare([['dcs hook', [0]]]); parser.reset(); testTerminal.clear(); } }); - it('trans DCS_INTERMEDIATE --> DCS_PASSTHROUGH with hook', function (): void { + it('trans DCS_INTERMEDIATE --> DCS_PASSTHROUGH with hook', () => { parser.reset(); testTerminal.clear(); const collect = r(0x40, 0x7f); for (let i = 0; i < collect.length; ++i) { parser.currentState = ParserState.DCS_INTERMEDIATE; parse(parser, collect[i]); - chai.expect(parser.currentState).equal(ParserState.DCS_PASSTHROUGH); + assert.equal(parser.currentState, ParserState.DCS_PASSTHROUGH); testTerminal.compare([['dcs hook', [0]]]); parser.reset(); testTerminal.clear(); } }); - it('state DCS_PASSTHROUGH put action', function (): void { + it('state DCS_PASSTHROUGH put action', () => { parser.reset(); testTerminal.clear(); let puts = r(0x00, 0x18); @@ -988,18 +988,18 @@ describe('EscapeSequenceParser', function (): void { for (let i = 0; i < puts.length; ++i) { parser.currentState = ParserState.DCS_PASSTHROUGH; parse(parser, puts[i]); - chai.expect(parser.currentState).equal(ParserState.DCS_PASSTHROUGH); + assert.equal(parser.currentState, ParserState.DCS_PASSTHROUGH); testTerminal.compare([['dcs put', puts[i]]]); parser.reset(); testTerminal.clear(); } }); - it('state DCS_PASSTHROUGH ignore', function (): void { + it('state DCS_PASSTHROUGH ignore', () => { parser.reset(); testTerminal.clear(); parser.currentState = ParserState.DCS_PASSTHROUGH; parse(parser, '\x7f'); - chai.expect(parser.currentState).equal(ParserState.DCS_PASSTHROUGH); + assert.equal(parser.currentState, ParserState.DCS_PASSTHROUGH); testTerminal.compare([]); parser.reset(); testTerminal.clear(); @@ -1015,8 +1015,8 @@ describe('EscapeSequenceParser', function (): void { testTerminal.compare(value); } - describe('escape sequence examples', function (): void { - it('CSI with print and execute', function (): void { + describe('escape sequence examples', () => { + it('CSI with print and execute', () => { test('\x1b[<31;5mHello World! öäü€\nabc', [ ['csi', '<', [31, 5], 'm'], @@ -1025,19 +1025,19 @@ describe('EscapeSequenceParser', function (): void { ['print', 'abc'] ], null); }); - it('OSC', function (): void { + it('OSC', () => { test('\x1b]0;abc123€öäü\x07', [ ['osc', '0;abc123€öäü, success: true'] ], null); }); - it('single DCS', function (): void { + it('single DCS', () => { test('\x1bP1;2;3+$aäbc;däe\x9c', [ ['dcs hook', [1, 2, 3]], ['dcs put', 'äbc;däe'], ['dcs unhook', true] ], null); }); - it('multi DCS', function (): void { + it('multi DCS', () => { test('\x1bP1;2;3+$abc;de', [ ['dcs hook', [1, 2, 3]], ['dcs put', 'bc;de'] @@ -1048,7 +1048,7 @@ describe('EscapeSequenceParser', function (): void { ['dcs unhook', true] ], true); }); - it('print + DCS(C1)', function (): void { + it('print + DCS(C1)', () => { test('abc\x901;2;3+$abc;de\x9c', [ ['print', 'abc'], ['dcs hook', [1, 2, 3]], @@ -1056,26 +1056,26 @@ describe('EscapeSequenceParser', function (): void { ['dcs unhook', true] ], null); }); - it('print + PM(C1) + print', function (): void { + it('print + PM(C1) + print', () => { test('abc\x98123tzf\x9cdefg', [ ['print', 'abc'], ['print', 'defg'] ], null); }); - it('print + OSC(C1) + print', function (): void { + it('print + OSC(C1) + print', () => { test('abc\x9d123;tzf\x9cdefg', [ ['print', 'abc'], ['osc', '123;tzf, success: true'], ['print', 'defg'] ], null); }); - it('error recovery', function (): void { + it('error recovery', () => { test('\x1b[1€abcdefg\x9b<;c', [ ['print', 'abcdefg'], ['csi', '<', [0, 0], 'c'] ], null); }); - it('7bit ST should be swallowed', function (): void { + it('7bit ST should be swallowed', () => { test('abc\x9d123;tzf\x1b\\defg', [ ['print', 'abc'], ['osc', '123;tzf, success: true'], @@ -1091,7 +1091,7 @@ describe('EscapeSequenceParser', function (): void { ['print', 'abc'] ], null); }); - it('colon notation in DCS params', function (): void { + it('colon notation in DCS params', () => { test('abc\x901;2::55;3+$abc;de\x9c', [ ['print', 'abc'], ['dcs hook', [1, 2, [-1, 55], 3]], @@ -1127,50 +1127,50 @@ describe('EscapeSequenceParser', function (): void { }); }); - describe('coverage tests', function (): void { - it('CSI_IGNORE error', function (): void { + describe('coverage tests', () => { + it('CSI_IGNORE error', () => { parser.reset(); testTerminal.clear(); parser.currentState = ParserState.CSI_IGNORE; parse(parser, '€öäü'); - chai.expect(parser.currentState).equal(ParserState.CSI_IGNORE); + assert.equal(parser.currentState, ParserState.CSI_IGNORE); testTerminal.compare([]); parser.reset(); testTerminal.clear(); }); - it('DCS_IGNORE error', function (): void { + it('DCS_IGNORE error', () => { parser.reset(); testTerminal.clear(); parser.currentState = ParserState.DCS_IGNORE; parse(parser, '€öäü'); - chai.expect(parser.currentState).equal(ParserState.DCS_IGNORE); + assert.equal(parser.currentState, ParserState.DCS_IGNORE); testTerminal.compare([]); parser.reset(); testTerminal.clear(); }); - it('DCS_PASSTHROUGH error', function (): void { + it('DCS_PASSTHROUGH error', () => { parser.reset(); testTerminal.clear(); parser.currentState = ParserState.DCS_PASSTHROUGH; parse(parser, '\x901;2;3+$a€öäü'); - chai.expect(parser.currentState).equal(ParserState.DCS_PASSTHROUGH); + assert.equal(parser.currentState, ParserState.DCS_PASSTHROUGH); testTerminal.compare([['dcs hook', [1, 2, 3]], ['dcs put', '€öäü']]); parser.reset(); testTerminal.clear(); }); - it('error else of if (code > 159)', function (): void { + it('error else of if (code > 159)', () => { parser.reset(); testTerminal.clear(); parser.currentState = ParserState.GROUND; parse(parser, '\x9c'); - chai.expect(parser.currentState).equal(ParserState.GROUND); + assert.equal(parser.currentState, ParserState.GROUND); testTerminal.compare([]); parser.reset(); testTerminal.clear(); }); }); - describe('set/clear handler', function (): void { + describe('set/clear handler', () => { const INPUT = '\x1b[1;31mhello \x1b%Gwor\x1bEld!\x1b[0m\r\n$>\x1b]1;foo=bar\x1b\\'; let parser2: TestEscapeSequenceParser; let print = ''; @@ -1187,25 +1187,25 @@ describe('EscapeSequenceParser', function (): void { osc.length = 0; dcs.length = 0; } - beforeEach(function (): void { + beforeEach(() => { parser2 = new TestEscapeSequenceParser(); clearAccu(); }); - it('print handler', function (): void { + it('print handler', () => { parser2.setPrintHandler(function (data: Uint32Array, start: number, end: number): void { for (let i = start; i < end; ++i) { print += stringFromCodePoint(data[i]); } }); parse(parser2, INPUT); - chai.expect(print).equal('hello world!$>'); + assert.equal(print, 'hello world!$>'); parser2.clearPrintHandler(); parser2.clearPrintHandler(); // should not throw clearAccu(); parse(parser2, INPUT); - chai.expect(print).equal(''); + assert.equal(print, ''); }); - it('ESC handler', function (): void { + it('ESC handler', () => { parser2.registerEscHandler({intermediates: '%', final: 'G'}, function (): boolean { esc.push('%G'); return true; @@ -1215,43 +1215,43 @@ describe('EscapeSequenceParser', function (): void { return true; }); parse(parser2, INPUT); - chai.expect(esc).eql(['%G', 'E']); + assert.deepEqual(esc, ['%G', 'E']); parser2.clearEscHandler({intermediates: '%', final: 'G'}); parser2.clearEscHandler({intermediates: '%', final: 'G'}); // should not throw clearAccu(); parse(parser2, INPUT); - chai.expect(esc).eql(['E']); + assert.deepEqual(esc, ['E']); parser2.clearEscHandler({final: 'E'}); clearAccu(); parse(parser2, INPUT); - chai.expect(esc).eql([]); + assert.deepEqual(esc, []); }); describe('ESC custom handlers', () => { it('prevent fallback', () => { parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); return true; }); parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return true; }); parse(parser2, INPUT); - chai.expect(esc).eql(['custom - %G']); + assert.deepEqual(esc, ['custom - %G']); }); it('allow fallback', () => { parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); return true; }); parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return false; }); parse(parser2, INPUT); - chai.expect(esc).eql(['custom - %G', 'default - %G']); + assert.deepEqual(esc, ['custom - %G', 'default - %G']); }); it('Multiple custom handlers fallback once', () => { parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); return true; }); parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return true; }); parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom2 - %G'); return false; }); parse(parser2, INPUT); - chai.expect(esc).eql(['custom2 - %G', 'custom - %G']); + assert.deepEqual(esc, ['custom2 - %G', 'custom - %G']); }); it('Multiple custom handlers no fallback', () => { parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); return true; }); parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return true; }); parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom2 - %G'); return true; }); parse(parser2, INPUT); - chai.expect(esc).eql(['custom2 - %G']); + assert.deepEqual(esc, ['custom2 - %G']); }); it('Execution order should go from latest handler down to the original', () => { const order: number[] = []; @@ -1259,14 +1259,14 @@ describe('EscapeSequenceParser', function (): void { parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { order.push(2); return false; }); parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { order.push(3); return false; }); parse(parser2, '\x1b%G'); - chai.expect(order).eql([3, 2, 1]); + assert.deepEqual(order, [3, 2, 1]); }); it('Dispose should work', () => { parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); return true; }); const dispo = parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return true; }); dispo.dispose(); parse(parser2, INPUT); - chai.expect(esc).eql(['default - %G']); + assert.deepEqual(esc, ['default - %G']); }); it('Should not corrupt the parser when dispose is called twice', () => { parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); return true; }); @@ -1274,21 +1274,21 @@ describe('EscapeSequenceParser', function (): void { dispo.dispose(); dispo.dispose(); parse(parser2, INPUT); - chai.expect(esc).eql(['default - %G']); + assert.deepEqual(esc, ['default - %G']); }); }); - it('CSI handler', function (): void { + it('CSI handler', () => { parser2.registerCsiHandler({final: 'm'}, function (params: IParams): boolean { csi.push(['m', params.toArray(), '']); return true; }); parse(parser2, INPUT); - chai.expect(csi).eql([['m', [1, 31], ''], ['m', [0], '']]); + assert.deepEqual(csi, [['m', [1, 31], ''], ['m', [0], '']]); parser2.clearCsiHandler({final: 'm'}); parser2.clearCsiHandler({final: 'm'}); // should not throw clearAccu(); parse(parser2, INPUT); - chai.expect(csi).eql([]); + assert.deepEqual(csi, []); }); describe('CSI custom handlers', () => { it('Prevent fallback', () => { @@ -1296,16 +1296,16 @@ describe('EscapeSequenceParser', function (): void { parser2.registerCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); return true; }); parser2.registerCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); parse(parser2, INPUT); - chai.expect(csi).eql([], 'Should not fallback to original handler'); - chai.expect(csiCustom).eql([['m', [1, 31], ''], ['m', [0], '']]); + assert.deepEqual(csi, [], 'Should not fallback to original handler'); + assert.deepEqual(csiCustom, [['m', [1, 31], ''], ['m', [0], '']]); }); it('Allow fallback', () => { const csiCustom: [string, ParamsArray, string][] = []; parser2.registerCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); return true; }); parser2.registerCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return false; }); parse(parser2, INPUT); - chai.expect(csi).eql([['m', [1, 31], ''], ['m', [0], '']], 'Should fallback to original handler'); - chai.expect(csiCustom).eql([['m', [1, 31], ''], ['m', [0], '']]); + assert.deepEqual(csi, [['m', [1, 31], ''], ['m', [0], '']], 'Should fallback to original handler'); + assert.deepEqual(csiCustom, [['m', [1, 31], ''], ['m', [0], '']]); }); it('Multiple custom handlers fallback once', () => { const csiCustom: [string, ParamsArray, string][] = []; @@ -1314,9 +1314,9 @@ describe('EscapeSequenceParser', function (): void { parser2.registerCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); parser2.registerCsiHandler({final: 'm'}, params => { csiCustom2.push(['m', params.toArray(), '']); return false; }); parse(parser2, INPUT); - chai.expect(csi).eql([], 'Should not fallback to original handler'); - chai.expect(csiCustom).eql([['m', [1, 31], ''], ['m', [0], '']]); - chai.expect(csiCustom2).eql([['m', [1, 31], ''], ['m', [0], '']]); + assert.deepEqual(csi, [], 'Should not fallback to original handler'); + assert.deepEqual(csiCustom, [['m', [1, 31], ''], ['m', [0], '']]); + assert.deepEqual(csiCustom2, [['m', [1, 31], ''], ['m', [0], '']]); }); it('Multiple custom handlers no fallback', () => { const csiCustom: [string, ParamsArray, string][] = []; @@ -1325,9 +1325,9 @@ describe('EscapeSequenceParser', function (): void { parser2.registerCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); parser2.registerCsiHandler({final: 'm'}, params => { csiCustom2.push(['m', params.toArray(), '']); return true; }); parse(parser2, INPUT); - chai.expect(csi).eql([], 'Should not fallback to original handler'); - chai.expect(csiCustom).eql([], 'Should not fallback once'); - chai.expect(csiCustom2).eql([['m', [1, 31], ''], ['m', [0], '']]); + assert.deepEqual(csi, [], 'Should not fallback to original handler'); + assert.deepEqual(csiCustom, [], 'Should not fallback once'); + assert.deepEqual(csiCustom2, [['m', [1, 31], ''], ['m', [0], '']]); }); it('Execution order should go from latest handler down to the original', () => { const order: number[] = []; @@ -1335,7 +1335,7 @@ describe('EscapeSequenceParser', function (): void { parser2.registerCsiHandler({final: 'm'}, () => { order.push(2); return false; }); parser2.registerCsiHandler({final: 'm'}, () => { order.push(3); return false; }); parse(parser2, '\x1b[0m'); - chai.expect(order).eql([3, 2, 1]); + assert.deepEqual(order, [3, 2, 1]); }); it('Dispose should work', () => { const csiCustom: [string, ParamsArray, string][] = []; @@ -1343,8 +1343,8 @@ describe('EscapeSequenceParser', function (): void { const customHandler = parser2.registerCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); customHandler.dispose(); parse(parser2, INPUT); - chai.expect(csi).eql([['m', [1, 31], ''], ['m', [0], '']]); - chai.expect(csiCustom).eql([], 'Should not use custom handler as it was disposed'); + assert.deepEqual(csi, [['m', [1, 31], ''], ['m', [0], '']]); + assert.deepEqual(csiCustom, [], 'Should not use custom handler as it was disposed'); }); it('Should not corrupt the parser when dispose is called twice', () => { const csiCustom: [string, ParamsArray, string][] = []; @@ -1353,11 +1353,11 @@ describe('EscapeSequenceParser', function (): void { customHandler.dispose(); customHandler.dispose(); parse(parser2, INPUT); - chai.expect(csi).eql([['m', [1, 31], ''], ['m', [0], '']]); - chai.expect(csiCustom).eql([], 'Should not use custom handler as it was disposed'); + assert.deepEqual(csi, [['m', [1, 31], ''], ['m', [0], '']]); + assert.deepEqual(csiCustom, [], 'Should not use custom handler as it was disposed'); }); }); - it('EXECUTE handler', function (): void { + it('EXECUTE handler', () => { parser2.setExecuteHandler('\n', function (): boolean { exe.push('\n'); return true; @@ -1367,25 +1367,25 @@ describe('EscapeSequenceParser', function (): void { return true; }); parse(parser2, INPUT); - chai.expect(exe).eql(['\r', '\n']); + assert.deepEqual(exe, ['\r', '\n']); parser2.clearExecuteHandler('\r'); parser2.clearExecuteHandler('\r'); // should not throw clearAccu(); parse(parser2, INPUT); - chai.expect(exe).eql(['\n']); + assert.deepEqual(exe, ['\n']); }); - it('OSC handler', function (): void { + it('OSC handler', () => { parser2.registerOscHandler(1, new OscHandler(function (data: string): boolean { osc.push([1, data]); return true; })); parse(parser2, INPUT); - chai.expect(osc).eql([[1, 'foo=bar']]); + assert.deepEqual(osc, [[1, 'foo=bar']]); parser2.clearOscHandler(1); parser2.clearOscHandler(1); // should not throw clearAccu(); parse(parser2, INPUT); - chai.expect(osc).eql([]); + assert.deepEqual(osc, []); }); describe('OSC custom handlers', () => { it('Prevent fallback', () => { @@ -1393,16 +1393,16 @@ describe('EscapeSequenceParser', function (): void { parser2.registerOscHandler(1, new OscHandler(data => { osc.push([1, data]); return true; })); parser2.registerOscHandler(1, new OscHandler(data => { oscCustom.push([1, data]); return true; })); parse(parser2, INPUT); - chai.expect(osc).eql([], 'Should not fallback to original handler'); - chai.expect(oscCustom).eql([[1, 'foo=bar']]); + assert.deepEqual(osc, [], 'Should not fallback to original handler'); + assert.deepEqual(oscCustom, [[1, 'foo=bar']]); }); it('Allow fallback', () => { const oscCustom: [number, string][] = []; parser2.registerOscHandler(1, new OscHandler(data => { osc.push([1, data]); return true; })); parser2.registerOscHandler(1, new OscHandler(data => { oscCustom.push([1, data]); return false; })); parse(parser2, INPUT); - chai.expect(osc).eql([[1, 'foo=bar']], 'Should fallback to original handler'); - chai.expect(oscCustom).eql([[1, 'foo=bar']]); + assert.deepEqual(osc, [[1, 'foo=bar']], 'Should fallback to original handler'); + assert.deepEqual(oscCustom, [[1, 'foo=bar']]); }); it('Multiple custom handlers fallback once', () => { const oscCustom: [number, string][] = []; @@ -1411,9 +1411,9 @@ describe('EscapeSequenceParser', function (): void { parser2.registerOscHandler(1, new OscHandler(data => { oscCustom.push([1, data]); return true; })); parser2.registerOscHandler(1, new OscHandler(data => { oscCustom2.push([1, data]); return false; })); parse(parser2, INPUT); - chai.expect(osc).eql([], 'Should not fallback to original handler'); - chai.expect(oscCustom).eql([[1, 'foo=bar']]); - chai.expect(oscCustom2).eql([[1, 'foo=bar']]); + assert.deepEqual(osc, [], 'Should not fallback to original handler'); + assert.deepEqual(oscCustom, [[1, 'foo=bar']]); + assert.deepEqual(oscCustom2, [[1, 'foo=bar']]); }); it('Multiple custom handlers no fallback', () => { const oscCustom: [number, string][] = []; @@ -1422,9 +1422,9 @@ describe('EscapeSequenceParser', function (): void { parser2.registerOscHandler(1, new OscHandler(data => { oscCustom.push([1, data]); return true; })); parser2.registerOscHandler(1, new OscHandler(data => { oscCustom2.push([1, data]); return true; })); parse(parser2, INPUT); - chai.expect(osc).eql([], 'Should not fallback to original handler'); - chai.expect(oscCustom).eql([], 'Should not fallback once'); - chai.expect(oscCustom2).eql([[1, 'foo=bar']]); + assert.deepEqual(osc, [], 'Should not fallback to original handler'); + assert.deepEqual(oscCustom, [], 'Should not fallback once'); + assert.deepEqual(oscCustom2, [[1, 'foo=bar']]); }); it('Execution order should go from latest handler down to the original', () => { const order: number[] = []; @@ -1432,7 +1432,7 @@ describe('EscapeSequenceParser', function (): void { parser2.registerOscHandler(1, new OscHandler(() => { order.push(2); return false; })); parser2.registerOscHandler(1, new OscHandler(() => { order.push(3); return false; })); parse(parser2, '\x1b]1;foo=bar\x1b\\'); - chai.expect(order).eql([3, 2, 1]); + assert.deepEqual(order, [3, 2, 1]); }); it('Dispose should work', () => { const oscCustom: [number, string][] = []; @@ -1440,8 +1440,8 @@ describe('EscapeSequenceParser', function (): void { const customHandler = parser2.registerOscHandler(1, new OscHandler(data => { oscCustom.push([1, data]); return true; })); customHandler.dispose(); parse(parser2, INPUT); - chai.expect(osc).eql([[1, 'foo=bar']]); - chai.expect(oscCustom).eql([], 'Should not use custom handler as it was disposed'); + assert.deepEqual(osc, [[1, 'foo=bar']]); + assert.deepEqual(oscCustom, [], 'Should not use custom handler as it was disposed'); }); it('Should not corrupt the parser when dispose is called twice', () => { const oscCustom: [number, string][] = []; @@ -1450,11 +1450,11 @@ describe('EscapeSequenceParser', function (): void { customHandler.dispose(); customHandler.dispose(); parse(parser2, INPUT); - chai.expect(osc).eql([[1, 'foo=bar']]); - chai.expect(oscCustom).eql([], 'Should not use custom handler as it was disposed'); + assert.deepEqual(osc, [[1, 'foo=bar']]); + assert.deepEqual(oscCustom, [], 'Should not use custom handler as it was disposed'); }); }); - it('DCS handler', function (): void { + it('DCS handler', () => { parser2.registerDcsHandler({intermediates: '+', final: 'p'}, { hook: function (params: IParams): void { dcs.push(['hook', '', params.toArray(), 0]); @@ -1473,7 +1473,7 @@ describe('EscapeSequenceParser', function (): void { }); parse(parser2, '\x1bP1;2;3+pabc'); parse(parser2, ';de\x9c'); - chai.expect(dcs).eql([ + assert.deepEqual(dcs, [ ['hook', '', [1, 2, 3], 0], ['put', 'abc'], ['put', ';de'], ['unhook'] @@ -1483,7 +1483,7 @@ describe('EscapeSequenceParser', function (): void { clearAccu(); parse(parser2, '\x1bP1;2;3+pabc'); parse(parser2, ';de\x9c'); - chai.expect(dcs).eql([]); + assert.deepEqual(dcs, []); }); describe('DCS custom handlers', () => { const DCS_INPUT = '\x1bP1;2;3+pabc\x1b\\'; @@ -1492,14 +1492,14 @@ describe('EscapeSequenceParser', function (): void { parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); parse(parser2, DCS_INPUT); - chai.expect(dcsCustom).eql([['B', [1, 2, 3], 'abc']]); + assert.deepEqual(dcsCustom, [['B', [1, 2, 3], 'abc']]); }); it('Allow fallback', () => { const dcsCustom: [string, (number | number[])[], string][] = []; parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return false; })); parse(parser2, DCS_INPUT); - chai.expect(dcsCustom).eql([['B', [1, 2, 3], 'abc'], ['A', [1, 2, 3], 'abc']]); + assert.deepEqual(dcsCustom, [['B', [1, 2, 3], 'abc'], ['A', [1, 2, 3], 'abc']]); }); it('Multiple custom handlers fallback once', () => { const dcsCustom: [string, (number | number[])[], string][] = []; @@ -1507,7 +1507,7 @@ describe('EscapeSequenceParser', function (): void { parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['C', params.toArray(), data]); return false; })); parse(parser2, DCS_INPUT); - chai.expect(dcsCustom).eql([['C', [1, 2, 3], 'abc'], ['B', [1, 2, 3], 'abc']]); + assert.deepEqual(dcsCustom, [['C', [1, 2, 3], 'abc'], ['B', [1, 2, 3], 'abc']]); }); it('Multiple custom handlers no fallback', () => { const dcsCustom: [string, (number | number[])[], string][] = []; @@ -1515,7 +1515,7 @@ describe('EscapeSequenceParser', function (): void { parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['C', params.toArray(), data]); return true; })); parse(parser2, DCS_INPUT); - chai.expect(dcsCustom).eql([['C', [1, 2, 3], 'abc']]); + assert.deepEqual(dcsCustom, [['C', [1, 2, 3], 'abc']]); }); it('Execution order should go from latest handler down to the original', () => { const order: number[] = []; @@ -1523,7 +1523,7 @@ describe('EscapeSequenceParser', function (): void { parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler(() => { order.push(2); return false; })); parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler(() => { order.push(3); return false; })); parse(parser2, DCS_INPUT); - chai.expect(order).eql([3, 2, 1]); + assert.deepEqual(order, [3, 2, 1]); }); it('Dispose should work', () => { const dcsCustom: [string, (number | number[])[], string][] = []; @@ -1531,7 +1531,7 @@ describe('EscapeSequenceParser', function (): void { const dispo = parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); dispo.dispose(); parse(parser2, DCS_INPUT); - chai.expect(dcsCustom).eql([['A', [1, 2, 3], 'abc']]); + assert.deepEqual(dcsCustom, [['A', [1, 2, 3], 'abc']]); }); it('Should not corrupt the parser when dispose is called twice', () => { const dcsCustom: [string, (number | number[])[], string][] = []; @@ -1540,17 +1540,17 @@ describe('EscapeSequenceParser', function (): void { dispo.dispose(); dispo.dispose(); parse(parser2, DCS_INPUT); - chai.expect(dcsCustom).eql([['A', [1, 2, 3], 'abc']]); + assert.deepEqual(dcsCustom, [['A', [1, 2, 3], 'abc']]); }); }); - it('ERROR handler', function (): void { + it('ERROR handler', () => { let errorState: IParsingState | null = null; parser2.setErrorHandler(function (state: IParsingState): IParsingState { errorState = state; return state; }); parse(parser2, '\x1b[1;2;€;3m'); // faulty escape sequence - chai.expect(errorState).eql({ + assert.deepEqual(errorState, { position: 6, code: '€'.charCodeAt(0), currentState: ParserState.CSI_PARAM, @@ -1562,7 +1562,7 @@ describe('EscapeSequenceParser', function (): void { parser2.clearErrorHandler(); // should not throw errorState = null; parse(parser2, '\x1b[1;2;a;3m'); - chai.expect(errorState).eql(null); + assert.equal(errorState, null); }); }); describe('function identifiers', () => { @@ -1570,46 +1570,46 @@ describe('EscapeSequenceParser', function (): void { it('prefix range 0x3c .. 0x3f, one byte', () => { for (let i = 0x3c; i <= 0x3f; ++i) { const c = String.fromCharCode(i); - chai.expect(parser.identToString(parser.identifier({prefix: c, final: 'z'}))).eql(c + 'z'); + assert.equal(parser.identToString(parser.identifier({prefix: c, final: 'z'})), c + 'z'); } - chai.assert.throws(() => { parser.identifier({prefix: '\x3b', final: 'z'}); }, 'prefix must be in range 0x3c .. 0x3f'); - chai.assert.throws(() => { parser.identifier({prefix: '\x40', final: 'z'}); }, 'prefix must be in range 0x3c .. 0x3f'); - chai.assert.throws(() => { parser.identifier({prefix: '??', final: 'z'}); }, 'only one byte as prefix supported'); + assert.throws(() => { parser.identifier({prefix: '\x3b', final: 'z'}); }, 'prefix must be in range 0x3c .. 0x3f'); + assert.throws(() => { parser.identifier({prefix: '\x40', final: 'z'}); }, 'prefix must be in range 0x3c .. 0x3f'); + assert.throws(() => { parser.identifier({prefix: '??', final: 'z'}); }, 'only one byte as prefix supported'); }); it('intermediates range 0x20 .. 0x2f, up to two bytes', () => { for (let i = 0x20; i <= 0x2f; ++i) { const c = String.fromCharCode(i); - chai.expect(parser.identToString(parser.identifier({intermediates: c + c, final: 'z'}))).eql(c + c + 'z'); + assert.equal(parser.identToString(parser.identifier({intermediates: c + c, final: 'z'})), c + c + 'z'); } - chai.assert.throws(() => { parser.identifier({intermediates: '\x1f', final: 'z'}); }, 'intermediate must be in range 0x20 .. 0x2f'); - chai.assert.throws(() => { parser.identifier({intermediates: '\x30', final: 'z'}); }, 'intermediate must be in range 0x20 .. 0x2f'); - chai.assert.throws(() => { parser.identifier({intermediates: '!!!', final: 'z'}); }, 'only two bytes as intermediates are supported'); + assert.throws(() => { parser.identifier({intermediates: '\x1f', final: 'z'}); }, 'intermediate must be in range 0x20 .. 0x2f'); + assert.throws(() => { parser.identifier({intermediates: '\x30', final: 'z'}); }, 'intermediate must be in range 0x20 .. 0x2f'); + assert.throws(() => { parser.identifier({intermediates: '!!!', final: 'z'}); }, 'only two bytes as intermediates are supported'); }); it('final CSI/DCS range 0x40 .. 0x7e (default), one byte', () => { for (let i = 0x40; i <= 0x7e; ++i) { const c = String.fromCharCode(i); - chai.expect(parser.identToString(parser.identifier({final: c}))).eql(c); + assert.equal(parser.identToString(parser.identifier({final: c})), c); } - chai.assert.throws(() => { parser.identifier({final: '\x3f'}); }, 'final must be in range 64 .. 126'); - chai.assert.throws(() => { parser.identifier({final: '\x7f'}); }, 'final must be in range 64 .. 126'); - chai.assert.throws(() => { parser.identifier({final: 'zz'}); }, 'final must be a single byte'); + assert.throws(() => { parser.identifier({final: '\x3f'}); }, 'final must be in range 64 .. 126'); + assert.throws(() => { parser.identifier({final: '\x7f'}); }, 'final must be in range 64 .. 126'); + assert.throws(() => { parser.identifier({final: 'zz'}); }, 'final must be a single byte'); }); it('final ESC range 0x30 .. 0x7e, one byte', () => { for (let i = 0x30; i <= 0x7e; ++i) { const final = String.fromCharCode(i); let handler: IDisposable | undefined; - chai.assert.doesNotThrow(() => { handler = parser.registerEscHandler({final}, () => true); }, 'final must be in range 48 .. 126'); + assert.doesNotThrow(() => { handler = parser.registerEscHandler({final}, () => true); }, 'final must be in range 48 .. 126'); if (handler) handler.dispose(); } - chai.assert.throws(() => { parser.registerEscHandler({final: '\x2f'}, () => true); }, 'final must be in range 48 .. 126'); - chai.assert.throws(() => { parser.registerEscHandler({final: '\x7f'}, () => true); }, 'final must be in range 48 .. 126'); + assert.throws(() => { parser.registerEscHandler({final: '\x2f'}, () => true); }, 'final must be in range 48 .. 126'); + assert.throws(() => { parser.registerEscHandler({final: '\x7f'}, () => true); }, 'final must be in range 48 .. 126'); }); it('id calculation - should stacking prefix -> intermediate -> final', () => { - chai.expect(parser.identToString(parser.identifier({final: 'z'}))).eql('z'); - chai.expect(parser.identToString(parser.identifier({prefix: '?', final: 'z'}))).eql('?z'); - chai.expect(parser.identToString(parser.identifier({intermediates: '!', final: 'z'}))).eql('!z'); - chai.expect(parser.identToString(parser.identifier({prefix: '?', intermediates: '!', final: 'z'}))).eql('?!z'); - chai.expect(parser.identToString(parser.identifier({prefix: '?', intermediates: '!!', final: 'z'}))).eql('?!!z'); + assert.equal(parser.identToString(parser.identifier({final: 'z'})), 'z'); + assert.equal(parser.identToString(parser.identifier({prefix: '?', final: 'z'})), '?z'); + assert.equal(parser.identToString(parser.identifier({intermediates: '!', final: 'z'})), '!z'); + assert.equal(parser.identToString(parser.identifier({prefix: '?', intermediates: '!', final: 'z'})), '?!z'); + assert.equal(parser.identToString(parser.identifier({prefix: '?', intermediates: '!!', final: 'z'})), '?!!z'); }); }); describe('identifier invocation', () => { @@ -1623,7 +1623,7 @@ describe('EscapeSequenceParser', function (): void { h2.dispose(); h3.dispose(); parse(parser, '\x1bz\x1b!z\x1b!!z'); - chai.expect(callstack).eql(['z', '!z', '!!z']); + assert.deepEqual(callstack, ['z', '!z', '!!z']); }); it('CSI', () => { const callstack: any[] = []; @@ -1641,7 +1641,10 @@ describe('EscapeSequenceParser', function (): void { h5.dispose(); h6.dispose(); parse(parser, '\x1b[1;z\x1b[1;!z\x1b[1;!!z\x1b[?1;z\x1b[?1;!z\x1b[?1;!!z'); - chai.expect(callstack).eql([['z', [1, 0]], ['!z', [1, 0]], ['!!z', [1, 0]], ['?z', [1, 0]], ['?!z', [1, 0]], ['?!!z', [1, 0]]]); + assert.deepEqual( + callstack, + [['z', [1, 0]], ['!z', [1, 0]], ['!!z', [1, 0]], ['?z', [1, 0]], ['?!z', [1, 0]], ['?!!z', [1, 0]]] + ); }); it('DCS', () => { const callstack: any[] = []; @@ -1659,14 +1662,17 @@ describe('EscapeSequenceParser', function (): void { h5.dispose(); h6.dispose(); parse(parser, '\x1bP1;zAB\x1b\\\x1bP1;!zAB\x1b\\\x1bP1;!!zAB\x1b\\\x1bP?1;zAB\x1b\\\x1bP?1;!zAB\x1b\\\x1bP?1;!!zAB\x1b\\'); - chai.expect(callstack).eql([ - ['z', [1, 0], 'AB'], - ['!z', [1, 0], 'AB'], - ['!!z', [1, 0], 'AB'], - ['?z', [1, 0], 'AB'], - ['?!z', [1, 0], 'AB'], - ['?!!z', [1, 0], 'AB'] - ]); + assert.deepEqual( + callstack, + [ + ['z', [1, 0], 'AB'], + ['!z', [1, 0], 'AB'], + ['!!z', [1, 0], 'AB'], + ['?z', [1, 0], 'AB'], + ['?!z', [1, 0], 'AB'], + ['?!!z', [1, 0], 'AB'] + ] + ); }); }); }); From 68b7f885235b22d20de40c4085d9582070264b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sun, 24 Jan 2021 17:09:16 +0100 Subject: [PATCH 080/377] async parser tests for CSI and ESC --- .../parser/EscapeSequenceParser.test.ts | 575 +++++++++++++++--- src/common/parser/EscapeSequenceParser.ts | 48 +- src/common/parser/Types.d.ts | 1 + 3 files changed, 523 insertions(+), 101 deletions(-) diff --git a/src/common/parser/EscapeSequenceParser.test.ts b/src/common/parser/EscapeSequenceParser.test.ts index f4ec5025..56d4c93e 100644 --- a/src/common/parser/EscapeSequenceParser.test.ts +++ b/src/common/parser/EscapeSequenceParser.test.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { IParsingState, IParams, ParamsArray, IOscParser, IOscHandler, OscFallbackHandlerType, IFunctionIdentifier } from 'common/parser/Types'; +import { IParsingState, IParams, ParamsArray, IOscParser, IOscHandler, OscFallbackHandlerType, IFunctionIdentifier, IParserStackState, ParserStackType, ResumableHandlersType } from 'common/parser/Types'; import { EscapeSequenceParser, TransitionTable, VT500_TRANSITION_TABLE } from 'common/parser/EscapeSequenceParser'; import { assert } from 'chai'; import { StringToUtf32, stringFromCodePoint, utf32ToString } from 'common/input/TextDecoder'; @@ -24,7 +24,7 @@ function r(a: number, b: number): string[] { } class MockOscPutParser implements IOscParser { - private _fallback: OscFallbackHandlerType = () => {}; + private _fallback: OscFallbackHandlerType = () => { }; public data = ''; public reset(): void { this.data = ''; @@ -92,6 +92,21 @@ class TestEscapeSequenceParser extends EscapeSequenceParser { public identifier(id: IFunctionIdentifier): number { return this._identifier(id); } + public get parseStack(): IParserStackState { + return this._parseStack; + } + private _trackStack = false; + public trackStackSavesOnPause(): void { + this._trackStack = true; + } + public trackedStack: IParserStackState[] = []; + public parse(data: Uint32Array, length: number, promiseResult?: boolean): void | Promise { + const result = super.parse(data, length, promiseResult); + if (result && this._trackStack) { + this.trackedStack.push({ ...this.parseStack }); + } + return result; + } } // test object to collect parser actions and compare them with expected values @@ -1206,71 +1221,71 @@ describe('EscapeSequenceParser', () => { assert.equal(print, ''); }); it('ESC handler', () => { - parser2.registerEscHandler({intermediates: '%', final: 'G'}, function (): boolean { + parser2.registerEscHandler({ intermediates: '%', final: 'G' }, function (): boolean { esc.push('%G'); return true; }); - parser2.registerEscHandler({final: 'E'}, function (): boolean { + parser2.registerEscHandler({ final: 'E' }, function (): boolean { esc.push('E'); return true; }); parse(parser2, INPUT); assert.deepEqual(esc, ['%G', 'E']); - parser2.clearEscHandler({intermediates: '%', final: 'G'}); - parser2.clearEscHandler({intermediates: '%', final: 'G'}); // should not throw + parser2.clearEscHandler({ intermediates: '%', final: 'G' }); + parser2.clearEscHandler({ intermediates: '%', final: 'G' }); // should not throw clearAccu(); parse(parser2, INPUT); assert.deepEqual(esc, ['E']); - parser2.clearEscHandler({final: 'E'}); + parser2.clearEscHandler({ final: 'E' }); clearAccu(); parse(parser2, INPUT); assert.deepEqual(esc, []); }); describe('ESC custom handlers', () => { it('prevent fallback', () => { - parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); return true; }); - parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return true; }); + parser2.registerEscHandler({ intermediates: '%', final: 'G' }, () => { esc.push('default - %G'); return true; }); + parser2.registerEscHandler({ intermediates: '%', final: 'G' }, () => { esc.push('custom - %G'); return true; }); parse(parser2, INPUT); assert.deepEqual(esc, ['custom - %G']); }); it('allow fallback', () => { - parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); return true; }); - parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return false; }); + parser2.registerEscHandler({ intermediates: '%', final: 'G' }, () => { esc.push('default - %G'); return true; }); + parser2.registerEscHandler({ intermediates: '%', final: 'G' }, () => { esc.push('custom - %G'); return false; }); parse(parser2, INPUT); assert.deepEqual(esc, ['custom - %G', 'default - %G']); }); it('Multiple custom handlers fallback once', () => { - parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); return true; }); - parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return true; }); - parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom2 - %G'); return false; }); + parser2.registerEscHandler({ intermediates: '%', final: 'G' }, () => { esc.push('default - %G'); return true; }); + parser2.registerEscHandler({ intermediates: '%', final: 'G' }, () => { esc.push('custom - %G'); return true; }); + parser2.registerEscHandler({ intermediates: '%', final: 'G' }, () => { esc.push('custom2 - %G'); return false; }); parse(parser2, INPUT); assert.deepEqual(esc, ['custom2 - %G', 'custom - %G']); }); it('Multiple custom handlers no fallback', () => { - parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); return true; }); - parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return true; }); - parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom2 - %G'); return true; }); + parser2.registerEscHandler({ intermediates: '%', final: 'G' }, () => { esc.push('default - %G'); return true; }); + parser2.registerEscHandler({ intermediates: '%', final: 'G' }, () => { esc.push('custom - %G'); return true; }); + parser2.registerEscHandler({ intermediates: '%', final: 'G' }, () => { esc.push('custom2 - %G'); return true; }); parse(parser2, INPUT); assert.deepEqual(esc, ['custom2 - %G']); }); it('Execution order should go from latest handler down to the original', () => { const order: number[] = []; - parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { order.push(1); return true; }); - parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { order.push(2); return false; }); - parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { order.push(3); return false; }); + parser2.registerEscHandler({ intermediates: '%', final: 'G' }, () => { order.push(1); return true; }); + parser2.registerEscHandler({ intermediates: '%', final: 'G' }, () => { order.push(2); return false; }); + parser2.registerEscHandler({ intermediates: '%', final: 'G' }, () => { order.push(3); return false; }); parse(parser2, '\x1b%G'); assert.deepEqual(order, [3, 2, 1]); }); it('Dispose should work', () => { - parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); return true; }); - const dispo = parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return true; }); + parser2.registerEscHandler({ intermediates: '%', final: 'G' }, () => { esc.push('default - %G'); return true; }); + const dispo = parser2.registerEscHandler({ intermediates: '%', final: 'G' }, () => { esc.push('custom - %G'); return true; }); dispo.dispose(); parse(parser2, INPUT); assert.deepEqual(esc, ['default - %G']); }); it('Should not corrupt the parser when dispose is called twice', () => { - parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('default - %G'); return true; }); - const dispo = parser2.registerEscHandler({intermediates: '%', final: 'G'}, () => { esc.push('custom - %G'); return true; }); + parser2.registerEscHandler({ intermediates: '%', final: 'G' }, () => { esc.push('default - %G'); return true; }); + const dispo = parser2.registerEscHandler({ intermediates: '%', final: 'G' }, () => { esc.push('custom - %G'); return true; }); dispo.dispose(); dispo.dispose(); parse(parser2, INPUT); @@ -1278,14 +1293,14 @@ describe('EscapeSequenceParser', () => { }); }); it('CSI handler', () => { - parser2.registerCsiHandler({final: 'm'}, function (params: IParams): boolean { + parser2.registerCsiHandler({ final: 'm' }, function (params: IParams): boolean { csi.push(['m', params.toArray(), '']); return true; }); parse(parser2, INPUT); assert.deepEqual(csi, [['m', [1, 31], ''], ['m', [0], '']]); - parser2.clearCsiHandler({final: 'm'}); - parser2.clearCsiHandler({final: 'm'}); // should not throw + parser2.clearCsiHandler({ final: 'm' }); + parser2.clearCsiHandler({ final: 'm' }); // should not throw clearAccu(); parse(parser2, INPUT); assert.deepEqual(csi, []); @@ -1293,16 +1308,16 @@ describe('EscapeSequenceParser', () => { describe('CSI custom handlers', () => { it('Prevent fallback', () => { const csiCustom: [string, ParamsArray, string][] = []; - parser2.registerCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); return true; }); - parser2.registerCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({ final: 'm' }, params => { csi.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({ final: 'm' }, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); parse(parser2, INPUT); assert.deepEqual(csi, [], 'Should not fallback to original handler'); assert.deepEqual(csiCustom, [['m', [1, 31], ''], ['m', [0], '']]); }); it('Allow fallback', () => { const csiCustom: [string, ParamsArray, string][] = []; - parser2.registerCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); return true; }); - parser2.registerCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return false; }); + parser2.registerCsiHandler({ final: 'm' }, params => { csi.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({ final: 'm' }, params => { csiCustom.push(['m', params.toArray(), '']); return false; }); parse(parser2, INPUT); assert.deepEqual(csi, [['m', [1, 31], ''], ['m', [0], '']], 'Should fallback to original handler'); assert.deepEqual(csiCustom, [['m', [1, 31], ''], ['m', [0], '']]); @@ -1310,9 +1325,9 @@ describe('EscapeSequenceParser', () => { it('Multiple custom handlers fallback once', () => { const csiCustom: [string, ParamsArray, string][] = []; const csiCustom2: [string, ParamsArray, string][] = []; - parser2.registerCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); return true; }); - parser2.registerCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); - parser2.registerCsiHandler({final: 'm'}, params => { csiCustom2.push(['m', params.toArray(), '']); return false; }); + parser2.registerCsiHandler({ final: 'm' }, params => { csi.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({ final: 'm' }, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({ final: 'm' }, params => { csiCustom2.push(['m', params.toArray(), '']); return false; }); parse(parser2, INPUT); assert.deepEqual(csi, [], 'Should not fallback to original handler'); assert.deepEqual(csiCustom, [['m', [1, 31], ''], ['m', [0], '']]); @@ -1321,9 +1336,9 @@ describe('EscapeSequenceParser', () => { it('Multiple custom handlers no fallback', () => { const csiCustom: [string, ParamsArray, string][] = []; const csiCustom2: [string, ParamsArray, string][] = []; - parser2.registerCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); return true; }); - parser2.registerCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); - parser2.registerCsiHandler({final: 'm'}, params => { csiCustom2.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({ final: 'm' }, params => { csi.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({ final: 'm' }, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({ final: 'm' }, params => { csiCustom2.push(['m', params.toArray(), '']); return true; }); parse(parser2, INPUT); assert.deepEqual(csi, [], 'Should not fallback to original handler'); assert.deepEqual(csiCustom, [], 'Should not fallback once'); @@ -1331,16 +1346,16 @@ describe('EscapeSequenceParser', () => { }); it('Execution order should go from latest handler down to the original', () => { const order: number[] = []; - parser2.registerCsiHandler({final: 'm'}, () => { order.push(1); return true; }); - parser2.registerCsiHandler({final: 'm'}, () => { order.push(2); return false; }); - parser2.registerCsiHandler({final: 'm'}, () => { order.push(3); return false; }); + parser2.registerCsiHandler({ final: 'm' }, () => { order.push(1); return true; }); + parser2.registerCsiHandler({ final: 'm' }, () => { order.push(2); return false; }); + parser2.registerCsiHandler({ final: 'm' }, () => { order.push(3); return false; }); parse(parser2, '\x1b[0m'); assert.deepEqual(order, [3, 2, 1]); }); it('Dispose should work', () => { const csiCustom: [string, ParamsArray, string][] = []; - parser2.registerCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); return true; }); - const customHandler = parser2.registerCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({ final: 'm' }, params => { csi.push(['m', params.toArray(), '']); return true; }); + const customHandler = parser2.registerCsiHandler({ final: 'm' }, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); customHandler.dispose(); parse(parser2, INPUT); assert.deepEqual(csi, [['m', [1, 31], ''], ['m', [0], '']]); @@ -1348,8 +1363,8 @@ describe('EscapeSequenceParser', () => { }); it('Should not corrupt the parser when dispose is called twice', () => { const csiCustom: [string, ParamsArray, string][] = []; - parser2.registerCsiHandler({final: 'm'}, params => { csi.push(['m', params.toArray(), '']); return true; }); - const customHandler = parser2.registerCsiHandler({final: 'm'}, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); + parser2.registerCsiHandler({ final: 'm' }, params => { csi.push(['m', params.toArray(), '']); return true; }); + const customHandler = parser2.registerCsiHandler({ final: 'm' }, params => { csiCustom.push(['m', params.toArray(), '']); return true; }); customHandler.dispose(); customHandler.dispose(); parse(parser2, INPUT); @@ -1455,7 +1470,7 @@ describe('EscapeSequenceParser', () => { }); }); it('DCS handler', () => { - parser2.registerDcsHandler({intermediates: '+', final: 'p'}, { + parser2.registerDcsHandler({ intermediates: '+', final: 'p' }, { hook: function (params: IParams): void { dcs.push(['hook', '', params.toArray(), 0]); }, @@ -1478,8 +1493,8 @@ describe('EscapeSequenceParser', () => { ['put', 'abc'], ['put', ';de'], ['unhook'] ]); - parser2.clearDcsHandler({intermediates: '+', final: 'p'}); - parser2.clearDcsHandler({intermediates: '+', final: 'p'}); // should not throw + parser2.clearDcsHandler({ intermediates: '+', final: 'p' }); + parser2.clearDcsHandler({ intermediates: '+', final: 'p' }); // should not throw clearAccu(); parse(parser2, '\x1bP1;2;3+pabc'); parse(parser2, ';de\x9c'); @@ -1489,54 +1504,54 @@ describe('EscapeSequenceParser', () => { const DCS_INPUT = '\x1bP1;2;3+pabc\x1b\\'; it('Prevent fallback', () => { const dcsCustom: [string, (number | number[])[], string][] = []; - parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); - parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({ intermediates: '+', final: 'p' }, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({ intermediates: '+', final: 'p' }, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); parse(parser2, DCS_INPUT); assert.deepEqual(dcsCustom, [['B', [1, 2, 3], 'abc']]); }); it('Allow fallback', () => { const dcsCustom: [string, (number | number[])[], string][] = []; - parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); - parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return false; })); + parser2.registerDcsHandler({ intermediates: '+', final: 'p' }, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({ intermediates: '+', final: 'p' }, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return false; })); parse(parser2, DCS_INPUT); assert.deepEqual(dcsCustom, [['B', [1, 2, 3], 'abc'], ['A', [1, 2, 3], 'abc']]); }); it('Multiple custom handlers fallback once', () => { const dcsCustom: [string, (number | number[])[], string][] = []; - parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); - parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); - parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['C', params.toArray(), data]); return false; })); + parser2.registerDcsHandler({ intermediates: '+', final: 'p' }, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({ intermediates: '+', final: 'p' }, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({ intermediates: '+', final: 'p' }, new DcsHandler((data, params) => { dcsCustom.push(['C', params.toArray(), data]); return false; })); parse(parser2, DCS_INPUT); assert.deepEqual(dcsCustom, [['C', [1, 2, 3], 'abc'], ['B', [1, 2, 3], 'abc']]); }); it('Multiple custom handlers no fallback', () => { const dcsCustom: [string, (number | number[])[], string][] = []; - parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); - parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); - parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['C', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({ intermediates: '+', final: 'p' }, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({ intermediates: '+', final: 'p' }, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({ intermediates: '+', final: 'p' }, new DcsHandler((data, params) => { dcsCustom.push(['C', params.toArray(), data]); return true; })); parse(parser2, DCS_INPUT); assert.deepEqual(dcsCustom, [['C', [1, 2, 3], 'abc']]); }); it('Execution order should go from latest handler down to the original', () => { const order: number[] = []; - parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler(() => { order.push(1); return true; })); - parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler(() => { order.push(2); return false; })); - parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler(() => { order.push(3); return false; })); + parser2.registerDcsHandler({ intermediates: '+', final: 'p' }, new DcsHandler(() => { order.push(1); return true; })); + parser2.registerDcsHandler({ intermediates: '+', final: 'p' }, new DcsHandler(() => { order.push(2); return false; })); + parser2.registerDcsHandler({ intermediates: '+', final: 'p' }, new DcsHandler(() => { order.push(3); return false; })); parse(parser2, DCS_INPUT); assert.deepEqual(order, [3, 2, 1]); }); it('Dispose should work', () => { const dcsCustom: [string, (number | number[])[], string][] = []; - parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); - const dispo = parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({ intermediates: '+', final: 'p' }, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); + const dispo = parser2.registerDcsHandler({ intermediates: '+', final: 'p' }, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); dispo.dispose(); parse(parser2, DCS_INPUT); assert.deepEqual(dcsCustom, [['A', [1, 2, 3], 'abc']]); }); it('Should not corrupt the parser when dispose is called twice', () => { const dcsCustom: [string, (number | number[])[], string][] = []; - parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); - const dispo = parser2.registerDcsHandler({intermediates: '+', final: 'p'}, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); + parser2.registerDcsHandler({ intermediates: '+', final: 'p' }, new DcsHandler((data, params) => { dcsCustom.push(['A', params.toArray(), data]); return true; })); + const dispo = parser2.registerDcsHandler({ intermediates: '+', final: 'p' }, new DcsHandler((data, params) => { dcsCustom.push(['B', params.toArray(), data]); return true; })); dispo.dispose(); dispo.dispose(); parse(parser2, DCS_INPUT); @@ -1570,54 +1585,54 @@ describe('EscapeSequenceParser', () => { it('prefix range 0x3c .. 0x3f, one byte', () => { for (let i = 0x3c; i <= 0x3f; ++i) { const c = String.fromCharCode(i); - assert.equal(parser.identToString(parser.identifier({prefix: c, final: 'z'})), c + 'z'); + assert.equal(parser.identToString(parser.identifier({ prefix: c, final: 'z' })), c + 'z'); } - assert.throws(() => { parser.identifier({prefix: '\x3b', final: 'z'}); }, 'prefix must be in range 0x3c .. 0x3f'); - assert.throws(() => { parser.identifier({prefix: '\x40', final: 'z'}); }, 'prefix must be in range 0x3c .. 0x3f'); - assert.throws(() => { parser.identifier({prefix: '??', final: 'z'}); }, 'only one byte as prefix supported'); + assert.throws(() => { parser.identifier({ prefix: '\x3b', final: 'z' }); }, 'prefix must be in range 0x3c .. 0x3f'); + assert.throws(() => { parser.identifier({ prefix: '\x40', final: 'z' }); }, 'prefix must be in range 0x3c .. 0x3f'); + assert.throws(() => { parser.identifier({ prefix: '??', final: 'z' }); }, 'only one byte as prefix supported'); }); it('intermediates range 0x20 .. 0x2f, up to two bytes', () => { for (let i = 0x20; i <= 0x2f; ++i) { const c = String.fromCharCode(i); - assert.equal(parser.identToString(parser.identifier({intermediates: c + c, final: 'z'})), c + c + 'z'); + assert.equal(parser.identToString(parser.identifier({ intermediates: c + c, final: 'z' })), c + c + 'z'); } - assert.throws(() => { parser.identifier({intermediates: '\x1f', final: 'z'}); }, 'intermediate must be in range 0x20 .. 0x2f'); - assert.throws(() => { parser.identifier({intermediates: '\x30', final: 'z'}); }, 'intermediate must be in range 0x20 .. 0x2f'); - assert.throws(() => { parser.identifier({intermediates: '!!!', final: 'z'}); }, 'only two bytes as intermediates are supported'); + assert.throws(() => { parser.identifier({ intermediates: '\x1f', final: 'z' }); }, 'intermediate must be in range 0x20 .. 0x2f'); + assert.throws(() => { parser.identifier({ intermediates: '\x30', final: 'z' }); }, 'intermediate must be in range 0x20 .. 0x2f'); + assert.throws(() => { parser.identifier({ intermediates: '!!!', final: 'z' }); }, 'only two bytes as intermediates are supported'); }); it('final CSI/DCS range 0x40 .. 0x7e (default), one byte', () => { for (let i = 0x40; i <= 0x7e; ++i) { const c = String.fromCharCode(i); - assert.equal(parser.identToString(parser.identifier({final: c})), c); + assert.equal(parser.identToString(parser.identifier({ final: c })), c); } - assert.throws(() => { parser.identifier({final: '\x3f'}); }, 'final must be in range 64 .. 126'); - assert.throws(() => { parser.identifier({final: '\x7f'}); }, 'final must be in range 64 .. 126'); - assert.throws(() => { parser.identifier({final: 'zz'}); }, 'final must be a single byte'); + assert.throws(() => { parser.identifier({ final: '\x3f' }); }, 'final must be in range 64 .. 126'); + assert.throws(() => { parser.identifier({ final: '\x7f' }); }, 'final must be in range 64 .. 126'); + assert.throws(() => { parser.identifier({ final: 'zz' }); }, 'final must be a single byte'); }); it('final ESC range 0x30 .. 0x7e, one byte', () => { for (let i = 0x30; i <= 0x7e; ++i) { const final = String.fromCharCode(i); let handler: IDisposable | undefined; - assert.doesNotThrow(() => { handler = parser.registerEscHandler({final}, () => true); }, 'final must be in range 48 .. 126'); + assert.doesNotThrow(() => { handler = parser.registerEscHandler({ final }, () => true); }, 'final must be in range 48 .. 126'); if (handler) handler.dispose(); } - assert.throws(() => { parser.registerEscHandler({final: '\x2f'}, () => true); }, 'final must be in range 48 .. 126'); - assert.throws(() => { parser.registerEscHandler({final: '\x7f'}, () => true); }, 'final must be in range 48 .. 126'); + assert.throws(() => { parser.registerEscHandler({ final: '\x2f' }, () => true); }, 'final must be in range 48 .. 126'); + assert.throws(() => { parser.registerEscHandler({ final: '\x7f' }, () => true); }, 'final must be in range 48 .. 126'); }); it('id calculation - should stacking prefix -> intermediate -> final', () => { - assert.equal(parser.identToString(parser.identifier({final: 'z'})), 'z'); - assert.equal(parser.identToString(parser.identifier({prefix: '?', final: 'z'})), '?z'); - assert.equal(parser.identToString(parser.identifier({intermediates: '!', final: 'z'})), '!z'); - assert.equal(parser.identToString(parser.identifier({prefix: '?', intermediates: '!', final: 'z'})), '?!z'); - assert.equal(parser.identToString(parser.identifier({prefix: '?', intermediates: '!!', final: 'z'})), '?!!z'); + assert.equal(parser.identToString(parser.identifier({ final: 'z' })), 'z'); + assert.equal(parser.identToString(parser.identifier({ prefix: '?', final: 'z' })), '?z'); + assert.equal(parser.identToString(parser.identifier({ intermediates: '!', final: 'z' })), '!z'); + assert.equal(parser.identToString(parser.identifier({ prefix: '?', intermediates: '!', final: 'z' })), '?!z'); + assert.equal(parser.identToString(parser.identifier({ prefix: '?', intermediates: '!!', final: 'z' })), '?!!z'); }); }); describe('identifier invocation', () => { it('ESC', () => { const callstack: string[] = []; - const h1 = parser.registerEscHandler({final: 'z'}, () => { callstack.push('z'); return true; }); - const h2 = parser.registerEscHandler({intermediates: '!', final: 'z'}, () => { callstack.push('!z'); return true; }); - const h3 = parser.registerEscHandler({intermediates: '!!', final: 'z'}, () => { callstack.push('!!z'); return true; }); + const h1 = parser.registerEscHandler({ final: 'z' }, () => { callstack.push('z'); return true; }); + const h2 = parser.registerEscHandler({ intermediates: '!', final: 'z' }, () => { callstack.push('!z'); return true; }); + const h3 = parser.registerEscHandler({ intermediates: '!!', final: 'z' }, () => { callstack.push('!!z'); return true; }); parse(parser, '\x1bz\x1b!z\x1b!!z'); h1.dispose(); h2.dispose(); @@ -1627,12 +1642,12 @@ describe('EscapeSequenceParser', () => { }); it('CSI', () => { const callstack: any[] = []; - const h1 = parser.registerCsiHandler({final: 'z'}, params => { callstack.push(['z', params.toArray()]); return true; }); - const h2 = parser.registerCsiHandler({intermediates: '!', final: 'z'}, params => { callstack.push(['!z', params.toArray()]); return true; }); - const h3 = parser.registerCsiHandler({intermediates: '!!', final: 'z'}, params => { callstack.push(['!!z', params.toArray()]); return true; }); - const h4 = parser.registerCsiHandler({prefix: '?', final: 'z'}, params => { callstack.push(['?z', params.toArray()]); return true; }); - const h5 = parser.registerCsiHandler({prefix: '?', intermediates: '!', final: 'z'}, params => { callstack.push(['?!z', params.toArray()]); return true; }); - const h6 = parser.registerCsiHandler({prefix: '?', intermediates: '!!', final: 'z'}, params => { callstack.push(['?!!z', params.toArray()]); return true; }); + const h1 = parser.registerCsiHandler({ final: 'z' }, params => { callstack.push(['z', params.toArray()]); return true; }); + const h2 = parser.registerCsiHandler({ intermediates: '!', final: 'z' }, params => { callstack.push(['!z', params.toArray()]); return true; }); + const h3 = parser.registerCsiHandler({ intermediates: '!!', final: 'z' }, params => { callstack.push(['!!z', params.toArray()]); return true; }); + const h4 = parser.registerCsiHandler({ prefix: '?', final: 'z' }, params => { callstack.push(['?z', params.toArray()]); return true; }); + const h5 = parser.registerCsiHandler({ prefix: '?', intermediates: '!', final: 'z' }, params => { callstack.push(['?!z', params.toArray()]); return true; }); + const h6 = parser.registerCsiHandler({ prefix: '?', intermediates: '!!', final: 'z' }, params => { callstack.push(['?!!z', params.toArray()]); return true; }); parse(parser, '\x1b[1;z\x1b[1;!z\x1b[1;!!z\x1b[?1;z\x1b[?1;!z\x1b[?1;!!z'); h1.dispose(); h2.dispose(); @@ -1648,12 +1663,12 @@ describe('EscapeSequenceParser', () => { }); it('DCS', () => { const callstack: any[] = []; - const h1 = parser.registerDcsHandler({final: 'z'}, new DcsHandler((data, params) => { callstack.push(['z', params.toArray(), data]); return true; })); - const h2 = parser.registerDcsHandler({intermediates: '!', final: 'z'}, new DcsHandler((data, params) => { callstack.push(['!z', params.toArray(), data]); return true; })); - const h3 = parser.registerDcsHandler({intermediates: '!!', final: 'z'}, new DcsHandler((data, params) => { callstack.push(['!!z', params.toArray(), data]); return true; })); - const h4 = parser.registerDcsHandler({prefix: '?', final: 'z'}, new DcsHandler((data, params) => { callstack.push(['?z', params.toArray(), data]); return true; })); - const h5 = parser.registerDcsHandler({prefix: '?', intermediates: '!', final: 'z'}, new DcsHandler((data, params) => { callstack.push(['?!z', params.toArray(), data]); return true; })); - const h6 = parser.registerDcsHandler({prefix: '?', intermediates: '!!', final: 'z'}, new DcsHandler((data, params) => { callstack.push(['?!!z', params.toArray(), data]); return true; })); + const h1 = parser.registerDcsHandler({ final: 'z' }, new DcsHandler((data, params) => { callstack.push(['z', params.toArray(), data]); return true; })); + const h2 = parser.registerDcsHandler({ intermediates: '!', final: 'z' }, new DcsHandler((data, params) => { callstack.push(['!z', params.toArray(), data]); return true; })); + const h3 = parser.registerDcsHandler({ intermediates: '!!', final: 'z' }, new DcsHandler((data, params) => { callstack.push(['!!z', params.toArray(), data]); return true; })); + const h4 = parser.registerDcsHandler({ prefix: '?', final: 'z' }, new DcsHandler((data, params) => { callstack.push(['?z', params.toArray(), data]); return true; })); + const h5 = parser.registerDcsHandler({ prefix: '?', intermediates: '!', final: 'z' }, new DcsHandler((data, params) => { callstack.push(['?!z', params.toArray(), data]); return true; })); + const h6 = parser.registerDcsHandler({ prefix: '?', intermediates: '!!', final: 'z' }, new DcsHandler((data, params) => { callstack.push(['?!!z', params.toArray(), data]); return true; })); parse(parser, '\x1bP1;zAB\x1b\\\x1bP1;!zAB\x1b\\\x1bP1;!!zAB\x1b\\\x1bP?1;zAB\x1b\\\x1bP?1;!zAB\x1b\\\x1bP?1;!!zAB\x1b\\'); h1.dispose(); h2.dispose(); @@ -1678,3 +1693,365 @@ describe('EscapeSequenceParser', () => { }); // TODO: error conditions and error recovery (not implemented yet in parser) }); + + +/** + * async handler tests. + */ + +function parseSync(parser: TestEscapeSequenceParser, data: string): void | Promise { + const container = new Uint32Array(data.length); + const decoder = new StringToUtf32(); + return parser.parse(container, decoder.decode(data, container)); +} +async function parseP(parser: TestEscapeSequenceParser, data: string): Promise { + const container = new Uint32Array(data.length); + const decoder = new StringToUtf32(); + const len = decoder.decode(data, container); + let result: void | Promise; + let prev: boolean | undefined; + while (result = parser.parse(container, len, prev)) { + prev = await result; + } +} +function evalStackSaves(stackSaves: IParserStackState[], data: [number, ParserStackType, number][]): void { + assert.equal(stackSaves.length, data.length); + for (let i = 0; i < data.length; ++i) { + assert.equal(stackSaves[i].chunkPos, data[i][0]); + assert.equal(stackSaves[i].state, data[i][1]); + assert.equal(stackSaves[i].handlerPos, data[i][2]); + } +} +// helper similiar to assert.throws for async functions +async function throwsAsync(fn: () => Promise, message?: string | undefined): Promise { + let msg: string | undefined; + try { + await fn(); + } catch (e) { + if (e instanceof Error) { + msg = e.message; + } else if (typeof e === 'string') { + msg = e; + } + if (typeof message === 'string') { + assert.equal(msg, message); + } + return; + } + assert.throws(fn, message); +} + +describe('EscapeSequenceParser - async', () => { + // sequences: SGR 1;31 | hello SP | ESC %G | wor | ESC E | ld! | SGR 0 | EXE \r\n | $> | OSC 1;foo=bar ST + // needed handlers: CSI m, PRINT, ESC %G, ESC E, EXE \r, EXE \n, OSC 1 + const INPUT = '\x1b[1;31mhello \x1b%Gwor\x1bEld!\x1b[0m\r\n$>\x1b]1;foo=bar\x1b\\'; + let RESULT: any[]; + let parser: TestEscapeSequenceParser; + const callstack: any[] = []; + function clearAccu(): void { + callstack.length = 0; + parser.trackedStack.length = 0; + } + beforeEach(() => { + RESULT = [ + ['SGR', [1, 31]], + ['PRINT', 'hello '], + ['ESC %G'], + ['PRINT', 'wor'], + ['ESC E'], + ['PRINT', 'ld!'], + ['SGR', [0]], + ['EXE \r'], + ['EXE \n'], + ['PRINT', '$>'], + ['OSC 1', 'foo=bar'] + ]; + parser = new TestEscapeSequenceParser(); + parser.reset(); + parser.trackStackSavesOnPause(); + clearAccu(); + }); + describe('sync handlers should behave as before', () => { + beforeEach(() => { + parser.setPrintHandler((data, start, end) => { + let result = ''; + for (let i = start; i < end; ++i) { + result += stringFromCodePoint(data[i]); + } + callstack.push(['PRINT', result]); + }); + parser.registerCsiHandler({ final: 'm' }, params => { callstack.push(['SGR', params.toArray()]); return true; }); + parser.registerEscHandler({ intermediates: '%', final: 'G' }, () => { callstack.push(['ESC %G']); return true; }); + parser.registerEscHandler({ final: 'E' }, () => { callstack.push(['ESC E']); return true; }); + parser.setExecuteHandler('\r', () => { callstack.push(['EXE \r']); return true; }); + parser.setExecuteHandler('\n', () => { callstack.push(['EXE \n']); return true; }); + parser.registerOscHandler(1, new OscHandler(data => { callstack.push(['OSC 1', data]); return true; })); + }); + + it('sync handlers keep parsed in sync mode', () => { + // note: if we have only sync handlers, a parse call should never return anything + assert.equal(!parseSync(parser, INPUT), true); + assert.equal(parser.parseStack.state, ParserStackType.NONE); // not paused + assert.equal(parser.trackedStack.length, 0); // never got paused + }); + it('correct result on sync parse call', () => { + parseSync(parser, INPUT); + assert.deepEqual(callstack, RESULT); + assert.equal(parser.trackedStack.length, 0); + }); + it('correct result on async parse call', async () => { + await parseP(parser, INPUT); + assert.deepEqual(callstack, RESULT); + assert.equal(parser.trackedStack.length, 0); + }); + }); + describe('async handlers', () => { + beforeEach(() => { + parser.setPrintHandler((data, start, end) => { + let result = ''; + for (let i = start; i < end; ++i) { + result += stringFromCodePoint(data[i]); + } + callstack.push(['PRINT', result]); + }); + parser.registerCsiHandler({ final: 'm' }, async params => { callstack.push(['SGR', params.toArray()]); return true; }); + parser.registerEscHandler({ intermediates: '%', final: 'G' }, async () => { callstack.push(['ESC %G']); return true; }); + parser.registerEscHandler({ final: 'E' }, async () => { callstack.push(['ESC E']); return true; }); + parser.setExecuteHandler('\r', () => { callstack.push(['EXE \r']); return true; }); + parser.setExecuteHandler('\n', () => { callstack.push(['EXE \n']); return true; }); + parser.registerOscHandler(1, new OscHandler(data => { callstack.push(['OSC 1', data]); return true; })); + }); + + it('sync parse call does not work anymore', () => { + assert.notEqual(!parseSync(parser, INPUT), true); + assert.notDeepEqual(callstack, RESULT); + // due to sync calling we should save exactly one saved stack + // proper continuation is not possible anymore, as we lost the promise resolve value + assert.equal(parser.trackedStack.length, 1); + }); + it('improper continuation should throw', async () => { + /** + * Explanation: + * The first sync call will stop at the first promise returned, + * but does not await its resolve value. + * The second sync call to parse will fail due to missing `promiseResult`, + * which is needed for correct continuation. + */ + assert.notEqual(!parseSync(parser, INPUT), true); + assert.notDeepEqual(callstack, RESULT); + assert.throws(() => parseSync(parser, INPUT), 'improper continuation due to previous async handler, giving up parsing'); + // keeps being broken for further parse calls (sync and async) + assert.throws(() => parseSync(parser, 'random'), 'improper continuation due to previous async handler, giving up parsing'); + await throwsAsync(() => parseP(parser, 'foobar'), 'improper continuation due to previous async handler, giving up parsing'); + // FIXME: come up with a good recovery strategy + }); + it('correct result on awaited parse call', async () => { + await parseP(parser, INPUT); + assert.deepEqual(callstack, RESULT); + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 0], [15, ParserStackType.ESC, 0], [20, ParserStackType.ESC, 0], [27, ParserStackType.CSI, 0] + ]); + }); + it('correct result on chunked awaited parse calls', async () => { + RESULT = [ + ['SGR', [1, 31]], + ['PRINT', 'h'], // due to single char input PRINT is split + ['PRINT', 'e'], + ['PRINT', 'l'], + ['PRINT', 'l'], + ['PRINT', 'o'], + ['PRINT', ' '], + ['ESC %G'], + ['PRINT', 'w'], + ['PRINT', 'o'], + ['PRINT', 'r'], + ['ESC E'], + ['PRINT', 'l'], + ['PRINT', 'd'], + ['PRINT', '!'], + ['SGR', [0]], + ['EXE \r'], + ['EXE \n'], + ['PRINT', '$'], + ['PRINT', '>'], + ['OSC 1', 'foo=bar'] + ]; + + // split to single char input + for (let i = 0; i < INPUT.length; ++i) { + // Note: a single fully awaited parse call always ends in sync mode, + // which re-enables faster sync processing in the higher up callstack + await parseP(parser, INPUT[i]); + } + assert.deepEqual(callstack, RESULT); + evalStackSaves(parser.trackedStack, [ + [0, ParserStackType.CSI, 0], + [0, ParserStackType.ESC, 0], + [0, ParserStackType.ESC, 0], + [0, ParserStackType.CSI, 0] + ]); + }); + it('multiple async SGR handlers', async () => { + // register with fallback + const SGR2 = parser.registerCsiHandler({ final: 'm' }, async params => { callstack.push(['2# SGR', params.toArray()]); return false; }); + await parseP(parser, INPUT); + // should contain [2# SGR, SGR] call pairs + for (let i = 0; i < callstack.length; ++i) { + const entry = callstack[i]; + if (entry[0] === '2# SGR') assert.equal(callstack[i + 1][0], 'SGR', 'Should fallback to original handler'); + } + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 1], + [6, ParserStackType.CSI, 0], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 0], + [27, ParserStackType.CSI, 1], + [27, ParserStackType.CSI, 0] + ]); + clearAccu(); + // after dispose we should be back to RESULT + SGR2.dispose(); + await parseP(parser, INPUT); + assert.deepEqual(callstack, RESULT, 'Should not call custom handler'); + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 0], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 0], + [27, ParserStackType.CSI, 0] + ]); + clearAccu(); + + // register without fallback + const SGR22 = parser.registerCsiHandler({ final: 'm' }, async params => { callstack.push(['2# SGR', params.toArray()]); return true; }); + await parseP(parser, INPUT); + // should only contain 2# SGR + for (let i = 0; i < callstack.length; ++i) { + const entry = callstack[i]; + if (entry[0] === '2# SGR') assert.notEqual(callstack[i + 1][0], 'SGR', 'Should not fallback to original handler'); + } + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 1], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 0], + [27, ParserStackType.CSI, 1] + ]); + clearAccu(); + // after dispose we should be back to RESULT + SGR22.dispose(); + await parseP(parser, INPUT); + assert.deepEqual(callstack, RESULT, 'Should not call custom handler'); + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 0], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 0], + [27, ParserStackType.CSI, 0] + ]); + }); + it('multiple async ESC handlers', async () => { + // register with fallback + const ESC2 = parser.registerEscHandler({ final: 'E' }, async () => { callstack.push(['2# ESC E']); return false; }); + await parseP(parser, INPUT); + for (let i = 0; i < callstack.length; ++i) { + const entry = callstack[i]; + if (entry[0] === '2# ESC E') assert.equal(callstack[i + 1][0], 'ESC E', 'Should fallback to original handler'); + } + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 0], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 1], + [20, ParserStackType.ESC, 0], + [27, ParserStackType.CSI, 0] + ]); + clearAccu(); + // after dispose we should be back to RESULT + ESC2.dispose(); + await parseP(parser, INPUT); + assert.deepEqual(callstack, RESULT, 'Should not call custom handler'); + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 0], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 0], + [27, ParserStackType.CSI, 0] + ]); + clearAccu(); + + // register without fallback + const ESC22 = parser.registerEscHandler({ final: 'E' }, async () => { callstack.push(['2# ESC E']); return true; }); + await parseP(parser, INPUT); + for (let i = 0; i < callstack.length; ++i) { + const entry = callstack[i]; + if (entry[0] === '2# ESC E') assert.notEqual(callstack[i + 1][0], 'ESC E', 'Should not fallback to original handler'); + } + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 0], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 1], + [27, ParserStackType.CSI, 0] + ]); + clearAccu(); + // after dispose we should be back to RESULT + ESC22.dispose(); + await parseP(parser, INPUT); + assert.deepEqual(callstack, RESULT, 'Should not call custom handler'); + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 0], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 0], + [27, ParserStackType.CSI, 0] + ]); + }); + it('sync/async SGR mixed', async () => { + // sync with fallback + const SGR2 = parser.registerCsiHandler({ final: 'm' }, params => { callstack.push(['2# SGR', params.toArray()]); return false; }); + // async with fallback + const SGR3 = parser.registerCsiHandler({ final: 'm' }, async params => { callstack.push(['3# SGR', params.toArray()]); return false; }); + await parseP(parser, INPUT); + // should contain [3# SGR, 2# SGR, SGR] call triples + for (let i = 0; i < callstack.length; ++i) { + const entry = callstack[i]; + if (entry[0] === '3# SGR') { + assert.equal(callstack[i + 1][0], '2# SGR', 'Should fallback to next handler'); + assert.equal(callstack[i + 2][0], 'SGR', 'Should fallback to original handler'); + } + } + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 2], + [6, ParserStackType.CSI, 0], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 0], + [27, ParserStackType.CSI, 2], + [27, ParserStackType.CSI, 0] + ]); + clearAccu(); + // dispose SGR2 (sync one) + SGR2.dispose(); + await parseP(parser, INPUT); + // should contain [3# SGR, SGR] call pairs + for (let i = 0; i < callstack.length; ++i) { + const entry = callstack[i]; + if (entry[0] === '3# SGR') { + assert.equal(callstack[i + 1][0], 'SGR', 'Should fallback to original handler'); + } + } + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 1], + [6, ParserStackType.CSI, 0], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 0], + [27, ParserStackType.CSI, 1], + [27, ParserStackType.CSI, 0] + ]); + clearAccu(); + // dispose SGR3 (async one) + SGR3.dispose(); + await parseP(parser, INPUT); + assert.deepEqual(callstack, RESULT, 'Should not call custom handler'); + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 0], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 0], + [27, ParserStackType.CSI, 0] + ]); + }); + }); +}); diff --git a/src/common/parser/EscapeSequenceParser.ts b/src/common/parser/EscapeSequenceParser.ts index e56655ae..1ac1a22b 100644 --- a/src/common/parser/EscapeSequenceParser.ts +++ b/src/common/parser/EscapeSequenceParser.ts @@ -440,14 +440,14 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP /** * Async parse support. */ - private _parseStack: IParserStackState = { + protected _parseStack: IParserStackState = { state: ParserStackType.NONE, handlers: [], handlerPos: 0, transition: 0, chunkPos: 0 }; - private _preserveStack( + protected _preserveStack( state: ParserStackType, handlers: ResumableHandlersType, handlerPos: number, @@ -474,6 +474,39 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP * - DCS_PARAM:PARAM * - OSC_STRING:OSC_PUT * - DCS_PASSTHROUGH:DCS_PUT + * + * Note on asynchronous handler support: + * Any handler returning a promise will be treated as asynchronous. + * To keep the in-band blocking working for async handlers, `parse` pauses execution, + * creates a stack save and returns the promise to the caller. + * For proper continuation of the paused state it is important + * to await the promise resolving. On resolve the parse must be repeated + * with the same chunk of data and the resolved value in `promiseResult` + * until no promise is returned. + * + * Important: With only sync handlers defined, parsing is completely synchronous as well. + * As soon as an async handler is involved, synchronous parsing is not possible anymore. + * + * FIXME: to be discussed + * While awaiting parse promises the terminal buffer state may not change. + * --> Implement lock semantics / promise chaining on buffer alterations? Waah, pandora's box ;) + * --> Maybe easier: Give up on non-mutating rule for async handlers... + * (needs explanation in docs about exact executor/thenable/worker execution contexts) + * + * Example for proper parsing of multiple chunks: + * + * ```typescript + * async function parseMultipleChunks(chunks: Uint32Array[]): Promise { + * for (const chunk of chunks) { + * let result: void | Promise; + * let prev: boolean | undefined; + * while (result = parser.parse(chunk, chunk.length, prev)) { + * prev = await result; + * } + * } + * // finished parsing all chunks... + * } + * ``` */ public parse(data: Uint32Array, length: number, promiseResult?: boolean): void | Promise { let code = 0; @@ -483,6 +516,17 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP // resume from async handler if (this._parseStack.state) { + if (promiseResult === undefined || this._parseStack.state === ParserStackType.FAIL) { + /** + * Reject further parsing on improper continuation after pausing. + * This will happen with sync parse calls not awaiting a returned promise. + * It is a really bad condition with screwed up execution order, + * therefore we exit hard with an exception. + * FIXME: Do we need a method to escape from this broken parser state? (hard to achieve properly) + */ + this._parseStack.state = ParserStackType.FAIL; + throw new Error('improper continuation due to previous async handler, giving up parsing'); + } let handlerPos = this._parseStack.handlerPos - 1; // we have to resume the old handler loop if: diff --git a/src/common/parser/Types.d.ts b/src/common/parser/Types.d.ts index 002fc8ed..f6db77fa 100644 --- a/src/common/parser/Types.d.ts +++ b/src/common/parser/Types.d.ts @@ -244,6 +244,7 @@ export interface IHandlerCollection { */ export const enum ParserStackType { NONE = 0, + FAIL, CSI, ESC, OSC, From 54bb0ee18999df013d12aff9ccbb52aa943395ba Mon Sep 17 00:00:00 2001 From: Mmis1000 Date: Mon, 25 Jan 2021 10:52:48 +0800 Subject: [PATCH 081/377] SerializeAddon: comment the intent of several check --- .../src/SerializeAddon.ts | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index 25fa9ad2..0caaaa03 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -149,22 +149,32 @@ class StringSerializeHandler extends BaseSerializeHandler { const isNextRowFirstCharDoubleWidth = nextRowFirstChar.getWidth() > 1; // validate whether this line wrap is ever possible + // which mean whether cursor can placed at a overflow position (x === row) naturally let isValid = false; if ( + // you must output character to cause overflow, control sequence can't do this nextRowFirstChar.getChars() && isNextRowFirstCharDoubleWidth ? this._nullCellCount <= 1 : this._nullCellCount <= 0 ) { if ( + // the last character can't be null, + // you can't use control sequence to move cursor to (x === row) (thisRowLastChar.getChars() || thisRowLastChar.getWidth() === 0) && + // change background of the first wrapped cell also affects BCE + // so we mark it as invalid to simply the process to determine line separator equalBg(thisRowLastChar, nextRowFirstChar) ) { isValid = true; } if ( + // the second to last character can't be null if the next line starts with CJK, + // you can't use control sequence to move cursor to (x === row) isNextRowFirstCharDoubleWidth && (thisRowLastSecondChar.getChars() || thisRowLastSecondChar.getWidth() === 0) && + // change background of the first wrapped cell also affects BCE + // so we mark it as invalid to simply the process to determine line separator equalBg(thisRowLastChar, nextRowFirstChar) && equalBg(thisRowLastSecondChar, nextRowFirstChar) ) { @@ -179,20 +189,20 @@ class StringSerializeHandler extends BaseSerializeHandler { // move back and erase next line head rowSeparator += '\x1b[1D\x1b[1X'; - // do these because we filled the last several null slot, which we shouldn't if (this._nullCellCount > 0) { + // do these because we filled the last several null slot, which we shouldn't rowSeparator += '\x1b[A'; rowSeparator += `\x1b[${currentLine.length - this._nullCellCount}C`; rowSeparator += `\x1b[${this._nullCellCount}X`; rowSeparator += `\x1b[${currentLine.length - this._nullCellCount}D`; rowSeparator += '\x1b[B'; - - // This is content even it is invisible - // without this, wrap will be missing - this._lastContentCursorRow = row + 1; - this._lastContentCursorCol = 0; } + // This is content and need the be serialized even it is invisible. + // without this, wrap will be missing from outputs. + this._lastContentCursorRow = row + 1; + this._lastContentCursorCol = 0; + // force commit the cursor position this._lastCursorRow = row + 1; this._lastCursorCol = 0; From 0b09f0bafd574171846b995648d3beac966c19e1 Mon Sep 17 00:00:00 2001 From: jeanp413 Date: Sun, 24 Jan 2021 23:17:36 -0500 Subject: [PATCH 082/377] Fixes #3221 --- addons/xterm-addon-webgl/src/WebglRenderer.ts | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index 9f982165..52d1eda4 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -116,12 +116,9 @@ export class WebglRenderer extends Disposable implements IRenderer { this._refreshCharAtlas(); - this._rectangleRenderer.updateSelection(this._model.selection); - this._glyphRenderer.updateSelection(this._model); - // Force a full refresh this._model.clear(); - this._model.clearSelection(); + this._updateSelectionModel(undefined, undefined); } public onDevicePixelRatioChange(): void { @@ -159,7 +156,7 @@ export class WebglRenderer extends Disposable implements IRenderer { // Force a full refresh this._model.clear(); - this._model.clearSelection(); + this._updateSelectionModel(undefined, undefined); } public onCharSizeChanged(): void { @@ -179,9 +176,6 @@ export class WebglRenderer extends Disposable implements IRenderer { this._updateSelectionModel(start, end, columnSelectMode); - this._rectangleRenderer.updateSelection(this._model.selection); - this._glyphRenderer.updateSelection(this._model); - this._onRequestRedraw.fire({ start: 0, end: this._terminal.rows - 1 }); } @@ -220,7 +214,6 @@ export class WebglRenderer extends Disposable implements IRenderer { this._charAtlas?.clearTexture(); this._model.clear(); this._updateModel(0, this._terminal.rows - 1); - this._glyphRenderer.updateSelection(this._model); this._onRequestRedraw.fire({ start: 0, end: this._terminal.rows - 1 }); } @@ -253,7 +246,7 @@ export class WebglRenderer extends Disposable implements IRenderer { // Tell renderer the frame is beginning if (this._glyphRenderer.beginFrame()) { this._model.clear(); - this._model.clearSelection(); + this._updateSelectionModel(undefined, undefined); } // Update model to reflect what's drawn @@ -303,14 +296,19 @@ export class WebglRenderer extends Disposable implements IRenderer { } } this._rectangleRenderer.updateBackgrounds(this._model); + if (this._model.selection.hasSelection) { + // Model could be updated but the selection is unchanged + this._glyphRenderer.updateSelection(this._model); + } } - private _updateSelectionModel(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void { + private _updateSelectionModel(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean = false): void { const terminal = this._terminal; // Selection does not exist if (!start || !end || (start[0] === end[0] && start[1] === end[1])) { this._model.clearSelection(); + this._rectangleRenderer.updateSelection(this._model.selection); return; } @@ -323,6 +321,7 @@ export class WebglRenderer extends Disposable implements IRenderer { // No need to draw the selection if (viewportCappedStartRow >= terminal.rows || viewportCappedEndRow < 0) { this._model.clearSelection(); + this._rectangleRenderer.updateSelection(this._model.selection); return; } @@ -334,6 +333,8 @@ export class WebglRenderer extends Disposable implements IRenderer { this._model.selection.viewportCappedEndRow = viewportCappedEndRow; this._model.selection.startCol = start[0]; this._model.selection.endCol = end[0]; + + this._rectangleRenderer.updateSelection(this._model.selection); } /** From c994c67dd9c667763de15b9e8efa8655c29a34bc Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 29 Jan 2021 09:14:31 -0800 Subject: [PATCH 083/377] v4.10.0 --- addons/xterm-addon-fit/package.json | 2 +- addons/xterm-addon-ligatures/package.json | 2 +- addons/xterm-addon-search/package.json | 2 +- package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/xterm-addon-fit/package.json b/addons/xterm-addon-fit/package.json index 859d6ebf..f9d96c4a 100644 --- a/addons/xterm-addon-fit/package.json +++ b/addons/xterm-addon-fit/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-fit", - "version": "0.4.0", + "version": "0.5.0", "author": { "name": "The xterm.js authors", "url": "https://xtermjs.org/" diff --git a/addons/xterm-addon-ligatures/package.json b/addons/xterm-addon-ligatures/package.json index a35cfc5c..4e2b4056 100644 --- a/addons/xterm-addon-ligatures/package.json +++ b/addons/xterm-addon-ligatures/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-ligatures", - "version": "0.3.0", + "version": "0.4.0", "description": "Add support for programming ligatures to xterm.js", "author": { "name": "The xterm.js authors", diff --git a/addons/xterm-addon-search/package.json b/addons/xterm-addon-search/package.json index 711335cb..659bd834 100644 --- a/addons/xterm-addon-search/package.json +++ b/addons/xterm-addon-search/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-search", - "version": "0.7.0", + "version": "0.8.0", "author": { "name": "The xterm.js authors", "url": "https://xtermjs.org/" diff --git a/package.json b/package.json index 59902931..445d4833 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "xterm", "description": "Full xterm terminal, in your browser", - "version": "4.9.0", + "version": "4.10.0", "main": "lib/xterm.js", "style": "css/xterm.css", "types": "typings/xterm.d.ts", From a0903fbf9b45e35616fce436d15ac27d2f0f6439 Mon Sep 17 00:00:00 2001 From: hantatsang Date: Sun, 31 Jan 2021 11:43:59 +1100 Subject: [PATCH 084/377] terminal.open: support webcomponent in dom node check --- src/browser/Terminal.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 06ac57f3..b0964c21 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -386,7 +386,7 @@ export class Terminal extends CoreTerminal implements ITerminal { throw new Error('Terminal requires a parent element.'); } - if (!document.body.contains(parent)) { + if (!parent.isConnected) { this._logService.debug('Terminal.open was called on an element that was not attached to the DOM'); } From 0a4b403f6a11d5bda043376c3d75911e5bf1a326 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 1 Feb 2021 09:28:26 -0800 Subject: [PATCH 085/377] Fix Demo Server debug launch config --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 59902931..819b3be3 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "prepackage": "npm run build", "package": "webpack", "start": "node demo/start", + "start-debug": "node --inspect-brk demo/start", "lint": "eslint -c .eslintrc.json --max-warnings 0 --ext .ts src/ addons/", "test": "npm run test-unit", "posttest": "npm run lint", From 46c93f1b63d61a841492648d40745bcd4c3f5c18 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 1 Feb 2021 09:34:38 -0800 Subject: [PATCH 086/377] Move util function into page.evaluate --- .../test/SerializeAddon.api.ts | 25 ++++++++++++----- .../test/SerializeAddonTestUtil.ts | 27 ------------------- demo/client.ts | 3 --- 3 files changed, 19 insertions(+), 36 deletions(-) delete mode 100644 addons/xterm-addon-serialize/test/SerializeAddonTestUtil.ts diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index 339ac162..47af9d91 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -18,12 +18,12 @@ const writeRawSync = (page: any, str: string): Promise => writeSync(page, const testNormalScreenEqual = async (page: any, str: string): Promise => { await writeRawSync(page, str); - const originalBuffer = await page.evaluate(`SerializeAddonTestUtil.inspectBuffer(term.buffer.normal);`); + const originalBuffer = await page.evaluate(`inspectBuffer(term.buffer.normal);`); const result = await page.evaluate(`serializeAddon.serialize();`) as string; await page.evaluate(`term.reset();`); await writeRawSync(page, result); - const newBuffer = await page.evaluate(`SerializeAddonTestUtil.inspectBuffer(term.buffer.normal);`); + const newBuffer = await page.evaluate(`inspectBuffer(term.buffer.normal);`); // chai decides -0 and 0 are different number... // and firefox have a bug that output -0 for unknown reason @@ -43,6 +43,19 @@ describe('SerializeAddon', () => { await page.evaluate(` window.serializeAddon = new SerializeAddon(); window.term.loadAddon(window.serializeAddon); + window.inspectBuffer = (buffer) => { + const lines = []; + for (let i = 0; i < buffer.length; i++) { + // Do this intentionally to get content of underlining source + const bufferLine = buffer.getLine(i)._line; + lines.push(JSON.stringify(bufferLine)); + } + return { + x: buffer.cursorX, + y: buffer.cursorY, + data: lines + }; + } `); }); @@ -51,11 +64,11 @@ describe('SerializeAddon', () => { it('produce different output when we call test util with different text', async function(): Promise { await writeRawSync(page, '12345'); - const buffer1 = await page.evaluate(`SerializeAddonTestUtil.inspectBuffer(term.buffer.normal);`); + const buffer1 = await page.evaluate(`inspectBuffer(term.buffer.normal);`); await page.evaluate(`term.reset();`); await writeRawSync(page, '67890'); - const buffer2 = await page.evaluate(`SerializeAddonTestUtil.inspectBuffer(term.buffer.normal);`); + const buffer2 = await page.evaluate(`inspectBuffer(term.buffer.normal);`); assert.throw(() => { assert.equal(JSON.stringify(buffer1), JSON.stringify(buffer2)); @@ -64,11 +77,11 @@ describe('SerializeAddon', () => { it('produce different output when we call test util with different line wrap', async function(): Promise { await writeRawSync(page, '1234567890\r\n12345'); - const buffer3 = await page.evaluate(`SerializeAddonTestUtil.inspectBuffer(term.buffer.normal);`); + const buffer3 = await page.evaluate(`inspectBuffer(term.buffer.normal);`); await page.evaluate(`term.reset();`); await writeRawSync(page, '1234567890n12345'); - const buffer4 = await page.evaluate(`SerializeAddonTestUtil.inspectBuffer(term.buffer.normal);`); + const buffer4 = await page.evaluate(`inspectBuffer(term.buffer.normal);`); assert.throw(() => { assert.equal(JSON.stringify(buffer3), JSON.stringify(buffer4)); diff --git a/addons/xterm-addon-serialize/test/SerializeAddonTestUtil.ts b/addons/xterm-addon-serialize/test/SerializeAddonTestUtil.ts deleted file mode 100644 index 23ac2237..00000000 --- a/addons/xterm-addon-serialize/test/SerializeAddonTestUtil.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2021 The xterm.js authors. All rights reserved. - * @license MIT - */ - -import { IBuffer } from 'xterm'; -export class SerializeAddonTestUtil { - // this is a util used only for test - public static inspectBuffer(buffer: IBuffer): { x: number, y: number, data: any[][] } { - const lines: any[] = []; - - for (let i = 0; i < buffer.length; i++) { - /** - * Do this intentionally to get content of underlining source - */ - const bufferLine = (buffer.getLine(i)! as any)._line; - - lines.push(JSON.stringify(bufferLine)); - } - - return { - x: buffer.cursorX, - y: buffer.cursorY, - data: lines - }; - } -} diff --git a/demo/client.ts b/demo/client.ts index 27d1c297..93b7c26c 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -13,7 +13,6 @@ import { AttachAddon } from '../addons/xterm-addon-attach/out/AttachAddon'; import { FitAddon } from '../addons/xterm-addon-fit/out/FitAddon'; import { SearchAddon, ISearchOptions } from '../addons/xterm-addon-search/out/SearchAddon'; import { SerializeAddon } from '../addons/xterm-addon-serialize/out/SerializeAddon'; -import { SerializeAddonTestUtil } from '../addons/xterm-addon-serialize/out-test/SerializeAddonTestUtil'; import { WebLinksAddon } from '../addons/xterm-addon-web-links/out/WebLinksAddon'; import { WebglAddon } from '../addons/xterm-addon-webgl/out/WebglAddon'; import { Unicode11Addon } from '../addons/xterm-addon-unicode11/out/Unicode11Addon'; @@ -39,7 +38,6 @@ export interface IWindowWithTerminal extends Window { FitAddon?: typeof FitAddon; SearchAddon?: typeof SearchAddon; SerializeAddon?: typeof SerializeAddon; - SerializeAddonTestUtil?: typeof SerializeAddonTestUtil; WebLinksAddon?: typeof WebLinksAddon; WebglAddon?: typeof WebglAddon; Unicode11Addon?: typeof Unicode11Addon; @@ -134,7 +132,6 @@ if (document.location.pathname === '/test') { window.FitAddon = FitAddon; window.SearchAddon = SearchAddon; window.SerializeAddon = SerializeAddon; - window.SerializeAddonTestUtil = SerializeAddonTestUtil; window.Unicode11Addon = Unicode11Addon; window.WebLinksAddon = WebLinksAddon; window.WebglAddon = WebglAddon; From 8b273e6939a2856fc978cdfbeb8e60c9fbc86ba0 Mon Sep 17 00:00:00 2001 From: Mmis1000 Date: Wed, 3 Feb 2021 11:01:55 +0800 Subject: [PATCH 087/377] SerializeAddon: fix parameter name in typing --- .../typings/xterm-addon-serialize.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts b/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts index 9e7b500a..58be9a97 100644 --- a/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts +++ b/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts @@ -25,10 +25,10 @@ declare module 'xterm-addon-serialize' { * to restore the state. The cursor will also be positioned to the correct cell. * When restoring a terminal it is best to do before `Terminal.open` is called * to avoid wasting CPU cycles rendering incomplete frames. - * @param rows The number of rows to serialize, starting from the bottom of the - * terminal. This defaults to the number of rows in the viewport. + * @param scrollback The number of rows in scrollback buffer to serialize, starting from the bottom of the + * scrollback buffer. This defaults to the all available rows in the scrollback buffer. */ - public serialize(rows?: number): string; + public serialize(scrollback?: number): string; /** * Disposes the addon. From 94d37bbe4c134ab32292063f54b59625bcc73b3e Mon Sep 17 00:00:00 2001 From: jeanp413 Date: Wed, 3 Feb 2021 00:23:52 -0500 Subject: [PATCH 088/377] Keep selection on resize and when changing colors --- addons/xterm-addon-webgl/src/WebglRenderer.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index 52d1eda4..ca772129 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -118,7 +118,6 @@ export class WebglRenderer extends Disposable implements IRenderer { // Force a full refresh this._model.clear(); - this._updateSelectionModel(undefined, undefined); } public onDevicePixelRatioChange(): void { @@ -156,7 +155,6 @@ export class WebglRenderer extends Disposable implements IRenderer { // Force a full refresh this._model.clear(); - this._updateSelectionModel(undefined, undefined); } public onCharSizeChanged(): void { From ff6d3a076822c2da38c827bd3fdc10275d239690 Mon Sep 17 00:00:00 2001 From: jeanp413 Date: Wed, 3 Feb 2021 01:29:39 -0500 Subject: [PATCH 089/377] Refresh selection on resize as dimensions changed --- addons/xterm-addon-webgl/src/WebglRenderer.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index ca772129..3bf74242 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -134,7 +134,6 @@ export class WebglRenderer extends Disposable implements IRenderer { this._updateDimensions(); this._model.resize(this._terminal.cols, this._terminal.rows); - this._rectangleRenderer.onResize(); // Resize all render layers this._renderLayers.forEach(l => l.resize(this._terminal, this.dimensions)); @@ -148,6 +147,13 @@ export class WebglRenderer extends Disposable implements IRenderer { // Resize the screen this._core.screenElement!.style.width = `${this.dimensions.canvasWidth}px`; this._core.screenElement!.style.height = `${this.dimensions.canvasHeight}px`; + + this._rectangleRenderer.onResize(); + if (this._model.selection.hasSelection) { + // Update selection as dimensions have changed + this._rectangleRenderer.updateSelection(this._model.selection); + } + this._glyphRenderer.setDimensions(this.dimensions); this._glyphRenderer.onResize(); From eec804dd7c7705d3e11598f535f0cf3cf352b6e6 Mon Sep 17 00:00:00 2001 From: ew Date: Fri, 28 Aug 2020 13:07:00 +0000 Subject: [PATCH 090/377] Add hover and leave callbacks for linkprovider Fixes #3056. --- .../src/WebLinkProvider.ts | 21 ++++++++++++++++--- .../src/WebLinksAddon.ts | 8 +++++-- typings/xterm.d.ts | 17 +++++++++++++++ 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/addons/xterm-addon-web-links/src/WebLinkProvider.ts b/addons/xterm-addon-web-links/src/WebLinkProvider.ts index af6ad7d3..f1c2b441 100644 --- a/addons/xterm-addon-web-links/src/WebLinkProvider.ts +++ b/addons/xterm-addon-web-links/src/WebLinkProvider.ts @@ -3,20 +3,35 @@ * @license MIT */ -import { ILinkProvider, IBufferCellPosition, ILink, Terminal } from 'xterm'; +import { ILinkProvider, ILink, Terminal, IViewportRange, ILinkProviderOptions } from 'xterm'; export class WebLinkProvider implements ILinkProvider { constructor( private readonly _terminal: Terminal, private readonly _regex: RegExp, - private readonly _handler: (event: MouseEvent, uri: string) => void + private readonly _handler: (event: MouseEvent, uri: string) => void, + private readonly _options: ILinkProviderOptions = {} ) { } public provideLinks(y: number, callback: (links: ILink[] | undefined) => void): void { - callback(LinkComputer.computeLink(y, this._regex, this._terminal, this._handler)); + const links = LinkComputer.computeLink(y, this._regex, this._terminal, this._handler); + callback(this._addCallbacks(links)); + } + + private _addCallbacks(links: ILink[]): ILink[] { + return links.map(link => { + link.leave = this._options.leave; + link.hover = (event: MouseEvent, uri: string): void => { + if (this._options.hover) { + const { range } = link; + this._options.hover(event, uri, range); + } + }; + return link; + }); } } diff --git a/addons/xterm-addon-web-links/src/WebLinksAddon.ts b/addons/xterm-addon-web-links/src/WebLinksAddon.ts index dce405a5..574a5c53 100644 --- a/addons/xterm-addon-web-links/src/WebLinksAddon.ts +++ b/addons/xterm-addon-web-links/src/WebLinksAddon.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { Terminal, ILinkMatcherOptions, ITerminalAddon, IDisposable } from 'xterm'; +import { Terminal, ILinkMatcherOptions, ITerminalAddon, IDisposable, ILinkProviderOptions } from 'xterm'; import { WebLinkProvider } from './WebLinkProvider'; const protocolClause = '(https?:\\/\\/)'; @@ -53,7 +53,11 @@ export class WebLinksAddon implements ITerminalAddon { this._terminal = terminal; if (this._useLinkProvider && 'registerLinkProvider' in this._terminal) { - this._linkProvider = this._terminal.registerLinkProvider(new WebLinkProvider(this._terminal, strictUrlRegex, this._handler)); + const options = { + hover: this._options.tooltipCallback, + leave: this._options.leaveCallback + }; + this._linkProvider = this._terminal.registerLinkProvider(new WebLinkProvider(this._terminal, strictUrlRegex, this._handler, options)); } else { // TODO: This should be removed eventually this._linkMatcherId = (this._terminal as Terminal).registerLinkMatcher(strictUrlRegex, this._handler, this._options); diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index d860ddfa..fcf3ff13 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -352,6 +352,23 @@ declare module 'xterm' { willLinkActivate?: (event: MouseEvent, uri: string) => boolean; } + /** + * An object containing options for a link provider. + */ + export interface ILinkProviderOptions { + /** + * A callback that fires when the mouse hovers over a link for a period of + * time (defined by {@link ITerminalOptions.linkTooltipHoverDuration}). + */ + hover?(event: MouseEvent, text: string, location: IViewportRange): void; + + /** + * A callback that fires when the mouse leaves a link. Note that this can + * happen even when tooltipCallback hasn't fired for the link yet. + */ + leave?(event: MouseEvent, text: string): void; + } + /** * An object that can be disposed via a dispose function. */ From bd6676d3b6d5404e9cf46c3882f543de2fae963f Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 3 Feb 2021 05:28:23 -0800 Subject: [PATCH 091/377] Move options to addon and avoid recreating options --- .../src/WebLinkProvider.ts | 7 ++++++- .../src/WebLinksAddon.ts | 19 ++++++++++------- .../typings/xterm-addon-web-links.d.ts | 21 +++++++++++++++++-- typings/xterm.d.ts | 17 --------------- 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/addons/xterm-addon-web-links/src/WebLinkProvider.ts b/addons/xterm-addon-web-links/src/WebLinkProvider.ts index f1c2b441..487d5fe6 100644 --- a/addons/xterm-addon-web-links/src/WebLinkProvider.ts +++ b/addons/xterm-addon-web-links/src/WebLinkProvider.ts @@ -3,7 +3,12 @@ * @license MIT */ -import { ILinkProvider, ILink, Terminal, IViewportRange, ILinkProviderOptions } from 'xterm'; +import { ILinkProvider, ILink, Terminal, IViewportRange } from 'xterm'; + +interface ILinkProviderOptions { + hover?(event: MouseEvent, text: string, location: IViewportRange): void; + leave?(event: MouseEvent, text: string): void; +} export class WebLinkProvider implements ILinkProvider { diff --git a/addons/xterm-addon-web-links/src/WebLinksAddon.ts b/addons/xterm-addon-web-links/src/WebLinksAddon.ts index 574a5c53..46ddcf7b 100644 --- a/addons/xterm-addon-web-links/src/WebLinksAddon.ts +++ b/addons/xterm-addon-web-links/src/WebLinksAddon.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { Terminal, ILinkMatcherOptions, ITerminalAddon, IDisposable, ILinkProviderOptions } from 'xterm'; +import { Terminal, ILinkMatcherOptions, ITerminalAddon, IDisposable, IViewportRange } from 'xterm'; import { WebLinkProvider } from './WebLinkProvider'; const protocolClause = '(https?:\\/\\/)'; @@ -36,6 +36,11 @@ function handleLink(event: MouseEvent, uri: string): void { } } +interface ILinkProviderOptions { + hover?(event: MouseEvent, text: string, location: IViewportRange): void; + leave?(event: MouseEvent, text: string): void; +} + export class WebLinksAddon implements ITerminalAddon { private _linkMatcherId: number | undefined; private _terminal: Terminal | undefined; @@ -43,24 +48,22 @@ export class WebLinksAddon implements ITerminalAddon { constructor( private _handler: (event: MouseEvent, uri: string) => void = handleLink, - private _options: ILinkMatcherOptions = {}, + private _options: ILinkMatcherOptions | ILinkProviderOptions = {}, private _useLinkProvider: boolean = false ) { - this._options.matchIndex = 1; } public activate(terminal: Terminal): void { this._terminal = terminal; if (this._useLinkProvider && 'registerLinkProvider' in this._terminal) { - const options = { - hover: this._options.tooltipCallback, - leave: this._options.leaveCallback - }; + const options = this._options as ILinkProviderOptions; this._linkProvider = this._terminal.registerLinkProvider(new WebLinkProvider(this._terminal, strictUrlRegex, this._handler, options)); } else { // TODO: This should be removed eventually - this._linkMatcherId = (this._terminal as Terminal).registerLinkMatcher(strictUrlRegex, this._handler, this._options); + const options = this._options as ILinkMatcherOptions; + options.matchIndex = 1; + this._linkMatcherId = (this._terminal as Terminal).registerLinkMatcher(strictUrlRegex, this._handler, options); } } diff --git a/addons/xterm-addon-web-links/typings/xterm-addon-web-links.d.ts b/addons/xterm-addon-web-links/typings/xterm-addon-web-links.d.ts index f0564704..78a258e5 100644 --- a/addons/xterm-addon-web-links/typings/xterm-addon-web-links.d.ts +++ b/addons/xterm-addon-web-links/typings/xterm-addon-web-links.d.ts @@ -4,7 +4,7 @@ */ -import { Terminal, ILinkMatcherOptions, ITerminalAddon } from 'xterm'; +import { Terminal, ILinkMatcherOptions, ITerminalAddon, IViewportRange } from 'xterm'; declare module 'xterm-addon-web-links' { /** @@ -20,7 +20,7 @@ declare module 'xterm-addon-web-links' { * link provider (new) may cause issues. Link provider will eventually be * the default and only option. */ - constructor(handler?: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions, useLinkProvider?: boolean); + constructor(handler?: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions | ILinkProviderOptions, useLinkProvider?: boolean); /** * Activates the addon @@ -33,4 +33,21 @@ declare module 'xterm-addon-web-links' { */ public dispose(): void; } + + /** + * An object containing options for a link provider. + */ + export interface ILinkProviderOptions { + /** + * A callback that fires when the mouse hovers over a link for a period of + * time (defined by {@link ITerminalOptions.linkTooltipHoverDuration}). + */ + hover?(event: MouseEvent, text: string, location: IViewportRange): void; + + /** + * A callback that fires when the mouse leaves a link. Note that this can + * happen even when tooltipCallback hasn't fired for the link yet. + */ + leave?(event: MouseEvent, text: string): void; + } } diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index fcf3ff13..d860ddfa 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -352,23 +352,6 @@ declare module 'xterm' { willLinkActivate?: (event: MouseEvent, uri: string) => boolean; } - /** - * An object containing options for a link provider. - */ - export interface ILinkProviderOptions { - /** - * A callback that fires when the mouse hovers over a link for a period of - * time (defined by {@link ITerminalOptions.linkTooltipHoverDuration}). - */ - hover?(event: MouseEvent, text: string, location: IViewportRange): void; - - /** - * A callback that fires when the mouse leaves a link. Note that this can - * happen even when tooltipCallback hasn't fired for the link yet. - */ - leave?(event: MouseEvent, text: string): void; - } - /** * An object that can be disposed via a dispose function. */ From 350f6cfea107fa22539511cb5dce098818a5afd5 Mon Sep 17 00:00:00 2001 From: jeanp413 Date: Fri, 5 Feb 2021 11:15:39 -0500 Subject: [PATCH 092/377] Fixes https://github.com/microsoft/vscode/issues/102194 --- src/browser/services/RenderService.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/browser/services/RenderService.ts b/src/browser/services/RenderService.ts index 174a1272..51971091 100644 --- a/src/browser/services/RenderService.ts +++ b/src/browser/services/RenderService.ts @@ -174,6 +174,10 @@ export class RenderService extends Disposable implements IRenderService { } public onDevicePixelRatioChange(): void { + // Force char size measurement as DomMeasureStrategy(getBoundingClientRect) is not stable + // when devicePixelRatio changes + this._charSizeService.measure(); + this._renderer.onDevicePixelRatioChange(); this.refreshRows(0, this._rowCount - 1); } From d59f4d2f6f6da9fe862e52e0152b8d87583d4b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Mon, 8 Feb 2021 01:53:59 +0100 Subject: [PATCH 093/377] async impl for DCS, DcsParser tests --- src/common/parser/DcsParser.test.ts | 205 ++++++++++++++++++++++ src/common/parser/DcsParser.ts | 63 +++++-- src/common/parser/EscapeSequenceParser.ts | 45 +++-- src/common/parser/Types.d.ts | 6 +- 4 files changed, 289 insertions(+), 30 deletions(-) diff --git a/src/common/parser/DcsParser.test.ts b/src/common/parser/DcsParser.test.ts index cf174139..096ebb58 100644 --- a/src/common/parser/DcsParser.test.ts +++ b/src/common/parser/DcsParser.test.ts @@ -252,3 +252,208 @@ describe('DcsParser', () => { }); }); }); + + +class TestHandlerAsync implements IDcsHandler { + constructor(public output: any[], public msg: string, public returnFalse: boolean = false) {} + public hook(params: IParams): void { + this.output.push([this.msg, 'HOOK', params.toArray()]); + } + public put(data: Uint32Array, start: number, end: number): void { + this.output.push([this.msg, 'PUT', utf32ToString(data, start, end)]); + } + public async unhook(success: boolean): Promise { + // simple sleep to check in tests whether ordering gets messed up + await new Promise(res => setTimeout(res, 20)); + this.output.push([this.msg, 'UNHOOK', success]); + if (this.returnFalse) { + return false; + } + return true; + } +} +async function unhookP(parser: DcsParser, success: boolean): Promise { + let result: void | Promise; + let prev: boolean | undefined; + while (result = parser.unhook(success, prev)) { + prev = await result; + } +} + + +describe('DcsParser - async tests', () => { + let parser: DcsParser; + let reports: any[] = []; + beforeEach(() => { + reports = []; + parser = new DcsParser(); + parser.setHandlerFallback((id, action, data) => { + if (action === 'HOOK') { + data = data.toArray(); + } + reports.push([id, action, data]); + }); + }); + describe('sync and async mixed', () => { + describe('sync | async | sync', () => { + it('first should run, cleanup action for others', async () => { + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 's1', false)); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandlerAsync(reports, 'a1', false)); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 's2', false)); + parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); + let data = toUtf32('Here comes'); + parser.put(data, 0, data.length); + data = toUtf32('the mouse!'); + parser.put(data, 0, data.length); + await unhookP(parser, true); + assert.deepEqual(reports, [ + // messages from TestHandler + ['s2', 'HOOK', [1, 2, 3]], + ['a1', 'HOOK', [1, 2, 3]], + ['s1', 'HOOK', [1, 2, 3]], + ['s2', 'PUT', 'Here comes'], + ['a1', 'PUT', 'Here comes'], + ['s1', 'PUT', 'Here comes'], + ['s2', 'PUT', 'the mouse!'], + ['a1', 'PUT', 'the mouse!'], + ['s1', 'PUT', 'the mouse!'], + ['s2', 'UNHOOK', true], + ['a1', 'UNHOOK', false], // important: a1 before s1 + ['s1', 'UNHOOK', false] + ]); + }); + it('all should run', async () => { + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 's1', true)); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandlerAsync(reports, 'a1', true)); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 's2', true)); + parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); + let data = toUtf32('Here comes'); + parser.put(data, 0, data.length); + data = toUtf32('the mouse!'); + parser.put(data, 0, data.length); + await unhookP(parser, true); + assert.deepEqual(reports, [ + // messages from TestHandler + ['s2', 'HOOK', [1, 2, 3]], + ['a1', 'HOOK', [1, 2, 3]], + ['s1', 'HOOK', [1, 2, 3]], + ['s2', 'PUT', 'Here comes'], + ['a1', 'PUT', 'Here comes'], + ['s1', 'PUT', 'Here comes'], + ['s2', 'PUT', 'the mouse!'], + ['a1', 'PUT', 'the mouse!'], + ['s1', 'PUT', 'the mouse!'], + ['s2', 'UNHOOK', true], + ['a1', 'UNHOOK', true], // important: a1 before s1 + ['s1', 'UNHOOK', true] + ]); + }); + }); + describe('async | sync | async', () => { + it('first should run, cleanup action for others', async () => { + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandlerAsync(reports, 'a1', false)); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 's1', false)); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandlerAsync(reports, 'a2', false)); + parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); + let data = toUtf32('Here comes'); + parser.put(data, 0, data.length); + data = toUtf32('the mouse!'); + parser.put(data, 0, data.length); + await unhookP(parser, true); + assert.deepEqual(reports, [ + // messages from TestHandler + ['a2', 'HOOK', [1, 2, 3]], + ['s1', 'HOOK', [1, 2, 3]], + ['a1', 'HOOK', [1, 2, 3]], + ['a2', 'PUT', 'Here comes'], + ['s1', 'PUT', 'Here comes'], + ['a1', 'PUT', 'Here comes'], + ['a2', 'PUT', 'the mouse!'], + ['s1', 'PUT', 'the mouse!'], + ['a1', 'PUT', 'the mouse!'], + ['a2', 'UNHOOK', true], + ['s1', 'UNHOOK', false], // important: s1 between a2 .. a1 + ['a1', 'UNHOOK', false] + ]); + }); + it('all should run', async () => { + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandlerAsync(reports, 'a1', true)); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandler(reports, 's1', true)); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new TestHandlerAsync(reports, 'a2', true)); + parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); + let data = toUtf32('Here comes'); + parser.put(data, 0, data.length); + data = toUtf32('the mouse!'); + parser.put(data, 0, data.length); + await unhookP(parser, true); + assert.deepEqual(reports, [ + // messages from TestHandler + ['a2', 'HOOK', [1, 2, 3]], + ['s1', 'HOOK', [1, 2, 3]], + ['a1', 'HOOK', [1, 2, 3]], + ['a2', 'PUT', 'Here comes'], + ['s1', 'PUT', 'Here comes'], + ['a1', 'PUT', 'Here comes'], + ['a2', 'PUT', 'the mouse!'], + ['s1', 'PUT', 'the mouse!'], + ['a1', 'PUT', 'the mouse!'], + ['a2', 'UNHOOK', true], + ['s1', 'UNHOOK', true], // important: s1 between a2 .. a1 + ['a1', 'UNHOOK', true] + ]); + }); + }); + describe('DcsHandlerFactory', () => { + it('should be called once on end(true)', async () => { + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler(async (data, params) => { reports.push([params.toArray(), data]); return true; })); + parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); + let data = toUtf32('Here comes'); + parser.put(data, 0, data.length); + data = toUtf32(' the mouse!'); + parser.put(data, 0, data.length); + await unhookP(parser, true); + assert.deepEqual(reports, [[[1, 2, 3], 'Here comes the mouse!']]); + }); + it('should not be called on end(false)', async () => { + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler(async (data, params) => { reports.push([params.toArray(), data]); return true; })); + parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); + let data = toUtf32('Here comes'); + parser.put(data, 0, data.length); + data = toUtf32(' the mouse!'); + parser.put(data, 0, data.length); + await unhookP(parser, false); + assert.deepEqual(reports, []); + }); + it('should be disposable', async () => { + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler(async (data, params) => { reports.push(['one', params.toArray(), data]); return true; })); + const dispo = parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler(async (data, params) => { reports.push(['two', params.toArray(), data]); return true; })); + parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); + let data = toUtf32('Here comes'); + parser.put(data, 0, data.length); + data = toUtf32(' the mouse!'); + parser.put(data, 0, data.length); + await unhookP(parser, true); + assert.deepEqual(reports, [['two', [1, 2, 3], 'Here comes the mouse!']]); + dispo.dispose(); + parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); + data = toUtf32('some other'); + parser.put(data, 0, data.length); + data = toUtf32(' data'); + parser.put(data, 0, data.length); + await unhookP(parser, true); + assert.deepEqual(reports, [['two', [1, 2, 3], 'Here comes the mouse!'], ['one', [1, 2, 3], 'some other data']]); + }); + it('should respect return false', async () => { + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler(async (data, params) => { reports.push(['one', params.toArray(), data]); return true; })); + parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler(async (data, params) => { reports.push(['two', params.toArray(), data]); return false; })); + parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); + let data = toUtf32('Here comes'); + parser.put(data, 0, data.length); + data = toUtf32(' the mouse!'); + parser.put(data, 0, data.length); + await unhookP(parser, true); + assert.deepEqual(reports, [['two', [1, 2, 3], 'Here comes the mouse!'], ['one', [1, 2, 3], 'Here comes the mouse!']]); + }); + }); + }); +}); diff --git a/src/common/parser/DcsParser.ts b/src/common/parser/DcsParser.ts index 2fa28992..9f326099 100644 --- a/src/common/parser/DcsParser.ts +++ b/src/common/parser/DcsParser.ts @@ -15,11 +15,11 @@ export class DcsParser implements IDcsParser { private _handlers: IHandlerCollection = Object.create(null); private _active: IDcsHandler[] = EMPTY_HANDLERS; private _ident: number = 0; - private _handlerFb: DcsFallbackHandlerType = () => {}; + private _handlerFb: DcsFallbackHandlerType = () => { }; public dispose(): void { this._handlers = Object.create(null); - this._handlerFb = () => {}; + this._handlerFb = () => { }; this._active = EMPTY_HANDLERS; } @@ -79,20 +79,46 @@ export class DcsParser implements IDcsParser { } } - public unhook(success: boolean): void { + private _stack = { + paused: false, + loopPosition: 0, + fallThrough: false + }; + public unhook(success: boolean, promiseResult?: boolean): void | Promise { if (!this._active.length) { this._handlerFb(this._ident, 'UNHOOK', success); } else { + let handlerResult: any = false; let j = this._active.length - 1; - for (; j >= 0; j--) { - if (this._active[j].unhook(success)) { - break; - } + let fallThrough = false; + if (this._stack.paused) { + j = this._stack.loopPosition - 1; + handlerResult = promiseResult; + fallThrough = this._stack.fallThrough; + this._stack.paused = false; } - j--; - // cleanup left over handlers + if (!fallThrough && handlerResult === false) { + for (; j >= 0; j--) { + if ((handlerResult = this._active[j].unhook(success)) !== false) { + if (handlerResult instanceof Promise) { + this._stack.paused = true; + this._stack.loopPosition = j; + this._stack.fallThrough = false; + return handlerResult; + } + break; + } + } + j--; + } + // cleanup left over handlers (fallThrough for async) for (; j >= 0; j--) { - this._active[j].unhook(false); + if ((handlerResult = this._active[j].unhook(false)) instanceof Promise) { + this._stack.paused = true; + this._stack.loopPosition = j; + this._stack.fallThrough = true; + return handlerResult; + } } } this._active = EMPTY_HANDLERS; @@ -113,7 +139,7 @@ export class DcsHandler implements IDcsHandler { private _params: IParams = EMPTY_PARAMS; private _hitLimit: boolean = false; - constructor(private _handler: (data: string, params: IParams) => boolean) {} + constructor(private _handler: (data: string, params: IParams) => boolean | Promise) { } public hook(params: IParams): void { // since we need to preserve params until `unhook`, we have to clone it @@ -136,12 +162,21 @@ export class DcsHandler implements IDcsHandler { } } - public unhook(success: boolean): boolean { - let ret = false; + public unhook(success: boolean): boolean | Promise { + let ret: boolean | Promise = false; if (this._hitLimit) { ret = false; } else if (success) { - ret = this._handler(this._data, this._params); + if ((ret = this._handler(this._data, this._params)) instanceof Promise) { + // FIXME: should this be behind a catch rule? + return ret.then(res => { + // cleanup handler state late + this._params = EMPTY_PARAMS; + this._data = ''; + this._hitLimit = false; + return res; + }); + } } this._params = EMPTY_PARAMS; this._data = ''; diff --git a/src/common/parser/EscapeSequenceParser.ts b/src/common/parser/EscapeSequenceParser.ts index 1ac1a22b..842a99b8 100644 --- a/src/common/parser/EscapeSequenceParser.ts +++ b/src/common/parser/EscapeSequenceParser.ts @@ -239,7 +239,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP // handler lookup containers protected _printHandler: PrintHandlerType; - protected _executeHandlers: {[flag: number]: ExecuteHandlerType}; + protected _executeHandlers: { [flag: number]: ExecuteHandlerType }; protected _csiHandlers: IHandlerCollection; protected _escHandlers: IHandlerCollection; protected _oscParser: IOscParser; @@ -280,7 +280,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP this._errorHandler = this._errorHandlerFb; // swallow 7bit ST (ESC+\) - this.registerEscHandler({final: '\\'}, () => true); + this.registerEscHandler({ final: '\\' }, () => true); } protected _identifier(id: IFunctionIdentifier, finalRange: number[] = [0x40, 0x7e]): number { @@ -452,8 +452,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP handlers: ResumableHandlersType, handlerPos: number, transition: number, - chunkPos: number): void - { + chunkPos: number): void { this._parseStack.state = state; this._parseStack.handlers = handlers; this._parseStack.handlerPos = handlerPos; @@ -534,10 +533,11 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP // - handlers are not exhausted yet // FIXME: removing handlers from within a handler of the same sequence // is not supported atm (also true for sync handlers)!! - if (promiseResult === false && handlerPos > -1) { - const handlers = this._parseStack.handlers; - switch (this._parseStack.state) { - case ParserStackType.CSI: + let handlers: ResumableHandlersType; + switch (this._parseStack.state) { + case ParserStackType.CSI: + if (promiseResult === false && handlerPos > -1) { + handlers = this._parseStack.handlers; for (; handlerPos >= 0; handlerPos--) { if ((handlerResult = (handlers as CsiHandlerType[])[handlerPos](this._params)) !== false) { if (handlerResult instanceof Promise) { @@ -547,8 +547,11 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP break; } } - break; - case ParserStackType.ESC: + } + break; + case ParserStackType.ESC: + if (promiseResult === false && handlerPos > -1) { + handlers = this._parseStack.handlers; for (; handlerPos >= 0; handlerPos--) { if ((handlerResult = (handlers as EscHandlerType[])[handlerPos]()) !== false) { if (handlerResult instanceof Promise) { @@ -558,8 +561,21 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP break; } } - break; - } + } + break; + case ParserStackType.DCS: + code = data[this._parseStack.chunkPos]; + if (handlerResult = this._dcsParser.unhook(code !== 0x18 && code !== 0x1a)) { + return handlerResult; + } + if (code === 0x1b) this._parseStack.transition |= ParserState.ESCAPE; + this._params.reset(); + this._params.addParam(0); // ZDM + this._collect = 0; + break; + case ParserStackType.OSC: + // TODO + break; } // cleanup before continuing with the main loop this._parseStack.state = ParserStackType.NONE; @@ -700,7 +716,10 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP } break; case ParserAction.DCS_UNHOOK: - this._dcsParser.unhook(code !== 0x18 && code !== 0x1a); + if (handlerResult = this._dcsParser.unhook(code !== 0x18 && code !== 0x1a)) { + this._parseStack.state = ParserStackType.DCS; + return handlerResult; + } if (code === 0x1b) transition |= ParserState.ESCAPE; this._params.reset(); this._params.addParam(0); // ZDM diff --git a/src/common/parser/Types.d.ts b/src/common/parser/Types.d.ts index f6db77fa..30217cc6 100644 --- a/src/common/parser/Types.d.ts +++ b/src/common/parser/Types.d.ts @@ -5,7 +5,7 @@ import { IDisposable } from 'common/Types'; import { ParserState } from 'common/parser/Constants'; -import { OscParser } from 'common/parser/OscParser'; + /** sequence params serialized to js arrays */ export type ParamsArray = (number | number[])[]; @@ -94,7 +94,7 @@ export interface IDcsHandler { * execution of the command should depend on `success`. * To save memory also cleanup data structures here. */ - unhook(success: boolean): boolean; + unhook(success: boolean): boolean | Promise; } export type DcsFallbackHandlerType = (ident: number, action: 'HOOK' | 'PUT' | 'UNHOOK', payload?: any) => void; @@ -219,7 +219,7 @@ export interface IOscParser extends ISubParser { hook(ident: number, params: IParams): void; - unhook(success: boolean): void; + unhook(success: boolean, promiseResult?: boolean): void | Promise; } /** From 041e259c11e065f8451052a300dd2e0c8b9fd59f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Mon, 8 Feb 2021 03:03:28 +0100 Subject: [PATCH 094/377] OSC impl, OscParser tests --- src/common/parser/EscapeSequenceParser.ts | 20 ++- src/common/parser/OscParser.test.ts | 201 ++++++++++++++++++++++ src/common/parser/OscParser.ts | 86 ++++++--- src/common/parser/Types.d.ts | 4 +- 4 files changed, 277 insertions(+), 34 deletions(-) diff --git a/src/common/parser/EscapeSequenceParser.ts b/src/common/parser/EscapeSequenceParser.ts index 842a99b8..d2da17c6 100644 --- a/src/common/parser/EscapeSequenceParser.ts +++ b/src/common/parser/EscapeSequenceParser.ts @@ -548,6 +548,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP } } } + this._parseStack.handlers = []; break; case ParserStackType.ESC: if (promiseResult === false && handlerPos > -1) { @@ -562,10 +563,11 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP } } } + this._parseStack.handlers = []; break; case ParserStackType.DCS: code = data[this._parseStack.chunkPos]; - if (handlerResult = this._dcsParser.unhook(code !== 0x18 && code !== 0x1a)) { + if (handlerResult = this._dcsParser.unhook(code !== 0x18 && code !== 0x1a, promiseResult)) { return handlerResult; } if (code === 0x1b) this._parseStack.transition |= ParserState.ESCAPE; @@ -574,7 +576,14 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP this._collect = 0; break; case ParserStackType.OSC: - // TODO + code = data[this._parseStack.chunkPos]; + if (handlerResult = this._oscParser.end(code !== 0x18 && code !== 0x1a, promiseResult)) { + return handlerResult; + } + if (code === 0x1b) transition |= ParserState.ESCAPE; + this._params.reset(); + this._params.addParam(0); // ZDM + this._collect = 0; break; } // cleanup before continuing with the main loop @@ -717,7 +726,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP break; case ParserAction.DCS_UNHOOK: if (handlerResult = this._dcsParser.unhook(code !== 0x18 && code !== 0x1a)) { - this._parseStack.state = ParserStackType.DCS; + this._preserveStack(ParserStackType.DCS, [], 0, transition, i); return handlerResult; } if (code === 0x1b) transition |= ParserState.ESCAPE; @@ -740,7 +749,10 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP } break; case ParserAction.OSC_END: - this._oscParser.end(code !== 0x18 && code !== 0x1a); + if (handlerResult = this._oscParser.end(code !== 0x18 && code !== 0x1a)) { + this._preserveStack(ParserStackType.OSC, [], 0, transition, i); + return handlerResult; + } if (code === 0x1b) transition |= ParserState.ESCAPE; this._params.reset(); this._params.addParam(0); // ZDM diff --git a/src/common/parser/OscParser.test.ts b/src/common/parser/OscParser.test.ts index e2c8641c..5c7f5777 100644 --- a/src/common/parser/OscParser.test.ts +++ b/src/common/parser/OscParser.test.ts @@ -250,3 +250,204 @@ describe('OscParser', () => { }); }); }); + + +class TestHandlerAsync implements IOscHandler { + constructor(public id: number, public output: any[], public msg: string, public returnFalse: boolean = false) {} + public start(): void { + this.output.push([this.msg, this.id, 'START']); + } + public put(data: Uint32Array, start: number, end: number): void { + this.output.push([this.msg, this.id, 'PUT', utf32ToString(data, start, end)]); + } + public async end(success: boolean): Promise { + await new Promise(res => setTimeout(res, 20)); + this.output.push([this.msg, this.id, 'END', success]); + if (this.returnFalse) { + return false; + } + return true; + } +} +async function endP(parser: OscParser, success: boolean): Promise { + let result: void | Promise; + let prev: boolean | undefined; + while (result = parser.end(success, prev)) { + prev = await result; + } +} + +describe('OscParser - async tests', () => { + let parser: OscParser; + let reports: any[] = []; + beforeEach(() => { + reports = []; + parser = new OscParser(); + parser.setHandlerFallback((id, action, data) => { + reports.push([id, action, data]); + }); + }); + describe('sync and async mixed', () => { + describe('sync | async | sync', () => { + it('first should run, cleanup action for others', async () => { + parser.registerHandler(1234, new TestHandler(1234, reports, 's1')); + parser.registerHandler(1234, new TestHandlerAsync(1234, reports, 'a1')); + parser.registerHandler(1234, new TestHandler(1234, reports, 's2')); + parser.start(); + let data = toUtf32('1234;Here comes'); + parser.put(data, 0, data.length); + data = toUtf32('the mouse!'); + parser.put(data, 0, data.length); + await endP(parser, true); + assert.deepEqual(reports, [ + // messages from TestHandler + ['s2', 1234, 'START'], + ['a1', 1234, 'START'], + ['s1', 1234, 'START'], + ['s2', 1234, 'PUT', 'Here comes'], + ['a1', 1234, 'PUT', 'Here comes'], + ['s1', 1234, 'PUT', 'Here comes'], + ['s2', 1234, 'PUT', 'the mouse!'], + ['a1', 1234, 'PUT', 'the mouse!'], + ['s1', 1234, 'PUT', 'the mouse!'], + ['s2', 1234, 'END', true], + ['a1', 1234, 'END', false], + ['s1', 1234, 'END', false] + ]); + }); + it('all should run', async () => { + parser.registerHandler(1234, new TestHandler(1234, reports, 's1', true)); + parser.registerHandler(1234, new TestHandlerAsync(1234, reports, 'a1', true)); + parser.registerHandler(1234, new TestHandler(1234, reports, 's2', true)); + parser.start(); + let data = toUtf32('1234;Here comes'); + parser.put(data, 0, data.length); + data = toUtf32('the mouse!'); + parser.put(data, 0, data.length); + await endP(parser, true); + assert.deepEqual(reports, [ + // messages from TestHandler + ['s2', 1234, 'START'], + ['a1', 1234, 'START'], + ['s1', 1234, 'START'], + ['s2', 1234, 'PUT', 'Here comes'], + ['a1', 1234, 'PUT', 'Here comes'], + ['s1', 1234, 'PUT', 'Here comes'], + ['s2', 1234, 'PUT', 'the mouse!'], + ['a1', 1234, 'PUT', 'the mouse!'], + ['s1', 1234, 'PUT', 'the mouse!'], + ['s2', 1234, 'END', true], + ['a1', 1234, 'END', true], + ['s1', 1234, 'END', true] + ]); + }); + }); + describe('async | sync | async', () => { + it('first should run, cleanup action for others', async () => { + parser.registerHandler(1234, new TestHandlerAsync(1234, reports, 's1')); + parser.registerHandler(1234, new TestHandler(1234, reports, 'a1')); + parser.registerHandler(1234, new TestHandlerAsync(1234, reports, 's2')); + parser.start(); + let data = toUtf32('1234;Here comes'); + parser.put(data, 0, data.length); + data = toUtf32('the mouse!'); + parser.put(data, 0, data.length); + await endP(parser, true); + assert.deepEqual(reports, [ + // messages from TestHandler + ['s2', 1234, 'START'], + ['a1', 1234, 'START'], + ['s1', 1234, 'START'], + ['s2', 1234, 'PUT', 'Here comes'], + ['a1', 1234, 'PUT', 'Here comes'], + ['s1', 1234, 'PUT', 'Here comes'], + ['s2', 1234, 'PUT', 'the mouse!'], + ['a1', 1234, 'PUT', 'the mouse!'], + ['s1', 1234, 'PUT', 'the mouse!'], + ['s2', 1234, 'END', true], + ['a1', 1234, 'END', false], + ['s1', 1234, 'END', false] + ]); + }); + it('all should run', async () => { + parser.registerHandler(1234, new TestHandlerAsync(1234, reports, 's1', true)); + parser.registerHandler(1234, new TestHandler(1234, reports, 'a1', true)); + parser.registerHandler(1234, new TestHandlerAsync(1234, reports, 's2', true)); + parser.start(); + let data = toUtf32('1234;Here comes'); + parser.put(data, 0, data.length); + data = toUtf32('the mouse!'); + parser.put(data, 0, data.length); + await endP(parser, true); + assert.deepEqual(reports, [ + // messages from TestHandler + ['s2', 1234, 'START'], + ['a1', 1234, 'START'], + ['s1', 1234, 'START'], + ['s2', 1234, 'PUT', 'Here comes'], + ['a1', 1234, 'PUT', 'Here comes'], + ['s1', 1234, 'PUT', 'Here comes'], + ['s2', 1234, 'PUT', 'the mouse!'], + ['a1', 1234, 'PUT', 'the mouse!'], + ['s1', 1234, 'PUT', 'the mouse!'], + ['s2', 1234, 'END', true], + ['a1', 1234, 'END', true], + ['s1', 1234, 'END', true] + ]); + }); + }); + describe('OscHandlerFactory', () => { + it('should be called once on end(true)', async () => { + parser.registerHandler(1234, new OscHandler(async data => { reports.push([1234, data]); return true; })); + parser.start(); + let data = toUtf32('1234;Here comes'); + parser.put(data, 0, data.length); + data = toUtf32(' the mouse!'); + parser.put(data, 0, data.length); + parser.end(true); + await endP(parser, true); + assert.deepEqual(reports, [[1234, 'Here comes the mouse!']]); + }); + it('should not be called on end(false)', async () => { + parser.registerHandler(1234, new OscHandler(async data => { reports.push([1234, data]); return true; })); + parser.start(); + let data = toUtf32('1234;Here comes'); + parser.put(data, 0, data.length); + data = toUtf32(' the mouse!'); + parser.put(data, 0, data.length); + await endP(parser, false); + assert.deepEqual(reports, []); + }); + it('should be disposable', async () => { + parser.registerHandler(1234, new OscHandler(async data => { reports.push(['one', data]); return true; })); + const dispo = parser.registerHandler(1234, new OscHandler(async data => { reports.push(['two', data]); return true; })); + parser.start(); + let data = toUtf32('1234;Here comes'); + parser.put(data, 0, data.length); + data = toUtf32(' the mouse!'); + parser.put(data, 0, data.length); + await endP(parser, true); + assert.deepEqual(reports, [['two', 'Here comes the mouse!']]); + dispo.dispose(); + parser.start(); + data = toUtf32('1234;some other'); + parser.put(data, 0, data.length); + data = toUtf32(' data'); + parser.put(data, 0, data.length); + await endP(parser, true); + assert.deepEqual(reports, [['two', 'Here comes the mouse!'], ['one', 'some other data']]); + }); + it('should respect return false', async () => { + parser.registerHandler(1234, new OscHandler(async data => { reports.push(['one', data]); return true; })); + parser.registerHandler(1234, new OscHandler(async data => { reports.push(['two', data]); return false; })); + parser.start(); + let data = toUtf32('1234;Here comes'); + parser.put(data, 0, data.length); + data = toUtf32(' the mouse!'); + parser.put(data, 0, data.length); + await endP(parser, true); + assert.deepEqual(reports, [['two', 'Here comes the mouse!'], ['one', 'Here comes the mouse!']]); + }); + }); + }); +}); diff --git a/src/common/parser/OscParser.ts b/src/common/parser/OscParser.ts index e7edac66..b0b51e23 100644 --- a/src/common/parser/OscParser.ts +++ b/src/common/parser/OscParser.ts @@ -41,7 +41,7 @@ export class OscParser implements IOscParser { public dispose(): void { this._handlers = Object.create(null); - this._handlerFb = () => {}; + this._handlerFb = () => { }; this._active = EMPTY_HANDLERS; } @@ -76,27 +76,6 @@ export class OscParser implements IOscParser { } } - private _end(success: boolean): void { - // other than the old code we always have to call .end - // to keep the bubbling we use `success` to indicate - // whether a handler should execute - if (!this._active.length) { - this._handlerFb(this._id, 'END', success); - } else { - let j = this._active.length - 1; - for (; j >= 0; j--) { - if (this._active[j].end(success)) { - break; - } - } - j--; - // cleanup left over handlers - for (; j >= 0; j--) { - this._active[j].end(false); - } - } - } - public start(): void { // always reset leftover handlers this.reset(); @@ -137,12 +116,18 @@ export class OscParser implements IOscParser { } } + private _stack = { + paused: false, + loopPosition: 0, + fallThrough: false + }; + /** * Indicates end of an OSC command. * Whether the OSC got aborted or finished normally * is indicated by `success`. */ - public end(success: boolean): void { + public end(success: boolean, promiseResult?: boolean): void | Promise { if (this._state === OscState.START) { return; } @@ -154,7 +139,46 @@ export class OscParser implements IOscParser { if (this._state === OscState.ID) { this._start(); } - this._end(success); + + if (!this._active.length) { + this._handlerFb(this._id, 'END', success); + } else { + let handlerResult: any = false; + let j = this._active.length - 1; + let fallThrough = false; + if (this._stack.paused) { + j = this._stack.loopPosition - 1; + handlerResult = promiseResult; + fallThrough = this._stack.fallThrough; + this._stack.paused = false; + } + if (!fallThrough && handlerResult === false) { + for (; j >= 0; j--) { + if ((handlerResult = this._active[j].end(success)) !== false) { + if (handlerResult instanceof Promise) { + this._stack.paused = true; + this._stack.loopPosition = j; + this._stack.fallThrough = false; + return handlerResult; + } + break; + } + } + j--; + } + // cleanup left over handlers + // we always have to call .end for proper cleanup, + // here we use `success` to indicate whether a handler should execute + for (; j >= 0; j--) { + if ((handlerResult = this._active[j].end(false)) instanceof Promise) { + this._stack.paused = true; + this._stack.loopPosition = j; + this._stack.fallThrough = true; + return handlerResult; + } + } + } + } this._active = EMPTY_HANDLERS; this._id = -1; @@ -170,7 +194,7 @@ export class OscHandler implements IOscHandler { private _data = ''; private _hitLimit: boolean = false; - constructor(private _handler: (data: string) => boolean) {} + constructor(private _handler: (data: string) => boolean | Promise) { } public start(): void { this._data = ''; @@ -188,12 +212,18 @@ export class OscHandler implements IOscHandler { } } - public end(success: boolean): boolean { - let ret = false; + public end(success: boolean): boolean | Promise { + let ret: boolean | Promise = false; if (this._hitLimit) { ret = false; } else if (success) { - ret = this._handler(this._data); + if ((ret = this._handler(this._data)) instanceof Promise) { + return ret.then(res => { + this._data = ''; + this._hitLimit = false; + return res; + }); + } } this._data = ''; this._hitLimit = false; diff --git a/src/common/parser/Types.d.ts b/src/common/parser/Types.d.ts index 30217cc6..dda798cc 100644 --- a/src/common/parser/Types.d.ts +++ b/src/common/parser/Types.d.ts @@ -130,7 +130,7 @@ export interface IOscHandler { * execution of the command should depend on `success`. * To save memory also cleanup data structures here. */ - end(success: boolean): boolean; + end(success: boolean): boolean | Promise; } export type OscFallbackHandlerType = (ident: number, action: 'START' | 'PUT' | 'END', payload?: any) => void; @@ -214,7 +214,7 @@ export interface ISubParser extends IDisposable { export interface IOscParser extends ISubParser { start(): void; - end(success: boolean): void; + end(success: boolean, promiseResult?: boolean): void | Promise; } export interface IDcsParser extends ISubParser { From d0b555687fc3f80d54f777060f30b7155b2498fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Mon, 8 Feb 2021 03:28:49 +0100 Subject: [PATCH 095/377] update parser hooks api and tests --- src/browser/Terminal2.test.ts | 2 +- src/browser/TestUtils.test.ts | 8 ++++---- src/browser/Types.d.ts | 8 ++++---- src/browser/public/Terminal.ts | 24 ++++++++++++------------ src/common/CoreTerminal.ts | 18 +++++++++--------- src/common/InputHandler.ts | 16 ++++++++-------- src/common/Types.d.ts | 6 +++++- test/api/Parser.api.ts | 28 ++++++++++++++-------------- 8 files changed, 57 insertions(+), 53 deletions(-) diff --git a/src/browser/Terminal2.test.ts b/src/browser/Terminal2.test.ts index 7d3fe851..1ad0e905 100644 --- a/src/browser/Terminal2.test.ts +++ b/src/browser/Terminal2.test.ts @@ -74,7 +74,7 @@ describe('Escape Sequence Files', function(): void { let content = ''; const OSC_CODE = 12345; await new Promise(resolve => { - customHandler = term.addOscHandler(OSC_CODE, () => { + customHandler = term.registerOscHandler(OSC_CODE, () => { // grab terminal viewport content content = terminalToString(term); resolve(); diff --git a/src/browser/TestUtils.test.ts b/src/browser/TestUtils.test.ts index 38f9c8f1..a2140aa5 100644 --- a/src/browser/TestUtils.test.ts +++ b/src/browser/TestUtils.test.ts @@ -78,16 +78,16 @@ export class MockTerminal implements ITerminal { public attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void { throw new Error('Method not implemented.'); } - public addCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean): IDisposable { + public registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise): IDisposable { throw new Error('Method not implemented.'); } - public addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean): IDisposable { + public registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise): IDisposable { throw new Error('Method not implemented.'); } - public addEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable { + public registerEscHandler(id: IFunctionIdentifier, handler: () => boolean | Promise): IDisposable { throw new Error('Method not implemented.'); } - public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { + public registerOscHandler(ident: number, callback: (data: string) => boolean | Promise): IDisposable { throw new Error('Method not implemented.'); } public registerLinkMatcher(regex: RegExp, handler: (event: MouseEvent, uri: string) => boolean | void, options?: ILinkMatcherOptions): number { diff --git a/src/browser/Types.d.ts b/src/browser/Types.d.ts index e8e0cabd..1262117f 100644 --- a/src/browser/Types.d.ts +++ b/src/browser/Types.d.ts @@ -52,10 +52,10 @@ export interface IPublicTerminal extends IDisposable { resize(columns: number, rows: number): void; open(parent: HTMLElement): void; attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void; - addCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean): IDisposable; - addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean): IDisposable; - addEscHandler(id: IFunctionIdentifier, callback: () => boolean): IDisposable; - addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable; + registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise): IDisposable; + registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise): IDisposable; + registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise): IDisposable; + registerOscHandler(ident: number, callback: (data: string) => boolean | Promise): IDisposable; registerLinkMatcher(regex: RegExp, handler: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions): number; deregisterLinkMatcher(matcherId: number): void; registerLinkProvider(linkProvider: ILinkProvider): IDisposable; diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index 70247f88..bd0b78f9 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -292,28 +292,28 @@ class BufferLineApiView implements IBufferLineApi { class ParserApi implements IParser { constructor(private _core: ITerminal) { } - public registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable { - return this._core.addCsiHandler(id, (params: IParams) => callback(params.toArray())); + public registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean | Promise): IDisposable { + return this._core.registerCsiHandler(id, (params: IParams) => callback(params.toArray())); } - public addCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable { + public addCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean | Promise): IDisposable { return this.registerCsiHandler(id, callback); } - public registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable { - return this._core.addDcsHandler(id, (data: string, params: IParams) => callback(data, params.toArray())); + public registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean | Promise): IDisposable { + return this._core.registerDcsHandler(id, (data: string, params: IParams) => callback(data, params.toArray())); } - public addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable { + public addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean | Promise): IDisposable { return this.registerDcsHandler(id, callback); } - public registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable { - return this._core.addEscHandler(id, handler); + public registerEscHandler(id: IFunctionIdentifier, handler: () => boolean | Promise): IDisposable { + return this._core.registerEscHandler(id, handler); } - public addEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable { + public addEscHandler(id: IFunctionIdentifier, handler: () => boolean | Promise): IDisposable { return this.registerEscHandler(id, handler); } - public registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { - return this._core.addOscHandler(ident, callback); + public registerOscHandler(ident: number, callback: (data: string) => boolean | Promise): IDisposable { + return this._core.registerOscHandler(ident, callback); } - public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { + public addOscHandler(ident: number, callback: (data: string) => boolean | Promise): IDisposable { return this.registerOscHandler(ident, callback); } } diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 7b45a172..50be0d7c 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -278,23 +278,23 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { } /** Add handler for ESC escape sequence. See xterm.d.ts for details. */ - public addEscHandler(id: IFunctionIdentifier, callback: () => boolean): IDisposable { - return this._inputHandler.addEscHandler(id, callback); + public registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise): IDisposable { + return this._inputHandler.registerEscHandler(id, callback); } /** Add handler for DCS escape sequence. See xterm.d.ts for details. */ - public addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean): IDisposable { - return this._inputHandler.addDcsHandler(id, callback); + public registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise): IDisposable { + return this._inputHandler.registerDcsHandler(id, callback); } /** Add handler for CSI escape sequence. See xterm.d.ts for details. */ - public addCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean): IDisposable { - return this._inputHandler.addCsiHandler(id, callback); + public registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise): IDisposable { + return this._inputHandler.registerCsiHandler(id, callback); } /** Add handler for OSC escape sequence. See xterm.d.ts for details. */ - public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { - return this._inputHandler.addOscHandler(ident, callback); + public registerOscHandler(ident: number, callback: (data: string) => boolean | Promise): IDisposable { + return this._inputHandler.registerOscHandler(ident, callback); } protected _setup(): void { @@ -332,7 +332,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { if (!this._windowsMode) { const disposables: IDisposable[] = []; disposables.push(this.onLineFeed(updateWindowsModeWrappedState.bind(null, this._bufferService))); - disposables.push(this.addCsiHandler({ final: 'H' }, () => { + disposables.push(this.registerCsiHandler({ final: 'H' }, () => { updateWindowsModeWrappedState(this._bufferService); return false; })); diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 099cdff7..08f04d9e 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -701,9 +701,9 @@ export class InputHandler extends Disposable implements IInputHandler { } /** - * Forward addCsiHandler from parser. + * Forward registerCsiHandler from parser. */ - public addCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean): IDisposable { + public registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise): IDisposable { if (id.final === 't' && !id.prefix && !id.intermediates) { // security: always check whether window option is allowed return this._parser.registerCsiHandler(id, params => { @@ -717,23 +717,23 @@ export class InputHandler extends Disposable implements IInputHandler { } /** - * Forward addDcsHandler from parser. + * Forward registerDcsHandler from parser. */ - public addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean): IDisposable { + public registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise): IDisposable { return this._parser.registerDcsHandler(id, new DcsHandler(callback)); } /** - * Forward addEscHandler from parser. + * Forward registerEscHandler from parser. */ - public addEscHandler(id: IFunctionIdentifier, callback: () => boolean): IDisposable { + public registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise): IDisposable { return this._parser.registerEscHandler(id, callback); } /** - * Forward addOscHandler from parser. + * Forward registerOscHandler from parser. */ - public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { + public registerOscHandler(ident: number, callback: (data: string) => boolean | Promise): IDisposable { return this._parser.registerOscHandler(ident, new OscHandler(callback)); } diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index 1ea26c2a..e345e11d 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { ITerminalOptions as IPublicTerminalOptions } from 'xterm'; +import { IFunctionIdentifier, ITerminalOptions as IPublicTerminalOptions } from 'xterm'; import { IEvent, IEventEmitter } from 'common/EventEmitter'; import { IDeleteEvent, IInsertEvent } from 'common/CircularList'; import { IParams } from 'common/parser/Types'; @@ -351,6 +351,10 @@ export interface IInputHandler { parse(data: string | Uint8Array): void; print(data: Uint32Array, start: number, end: number): void; + registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise): IDisposable; + registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise): IDisposable; + registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise): IDisposable; + registerOscHandler(ident: number, callback: (data: string) => boolean | Promise): IDisposable; /** C0 BEL */ bell(): void; /** C0 LF */ lineFeed(): void; diff --git a/test/api/Parser.api.ts b/test/api/Parser.api.ts index 77101e23..ff82895d 100644 --- a/test/api/Parser.api.ts +++ b/test/api/Parser.api.ts @@ -28,12 +28,12 @@ describe('Parser Integration Tests', function(): void { after(async () => browser.close()); - describe('addCsiHandler', () => { + describe('registerCsiHandler', () => { it('should call custom CSI handler with js array params', async () => { await page.evaluate(` window.term.reset(); window._customCsiHandlerParams = []; - const _customCsiHandler = window.term.parser.addCsiHandler({final: 'm'}, (params, collect) => { + const _customCsiHandler = window.term.parser.registerCsiHandler({final: 'm'}, (params, collect) => { window._customCsiHandlerParams.push(params); return false; }, ''); @@ -42,20 +42,20 @@ describe('Parser Integration Tests', function(): void { assert.deepEqual(await page.evaluate(`(() => window._customCsiHandlerParams)();`), [[38, 5, 123], [38, [2, -1, 50, 100, 150]]]); }); }); - describe('addDcsHandler', () => { + describe('registerDcsHandler', () => { it('should respects return value', async () => { await page.evaluate(` window.term.reset(); window._customDcsHandlerCallStack = []; - const _customDcsHandlerA = window.term.parser.addDcsHandler({intermediates:'+', final: 'p'}, (data, params) => { + const _customDcsHandlerA = window.term.parser.registerDcsHandler({intermediates:'+', final: 'p'}, (data, params) => { window._customDcsHandlerCallStack.push(['A', params, data]); return false; }); - const _customDcsHandlerB = window.term.parser.addDcsHandler({intermediates:'+', final: 'p'}, (data, params) => { + const _customDcsHandlerB = window.term.parser.registerDcsHandler({intermediates:'+', final: 'p'}, (data, params) => { window._customDcsHandlerCallStack.push(['B', params, data]); return true; }); - const _customDcsHandlerC = window.term.parser.addDcsHandler({intermediates:'+', final: 'p'}, (data, params) => { + const _customDcsHandlerC = window.term.parser.registerDcsHandler({intermediates:'+', final: 'p'}, (data, params) => { window._customDcsHandlerCallStack.push(['C', params, data]); return false; }); @@ -64,20 +64,20 @@ describe('Parser Integration Tests', function(): void { assert.deepEqual(await page.evaluate(`(() => window._customDcsHandlerCallStack)();`), [['C', [1, 2], 'some data'], ['B', [1, 2], 'some data']]); }); }); - describe('addEscHandler', () => { + describe('registerEscHandler', () => { it('should respects return value', async () => { await page.evaluate(` window.term.reset(); window._customEscHandlerCallStack = []; - const _customEscHandlerA = window.term.parser.addEscHandler({intermediates:'(', final: 'B'}, () => { + const _customEscHandlerA = window.term.parser.registerEscHandler({intermediates:'(', final: 'B'}, () => { window._customEscHandlerCallStack.push('A'); return false; }); - const _customEscHandlerB = window.term.parser.addEscHandler({intermediates:'(', final: 'B'}, () => { + const _customEscHandlerB = window.term.parser.registerEscHandler({intermediates:'(', final: 'B'}, () => { window._customEscHandlerCallStack.push('B'); return true; }); - const _customEscHandlerC = window.term.parser.addEscHandler({intermediates:'(', final: 'B'}, () => { + const _customEscHandlerC = window.term.parser.registerEscHandler({intermediates:'(', final: 'B'}, () => { window._customEscHandlerCallStack.push('C'); return false; }); @@ -86,20 +86,20 @@ describe('Parser Integration Tests', function(): void { assert.deepEqual(await page.evaluate(`(() => window._customEscHandlerCallStack)();`), ['C', 'B']); }); }); - describe('addOscHandler', () => { + describe('registerOscHandler', () => { it('should respects return value', async () => { await page.evaluate(` window.term.reset(); window._customOscHandlerCallStack = []; - const _customOscHandlerA = window.term.parser.addOscHandler(1234, data => { + const _customOscHandlerA = window.term.parser.registerOscHandler(1234, data => { window._customOscHandlerCallStack.push(['A', data]); return false; }); - const _customOscHandlerB = window.term.parser.addOscHandler(1234, data => { + const _customOscHandlerB = window.term.parser.registerOscHandler(1234, data => { window._customOscHandlerCallStack.push(['B', data]); return true; }); - const _customOscHandlerC = window.term.parser.addOscHandler(1234, data => { + const _customOscHandlerC = window.term.parser.registerOscHandler(1234, data => { window._customOscHandlerCallStack.push(['C', data]); return false; }); From 5db479c25d706c22e0ba14a80bdfe95b83fc81ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Mon, 8 Feb 2021 03:35:42 +0100 Subject: [PATCH 096/377] update public API --- typings/xterm.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index d860ddfa..a842a82b 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -1515,7 +1515,7 @@ declare module 'xterm' { * The most recently added handler is tried first. * @return An IDisposable you can call to remove this handler. */ - registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable; + registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean | Promise): IDisposable; /** * Adds a handler for DCS escape sequences. @@ -1534,7 +1534,7 @@ declare module 'xterm' { * The most recently added handler is tried first. * @return An IDisposable you can call to remove this handler. */ - registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable; + registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean | Promise): IDisposable; /** * Adds a handler for ESC escape sequences. @@ -1547,7 +1547,7 @@ declare module 'xterm' { * The most recently added handler is tried first. * @return An IDisposable you can call to remove this handler. */ - registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable; + registerEscHandler(id: IFunctionIdentifier, handler: () => boolean | Promise): IDisposable; /** * Adds a handler for OSC escape sequences. @@ -1565,7 +1565,7 @@ declare module 'xterm' { * The most recently added handler is tried first. * @return An IDisposable you can call to remove this handler. */ - registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable; + registerOscHandler(ident: number, callback: (data: string) => boolean | Promise): IDisposable; } /** From 26502114d42134f7b67bb6602759f20b7f0710b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Mon, 15 Feb 2021 16:24:29 +0100 Subject: [PATCH 097/377] minor tweaks, API docs update --- src/common/parser/EscapeSequenceParser.ts | 6 ++-- typings/xterm.d.ts | 37 +++++++++++++++-------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/common/parser/EscapeSequenceParser.ts b/src/common/parser/EscapeSequenceParser.ts index d2da17c6..79f8b844 100644 --- a/src/common/parser/EscapeSequenceParser.ts +++ b/src/common/parser/EscapeSequenceParser.ts @@ -526,18 +526,17 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP this._parseStack.state = ParserStackType.FAIL; throw new Error('improper continuation due to previous async handler, giving up parsing'); } - let handlerPos = this._parseStack.handlerPos - 1; // we have to resume the old handler loop if: // - return value of the promise was `false` // - handlers are not exhausted yet // FIXME: removing handlers from within a handler of the same sequence // is not supported atm (also true for sync handlers)!! - let handlers: ResumableHandlersType; + let handlers = this._parseStack.handlers; + let handlerPos = this._parseStack.handlerPos - 1; switch (this._parseStack.state) { case ParserStackType.CSI: if (promiseResult === false && handlerPos > -1) { - handlers = this._parseStack.handlers; for (; handlerPos >= 0; handlerPos--) { if ((handlerResult = (handlers as CsiHandlerType[])[handlerPos](this._params)) !== false) { if (handlerResult instanceof Promise) { @@ -552,7 +551,6 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP break; case ParserStackType.ESC: if (promiseResult === false && handlerPos > -1) { - handlers = this._parseStack.handlers; for (; handlerPos >= 0; handlerPos--) { if ((handlerResult = (handlers as EscHandlerType[])[handlerPos]()) !== false) { if (handlerResult instanceof Promise) { diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index a842a82b..cab9bdcc 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -1501,6 +1501,23 @@ declare module 'xterm' { /** * Allows hooking into the parser for custom handling of escape sequences. + * + * Note on sync vs. async handlers: + * xterm.js implements all parser actions with synchronous handlers. + * In general custom handlers should also operate in sync mode wherever + * possible to keep the parser fast. + * Still the exposed interfaces allow to register async handlers by returning + * a `Promise`. Here the parser will pause input processing until + * the promise got resolved or rejected (in-band blocking). This "full stop" + * on the input chain allows to implement backpressure from a certain async + * action while the terminal state will not progress any further from input. + * It does not mean that the terminal state will not change at all in between, + * as user actions like resize or reset are still processed immediately. + * It is an error to assume a stable terminal state while giving back control + * in between, e.g. by multiple chained `then` calls. + * Downside of an async handler is a rather bad throughput performance, + * thus use async handlers only as a last resort or for actions that have + * to rely on async interfaces itself. */ export interface IParser { /** @@ -1510,9 +1527,8 @@ declare module 'xterm' { * @param callback The function to handle the sequence. The callback is * called with the numerical params. If the sequence has subparams the * array will contain subarrays with their numercial values. - * Return true if the sequence was handled; false if we should try - * a previous handler (set by addCsiHandler or setCsiHandler). - * The most recently added handler is tried first. + * Return `true` if the sequence was handled, `false` if the parser should try + * a previous handler. The most recently added handler is tried first. * @return An IDisposable you can call to remove this handler. */ registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean | Promise): IDisposable; @@ -1529,9 +1545,8 @@ declare module 'xterm' { * big payloads. Currently xterm.js limits DCS payload to 10 MB * which should give enough room for most use cases. * The function gets the payload and numerical parameters as arguments. - * Return true if the sequence was handled; false if we should try - * a previous handler (set by addDcsHandler or setDcsHandler). - * The most recently added handler is tried first. + * Return `true` if the sequence was handled, `false` if the parser should try + * a previous handler. The most recently added handler is tried first. * @return An IDisposable you can call to remove this handler. */ registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean | Promise): IDisposable; @@ -1542,9 +1557,8 @@ declare module 'xterm' { * gets registered, e.g. {intermediates: '%' final: 'G'} for * default charset selection. * @param callback The function to handle the sequence. - * Return true if the sequence was handled; false if we should try - * a previous handler (set by addEscHandler or setEscHandler). - * The most recently added handler is tried first. + * Return `true` if the sequence was handled, `false` if the parser should try + * a previous handler. The most recently added handler is tried first. * @return An IDisposable you can call to remove this handler. */ registerEscHandler(id: IFunctionIdentifier, handler: () => boolean | Promise): IDisposable; @@ -1560,9 +1574,8 @@ declare module 'xterm' { * big payloads. Currently xterm.js limits OSC payload to 10 MB * which should give enough room for most use cases. * The callback is called with OSC data string. - * Return true if the sequence was handled; false if we should try - * a previous handler (set by addOscHandler or setOscHandler). - * The most recently added handler is tried first. + * Return `true` if the sequence was handled, `false` if the parser should try + * a previous handler. The most recently added handler is tried first. * @return An IDisposable you can call to remove this handler. */ registerOscHandler(ident: number, callback: (data: string) => boolean | Promise): IDisposable; From 3ab2376517930e2da157a6ee4902e449b1ce592d Mon Sep 17 00:00:00 2001 From: nxshell <74552956+nxshell@users.noreply.github.com> Date: Tue, 16 Feb 2021 19:37:03 +0800 Subject: [PATCH 098/377] feat: Add nxshell which use xtermjs --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b46b7e93..26db59d0 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,7 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**TRASA**](https://trasa.io): Zero trust access to Web, SSH, RDP and Database services. - [**Commas**](https://github.com/CyanSalt/commas): Commas is a hackable terminal and command runner. - [**Devtron**](https://github.com/devtron-labs/devtron): Software Delivery Workflow For Kubernetes. +- [**NxShell**](https://github.com/nxshell/nxshell): An easy to use new terminal for SSH. [And much more...](https://github.com/xtermjs/xterm.js/network/dependents) Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it in our list. Note: Please add any new contributions to the end of the list only. From bce3269e445376f3dc7c5b3faac65855c30209f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Thu, 25 Feb 2021 15:41:10 +0100 Subject: [PATCH 099/377] async OSC/DCS registering/dispose tests on parser instance --- .../parser/EscapeSequenceParser.test.ts | 201 ++++++++++++++++-- src/common/parser/EscapeSequenceParser.ts | 18 +- 2 files changed, 192 insertions(+), 27 deletions(-) diff --git a/src/common/parser/EscapeSequenceParser.test.ts b/src/common/parser/EscapeSequenceParser.test.ts index 56d4c93e..6d00adda 100644 --- a/src/common/parser/EscapeSequenceParser.test.ts +++ b/src/common/parser/EscapeSequenceParser.test.ts @@ -102,7 +102,7 @@ class TestEscapeSequenceParser extends EscapeSequenceParser { public trackedStack: IParserStackState[] = []; public parse(data: Uint32Array, length: number, promiseResult?: boolean): void | Promise { const result = super.parse(data, length, promiseResult); - if (result && this._trackStack) { + if (result instanceof Promise && this._trackStack) { this.trackedStack.push({ ...this.parseStack }); } return result; @@ -1742,9 +1742,9 @@ async function throwsAsync(fn: () => Promise, message?: string | undefined) } describe('EscapeSequenceParser - async', () => { - // sequences: SGR 1;31 | hello SP | ESC %G | wor | ESC E | ld! | SGR 0 | EXE \r\n | $> | OSC 1;foo=bar ST + // sequences: SGR 1;31 | hello SP | ESC %G | wor | ESC E | ld! | SGR 0 | EXE \r\n | $> | DCS 1;2 a [xyz] ST | OSC 1;foo=bar ST | FIN // needed handlers: CSI m, PRINT, ESC %G, ESC E, EXE \r, EXE \n, OSC 1 - const INPUT = '\x1b[1;31mhello \x1b%Gwor\x1bEld!\x1b[0m\r\n$>\x1b]1;foo=bar\x1b\\'; + const INPUT = '\x1b[1;31mhello \x1b%Gwor\x1bEld!\x1b[0m\r\n$>\x1bP1;2axyz\x1b\\\x1b]1;foo=bar\x1b\\FIN'; let RESULT: any[]; let parser: TestEscapeSequenceParser; const callstack: any[] = []; @@ -1764,7 +1764,9 @@ describe('EscapeSequenceParser - async', () => { ['EXE \r'], ['EXE \n'], ['PRINT', '$>'], - ['OSC 1', 'foo=bar'] + ['DCS a', ['xyz', [1, 2]]], + ['OSC 1', 'foo=bar'], + ['PRINT', 'FIN'] ]; parser = new TestEscapeSequenceParser(); parser.reset(); @@ -1786,9 +1788,10 @@ describe('EscapeSequenceParser - async', () => { parser.setExecuteHandler('\r', () => { callstack.push(['EXE \r']); return true; }); parser.setExecuteHandler('\n', () => { callstack.push(['EXE \n']); return true; }); parser.registerOscHandler(1, new OscHandler(data => { callstack.push(['OSC 1', data]); return true; })); + parser.registerDcsHandler({final: 'a'}, new DcsHandler((data, params) => { callstack.push(['DCS a', [data, params.toArray()]]); return true;})); }); - it('sync handlers keep parsed in sync mode', () => { + it('sync handlers keep being parsed in sync mode', () => { // note: if we have only sync handlers, a parse call should never return anything assert.equal(!parseSync(parser, INPUT), true); assert.equal(parser.parseStack.state, ParserStackType.NONE); // not paused @@ -1819,7 +1822,8 @@ describe('EscapeSequenceParser - async', () => { parser.registerEscHandler({ final: 'E' }, async () => { callstack.push(['ESC E']); return true; }); parser.setExecuteHandler('\r', () => { callstack.push(['EXE \r']); return true; }); parser.setExecuteHandler('\n', () => { callstack.push(['EXE \n']); return true; }); - parser.registerOscHandler(1, new OscHandler(data => { callstack.push(['OSC 1', data]); return true; })); + parser.registerOscHandler(1, new OscHandler(async data => { callstack.push(['OSC 1', data]); return true; })); + parser.registerDcsHandler({final: 'a'}, new DcsHandler(async (data, params) => { callstack.push(['DCS a', [data, params.toArray()]]); return true;})); }); it('sync parse call does not work anymore', () => { @@ -1849,7 +1853,12 @@ describe('EscapeSequenceParser - async', () => { await parseP(parser, INPUT); assert.deepEqual(callstack, RESULT); evalStackSaves(parser.trackedStack, [ - [6, ParserStackType.CSI, 0], [15, ParserStackType.ESC, 0], [20, ParserStackType.ESC, 0], [27, ParserStackType.CSI, 0] + [6, ParserStackType.CSI, 0], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 0], + [27, ParserStackType.CSI, 0], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0] ]); }); it('correct result on chunked awaited parse calls', async () => { @@ -1874,7 +1883,11 @@ describe('EscapeSequenceParser - async', () => { ['EXE \n'], ['PRINT', '$'], ['PRINT', '>'], - ['OSC 1', 'foo=bar'] + ['DCS a', ['xyz', [1, 2]]], + ['OSC 1', 'foo=bar'], + ['PRINT', 'F'], + ['PRINT', 'I'], + ['PRINT', 'N'] ]; // split to single char input @@ -1888,7 +1901,9 @@ describe('EscapeSequenceParser - async', () => { [0, ParserStackType.CSI, 0], [0, ParserStackType.ESC, 0], [0, ParserStackType.ESC, 0], - [0, ParserStackType.CSI, 0] + [0, ParserStackType.CSI, 0], + [0, ParserStackType.DCS, 0], + [0, ParserStackType.OSC, 0] ]); }); it('multiple async SGR handlers', async () => { @@ -1906,7 +1921,9 @@ describe('EscapeSequenceParser - async', () => { [15, ParserStackType.ESC, 0], [20, ParserStackType.ESC, 0], [27, ParserStackType.CSI, 1], - [27, ParserStackType.CSI, 0] + [27, ParserStackType.CSI, 0], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0] ]); clearAccu(); // after dispose we should be back to RESULT @@ -1917,7 +1934,9 @@ describe('EscapeSequenceParser - async', () => { [6, ParserStackType.CSI, 0], [15, ParserStackType.ESC, 0], [20, ParserStackType.ESC, 0], - [27, ParserStackType.CSI, 0] + [27, ParserStackType.CSI, 0], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0] ]); clearAccu(); @@ -1933,7 +1952,9 @@ describe('EscapeSequenceParser - async', () => { [6, ParserStackType.CSI, 1], [15, ParserStackType.ESC, 0], [20, ParserStackType.ESC, 0], - [27, ParserStackType.CSI, 1] + [27, ParserStackType.CSI, 1], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0] ]); clearAccu(); // after dispose we should be back to RESULT @@ -1944,7 +1965,9 @@ describe('EscapeSequenceParser - async', () => { [6, ParserStackType.CSI, 0], [15, ParserStackType.ESC, 0], [20, ParserStackType.ESC, 0], - [27, ParserStackType.CSI, 0] + [27, ParserStackType.CSI, 0], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0] ]); }); it('multiple async ESC handlers', async () => { @@ -1960,7 +1983,9 @@ describe('EscapeSequenceParser - async', () => { [15, ParserStackType.ESC, 0], [20, ParserStackType.ESC, 1], [20, ParserStackType.ESC, 0], - [27, ParserStackType.CSI, 0] + [27, ParserStackType.CSI, 0], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0] ]); clearAccu(); // after dispose we should be back to RESULT @@ -1971,7 +1996,9 @@ describe('EscapeSequenceParser - async', () => { [6, ParserStackType.CSI, 0], [15, ParserStackType.ESC, 0], [20, ParserStackType.ESC, 0], - [27, ParserStackType.CSI, 0] + [27, ParserStackType.CSI, 0], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0] ]); clearAccu(); @@ -1986,7 +2013,9 @@ describe('EscapeSequenceParser - async', () => { [6, ParserStackType.CSI, 0], [15, ParserStackType.ESC, 0], [20, ParserStackType.ESC, 1], - [27, ParserStackType.CSI, 0] + [27, ParserStackType.CSI, 0], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0] ]); clearAccu(); // after dispose we should be back to RESULT @@ -1997,7 +2026,9 @@ describe('EscapeSequenceParser - async', () => { [6, ParserStackType.CSI, 0], [15, ParserStackType.ESC, 0], [20, ParserStackType.ESC, 0], - [27, ParserStackType.CSI, 0] + [27, ParserStackType.CSI, 0], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0] ]); }); it('sync/async SGR mixed', async () => { @@ -2020,7 +2051,9 @@ describe('EscapeSequenceParser - async', () => { [15, ParserStackType.ESC, 0], [20, ParserStackType.ESC, 0], [27, ParserStackType.CSI, 2], - [27, ParserStackType.CSI, 0] + [27, ParserStackType.CSI, 0], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0] ]); clearAccu(); // dispose SGR2 (sync one) @@ -2039,7 +2072,9 @@ describe('EscapeSequenceParser - async', () => { [15, ParserStackType.ESC, 0], [20, ParserStackType.ESC, 0], [27, ParserStackType.CSI, 1], - [27, ParserStackType.CSI, 0] + [27, ParserStackType.CSI, 0], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0] ]); clearAccu(); // dispose SGR3 (async one) @@ -2050,8 +2085,134 @@ describe('EscapeSequenceParser - async', () => { [6, ParserStackType.CSI, 0], [15, ParserStackType.ESC, 0], [20, ParserStackType.ESC, 0], - [27, ParserStackType.CSI, 0] + [27, ParserStackType.CSI, 0], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0] ]); }); + it('multiple async OSC handlers', async () => { + // register with fallback + const OSC2 = parser.registerOscHandler(1, new OscHandler(async data => { callstack.push(['2# OSC 1', data]); return false; })); + await parseP(parser, INPUT); + for (let i = 0; i < callstack.length; ++i) { + const entry = callstack[i]; + if (entry[0] === '2# OSC 1') assert.equal(callstack[i + 1][0], 'OSC 1', 'Should fallback to original handler'); + } + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 0], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 0], + [27, ParserStackType.CSI, 0], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0], + [54, ParserStackType.OSC, 0] + ]); + clearAccu(); + // after dispose we should be back to RESULT + OSC2.dispose(); + await parseP(parser, INPUT); + assert.deepEqual(callstack, RESULT, 'Should not call custom handler'); + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 0], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 0], + [27, ParserStackType.CSI, 0], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0] + ]); + clearAccu(); + + // register without fallback + const OSC22 = parser.registerOscHandler(1, new OscHandler(async data => { callstack.push(['2# OSC 1', data]); return true; })); + await parseP(parser, INPUT); + for (let i = 0; i < callstack.length; ++i) { + const entry = callstack[i]; + if (entry[0] === '2# OSC 1') assert.notEqual(callstack[i + 1][0], 'OSC 1', 'Should fallback to original handler'); + } + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 0], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 0], + [27, ParserStackType.CSI, 0], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0] + ]); + clearAccu(); + // after dispose we should be back to RESULT + OSC22.dispose(); + await parseP(parser, INPUT); + assert.deepEqual(callstack, RESULT, 'Should not call custom handler'); + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 0], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 0], + [27, ParserStackType.CSI, 0], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0] + ]); + clearAccu(); + }); + it('multiple async DCS handlers', async () => { + // register with fallback + const DCS2 = parser.registerDcsHandler({final: 'a'}, new DcsHandler(async (data, params) => { callstack.push(['#2 DCS a', [data, params.toArray()]]); return false;})); + await parseP(parser, INPUT); + for (let i = 0; i < callstack.length; ++i) { + const entry = callstack[i]; + if (entry[0] === '2# DCS a') assert.equal(callstack[i + 1][0], 'DCS a', 'Should fallback to original handler'); + } + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 0], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 0], + [27, ParserStackType.CSI, 0], + [41, ParserStackType.DCS, 0], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0] + ]); + clearAccu(); + // after dispose we should be back to RESULT + DCS2.dispose(); + await parseP(parser, INPUT); + assert.deepEqual(callstack, RESULT, 'Should not call custom handler'); + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 0], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 0], + [27, ParserStackType.CSI, 0], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0] + ]); + clearAccu(); + + // register without fallback + const DCS22 = parser.registerDcsHandler({final: 'a'}, new DcsHandler(async (data, params) => { callstack.push(['#2 DCS a', [data, params.toArray()]]); return true;})); + await parseP(parser, INPUT); + for (let i = 0; i < callstack.length; ++i) { + const entry = callstack[i]; + if (entry[0] === '2# DCS a') assert.notEqual(callstack[i + 1][0], 'DCS a', 'Should fallback to original handler'); + } + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 0], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 0], + [27, ParserStackType.CSI, 0], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0] + ]); + clearAccu(); + // after dispose we should be back to RESULT + DCS22.dispose(); + await parseP(parser, INPUT); + assert.deepEqual(callstack, RESULT, 'Should not call custom handler'); + evalStackSaves(parser.trackedStack, [ + [6, ParserStackType.CSI, 0], + [15, ParserStackType.ESC, 0], + [20, ParserStackType.ESC, 0], + [27, ParserStackType.CSI, 0], + [41, ParserStackType.DCS, 0], + [54, ParserStackType.OSC, 0] + ]); + clearAccu(); + }); }); }); diff --git a/src/common/parser/EscapeSequenceParser.ts b/src/common/parser/EscapeSequenceParser.ts index 79f8b844..3b5c1d05 100644 --- a/src/common/parser/EscapeSequenceParser.ts +++ b/src/common/parser/EscapeSequenceParser.ts @@ -492,7 +492,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP * --> Maybe easier: Give up on non-mutating rule for async handlers... * (needs explanation in docs about exact executor/thenable/worker execution contexts) * - * Example for proper parsing of multiple chunks: + * Boilerplate for proper parsing of multiple chunks with async handlers: * * ```typescript * async function parseMultipleChunks(chunks: Uint32Array[]): Promise { @@ -518,10 +518,14 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP if (promiseResult === undefined || this._parseStack.state === ParserStackType.FAIL) { /** * Reject further parsing on improper continuation after pausing. - * This will happen with sync parse calls not awaiting a returned promise. - * It is a really bad condition with screwed up execution order, - * therefore we exit hard with an exception. - * FIXME: Do we need a method to escape from this broken parser state? (hard to achieve properly) + * This is a really bad condition with screwed up execution order and messed up terminal state, + * therefore we exit hard with an exception and reject any further parsing. + * + * Note: With `Terminal.write` usage this exception should never occur, as the top level + * calls are guaranteed to handle async conditions properly. If you ever encounter this + * exception in your terminal integration it indicates, that you injected data chunks to + * `InputHandler.parse` or `EscapeSequenceParser.parse` synchronously without waiting for + * continuation of a running async handler. */ this._parseStack.state = ParserStackType.FAIL; throw new Error('improper continuation due to previous async handler, giving up parsing'); @@ -578,13 +582,13 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP if (handlerResult = this._oscParser.end(code !== 0x18 && code !== 0x1a, promiseResult)) { return handlerResult; } - if (code === 0x1b) transition |= ParserState.ESCAPE; + if (code === 0x1b) this._parseStack.transition |= ParserState.ESCAPE; this._params.reset(); this._params.addParam(0); // ZDM this._collect = 0; break; } - // cleanup before continuing with the main loop + // cleanup before continuing with the main sync loop this._parseStack.state = ParserStackType.NONE; start = this._parseStack.chunkPos + 1; this.precedingCodepoint = 0; From 9985ae2c38de82968a7bb7e4c5e496caf753698b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Thu, 25 Feb 2021 15:44:39 +0100 Subject: [PATCH 100/377] fix linter warning --- src/common/parser/EscapeSequenceParser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/parser/EscapeSequenceParser.ts b/src/common/parser/EscapeSequenceParser.ts index 3b5c1d05..f9a14553 100644 --- a/src/common/parser/EscapeSequenceParser.ts +++ b/src/common/parser/EscapeSequenceParser.ts @@ -536,7 +536,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP // - handlers are not exhausted yet // FIXME: removing handlers from within a handler of the same sequence // is not supported atm (also true for sync handlers)!! - let handlers = this._parseStack.handlers; + const handlers = this._parseStack.handlers; let handlerPos = this._parseStack.handlerPos - 1; switch (this._parseStack.state) { case ParserStackType.CSI: From d500b0f204ffad672139f63f78293a8e3ac11ff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Thu, 25 Feb 2021 17:06:10 +0100 Subject: [PATCH 101/377] inputhandler tests --- src/common/InputHandler.test.ts | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index d127f673..0402f262 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -17,6 +17,7 @@ import { DEFAULT_OPTIONS } from 'common/services/OptionsService'; import { clone } from 'common/Clone'; import { BufferService } from 'common/services/BufferService'; import { CoreService } from 'common/services/CoreService'; +import { OscHandler } from 'common/parser/OscParser'; function getCursor(bufferService: IBufferService): number[] { return [ @@ -1805,3 +1806,61 @@ describe('InputHandler', () => { }); }); }); + + +describe('InputHandler - async handlers', () => { + let bufferService: IBufferService; + let coreService: ICoreService; + let optionsService: MockOptionsService; + let inputHandler: TestInputHandler; + + beforeEach(() => { + optionsService = new MockOptionsService(); + bufferService = new BufferService(optionsService); + bufferService.resize(80, 30); + coreService = new CoreService(() => {}, bufferService, new MockLogService(), optionsService); + coreService.onData(data => { console.log(data); }); + + inputHandler = new TestInputHandler(bufferService, new MockCharsetService(), coreService, new MockDirtyRowService(), new MockLogService(), optionsService, new MockCoreMouseService(), new MockUnicodeService()); + }); + + it('async CUP with CPR check', async () => { + const cup: number[][] = []; + const cpr: number[][] = []; + inputHandler.registerCsiHandler({final: 'H'}, async params => { + cup.push(params.toArray() as number[]); + await new Promise(res => setTimeout(res, 50)); + // late call of real repositioning + return inputHandler.cursorPosition(params); + }); + coreService.onData(data => { + const m = data.match(/\x1b\[(.*?);(.*?)R/); + if (m) { + cpr.push([parseInt(m[1]), parseInt(m[2])]); + } + }); + await inputHandler.parseP('aaa\x1b[3;4H\x1b[6nbbb\x1b[6;8H\x1b[6n'); + assert.deepEqual(cup, cpr); + }); + it('async OSC between', async () => { + inputHandler.registerOscHandler(1000, async data => { + await new Promise(res => setTimeout(res, 50)); + assert.deepEqual(getLines(bufferService, 2), ['hello world!', '']); + assert.equal(data, 'some data'); + return true; + }); + await inputHandler.parseP('hello world!\r\n\x1b]1000;some data\x07second line'); + assert.deepEqual(getLines(bufferService, 2), ['hello world!', 'second line']); + }); + it('async DCS between', async () => { + inputHandler.registerDcsHandler({final: 'a'}, async (data, params) => { + await new Promise(res => setTimeout(res, 50)); + assert.deepEqual(getLines(bufferService, 2), ['hello world!', '']); + assert.equal(data, 'some data'); + assert.deepEqual(params.toArray(), [1, 2]); + return true; + }); + await inputHandler.parseP('hello world!\r\n\x1bP1;2asome data\x1b\\second line'); + assert.deepEqual(getLines(bufferService, 2), ['hello world!', 'second line']); + }); +}); From 6b579215674808166b0f62c0ba5ba228967ef0b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Thu, 25 Feb 2021 17:41:16 +0100 Subject: [PATCH 102/377] async handler API tests --- test/api/Parser.api.ts | 117 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 111 insertions(+), 6 deletions(-) diff --git a/test/api/Parser.api.ts b/test/api/Parser.api.ts index ff82895d..7bd55544 100644 --- a/test/api/Parser.api.ts +++ b/test/api/Parser.api.ts @@ -14,8 +14,8 @@ let page: Page; const width = 800; const height = 600; -describe('Parser Integration Tests', function(): void { - before(async function(): Promise { +describe('Parser Integration Tests', function (): void { + before(async function (): Promise { const browserType = getBrowserType(); browser = await browserType.launch({ headless: process.argv.indexOf('--headless') !== -1 @@ -39,7 +39,35 @@ describe('Parser Integration Tests', function(): void { }, ''); `); await writeSync(page, '\x1b[38;5;123mparams\x1b[38:2::50:100:150msubparams'); - assert.deepEqual(await page.evaluate(`(() => window._customCsiHandlerParams)();`), [[38, 5, 123], [38, [2, -1, 50, 100, 150]]]); + assert.deepEqual(await page.evaluate(`window._customCsiHandlerParams`), [ + [38, 5, 123], + [38, [2, -1, 50, 100, 150]] + ]); + }); + it('async', async () => { + await page.evaluate(` + window.term.reset(); + window._customCsiHandlerCallStack = []; + const _customCsiHandlerA = window.term.parser.registerCsiHandler({intermediates:'+', final: 'Z'}, params => { + window._customCsiHandlerCallStack.push(['A', params]); + return false; + }); + const _customCsiHandlerB = window.term.parser.registerCsiHandler({intermediates:'+', final: 'Z'}, async params => { + await new Promise(res => setTimeout(res, 50)); + window._customCsiHandlerCallStack.push(['B', params]); + return false; + }); + const _customCsiHandlerC = window.term.parser.registerCsiHandler({intermediates:'+', final: 'Z'}, params => { + window._customCsiHandlerCallStack.push(['C', params]); + return false; + }); + `); + await writeSync(page, '\x1b[1;2+Z'); + assert.deepEqual(await page.evaluate(`window._customCsiHandlerCallStack`), [ + ['C', [1, 2]], + ['B', [1, 2]], + ['A', [1, 2]] + ]); }); }); describe('registerDcsHandler', () => { @@ -61,7 +89,35 @@ describe('Parser Integration Tests', function(): void { }); `); await writeSync(page, '\x1bP1;2+psome data\x1b\\\\'); - assert.deepEqual(await page.evaluate(`(() => window._customDcsHandlerCallStack)();`), [['C', [1, 2], 'some data'], ['B', [1, 2], 'some data']]); + assert.deepEqual(await page.evaluate(`window._customDcsHandlerCallStack`), [ + ['C', [1, 2], 'some data'], + ['B', [1, 2], 'some data'] + ]); + }); + it('async', async () => { + await page.evaluate(` + window.term.reset(); + window._customDcsHandlerCallStack = []; + const _customDcsHandlerA = window.term.parser.registerDcsHandler({intermediates:'+', final: 'q'}, (data, params) => { + window._customDcsHandlerCallStack.push(['A', params, data]); + return false; + }); + const _customDcsHandlerB = window.term.parser.registerDcsHandler({intermediates:'+', final: 'q'}, async (data, params) => { + await new Promise(res => setTimeout(res, 50)); + window._customDcsHandlerCallStack.push(['B', params, data]); + return false; + }); + const _customDcsHandlerC = window.term.parser.registerDcsHandler({intermediates:'+', final: 'q'}, (data, params) => { + window._customDcsHandlerCallStack.push(['C', params, data]); + return false; + }); + `); + await writeSync(page, '\x1bP1;2+qsome data\x1b\\\\'); + assert.deepEqual(await page.evaluate(`window._customDcsHandlerCallStack`), [ + ['C', [1, 2], 'some data'], + ['B', [1, 2], 'some data'], + ['A', [1, 2], 'some data'] + ]); }); }); describe('registerEscHandler', () => { @@ -83,7 +139,28 @@ describe('Parser Integration Tests', function(): void { }); `); await writeSync(page, '\x1b(B'); - assert.deepEqual(await page.evaluate(`(() => window._customEscHandlerCallStack)();`), ['C', 'B']); + assert.deepEqual(await page.evaluate(`window._customEscHandlerCallStack`), ['C', 'B']); + }); + it('async', async () => { + await page.evaluate(` + window.term.reset(); + window._customEscHandlerCallStack = []; + const _customEscHandlerA = window.term.parser.registerEscHandler({intermediates:'(', final: 'Z'}, () => { + window._customEscHandlerCallStack.push('A'); + return false; + }); + const _customEscHandlerB = window.term.parser.registerEscHandler({intermediates:'(', final: 'Z'}, async () => { + await new Promise(res => setTimeout(res, 50)); + window._customEscHandlerCallStack.push('B'); + return false; + }); + const _customEscHandlerC = window.term.parser.registerEscHandler({intermediates:'(', final: 'Z'}, () => { + window._customEscHandlerCallStack.push('C'); + return false; + }); + `); + await writeSync(page, '\x1b(Z'); + assert.deepEqual(await page.evaluate(`window._customEscHandlerCallStack`), ['C', 'B', 'A']); }); }); describe('registerOscHandler', () => { @@ -105,7 +182,35 @@ describe('Parser Integration Tests', function(): void { }); `); await writeSync(page, '\x1b]1234;some data\x07'); - assert.deepEqual(await page.evaluate(`(() => window._customOscHandlerCallStack)();`), [['C', 'some data'], ['B', 'some data']]); + assert.deepEqual(await page.evaluate(`window._customOscHandlerCallStack`), [ + ['C', 'some data'], + ['B', 'some data'] + ]); + }); + it('async', async () => { + await page.evaluate(` + window.term.reset(); + window._customOscHandlerCallStack = []; + const _customOscHandlerA = window.term.parser.registerOscHandler(666, data => { + window._customOscHandlerCallStack.push(['A', data]); + return false; + }); + const _customOscHandlerB = window.term.parser.registerOscHandler(666, async data => { + await new Promise(res => setTimeout(res, 50)); + window._customOscHandlerCallStack.push(['B', data]); + return false; + }); + const _customOscHandlerC = window.term.parser.registerOscHandler(666, data => { + window._customOscHandlerCallStack.push(['C', data]); + return false; + }); + `); + await writeSync(page, '\x1b]666;some data\x07'); + assert.deepEqual(await page.evaluate(`window._customOscHandlerCallStack`), [ + ['C', 'some data'], + ['B', 'some data'], + ['A', 'some data'] + ]); }); }); }); From b4635eddf3ec6c206c32bc81e2aa22ef84d916e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Thu, 25 Feb 2021 19:04:37 +0100 Subject: [PATCH 103/377] make reset async aware --- src/common/parser/DcsParser.ts | 6 +- .../parser/EscapeSequenceParser.test.ts | 4 +- src/common/parser/EscapeSequenceParser.ts | 173 ++++++++++-------- src/common/parser/OscParser.ts | 7 +- src/common/parser/Types.d.ts | 1 + 5 files changed, 111 insertions(+), 80 deletions(-) diff --git a/src/common/parser/DcsParser.ts b/src/common/parser/DcsParser.ts index 9f326099..5389b828 100644 --- a/src/common/parser/DcsParser.ts +++ b/src/common/parser/DcsParser.ts @@ -48,9 +48,13 @@ export class DcsParser implements IDcsParser { } public reset(): void { + // force cleanup leftover handlers if (this._active.length) { - this.unhook(false); + for (let j = this._stack.paused ? this._stack.loopPosition - 1 : this._active.length - 1; j >= 0; --j) { + this._active[j].unhook(false); + } } + this._stack.paused = false; this._active = EMPTY_HANDLERS; this._ident = 0; } diff --git a/src/common/parser/EscapeSequenceParser.test.ts b/src/common/parser/EscapeSequenceParser.test.ts index 6d00adda..4b23fa00 100644 --- a/src/common/parser/EscapeSequenceParser.test.ts +++ b/src/common/parser/EscapeSequenceParser.test.ts @@ -1847,7 +1847,9 @@ describe('EscapeSequenceParser - async', () => { // keeps being broken for further parse calls (sync and async) assert.throws(() => parseSync(parser, 'random'), 'improper continuation due to previous async handler, giving up parsing'); await throwsAsync(() => parseP(parser, 'foobar'), 'improper continuation due to previous async handler, giving up parsing'); - // FIXME: come up with a good recovery strategy + // reset should lift the error condition + parser.reset(); + await parseP(parser, INPUT); // does not throw anymore }); it('correct result on awaited parse call', async () => { await parseP(parser, INPUT); diff --git a/src/common/parser/EscapeSequenceParser.ts b/src/common/parser/EscapeSequenceParser.ts index f9a14553..9ed3e462 100644 --- a/src/common/parser/EscapeSequenceParser.ts +++ b/src/common/parser/EscapeSequenceParser.ts @@ -427,6 +427,15 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP this._errorHandler = this._errorHandlerFb; } + /** + * Reset parser to initial values. + * + * This can also be used to lift the improper continuation error condition + * when dealing with async handlers. Use this only as a last resort to silence + * that error when the terminal has no pending data to be processed. Note that + * the interrupted async handler might continue its work in the future messing + * up the terminal state even further. + */ public reset(): void { this.currentState = this.initialState; this._oscParser.reset(); @@ -435,6 +444,13 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP this._params.addParam(0); // ZDM this._collect = 0; this.precedingCodepoint = 0; + // abort pending continuation from async handler + // Here the RESET type indicates, that the next parse call will + // ignore any saved stack, instead continues sync with next codepoint from GROUND + if (this._parseStack.state !== ParserStackType.NONE) { + this._parseStack.state = ParserStackType.RESET; + this._parseStack.handlers = []; // also release handlers ref + } } /** @@ -486,12 +502,6 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP * Important: With only sync handlers defined, parsing is completely synchronous as well. * As soon as an async handler is involved, synchronous parsing is not possible anymore. * - * FIXME: to be discussed - * While awaiting parse promises the terminal buffer state may not change. - * --> Implement lock semantics / promise chaining on buffer alterations? Waah, pandora's box ;) - * --> Maybe easier: Give up on non-mutating rule for async handlers... - * (needs explanation in docs about exact executor/thenable/worker execution contexts) - * * Boilerplate for proper parsing of multiple chunks with async handlers: * * ```typescript @@ -515,84 +525,95 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP // resume from async handler if (this._parseStack.state) { - if (promiseResult === undefined || this._parseStack.state === ParserStackType.FAIL) { - /** - * Reject further parsing on improper continuation after pausing. - * This is a really bad condition with screwed up execution order and messed up terminal state, - * therefore we exit hard with an exception and reject any further parsing. - * - * Note: With `Terminal.write` usage this exception should never occur, as the top level - * calls are guaranteed to handle async conditions properly. If you ever encounter this - * exception in your terminal integration it indicates, that you injected data chunks to - * `InputHandler.parse` or `EscapeSequenceParser.parse` synchronously without waiting for - * continuation of a running async handler. - */ - this._parseStack.state = ParserStackType.FAIL; - throw new Error('improper continuation due to previous async handler, giving up parsing'); - } + // allow sync parser reset even in continuation mode + // Note: can be used to recover parser from improper continuation error above + if (this._parseStack.state === ParserStackType.RESET) { + this._parseStack.state = ParserStackType.NONE; + start = this._parseStack.chunkPos + 1; // continue with next codepoint in GROUND + } else { + if (promiseResult === undefined || this._parseStack.state === ParserStackType.FAIL) { + /** + * Reject further parsing on improper continuation after pausing. + * This is a really bad condition with screwed up execution order and messed up terminal state, + * therefore we exit hard with an exception and reject any further parsing. + * + * Note: With `Terminal.write` usage this exception should never occur, as the top level + * calls are guaranteed to handle async conditions properly. If you ever encounter this + * exception in your terminal integration it indicates, that you injected data chunks to + * `InputHandler.parse` or `EscapeSequenceParser.parse` synchronously without waiting for + * continuation of a running async handler. + * + * Its possible to get rid of this error condition by calling `reset`, but dont rely on that, + * as the pending async handler might mess up the terminal even further. Instead fix the faulty + * async handling, so this error will not be thrown anymore. + */ + this._parseStack.state = ParserStackType.FAIL; + throw new Error('improper continuation due to previous async handler, giving up parsing'); + } - // we have to resume the old handler loop if: - // - return value of the promise was `false` - // - handlers are not exhausted yet - // FIXME: removing handlers from within a handler of the same sequence - // is not supported atm (also true for sync handlers)!! - const handlers = this._parseStack.handlers; - let handlerPos = this._parseStack.handlerPos - 1; - switch (this._parseStack.state) { - case ParserStackType.CSI: - if (promiseResult === false && handlerPos > -1) { - for (; handlerPos >= 0; handlerPos--) { - if ((handlerResult = (handlers as CsiHandlerType[])[handlerPos](this._params)) !== false) { - if (handlerResult instanceof Promise) { - this._parseStack.handlerPos = handlerPos; - return handlerResult; + // we have to resume the old handler loop if: + // - return value of the promise was `false` + // - handlers are not exhausted yet + // FIXME: removing handlers from within a handler of the same sequence + // is not supported atm (also true for sync handlers)!! + const handlers = this._parseStack.handlers; + let handlerPos = this._parseStack.handlerPos - 1; + switch (this._parseStack.state) { + case ParserStackType.CSI: + if (promiseResult === false && handlerPos > -1) { + for (; handlerPos >= 0; handlerPos--) { + if ((handlerResult = (handlers as CsiHandlerType[])[handlerPos](this._params)) !== false) { + if (handlerResult instanceof Promise) { + this._parseStack.handlerPos = handlerPos; + return handlerResult; + } + break; } - break; } } - } - this._parseStack.handlers = []; - break; - case ParserStackType.ESC: - if (promiseResult === false && handlerPos > -1) { - for (; handlerPos >= 0; handlerPos--) { - if ((handlerResult = (handlers as EscHandlerType[])[handlerPos]()) !== false) { - if (handlerResult instanceof Promise) { - this._parseStack.handlerPos = handlerPos; - return handlerResult; + this._parseStack.handlers = []; + break; + case ParserStackType.ESC: + if (promiseResult === false && handlerPos > -1) { + for (; handlerPos >= 0; handlerPos--) { + if ((handlerResult = (handlers as EscHandlerType[])[handlerPos]()) !== false) { + if (handlerResult instanceof Promise) { + this._parseStack.handlerPos = handlerPos; + return handlerResult; + } + break; } - break; } } - } - this._parseStack.handlers = []; - break; - case ParserStackType.DCS: - code = data[this._parseStack.chunkPos]; - if (handlerResult = this._dcsParser.unhook(code !== 0x18 && code !== 0x1a, promiseResult)) { - return handlerResult; - } - if (code === 0x1b) this._parseStack.transition |= ParserState.ESCAPE; - this._params.reset(); - this._params.addParam(0); // ZDM - this._collect = 0; - break; - case ParserStackType.OSC: - code = data[this._parseStack.chunkPos]; - if (handlerResult = this._oscParser.end(code !== 0x18 && code !== 0x1a, promiseResult)) { - return handlerResult; - } - if (code === 0x1b) this._parseStack.transition |= ParserState.ESCAPE; - this._params.reset(); - this._params.addParam(0); // ZDM - this._collect = 0; - break; + this._parseStack.handlers = []; + break; + case ParserStackType.DCS: + code = data[this._parseStack.chunkPos]; + if (handlerResult = this._dcsParser.unhook(code !== 0x18 && code !== 0x1a, promiseResult)) { + return handlerResult; + } + if (code === 0x1b) this._parseStack.transition |= ParserState.ESCAPE; + this._params.reset(); + this._params.addParam(0); // ZDM + this._collect = 0; + break; + case ParserStackType.OSC: + code = data[this._parseStack.chunkPos]; + if (handlerResult = this._oscParser.end(code !== 0x18 && code !== 0x1a, promiseResult)) { + return handlerResult; + } + if (code === 0x1b) this._parseStack.transition |= ParserState.ESCAPE; + this._params.reset(); + this._params.addParam(0); // ZDM + this._collect = 0; + break; + } + // cleanup before continuing with the main sync loop + this._parseStack.state = ParserStackType.NONE; + start = this._parseStack.chunkPos + 1; + this.precedingCodepoint = 0; + this.currentState = this._parseStack.transition & TableAccess.TRANSITION_STATE_MASK; } - // cleanup before continuing with the main sync loop - this._parseStack.state = ParserStackType.NONE; - start = this._parseStack.chunkPos + 1; - this.precedingCodepoint = 0; - this.currentState = this._parseStack.transition & TableAccess.TRANSITION_STATE_MASK; } // continue with main sync loop diff --git a/src/common/parser/OscParser.ts b/src/common/parser/OscParser.ts index b0b51e23..1516308c 100644 --- a/src/common/parser/OscParser.ts +++ b/src/common/parser/OscParser.ts @@ -46,10 +46,13 @@ export class OscParser implements IOscParser { } public reset(): void { - // cleanup handlers if payload was already sent + // force cleanup handlers if payload was already sent if (this._state === OscState.PAYLOAD) { - this.end(false); + for (let j = this._stack.paused ? this._stack.loopPosition - 1 : this._active.length - 1; j >= 0; --j) { + this._active[j].end(false); + } } + this._stack.paused = false; this._active = EMPTY_HANDLERS; this._id = -1; this._state = OscState.START; diff --git a/src/common/parser/Types.d.ts b/src/common/parser/Types.d.ts index dda798cc..26a02e83 100644 --- a/src/common/parser/Types.d.ts +++ b/src/common/parser/Types.d.ts @@ -245,6 +245,7 @@ export interface IHandlerCollection { export const enum ParserStackType { NONE = 0, FAIL, + RESET, CSI, ESC, OSC, From cc005a274dc440c40cf985fe1ebfa184e2f0f517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sat, 27 Feb 2021 20:18:41 +0100 Subject: [PATCH 104/377] multiple changes: - reorder exception throwing to be sync to band position - document WriteBuffer._innerWrite - remove any declarations - remove conditional assigments - use faster return value branching in all parsers - remove dead code in benchmark --- src/common/InputHandler.ts | 4 +- src/common/input/WriteBuffer.ts | 57 +++++++++++++++++++---- src/common/parser/DcsParser.ts | 28 +++++------ src/common/parser/EscapeSequenceParser.ts | 55 ++++++++++++---------- src/common/parser/OscParser.ts | 26 ++++++----- test/benchmark/Terminal.benchmark.ts | 22 --------- 6 files changed, 111 insertions(+), 81 deletions(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 08f04d9e..f663ded7 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -488,8 +488,8 @@ export class InputHandler extends Disposable implements IInputHandler { * execution stopped at async handler, stack saved, continue with * same chunk and the promise resolve value as `promiseResult` until the method returns `undefined` * - * Note: Never call this directly for a running terminal instance in production. - * Always use `Terminal.write`, which provides in-band blocking and correct exection order. + * Note: This method should only be called by `Terminal.write` to ensure correct execution order and + * proper continuation of async parser handlers. */ public parse(data: string | Uint8Array, promiseResult?: boolean): void | Promise { let result: void | Promise; diff --git a/src/common/input/WriteBuffer.ts b/src/common/input/WriteBuffer.ts index c6178024..a2c70004 100644 --- a/src/common/input/WriteBuffer.ts +++ b/src/common/input/WriteBuffer.ts @@ -31,6 +31,12 @@ const WRITE_TIMEOUT_MS = 12; */ const WRITE_BUFFER_LENGTH_THRESHOLD = 50; +// queueMicrotask polyfill for nodejs < v11 +const qmt: (cb: () => void) => void = (typeof queueMicrotask === 'undefined') + ? (cb: () => void) => { Promise.resolve().then(cb); } + : queueMicrotask; + + export class WriteBuffer { private _writeBuffer: (string | Uint8Array)[] = []; private _callbacks: ((() => void) | undefined)[] = []; @@ -39,7 +45,9 @@ export class WriteBuffer { constructor(private _action: (data: string | Uint8Array, promiseResult?: boolean) => void | Promise) { } - // FIXME: does not work that way anymore with async handlers!!! + /** + * @deprecated Unreliable, to be removed soon. + */ public writeSync(data: string | Uint8Array): void { // force sync processing on pending data chunks to avoid in-band data scrambling // does the same as innerWrite but without event loop @@ -77,13 +85,40 @@ export class WriteBuffer { this._callbacks.push(callback); } - protected _innerWrite(d: number = 0, promiseResult: boolean = true): void { - let result: void | Promise; - const startTime = d || Date.now(); + /** + * Inner write call, that enters the sliced chunk processing by timing. + * + * `lastTime` indicates, when the last _innerWrite call had started. + * It is used to aggregate async handler execution under a timeout constraint + * effectively lowering the redrawing needs, schematically: + * + * macroTask _innerWrite: + * if (Date.now() - (lastTime | 0) < WRITE_TIMEOUT_MS): + * schedule microTask _innerWrite(lastTime) + * else: + * schedule macroTask _innerWrite(0) + * + * overall execution order on task queues: + * + * macrotasks: [...] --> _innerWrite(0) --> [...] --> screenUpdate --> [...] + * m t: | + * i a: [...] + * c s: | + * r k: while < timeout: + * o s: _innerWrite(timeout) + * + * `promiseResult` depicts the promise resolve value of an async handler. + * This value gets carried forward through all saved stack states of the + * paused parser for proper continuation. + * + * Note, for pure sync code `lastTime` and `promiseResult` have no meaning. + */ + protected _innerWrite(lastTime: number = 0, promiseResult: boolean = true): void { + const startTime = lastTime || Date.now(); while (this._writeBuffer.length > this._bufferOffset) { const data = this._writeBuffer[this._bufferOffset]; - - if (result = this._action(data, promiseResult)) { + const result = this._action(data, promiseResult); + if (result) { /** * If we get a promise as return value, we re-schedule the continuation * as thenable on the promise and exit right away. @@ -98,7 +133,6 @@ export class WriteBuffer { * * Exceptions on async handlers will be logged to console async, but do not interrupt * the input processing (continues with next handler at the current input position). - * FIXME: No clear exception handling rules for sync handlers yet (will exit whole processing?). */ /** @@ -127,7 +161,14 @@ export class WriteBuffer { // ? r => setTimeout(() => this._innerWrite(0, r)) // : r => this._innerWrite(startTime, r); - result.then(continuation, err => { setTimeout(() => { throw err; }); continuation(true); }); + // Handle exceptions synchronously to current band position, idea: + // 1. spawn a single microtask which we allow to throw hard + // 2. spawn a promise immediately resolving to `true` + // (executed on the same queue, thus properly aligned before continuation happens) + result.catch(err => { + qmt(() => {throw err;}); + return Promise.resolve(true); + }).then(continuation); return; } diff --git a/src/common/parser/DcsParser.ts b/src/common/parser/DcsParser.ts index 5389b828..6b5ddd6e 100644 --- a/src/common/parser/DcsParser.ts +++ b/src/common/parser/DcsParser.ts @@ -88,11 +88,11 @@ export class DcsParser implements IDcsParser { loopPosition: 0, fallThrough: false }; - public unhook(success: boolean, promiseResult?: boolean): void | Promise { + public unhook(success: boolean, promiseResult: boolean = true): void | Promise { if (!this._active.length) { this._handlerFb(this._ident, 'UNHOOK', success); } else { - let handlerResult: any = false; + let handlerResult: boolean | Promise = false; let j = this._active.length - 1; let fallThrough = false; if (this._stack.paused) { @@ -103,21 +103,22 @@ export class DcsParser implements IDcsParser { } if (!fallThrough && handlerResult === false) { for (; j >= 0; j--) { - if ((handlerResult = this._active[j].unhook(success)) !== false) { - if (handlerResult instanceof Promise) { - this._stack.paused = true; - this._stack.loopPosition = j; - this._stack.fallThrough = false; - return handlerResult; - } + handlerResult = this._active[j].unhook(success); + if (handlerResult === true) { break; + } else if (handlerResult instanceof Promise) { + this._stack.paused = true; + this._stack.loopPosition = j; + this._stack.fallThrough = false; + return handlerResult; } } j--; } // cleanup left over handlers (fallThrough for async) for (; j >= 0; j--) { - if ((handlerResult = this._active[j].unhook(false)) instanceof Promise) { + handlerResult = this._active[j].unhook(false); + if (handlerResult instanceof Promise) { this._stack.paused = true; this._stack.loopPosition = j; this._stack.fallThrough = true; @@ -171,10 +172,11 @@ export class DcsHandler implements IDcsHandler { if (this._hitLimit) { ret = false; } else if (success) { - if ((ret = this._handler(this._data, this._params)) instanceof Promise) { - // FIXME: should this be behind a catch rule? + ret = this._handler(this._data, this._params); + if (ret instanceof Promise) { + // need to hold data and params until `ret` got resolved + // dont care for errors, data will be freed anyway on next start return ret.then(res => { - // cleanup handler state late this._params = EMPTY_PARAMS; this._data = ''; this._hitLimit = false; diff --git a/src/common/parser/EscapeSequenceParser.ts b/src/common/parser/EscapeSequenceParser.ts index 9ed3e462..c1d80c5c 100644 --- a/src/common/parser/EscapeSequenceParser.ts +++ b/src/common/parser/EscapeSequenceParser.ts @@ -468,7 +468,8 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP handlers: ResumableHandlersType, handlerPos: number, transition: number, - chunkPos: number): void { + chunkPos: number + ): void { this._parseStack.state = state; this._parseStack.handlers = handlers; this._parseStack.handlerPos = handlerPos; @@ -521,12 +522,12 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP let code = 0; let transition = 0; let start = 0; - let handlerResult: any; + let handlerResult: void | boolean | Promise; // resume from async handler if (this._parseStack.state) { // allow sync parser reset even in continuation mode - // Note: can be used to recover parser from improper continuation error above + // Note: can be used to recover parser from improper continuation error below if (this._parseStack.state === ParserStackType.RESET) { this._parseStack.state = ParserStackType.NONE; start = this._parseStack.chunkPos + 1; // continue with next codepoint in GROUND @@ -534,8 +535,8 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP if (promiseResult === undefined || this._parseStack.state === ParserStackType.FAIL) { /** * Reject further parsing on improper continuation after pausing. - * This is a really bad condition with screwed up execution order and messed up terminal state, - * therefore we exit hard with an exception and reject any further parsing. + * This is a really bad condition with screwed up execution order and prolly messed up + * terminal state, therefore we exit hard with an exception and reject any further parsing. * * Note: With `Terminal.write` usage this exception should never occur, as the top level * calls are guaranteed to handle async conditions properly. If you ever encounter this @@ -543,8 +544,8 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP * `InputHandler.parse` or `EscapeSequenceParser.parse` synchronously without waiting for * continuation of a running async handler. * - * Its possible to get rid of this error condition by calling `reset`, but dont rely on that, - * as the pending async handler might mess up the terminal even further. Instead fix the faulty + * It is possible to get rid of this error by calling `reset`. But dont rely on that, + * as the pending async handler still might mess up the terminal later. Instead fix the faulty * async handling, so this error will not be thrown anymore. */ this._parseStack.state = ParserStackType.FAIL; @@ -554,20 +555,18 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP // we have to resume the old handler loop if: // - return value of the promise was `false` // - handlers are not exhausted yet - // FIXME: removing handlers from within a handler of the same sequence - // is not supported atm (also true for sync handlers)!! const handlers = this._parseStack.handlers; let handlerPos = this._parseStack.handlerPos - 1; switch (this._parseStack.state) { case ParserStackType.CSI: if (promiseResult === false && handlerPos > -1) { for (; handlerPos >= 0; handlerPos--) { - if ((handlerResult = (handlers as CsiHandlerType[])[handlerPos](this._params)) !== false) { - if (handlerResult instanceof Promise) { - this._parseStack.handlerPos = handlerPos; - return handlerResult; - } + handlerResult = (handlers as CsiHandlerType[])[handlerPos](this._params); + if (handlerResult === true) { break; + } else if (handlerResult instanceof Promise) { + this._parseStack.handlerPos = handlerPos; + return handlerResult; } } } @@ -576,12 +575,12 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP case ParserStackType.ESC: if (promiseResult === false && handlerPos > -1) { for (; handlerPos >= 0; handlerPos--) { - if ((handlerResult = (handlers as EscHandlerType[])[handlerPos]()) !== false) { - if (handlerResult instanceof Promise) { - this._parseStack.handlerPos = handlerPos; - return handlerResult; - } + handlerResult = (handlers as EscHandlerType[])[handlerPos](); + if (handlerResult === true) { break; + } else if (handlerResult instanceof Promise) { + this._parseStack.handlerPos = handlerPos; + return handlerResult; } } } @@ -589,7 +588,8 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP break; case ParserStackType.DCS: code = data[this._parseStack.chunkPos]; - if (handlerResult = this._dcsParser.unhook(code !== 0x18 && code !== 0x1a, promiseResult)) { + handlerResult = this._dcsParser.unhook(code !== 0x18 && code !== 0x1a, promiseResult); + if (handlerResult) { return handlerResult; } if (code === 0x1b) this._parseStack.transition |= ParserState.ESCAPE; @@ -599,7 +599,8 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP break; case ParserStackType.OSC: code = data[this._parseStack.chunkPos]; - if (handlerResult = this._oscParser.end(code !== 0x18 && code !== 0x1a, promiseResult)) { + handlerResult = this._oscParser.end(code !== 0x18 && code !== 0x1a, promiseResult); + if (handlerResult) { return handlerResult; } if (code === 0x1b) this._parseStack.transition |= ParserState.ESCAPE; @@ -678,7 +679,8 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP for (; j >= 0; j--) { // true means success and to stop bubbling // a promise indicates an async handler that needs to finish before progressing - if ((handlerResult = handlers[j](this._params)) === true) { + handlerResult = handlers[j](this._params); + if (handlerResult === true) { break; } else if (handlerResult instanceof Promise) { this._preserveStack(ParserStackType.CSI, handlers, j, transition, i); @@ -716,7 +718,8 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP for (; jj >= 0; jj--) { // true means success and to stop bubbling // a promise indicates an async handler that needs to finish before progressing - if ((handlerResult = handlersEsc[jj]()) === true) { + handlerResult = handlersEsc[jj](); + if (handlerResult === true) { break; } else if (handlerResult instanceof Promise) { this._preserveStack(ParserStackType.ESC, handlersEsc, jj, transition, i); @@ -748,7 +751,8 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP } break; case ParserAction.DCS_UNHOOK: - if (handlerResult = this._dcsParser.unhook(code !== 0x18 && code !== 0x1a)) { + handlerResult = this._dcsParser.unhook(code !== 0x18 && code !== 0x1a); + if (handlerResult) { this._preserveStack(ParserStackType.DCS, [], 0, transition, i); return handlerResult; } @@ -772,7 +776,8 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP } break; case ParserAction.OSC_END: - if (handlerResult = this._oscParser.end(code !== 0x18 && code !== 0x1a)) { + handlerResult = this._oscParser.end(code !== 0x18 && code !== 0x1a); + if (handlerResult) { this._preserveStack(ParserStackType.OSC, [], 0, transition, i); return handlerResult; } diff --git a/src/common/parser/OscParser.ts b/src/common/parser/OscParser.ts index 1516308c..f043bd82 100644 --- a/src/common/parser/OscParser.ts +++ b/src/common/parser/OscParser.ts @@ -130,7 +130,7 @@ export class OscParser implements IOscParser { * Whether the OSC got aborted or finished normally * is indicated by `success`. */ - public end(success: boolean, promiseResult?: boolean): void | Promise { + public end(success: boolean, promiseResult: boolean = true): void | Promise { if (this._state === OscState.START) { return; } @@ -146,7 +146,7 @@ export class OscParser implements IOscParser { if (!this._active.length) { this._handlerFb(this._id, 'END', success); } else { - let handlerResult: any = false; + let handlerResult: boolean | Promise = false; let j = this._active.length - 1; let fallThrough = false; if (this._stack.paused) { @@ -157,14 +157,14 @@ export class OscParser implements IOscParser { } if (!fallThrough && handlerResult === false) { for (; j >= 0; j--) { - if ((handlerResult = this._active[j].end(success)) !== false) { - if (handlerResult instanceof Promise) { - this._stack.paused = true; - this._stack.loopPosition = j; - this._stack.fallThrough = false; - return handlerResult; - } + handlerResult = this._active[j].end(success); + if (handlerResult === true) { break; + } else if (handlerResult instanceof Promise) { + this._stack.paused = true; + this._stack.loopPosition = j; + this._stack.fallThrough = false; + return handlerResult; } } j--; @@ -173,7 +173,8 @@ export class OscParser implements IOscParser { // we always have to call .end for proper cleanup, // here we use `success` to indicate whether a handler should execute for (; j >= 0; j--) { - if ((handlerResult = this._active[j].end(false)) instanceof Promise) { + handlerResult = this._active[j].end(false); + if (handlerResult instanceof Promise) { this._stack.paused = true; this._stack.loopPosition = j; this._stack.fallThrough = true; @@ -220,7 +221,10 @@ export class OscHandler implements IOscHandler { if (this._hitLimit) { ret = false; } else if (success) { - if ((ret = this._handler(this._data)) instanceof Promise) { + ret = this._handler(this._data); + if (ret instanceof Promise) { + // need to hold data until `ret` got resolved + // dont care for errors, data will be freed anyway on next start return ret.then(res => { this._data = ''; this._hitLimit = false; diff --git a/test/benchmark/Terminal.benchmark.ts b/test/benchmark/Terminal.benchmark.ts index 7d0f5d84..40a3c208 100644 --- a/test/benchmark/Terminal.benchmark.ts +++ b/test/benchmark/Terminal.benchmark.ts @@ -44,28 +44,6 @@ perfContext('Terminal: ls -lR /usr/lib', () => { } }); - // perfContext('write/string/sync', () => { - // let terminal: Terminal; - // before(() => { - // terminal = new Terminal({cols: 80, rows: 25, scrollback: 1000}); - // }); - // new ThroughputRuntimeCase('', () => { - // terminal.writeSync(content); - // return {payloadSize: contentUtf8.length}; - // }, {fork: false}).showAverageThroughput(); - // }); - // - // perfContext('write/Utf8/sync', () => { - // let terminal: Terminal; - // before(() => { - // terminal = new Terminal({cols: 80, rows: 25, scrollback: 1000}); - // }); - // new ThroughputRuntimeCase('', () => { - // terminal.writeSync(content); - // return {payloadSize: contentUtf8.length}; - // }, {fork: false}).showAverageThroughput(); - // }); - perfContext('write/string/async', () => { let terminal: Terminal; before(() => { From 48a93c379fb2aa04a02317ae9c6768d1c7cc9465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sat, 27 Feb 2021 22:24:55 +0100 Subject: [PATCH 105/377] log a warning if an async handler takes too long --- src/common/InputHandler.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index f663ded7..228df3a3 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -20,6 +20,7 @@ import { AttributeData } from 'common/buffer/AttributeData'; import { ICoreService, IBufferService, IOptionsService, ILogService, IDirtyRowService, ICoreMouseService, ICharsetService, IUnicodeService } from 'common/services/Services'; import { OscHandler } from 'common/parser/OscParser'; import { DcsHandler } from 'common/parser/DcsParser'; +import { LogLevel } from 'common/services/LogService'; /** * Map collect to glevel. Used in `selectCharset`. @@ -97,6 +98,9 @@ export enum WindowsOptionsReportType { GET_CELL_SIZE_PIXELS = 1 } +// create a warning log if an async handler takes longer than the limit (in ms) +const SLOW_ASYNC_LIMIT = 5000; + /** * DCS subparser implementations */ @@ -477,6 +481,13 @@ export class InputHandler extends Disposable implements IInputHandler { this._parseStack.decodedLength = decodedLength; this._parseStack.position = position; } + private _logSlowResolvingAsync(p: Promise): void { + // log a limited warning about an async taking too long + if ((this._logService as any)._logLevel <= LogLevel.WARN) { + Promise.race([p, new Promise((res, rej) => setTimeout(rej, SLOW_ASYNC_LIMIT))]) + .catch(() => console.warn(`async parser handler taking longer than ${SLOW_ASYNC_LIMIT} ms`)); + } + } /** * Parse call with async handler support. @@ -502,6 +513,7 @@ export class InputHandler extends Disposable implements IInputHandler { if (wasPaused) { // assumption: _parseBuffer never mutates between async calls if (result = this._parser.parse(this._parseBuffer, this._parseStack.decodedLength, promiseResult)) { + this._logSlowResolvingAsync(result); return result; } cursorStartX = this._parseStack.cursorStartX; @@ -536,6 +548,7 @@ export class InputHandler extends Disposable implements IInputHandler { : this._utf8Decoder.decode(data.subarray(i, end), this._parseBuffer); if (result = this._parser.parse(this._parseBuffer, len)) { this._preserveStack(cursorStartX, cursorStartY, len, i); + this._logSlowResolvingAsync(result); return result; } } @@ -546,6 +559,7 @@ export class InputHandler extends Disposable implements IInputHandler { : this._utf8Decoder.decode(data, this._parseBuffer); if (result = this._parser.parse(this._parseBuffer, len)) { this._preserveStack(cursorStartX, cursorStartY, len, 0); + this._logSlowResolvingAsync(result); return result; } } From cdd238d75e72b9ffe3b484242caa87be2cccd58b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sun, 28 Feb 2021 13:53:06 +0100 Subject: [PATCH 106/377] do not timeout on faulty async handlers, continue with false to give default handlers chance to run --- src/common/InputHandler.ts | 9 +++++++-- src/common/input/WriteBuffer.ts | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 228df3a3..7ab2a186 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -484,8 +484,13 @@ export class InputHandler extends Disposable implements IInputHandler { private _logSlowResolvingAsync(p: Promise): void { // log a limited warning about an async taking too long if ((this._logService as any)._logLevel <= LogLevel.WARN) { - Promise.race([p, new Promise((res, rej) => setTimeout(rej, SLOW_ASYNC_LIMIT))]) - .catch(() => console.warn(`async parser handler taking longer than ${SLOW_ASYNC_LIMIT} ms`)); + Promise.race([p, new Promise((res, rej) => setTimeout(() => rej('#SLOW_TIMEOUT'), SLOW_ASYNC_LIMIT))]) + .catch(err => { + if (err !== '#SLOW_TIMEOUT') { + throw err; + } + console.warn(`async parser handler taking longer than ${SLOW_ASYNC_LIMIT} ms`); + }); } } diff --git a/src/common/input/WriteBuffer.ts b/src/common/input/WriteBuffer.ts index a2c70004..d22de912 100644 --- a/src/common/input/WriteBuffer.ts +++ b/src/common/input/WriteBuffer.ts @@ -167,7 +167,7 @@ export class WriteBuffer { // (executed on the same queue, thus properly aligned before continuation happens) result.catch(err => { qmt(() => {throw err;}); - return Promise.resolve(true); + return Promise.resolve(false); }).then(continuation); return; } From 9b3fbc9b84e49928989f03b2dcaab72f9c73e922 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Tue, 9 Mar 2021 10:18:14 -0800 Subject: [PATCH 107/377] v 4.11.0 --- addons/xterm-addon-serialize/package.json | 2 +- addons/xterm-addon-webgl/package.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/xterm-addon-serialize/package.json b/addons/xterm-addon-serialize/package.json index bb799aec..770771c4 100644 --- a/addons/xterm-addon-serialize/package.json +++ b/addons/xterm-addon-serialize/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-serialize", - "version": "0.4.0", + "version": "0.5.0", "author": { "name": "The xterm.js authors", "url": "https://xtermjs.org/" diff --git a/addons/xterm-addon-webgl/package.json b/addons/xterm-addon-webgl/package.json index c0e91b37..28c6f5bc 100644 --- a/addons/xterm-addon-webgl/package.json +++ b/addons/xterm-addon-webgl/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-webgl", - "version": "0.9.0", + "version": "0.10.0", "author": { "name": "The xterm.js authors", "url": "https://xtermjs.org/" diff --git a/package.json b/package.json index 91d9a646..9134a378 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "xterm", "description": "Full xterm terminal, in your browser", - "version": "4.10.0", + "version": "4.11.0", "main": "lib/xterm.js", "style": "css/xterm.css", "types": "typings/xterm.d.ts", From 7968b7ce7e5811e684dc02f3ac42511ca68cae2f Mon Sep 17 00:00:00 2001 From: Python-37 <19404655+Python-37@users.noreply.github.com> Date: Wed, 10 Mar 2021 17:27:58 +0800 Subject: [PATCH 108/377] Fix bug of some IMEs cannot input in terminal Fix bug of QQ pinyin and Rime IME cannot input characters in terminal. --- css/xterm.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css/xterm.css b/css/xterm.css index 7ddcc2d0..bbadb190 100644 --- a/css/xterm.css +++ b/css/xterm.css @@ -59,7 +59,7 @@ } .xterm .xterm-helper-textarea { - padding: 0; +/* padding: 0; */ border: 0; margin: 0; /* Move textarea out of the screen to the far left, so that the cursor is not visible */ From 5185e5f894527080c778e92794922d52bd8c783f Mon Sep 17 00:00:00 2001 From: Martin Sander Date: Mon, 25 Jan 2021 00:12:47 +0100 Subject: [PATCH 109/377] Use linkifier2 to double click select links Also works with right click select. Fixes #682. --- src/browser/Linkifier2.ts | 13 ++------- src/browser/Terminal.ts | 4 ++- src/browser/Types.d.ts | 10 +++++++ src/browser/services/SelectionService.test.ts | 2 +- src/browser/services/SelectionService.ts | 27 +++++++++++++------ 5 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/browser/Linkifier2.ts b/src/browser/Linkifier2.ts index 73ea0268..89542936 100644 --- a/src/browser/Linkifier2.ts +++ b/src/browser/Linkifier2.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { ILinkifier2, ILinkProvider, IBufferCellPosition, ILink, ILinkifierEvent, ILinkDecorations } from 'browser/Types'; +import { ILinkifier2, ILinkProvider, IBufferCellPosition, ILink, ILinkifierEvent, ILinkDecorations, ILinkWithState } from 'browser/Types'; import { IDisposable } from 'common/Types'; import { IMouseService, IRenderService } from './services/Services'; import { IBufferService } from 'common/services/Services'; @@ -11,21 +11,12 @@ import { EventEmitter, IEvent } from 'common/EventEmitter'; import { Disposable, getDisposeArrayDisposable, disposeArray } from 'common/Lifecycle'; import { addDisposableDomListener } from 'browser/Lifecycle'; -interface ILinkState { - decorations: ILinkDecorations; - isHovered: boolean; -} - -interface ILinkWithState { - link: ILink; - state?: ILinkState; -} - export class Linkifier2 extends Disposable implements ILinkifier2 { private _element: HTMLElement | undefined; private _mouseService: IMouseService | undefined; private _renderService: IRenderService | undefined; private _linkProviders: ILinkProvider[] = []; + public get currentLink(): ILinkWithState | undefined { return this._currentLink; } protected _currentLink: ILinkWithState | undefined; private _lastMouseEvent: MouseEvent | undefined; private _linkCacheDisposables: IDisposable[] = []; diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index b0964c21..03ee1f10 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -482,7 +482,9 @@ export class Terminal extends CoreTerminal implements ITerminal { this._selectionService = this.register(this._instantiationService.createInstance(SelectionService, this.element, - this.screenElement)); + this.screenElement, + this.linkifier2 + )); this._instantiationService.setService(ISelectionService, this._selectionService); this.register(this._selectionService.onRequestScrollLines(e => this.scrollLines(e.amount, e.suppressScrollEvent))); this.register(this._selectionService.onSelectionChange(() => this._onSelectionChange.fire())); diff --git a/src/browser/Types.d.ts b/src/browser/Types.d.ts index e8e0cabd..44849b70 100644 --- a/src/browser/Types.d.ts +++ b/src/browser/Types.d.ts @@ -205,9 +205,19 @@ export interface ILinkifier { deregisterLinkMatcher(matcherId: number): boolean; } +interface ILinkState { + decorations: ILinkDecorations; + isHovered: boolean; +} +export interface ILinkWithState { + link: ILink; + state?: ILinkState; +} + export interface ILinkifier2 { onShowLinkUnderline: IEvent; onHideLinkUnderline: IEvent; + currentLink: ILinkWithState | undefined; attachToDom(element: HTMLElement, mouseService: IMouseService, renderService: IRenderService): void; registerLinkProvider(linkProvider: ILinkProvider): IDisposable; diff --git a/src/browser/services/SelectionService.test.ts b/src/browser/services/SelectionService.test.ts index eb90ba44..514d5803 100644 --- a/src/browser/services/SelectionService.test.ts +++ b/src/browser/services/SelectionService.test.ts @@ -21,7 +21,7 @@ class TestSelectionService extends SelectionService { optionsService: IOptionsService, renderService: IRenderService ) { - super(null!, null!, bufferService, new MockCoreService(), new MockMouseService(), optionsService, renderService); + super(null!, null!, null!, bufferService, new MockCoreService(), new MockMouseService(), optionsService, renderService); } public get model(): SelectionModel { return this._model; } diff --git a/src/browser/services/SelectionService.ts b/src/browser/services/SelectionService.ts index 3b993876..547bba4a 100644 --- a/src/browser/services/SelectionService.ts +++ b/src/browser/services/SelectionService.ts @@ -11,6 +11,7 @@ import { SelectionModel } from 'browser/selection/SelectionModel'; import { CellData } from 'common/buffer/CellData'; import { EventEmitter, IEvent } from 'common/EventEmitter'; import { ICharSizeService, IMouseService, ISelectionService, IRenderService } from 'browser/services/Services'; +import { ILinkifier2 } from 'browser/Types'; import { IBufferService, IOptionsService, ICoreService } from 'common/services/Services'; import { getCoordsRelativeToElement } from 'browser/input/Mouse'; import { moveToCellSequence } from 'browser/input/MoveToCell'; @@ -121,6 +122,7 @@ export class SelectionService extends Disposable implements ISelectionService { constructor( private readonly _element: HTMLElement, private readonly _screenElement: HTMLElement, + private readonly _linkifier: ILinkifier2, @IBufferService private readonly _bufferService: IBufferService, @ICoreService private readonly _coreService: ICoreService, @IMouseService private readonly _mouseService: IMouseService, @@ -316,13 +318,22 @@ export class SelectionService extends Disposable implements ISelectionService { * Selects word at the current mouse event coordinates. * @param event The mouse event. */ - private _selectWordAtCursor(event: MouseEvent): void { + private _selectWordAtCursor(event: MouseEvent, allowWhitespaceOnlySelection: boolean): boolean { + const range = this._linkifier.currentLink?.link?.range; + if (range) { + const scrollOffset = this._bufferService.buffer.ydisp; + this._model.selectionStart = [range.start.x - 1, range.start.y - scrollOffset - 1]; + this._model.selectionEnd = [range.end.x, range.end.y - scrollOffset - 1]; + return true; + } + const coords = this._getMouseBufferCoords(event); if (coords) { - this._selectWordAt(coords, false); + this._selectWordAt(coords, allowWhitespaceOnlySelection); this._model.selectionEnd = undefined; - this.refresh(true); + return true; } + return false; } /** @@ -527,14 +538,12 @@ export class SelectionService extends Disposable implements ISelectionService { } /** - * Performs a double click, selecting the current work. + * Performs a double click, selecting the current word. * @param event The mouse event. */ private _onDoubleClick(event: MouseEvent): void { - const coords = this._getMouseBufferCoords(event); - if (coords) { + if (this._selectWordAtCursor(event, true)) { this._activeSelectionMode = SelectionMode.WORD; - this._selectWordAt(coords, true); } } @@ -764,7 +773,9 @@ export class SelectionService extends Disposable implements ISelectionService { public rightClickSelect(ev: MouseEvent): void { if (!this._isClickInSelection(ev)) { - this._selectWordAtCursor(ev); + if (this._selectWordAtCursor(ev, false)) { + this.refresh(true); + } this._fireEventIfSelectionChanged(); } } From 8e7cdd25874c2792497888313c46e6dcd59c1242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Wed, 17 Mar 2021 22:29:01 +0100 Subject: [PATCH 110/377] interface for inputhandler parse stack, proper typing of LogService.logLevel --- src/common/InputHandler.ts | 25 +++++++++++----------- src/common/TestUtils.test.ts | 3 ++- src/common/Types.d.ts | 10 ++++++++- src/common/services/LogService.ts | 35 ++++++++++++------------------- src/common/services/Services.ts | 9 ++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 7ab2a186..a35f7981 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -4,7 +4,7 @@ * @license MIT */ -import { IInputHandler, IAttributeData, IDisposable, IWindowOptions, IAnsiColorChangeEvent } from 'common/Types'; +import { IInputHandler, IAttributeData, IDisposable, IWindowOptions, IAnsiColorChangeEvent, IParseStack } from 'common/Types'; import { C0, C1 } from 'common/data/EscapeSequences'; import { CHARSETS, DEFAULT_CHARSET } from 'common/data/Charsets'; import { EscapeSequenceParser } from 'common/parser/EscapeSequenceParser'; @@ -17,10 +17,9 @@ import { IParsingState, IDcsHandler, IEscapeSequenceParser, IParams, IFunctionId import { NULL_CELL_CODE, NULL_CELL_WIDTH, Attributes, FgFlags, BgFlags, Content, UnderlineStyle } from 'common/buffer/Constants'; import { CellData } from 'common/buffer/CellData'; import { AttributeData } from 'common/buffer/AttributeData'; -import { ICoreService, IBufferService, IOptionsService, ILogService, IDirtyRowService, ICoreMouseService, ICharsetService, IUnicodeService } from 'common/services/Services'; +import { ICoreService, IBufferService, IOptionsService, ILogService, IDirtyRowService, ICoreMouseService, ICharsetService, IUnicodeService, LogLevelEnum } from 'common/services/Services'; import { OscHandler } from 'common/parser/OscParser'; import { DcsHandler } from 'common/parser/DcsParser'; -import { LogLevel } from 'common/services/LogService'; /** * Map collect to glevel. Used in `selectCharset`. @@ -263,6 +262,14 @@ export class InputHandler extends Disposable implements IInputHandler { private _onAnsiColorChange = new EventEmitter(); public get onAnsiColorChange(): IEvent { return this._onAnsiColorChange.event; } + private _parseStack: IParseStack = { + paused: false, + cursorStartX: 0, + cursorStartY: 0, + decodedLength: 0, + position: 0 + }; + constructor( private readonly _bufferService: IBufferService, private readonly _charsetService: ICharsetService, @@ -467,13 +474,6 @@ export class InputHandler extends Disposable implements IInputHandler { /** * Async parse support. */ - private _parseStack = { - paused: false, - cursorStartX: 0, - cursorStartY: 0, - decodedLength: 0, - position: 0 - }; private _preserveStack(cursorStartX: number, cursorStartY: number, decodedLength: number, position: number): void { this._parseStack.paused = true; this._parseStack.cursorStartX = cursorStartX; @@ -481,9 +481,10 @@ export class InputHandler extends Disposable implements IInputHandler { this._parseStack.decodedLength = decodedLength; this._parseStack.position = position; } + private _logSlowResolvingAsync(p: Promise): void { - // log a limited warning about an async taking too long - if ((this._logService as any)._logLevel <= LogLevel.WARN) { + // log a limited warning about an async handler taking too long + if (this._logService.logLevel <= LogLevelEnum.WARN) { Promise.race([p, new Promise((res, rej) => setTimeout(() => rej('#SLOW_TIMEOUT'), SLOW_ASYNC_LIMIT))]) .catch(err => { if (err !== '#SLOW_TIMEOUT') { diff --git a/src/common/TestUtils.test.ts b/src/common/TestUtils.test.ts index 35357744..01ceacbd 100644 --- a/src/common/TestUtils.test.ts +++ b/src/common/TestUtils.test.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { IBufferService, ICoreService, ILogService, IOptionsService, ITerminalOptions, IPartialTerminalOptions, IDirtyRowService, ICoreMouseService, ICharsetService, IUnicodeService, IUnicodeVersionProvider } from 'common/services/Services'; +import { IBufferService, ICoreService, ILogService, IOptionsService, ITerminalOptions, IPartialTerminalOptions, IDirtyRowService, ICoreMouseService, ICharsetService, IUnicodeService, IUnicodeVersionProvider, LogLevelEnum } from 'common/services/Services'; import { IEvent, EventEmitter } from 'common/EventEmitter'; import { clone } from 'common/Clone'; import { DEFAULT_OPTIONS } from 'common/services/OptionsService'; @@ -92,6 +92,7 @@ export class MockDirtyRowService implements IDirtyRowService { export class MockLogService implements ILogService { public serviceBrand: any; + public logLevel = LogLevelEnum.DEBUG; public debug(message: any, ...optionalParams: any[]): void {} public info(message: any, ...optionalParams: any[]): void {} public warn(message: any, ...optionalParams: any[]): void {} diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index e345e11d..108d81ac 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -349,7 +349,7 @@ export interface IInputHandler { onTitleChange: IEvent; onRequestScroll: IEvent; - parse(data: string | Uint8Array): void; + parse(data: string | Uint8Array, promiseResult?: boolean): void | Promise; print(data: Uint32Array, start: number, end: number): void; registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise): IDisposable; registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise): IDisposable; @@ -431,3 +431,11 @@ export interface IInputHandler { ESC ~ */ setgLevel(level: number): void; /** ESC # 8 */ screenAlignmentPattern(): void; } + +interface IParseStack { + paused: boolean; + cursorStartX: number; + cursorStartY: number; + decodedLength: number; + position: number; +} diff --git a/src/common/services/LogService.ts b/src/common/services/LogService.ts index 3c0ccaf1..de4e18f8 100644 --- a/src/common/services/LogService.ts +++ b/src/common/services/LogService.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { ILogService, IOptionsService } from 'common/services/Services'; +import { ILogService, IOptionsService, LogLevelEnum } from 'common/services/Services'; type LogType = (message?: any, ...optionalParams: any[]) => void; @@ -19,21 +19,12 @@ interface IConsole { // module doesn't depend on them so we need to explicitly declare it. declare const console: IConsole; - -export enum LogLevel { - DEBUG = 0, - INFO = 1, - WARN = 2, - ERROR = 3, - OFF = 4 -} - -const optionsKeyToLogLevel: { [key: string]: LogLevel } = { - debug: LogLevel.DEBUG, - info: LogLevel.INFO, - warn: LogLevel.WARN, - error: LogLevel.ERROR, - off: LogLevel.OFF +const optionsKeyToLogLevel: { [key: string]: LogLevelEnum } = { + debug: LogLevelEnum.DEBUG, + info: LogLevelEnum.INFO, + warn: LogLevelEnum.WARN, + error: LogLevelEnum.ERROR, + off: LogLevelEnum.OFF }; const LOG_PREFIX = 'xterm.js: '; @@ -41,7 +32,7 @@ const LOG_PREFIX = 'xterm.js: '; export class LogService implements ILogService { public serviceBrand: any; - private _logLevel!: LogLevel; + public logLevel: LogLevelEnum = LogLevelEnum.OFF; constructor( @IOptionsService private readonly _optionsService: IOptionsService @@ -55,7 +46,7 @@ export class LogService implements ILogService { } private _updateLogLevel(): void { - this._logLevel = optionsKeyToLogLevel[this._optionsService.options.logLevel]; + this.logLevel = optionsKeyToLogLevel[this._optionsService.options.logLevel]; } private _evalLazyOptionalParams(optionalParams: any[]): void { @@ -72,25 +63,25 @@ export class LogService implements ILogService { } public debug(message: string, ...optionalParams: any[]): void { - if (this._logLevel <= LogLevel.DEBUG) { + if (this.logLevel <= LogLevelEnum.DEBUG) { this._log(console.log, message, optionalParams); } } public info(message: string, ...optionalParams: any[]): void { - if (this._logLevel <= LogLevel.INFO) { + if (this.logLevel <= LogLevelEnum.INFO) { this._log(console.info, message, optionalParams); } } public warn(message: string, ...optionalParams: any[]): void { - if (this._logLevel <= LogLevel.WARN) { + if (this.logLevel <= LogLevelEnum.WARN) { this._log(console.warn, message, optionalParams); } } public error(message: string, ...optionalParams: any[]): void { - if (this._logLevel <= LogLevel.ERROR) { + if (this.logLevel <= LogLevelEnum.ERROR) { this._log(console.error, message, optionalParams); } } diff --git a/src/common/services/Services.ts b/src/common/services/Services.ts index c733e73e..1fbf57fb 100644 --- a/src/common/services/Services.ts +++ b/src/common/services/Services.ts @@ -161,6 +161,8 @@ export const ILogService = createDecorator('LogService'); export interface ILogService { serviceBrand: undefined; + logLevel: LogLevelEnum; + debug(message: any, ...optionalParams: any[]): void; info(message: any, ...optionalParams: any[]): void; warn(message: any, ...optionalParams: any[]): void; @@ -181,6 +183,13 @@ export interface IOptionsService { export type FontWeight = 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number; export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off'; +export enum LogLevelEnum { + DEBUG = 0, + INFO = 1, + WARN = 2, + ERROR = 3, + OFF = 4 +} export type RendererType = 'dom' | 'canvas'; export interface IPartialTerminalOptions { From 869c11f1d8ce7edee3a262d904f8e4a4768ad746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Wed, 17 Mar 2021 22:39:09 +0100 Subject: [PATCH 111/377] interface for subparser stack saves --- src/common/parser/DcsParser.ts | 12 ++++++------ src/common/parser/EscapeSequenceParser.ts | 16 +++++++++------- src/common/parser/OscParser.ts | 13 ++++++------- src/common/parser/Types.d.ts | 13 +++++++++++++ 4 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/common/parser/DcsParser.ts b/src/common/parser/DcsParser.ts index 6b5ddd6e..b66524ba 100644 --- a/src/common/parser/DcsParser.ts +++ b/src/common/parser/DcsParser.ts @@ -4,7 +4,7 @@ */ import { IDisposable } from 'common/Types'; -import { IDcsHandler, IParams, IHandlerCollection, IDcsParser, DcsFallbackHandlerType } from 'common/parser/Types'; +import { IDcsHandler, IParams, IHandlerCollection, IDcsParser, DcsFallbackHandlerType, ISubParserStackState } from 'common/parser/Types'; import { utf32ToString } from 'common/input/TextDecoder'; import { Params } from 'common/parser/Params'; import { PAYLOAD_LIMIT } from 'common/parser/Constants'; @@ -16,6 +16,11 @@ export class DcsParser implements IDcsParser { private _active: IDcsHandler[] = EMPTY_HANDLERS; private _ident: number = 0; private _handlerFb: DcsFallbackHandlerType = () => { }; + private _stack: ISubParserStackState = { + paused: false, + loopPosition: 0, + fallThrough: false + }; public dispose(): void { this._handlers = Object.create(null); @@ -83,11 +88,6 @@ export class DcsParser implements IDcsParser { } } - private _stack = { - paused: false, - loopPosition: 0, - fallThrough: false - }; public unhook(success: boolean, promiseResult: boolean = true): void | Promise { if (!this._active.length) { this._handlerFb(this._ident, 'UNHOOK', success); diff --git a/src/common/parser/EscapeSequenceParser.ts b/src/common/parser/EscapeSequenceParser.ts index c1d80c5c..f20a7e91 100644 --- a/src/common/parser/EscapeSequenceParser.ts +++ b/src/common/parser/EscapeSequenceParser.ts @@ -253,6 +253,15 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP protected _escHandlerFb: EscFallbackHandlerType; protected _errorHandlerFb: (state: IParsingState) => IParsingState; + // parser stack save for async handler support + protected _parseStack: IParserStackState = { + state: ParserStackType.NONE, + handlers: [], + handlerPos: 0, + transition: 0, + chunkPos: 0 + }; + constructor( protected readonly _transitions: TransitionTable = VT500_TRANSITION_TABLE ) { @@ -456,13 +465,6 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP /** * Async parse support. */ - protected _parseStack: IParserStackState = { - state: ParserStackType.NONE, - handlers: [], - handlerPos: 0, - transition: 0, - chunkPos: 0 - }; protected _preserveStack( state: ParserStackType, handlers: ResumableHandlersType, diff --git a/src/common/parser/OscParser.ts b/src/common/parser/OscParser.ts index f043bd82..32710aed 100644 --- a/src/common/parser/OscParser.ts +++ b/src/common/parser/OscParser.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { IOscHandler, IHandlerCollection, OscFallbackHandlerType, IOscParser } from 'common/parser/Types'; +import { IOscHandler, IHandlerCollection, OscFallbackHandlerType, IOscParser, ISubParserStackState } from 'common/parser/Types'; import { OscState, PAYLOAD_LIMIT } from 'common/parser/Constants'; import { utf32ToString } from 'common/input/TextDecoder'; import { IDisposable } from 'common/Types'; @@ -16,6 +16,11 @@ export class OscParser implements IOscParser { private _id = -1; private _handlers: IHandlerCollection = Object.create(null); private _handlerFb: OscFallbackHandlerType = () => { }; + private _stack: ISubParserStackState = { + paused: false, + loopPosition: 0, + fallThrough: false + }; public registerHandler(ident: number, handler: IOscHandler): IDisposable { if (this._handlers[ident] === undefined) { @@ -119,12 +124,6 @@ export class OscParser implements IOscParser { } } - private _stack = { - paused: false, - loopPosition: 0, - fallThrough: false - }; - /** * Indicates end of an OSC command. * Whether the OSC got aborted or finished normally diff --git a/src/common/parser/Types.d.ts b/src/common/parser/Types.d.ts index 26a02e83..3a621eab 100644 --- a/src/common/parser/Types.d.ts +++ b/src/common/parser/Types.d.ts @@ -242,6 +242,8 @@ export interface IHandlerCollection { /** * Types for async parser support. */ + +// type of saved stack state in parser export const enum ParserStackType { NONE = 0, FAIL, @@ -251,7 +253,11 @@ export const enum ParserStackType { OSC, DCS } + +// aggregate of resumable handler lists export type ResumableHandlersType = CsiHandlerType[] | EscHandlerType[]; + +// saved stack state of the parser export interface IParserStackState { state: ParserStackType; handlers: ResumableHandlersType; @@ -259,3 +265,10 @@ export interface IParserStackState { transition: number; chunkPos: number; } + +// saved stack state of subparser (OSC and DCS) +export interface ISubParserStackState { + paused: boolean; + loopPosition: number; + fallThrough: boolean; +} From 00bdd2805a27c2bef8d2e4ac7d61c2cdefa2c17b Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Thu, 18 Mar 2021 08:14:27 -0700 Subject: [PATCH 112/377] Ensure in js that the textarea is always > 1x1px --- css/xterm.css | 2 +- src/browser/input/CompositionHelper.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/css/xterm.css b/css/xterm.css index bbadb190..7ddcc2d0 100644 --- a/css/xterm.css +++ b/css/xterm.css @@ -59,7 +59,7 @@ } .xterm .xterm-helper-textarea { -/* padding: 0; */ + padding: 0; border: 0; margin: 0; /* Move textarea out of the screen to the far left, so that the cursor is not visible */ diff --git a/src/browser/input/CompositionHelper.ts b/src/browser/input/CompositionHelper.ts index f93483d3..32f8bbb9 100644 --- a/src/browser/input/CompositionHelper.ts +++ b/src/browser/input/CompositionHelper.ts @@ -222,6 +222,9 @@ export class CompositionHelper { const compositionViewBounds = this._compositionView.getBoundingClientRect(); this._textarea.style.left = cursorLeft + 'px'; this._textarea.style.top = cursorTop + 'px'; + // Ensure the text area is at least 1x1, otherwise certain IMEs may break + this._textarea.style.width = Math.max(compositionViewBounds.width, 1) + 'px'; + this._textarea.style.height = Math.max(compositionViewBounds.height, 1) + 'px'; this._textarea.style.width = compositionViewBounds.width + 'px'; this._textarea.style.height = compositionViewBounds.height + 'px'; this._textarea.style.lineHeight = compositionViewBounds.height + 'px'; From 886f285ab7c54b29b4b0c4e15174e43743d2997d Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Thu, 18 Mar 2021 08:31:13 -0700 Subject: [PATCH 113/377] Remove old setting dimensions --- src/browser/input/CompositionHelper.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/browser/input/CompositionHelper.ts b/src/browser/input/CompositionHelper.ts index 32f8bbb9..85cfc3b6 100644 --- a/src/browser/input/CompositionHelper.ts +++ b/src/browser/input/CompositionHelper.ts @@ -225,8 +225,6 @@ export class CompositionHelper { // Ensure the text area is at least 1x1, otherwise certain IMEs may break this._textarea.style.width = Math.max(compositionViewBounds.width, 1) + 'px'; this._textarea.style.height = Math.max(compositionViewBounds.height, 1) + 'px'; - this._textarea.style.width = compositionViewBounds.width + 'px'; - this._textarea.style.height = compositionViewBounds.height + 'px'; this._textarea.style.lineHeight = compositionViewBounds.height + 'px'; } From 5170a12cb1ff66c55557159eff0e8655c63111a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Fri, 19 Mar 2021 01:07:43 +0100 Subject: [PATCH 114/377] silence writeSync warning --- src/common/CoreTerminal.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 50be0d7c..a8961451 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -22,7 +22,7 @@ */ import { Disposable } from 'common/Lifecycle'; -import { IInstantiationService, IOptionsService, IBufferService, ILogService, ICharsetService, ICoreService, ICoreMouseService, IUnicodeService, IDirtyRowService } from 'common/services/Services'; +import { IInstantiationService, IOptionsService, IBufferService, ILogService, ICharsetService, ICoreService, ICoreMouseService, IUnicodeService, IDirtyRowService, LogLevelEnum } from 'common/services/Services'; import { InstantiationService } from 'common/services/InstantiationService'; import { LogService } from 'common/services/LogService'; import { BufferService, MINIMUM_COLS, MINIMUM_ROWS } from 'common/services/BufferService'; @@ -135,9 +135,13 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { * @deprecated Unreliable, will be removed soon. */ public writeSync(data: string | Uint8Array): void { - console.error('writeSync is unreliable and will be removed soon.'); + if (this._logService.logLevel <= LogLevelEnum.WARN && !this._hasBeenWarnedOnce) { + this._logService.warn('writeSync is unreliable and will be removed soon.'); + this._hasBeenWarnedOnce = true; + } this._writeBuffer.writeSync(data); } + private _hasBeenWarnedOnce = false; public resize(x: number, y: number): void { if (isNaN(x) || isNaN(y)) { From 5c5ca4e213c4bfe8b7a1cfa5fb65676af5b37a92 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 19 Mar 2021 06:24:42 -0700 Subject: [PATCH 115/377] Change warning to one per session not terminal --- src/common/CoreTerminal.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index a8961451..0236d39f 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -40,6 +40,9 @@ import { IBufferSet } from 'common/buffer/Types'; import { InputHandler } from 'common/InputHandler'; import { WriteBuffer } from 'common/input/WriteBuffer'; +// Only trigger this warning a single time per session +let hasWriteSyncWarnHappened: boolean = false; + export abstract class CoreTerminal extends Disposable implements ICoreTerminal { protected readonly _instantiationService: IInstantiationService; protected readonly _bufferService: IBufferService; @@ -135,13 +138,12 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { * @deprecated Unreliable, will be removed soon. */ public writeSync(data: string | Uint8Array): void { - if (this._logService.logLevel <= LogLevelEnum.WARN && !this._hasBeenWarnedOnce) { + if (this._logService.logLevel <= LogLevelEnum.WARN && !hasWriteSyncWarnHappened) { this._logService.warn('writeSync is unreliable and will be removed soon.'); - this._hasBeenWarnedOnce = true; + hasWriteSyncWarnHappened = true; } this._writeBuffer.writeSync(data); } - private _hasBeenWarnedOnce = false; public resize(x: number, y: number): void { if (isNaN(x) || isNaN(y)) { From c2f4c4dd323413a650a695c5b0dde8b1c4c9902d Mon Sep 17 00:00:00 2001 From: Daniel Steinberg Date: Fri, 19 Mar 2021 18:40:36 -0400 Subject: [PATCH 116/377] Add gifcast to "Real-world uses" in README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 26db59d0..d5488125 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,7 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**Commas**](https://github.com/CyanSalt/commas): Commas is a hackable terminal and command runner. - [**Devtron**](https://github.com/devtron-labs/devtron): Software Delivery Workflow For Kubernetes. - [**NxShell**](https://github.com/nxshell/nxshell): An easy to use new terminal for SSH. +- [**gifcast**](https://dstein64.github.io/gifcast/): Converts an asciinema cast to an animated GIF. [And much more...](https://github.com/xtermjs/xterm.js/network/dependents) Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it in our list. Note: Please add any new contributions to the end of the list only. From 67934ff35f5d9b9ddff9f80741d5e4dc61f492a8 Mon Sep 17 00:00:00 2001 From: Labhansh Agrawal Date: Tue, 16 Mar 2021 13:36:32 +0530 Subject: [PATCH 117/377] Enable using ligatures addon outside electron --- addons/xterm-addon-ligatures/package.json | 2 +- addons/xterm-addon-ligatures/src/font.ts | 57 +++++++++++++++++-- .../xterm-addon-ligatures/webpack.config.js | 14 ++++- addons/xterm-addon-ligatures/yarn.lock | 33 +++++------ demo/client.ts | 16 +++++- demo/start.js | 7 +++ 6 files changed, 99 insertions(+), 30 deletions(-) diff --git a/addons/xterm-addon-ligatures/package.json b/addons/xterm-addon-ligatures/package.json index 4e2b4056..f96ce167 100644 --- a/addons/xterm-addon-ligatures/package.json +++ b/addons/xterm-addon-ligatures/package.json @@ -32,7 +32,7 @@ "license": "MIT", "dependencies": { "font-finder": "^1.1.0", - "font-ligatures": "^1.3.3" + "font-ligatures": "^1.4.0" }, "devDependencies": { "@types/sinon": "^5.0.1", diff --git a/addons/xterm-addon-ligatures/src/font.ts b/addons/xterm-addon-ligatures/src/font.ts index 825fc797..0d01d3cc 100644 --- a/addons/xterm-addon-ligatures/src/font.ts +++ b/addons/xterm-addon-ligatures/src/font.ts @@ -3,12 +3,19 @@ * @license MIT */ -import * as fontFinder from 'font-finder'; -import * as fontLigatures from 'font-ligatures'; +import {FontList} from 'font-finder'; +import {Font, loadBuffer, loadFile} from 'font-ligatures'; import parse from './parse'; -let fontsPromise: Promise | undefined = undefined; +interface IFontMetadata { + family: string; + fullName: string; + postscriptName: string; + blob: () => Promise; +} + +let fontsPromise: Promise> | undefined = undefined; /** * Loads the font ligature wrapper for the specified font family if it could be @@ -16,9 +23,43 @@ let fontsPromise: Promise | undefined = undefined; * @param fontFamily The CSS font family definition to resolve * @param cacheSize The size of the ligature cache to maintain if the font is resolved */ -export default async function load(fontFamily: string, cacheSize: number): Promise { +export default async function load(fontFamily: string, cacheSize: number): Promise { + if (!fontsPromise && 'fonts' in navigator) { + try { + const status = await (navigator as any).permissions.request?.({ + name: 'local-fonts' + }); + if (status && status.state !== 'granted') { + throw new Error('Permission to access local fonts not granted.'); + } + } catch (err) { + // A `TypeError` indicates the 'local-fonts' + // permission is not yet implemented, so + // only `throw` if this is _not_ the problem. + if (err.name !== 'TypeError') { + throw err; + } + } + const fonts: Record = {}; + try { + const fontsIterator: AsyncIterableIterator = (navigator as any).fonts.query(); + for await (const metadata of fontsIterator) { + if (!fonts.hasOwnProperty(metadata.family)) { + fonts[metadata.family] = []; + } + fonts[metadata.family].push(metadata); + } + fontsPromise = Promise.resolve(fonts); + } catch (err) { + console.error(err.name, err.message); + } + } if (!fontsPromise) { - fontsPromise = fontFinder.list(); + try { + fontsPromise = (await import('font-finder')).list(); + } catch (err) { + fontsPromise = Promise.resolve({}); + } } const fonts = await fontsPromise; @@ -31,7 +72,11 @@ export default async function load(fontFamily: string, cacheSize: number): Promi } if (fonts.hasOwnProperty(family) && fonts[family].length > 0) { - return await fontLigatures.loadFile(fonts[family][0].path, { cacheSize }); + const font = fonts[family][0]; + if ('blob' in font) { + return loadBuffer(await (await font.blob()).arrayBuffer(), {cacheSize}); + } + return await loadFile(font.path, {cacheSize}); } } diff --git a/addons/xterm-addon-ligatures/webpack.config.js b/addons/xterm-addon-ligatures/webpack.config.js index 253e1207..6bdbd156 100644 --- a/addons/xterm-addon-ligatures/webpack.config.js +++ b/addons/xterm-addon-ligatures/webpack.config.js @@ -30,7 +30,17 @@ module.exports = { }, mode: 'production', externals: { - 'font-finder':'font-finder', - 'font-ligatures':'font-ligatures' + 'font-finder': 'font-finder', + 'stream': 'stream', + 'os': 'os', + 'util': 'util' + }, + resolve: { + fallback: { + stream: false, + util: false, + os: false, + path: false + } } }; diff --git a/addons/xterm-addon-ligatures/yarn.lock b/addons/xterm-addon-ligatures/yarn.lock index 049b798a..2191ce37 100644 --- a/addons/xterm-addon-ligatures/yarn.lock +++ b/addons/xterm-addon-ligatures/yarn.lock @@ -87,19 +87,19 @@ font-finder@^1.0.3: font-finder@^1.1.0: version "1.1.0" - resolved "https://registry.yarnpkg.com/font-finder/-/font-finder-1.1.0.tgz#2bff2b2762acba720239c8bec898a96daae90858" + resolved "https://registry.npmjs.org/font-finder/-/font-finder-1.1.0.tgz#2bff2b2762acba720239c8bec898a96daae90858" integrity sha512-wpCL2uIbi6GurJbU7ZlQ3nGd61Ho+dSU6U83/xJT5UPFfN35EeCW/rOtS+5k+IuEZu2SYmHzDIPL9eA5tSYRAw== dependencies: get-system-fonts "^2.0.0" promise-stream-reader "^1.0.1" -font-ligatures@^1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/font-ligatures/-/font-ligatures-1.3.3.tgz#63fff18dc8adb3a11fe5eec1f4e8d7edfa8075b9" - integrity sha512-NSGpHgVNX81M7AWS1XylK1UZbN3QllfUIDAAuPv6TUcl5O2b781JcKS5L2RopAU0AqlTyX3ZuX/04eaMpbVrHA== +font-ligatures@^1.4.0: + version "1.4.0" + resolved "https://registry.npmjs.org/font-ligatures/-/font-ligatures-1.4.0.tgz#6a7b370d96be1358dddfad67830e82fbfd59e6dc" + integrity sha512-n7DFnnEpJ0NrVoLqZIL4tMGVs+CnFwQc92m80LWyrbgAFO4x234+t2/H9o4eOYA1eh6ta9dZAEEsJAwsBdNezA== dependencies: font-finder "^1.0.3" - lru-cache "^4.1.3" + lru-cache "^6.0.0" opentype.js "^0.8.0" get-system-fonts@^2.0.0: @@ -144,12 +144,12 @@ lolex@^5.0.1: dependencies: "@sinonjs/commons" "^1.7.0" -lru-cache@^4.1.3: - version "4.1.3" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.3.tgz#a1175cf3496dfc8436c156c334b4955992bce69c" +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== dependencies: - pseudomap "^1.0.2" - yallist "^2.1.2" + yallist "^4.0.0" minimist@^1.2.5: version "1.2.5" @@ -198,10 +198,6 @@ promise-stream-reader@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/promise-stream-reader/-/promise-stream-reader-1.0.1.tgz#4e793a79c9d49a73ccd947c6da9c127f12923649" -pseudomap@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" - sinon@6.3.5: version "6.3.5" resolved "https://registry.yarnpkg.com/sinon/-/sinon-6.3.5.tgz#0f6d6a5b4ebaad1f6e8e019395542d1d02c144a0" @@ -232,9 +228,10 @@ type-detect@4.0.8, type-detect@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" -yallist@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== yauzl@^2.10.0: version "2.10.0" diff --git a/demo/client.ts b/demo/client.ts index 93b7c26c..1f5eb49a 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -16,6 +16,7 @@ import { SerializeAddon } from '../addons/xterm-addon-serialize/out/SerializeAdd import { WebLinksAddon } from '../addons/xterm-addon-web-links/out/WebLinksAddon'; import { WebglAddon } from '../addons/xterm-addon-webgl/out/WebglAddon'; import { Unicode11Addon } from '../addons/xterm-addon-unicode11/out/Unicode11Addon'; +import { LigaturesAddon } from '../addons/xterm-addon-ligatures/out/LigaturesAddon'; // Use webpacked version (yarn package) // import { Terminal } from '../lib/xterm'; @@ -26,6 +27,7 @@ import { Unicode11Addon } from '../addons/xterm-addon-unicode11/out/Unicode11Add // import { WebLinksAddon } from 'xterm-addon-web-links'; // import { WebglAddon } from 'xterm-addon-webgl'; // import { Unicode11Addon } from 'xterm-addon-unicode11'; +// import { LigaturesAddon } from 'xterm-addon-ligatures'; // Pulling in the module's types relies on the above, it's looks a // little weird here as we're importing "this" module @@ -41,6 +43,7 @@ export interface IWindowWithTerminal extends Window { WebLinksAddon?: typeof WebLinksAddon; WebglAddon?: typeof WebglAddon; Unicode11Addon?: typeof Unicode11Addon; + LigaturesAddon?: typeof LigaturesAddon; } declare let window: IWindowWithTerminal; @@ -50,7 +53,7 @@ let socketURL; let socket; let pid; -type AddonType = 'attach' | 'fit' | 'search' | 'serialize' | 'unicode11' | 'web-links' | 'webgl'; +type AddonType = 'attach' | 'fit' | 'search' | 'serialize' | 'unicode11' | 'web-links' | 'webgl' | 'ligatures'; interface IDemoAddon { name: T; @@ -62,8 +65,9 @@ interface IDemoAddon { T extends 'serialize' ? typeof SerializeAddon : T extends 'web-links' ? typeof WebLinksAddon : T extends 'unicode11' ? typeof Unicode11Addon : + T extends 'ligatures' ? typeof LigaturesAddon : typeof WebglAddon; - instance?: + instance?: T extends 'attach' ? AttachAddon : T extends 'fit' ? FitAddon : T extends 'search' ? SearchAddon : @@ -71,6 +75,7 @@ interface IDemoAddon { T extends 'web-links' ? WebLinksAddon : T extends 'webgl' ? WebglAddon : T extends 'unicode11' ? typeof Unicode11Addon : + T extends 'ligatures' ? typeof LigaturesAddon : never; } @@ -81,7 +86,8 @@ const addons: { [T in AddonType]: IDemoAddon} = { serialize: { name: 'serialize', ctor: SerializeAddon, canChange: true }, 'web-links': { name: 'web-links', ctor: WebLinksAddon, canChange: true }, webgl: { name: 'webgl', ctor: WebglAddon, canChange: true }, - unicode11: { name: 'unicode11', ctor: Unicode11Addon, canChange: true } + unicode11: { name: 'unicode11', ctor: Unicode11Addon, canChange: true }, + ligatures: { name: 'ligatures', ctor: LigaturesAddon, canChange: true } }; const terminalContainer = document.getElementById('terminal-container'); @@ -117,6 +123,7 @@ const disposeRecreateButtonHandler = () => { addons.search.instance = undefined; addons.serialize.instance = undefined; addons.unicode11.instance = undefined; + addons.ligatures.instance = undefined; addons['web-links'].instance = undefined; addons.webgl.instance = undefined; document.getElementById('dispose').innerHTML = 'Recreate Terminal'; @@ -133,6 +140,7 @@ if (document.location.pathname === '/test') { window.SearchAddon = SearchAddon; window.SerializeAddon = SerializeAddon; window.Unicode11Addon = Unicode11Addon; + window.LigaturesAddon = LigaturesAddon; window.WebLinksAddon = WebLinksAddon; window.WebglAddon = WebglAddon; } else { @@ -158,6 +166,7 @@ function createTerminal(): void { addons.serialize.instance = new SerializeAddon(); addons.fit.instance = new FitAddon(); addons.unicode11.instance = new Unicode11Addon(); + addons.ligatures.instance = new LigaturesAddon(); // TODO: Remove arguments when link provider API is the default addons['web-links'].instance = new WebLinksAddon(undefined, undefined, true); typedTerm.loadAddon(addons.fit.instance); @@ -181,6 +190,7 @@ function createTerminal(): void { socketURL = protocol + location.hostname + ((location.port) ? (':' + location.port) : '') + '/terminals/'; term.open(terminalContainer); + typedTerm.loadAddon(addons.ligatures.instance); addons.fit.instance!.fit(); term.focus(); diff --git a/demo/start.js b/demo/start.js index a14627c1..c4caea77 100644 --- a/demo/start.js +++ b/demo/start.js @@ -49,6 +49,13 @@ const clientConfig = { alias: { common: path.resolve('./out/common'), browser: path.resolve('./out/browser') + }, + fallback: { + stream: false, + util: false, + os: false, + path: false, + fs: false } }, output: { From 61213159ee8f00550169b12147ebf21d58b823d6 Mon Sep 17 00:00:00 2001 From: Thomas Zilz Date: Thu, 25 Mar 2021 13:55:29 +0100 Subject: [PATCH 118/377] Test test --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d5488125..d6e6cb7c 100644 --- a/README.md +++ b/README.md @@ -204,3 +204,5 @@ If you contribute code to this project, you are implicitly allowing your code to Copyright (c) 2017-2019, [The xterm.js authors](https://github.com/xtermjs/xterm.js/graphs/contributors) (MIT License)
Copyright (c) 2014-2017, SourceLair, Private Company ([www.sourcelair.com](https://www.sourcelair.com/home)) (MIT License)
Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) +1 +hallo heiko From b666e6a924b5b16d575e5b4a36a33f38af2cd394 Mon Sep 17 00:00:00 2001 From: Thomas Zilz Date: Thu, 25 Mar 2021 13:59:20 +0100 Subject: [PATCH 119/377] =?UTF-8?q?Noch=20mehr=20=C3=A4nderungen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LICENSE | 6 ++++++ src/tsconfig-base.json | 1 + 2 files changed, 7 insertions(+) diff --git a/LICENSE b/LICENSE index 4472336c..2193d688 100644 --- a/LICENSE +++ b/LICENSE @@ -19,3 +19,9 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +asdfasd asdfasddf +asdfasd as +df +asdfasdf asdfasddfsad +f diff --git a/src/tsconfig-base.json b/src/tsconfig-base.json index 0cd951a7..d16ffcad 100644 --- a/src/tsconfig-base.json +++ b/src/tsconfig-base.json @@ -12,3 +12,4 @@ "experimentalDecorators": true } } +asdfasdf s From 61519cc10c375c4012faf35a196e3e9be48fe0cf Mon Sep 17 00:00:00 2001 From: Thomas Zilz Date: Thu, 25 Mar 2021 14:09:44 +0100 Subject: [PATCH 120/377] Revert "Test test" This reverts commit 61213159ee8f00550169b12147ebf21d58b823d6. --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index d6e6cb7c..d5488125 100644 --- a/README.md +++ b/README.md @@ -204,5 +204,3 @@ If you contribute code to this project, you are implicitly allowing your code to Copyright (c) 2017-2019, [The xterm.js authors](https://github.com/xtermjs/xterm.js/graphs/contributors) (MIT License)
Copyright (c) 2014-2017, SourceLair, Private Company ([www.sourcelair.com](https://www.sourcelair.com/home)) (MIT License)
Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) -1 -hallo heiko From 787ef30279777e1602bf0ca4d16c01a6bb4453d9 Mon Sep 17 00:00:00 2001 From: Thomas Zilz Date: Thu, 25 Mar 2021 14:09:47 +0100 Subject: [PATCH 121/377] =?UTF-8?q?Revert=20"Noch=20mehr=20=C3=A4nderungen?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit b666e6a924b5b16d575e5b4a36a33f38af2cd394. --- LICENSE | 6 ------ src/tsconfig-base.json | 1 - 2 files changed, 7 deletions(-) diff --git a/LICENSE b/LICENSE index 2193d688..4472336c 100644 --- a/LICENSE +++ b/LICENSE @@ -19,9 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -asdfasd asdfasddf -asdfasd as -df -asdfasdf asdfasddfsad -f diff --git a/src/tsconfig-base.json b/src/tsconfig-base.json index d16ffcad..0cd951a7 100644 --- a/src/tsconfig-base.json +++ b/src/tsconfig-base.json @@ -12,4 +12,3 @@ "experimentalDecorators": true } } -asdfasdf s From e106cd02cfcfe1c63144b2c3ab3affd9d3cbb5c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Fri, 26 Mar 2021 12:46:39 +0100 Subject: [PATCH 122/377] fix callstack overflow of writeSync --- src/common/CoreTerminal.ts | 4 +- src/common/input/WriteBuffer.test.ts | 21 ++++++++++ src/common/input/WriteBuffer.ts | 60 +++++++++++++++++++--------- 3 files changed, 65 insertions(+), 20 deletions(-) diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 0236d39f..c11554f1 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -137,12 +137,12 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { * * @deprecated Unreliable, will be removed soon. */ - public writeSync(data: string | Uint8Array): void { + public writeSync(data: string | Uint8Array, maxSubsequentCalls?: number): void { if (this._logService.logLevel <= LogLevelEnum.WARN && !hasWriteSyncWarnHappened) { this._logService.warn('writeSync is unreliable and will be removed soon.'); hasWriteSyncWarnHappened = true; } - this._writeBuffer.writeSync(data); + this._writeBuffer.writeSync(data, maxSubsequentCalls); } public resize(x: number, y: number): void { diff --git a/src/common/input/WriteBuffer.test.ts b/src/common/input/WriteBuffer.test.ts index d3dfebd0..89106423 100644 --- a/src/common/input/WriteBuffer.test.ts +++ b/src/common/input/WriteBuffer.test.ts @@ -85,5 +85,26 @@ describe('WriteBuffer', () => { done(); }); }); + it('writeSync called from action does not overflow callstack - issue #3265', () => { + wb = new WriteBuffer(data => { + const num = parseInt(data as string); + if (num < 1000000) { + wb.writeSync('' + (num + 1)); + } + }); + wb.writeSync('1'); + }); + it('writeSync maxSubsequentCalls argument', () => { + let last: string = ''; + wb = new WriteBuffer(data => { + last = data as string; + const num = parseInt(data as string); + if (num < 1000000) { + wb.writeSync('' + (num + 1), 10); + } + }); + wb.writeSync('1', 10); + assert.equal(last, '11'); // 1 + 10 sub calls = 11 + }); }); }); diff --git a/src/common/input/WriteBuffer.ts b/src/common/input/WriteBuffer.ts index d22de912..cc84c9ab 100644 --- a/src/common/input/WriteBuffer.ts +++ b/src/common/input/WriteBuffer.ts @@ -42,31 +42,55 @@ export class WriteBuffer { private _callbacks: ((() => void) | undefined)[] = []; private _pendingData = 0; private _bufferOffset = 0; + private _isSyncWriting = false; + private _syncCalls = 0; constructor(private _action: (data: string | Uint8Array, promiseResult?: boolean) => void | Promise) { } /** * @deprecated Unreliable, to be removed soon. */ - public writeSync(data: string | Uint8Array): void { + public writeSync(data: string | Uint8Array, maxSubsequentCalls?: number): void { + // stop writeSync recursions with maxSubsequentCalls argument + // This is dangerous to use as it will lose the current data chunk + // and return immediately. + if (maxSubsequentCalls !== undefined && this._syncCalls > maxSubsequentCalls) { + // comment next line if a whole loop block should only contain x `writeSync` calls + // (total flat vs. deep nested limit) + this._syncCalls = 0; + return; + } + // append chunk to buffer + this._pendingData += data.length; + this._writeBuffer.push(data); + this._callbacks.push(undefined); + + // increase recursion counter + this._syncCalls++; + // exit early if another writeSync loop is active + if (this._isSyncWriting) { + return; + } + this._isSyncWriting = true; + // force sync processing on pending data chunks to avoid in-band data scrambling // does the same as innerWrite but without event loop - if (this._writeBuffer.length) { - for (let i = this._bufferOffset; i < this._writeBuffer.length; ++i) { - const data = this._writeBuffer[i]; - const cb = this._callbacks[i]; - this._action(data); - if (cb) cb(); - } - // reset all to avoid reprocessing of chunks with scheduled innerWrite call - this._writeBuffer = []; - this._callbacks = []; - this._pendingData = 0; - // stop scheduled innerWrite by offset > length condition - this._bufferOffset = 0x7FFFFFFF; + // we have to do it here as single loop steps to not corrupt loop subject + // by another writeSync call triggered from _action + let chunk: string | Uint8Array | undefined; + while (chunk = this._writeBuffer.shift()) { + this._action(chunk); + const cb = this._callbacks.shift(); + if (cb) cb(); } - // handle current data chunk - this._action(data); + // reset to avoid reprocessing of chunks with scheduled innerWrite call + // stopping scheduled innerWrite by offset > length condition + this._pendingData = 0; + this._bufferOffset = 0x7FFFFFFF; + + // allow another writeSync to loop + this._isSyncWriting = false; + this._syncCalls = 0; } public write(data: string | Uint8Array, callback?: () => void): void { @@ -191,8 +215,8 @@ export class WriteBuffer { } setTimeout(() => this._innerWrite()); } else { - this._writeBuffer = []; - this._callbacks = []; + this._writeBuffer.length = 0; + this._callbacks.length = 0; this._pendingData = 0; this._bufferOffset = 0; } From de791cfb35897d9121729252c07a138dd1062e10 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Sun, 28 Mar 2021 15:27:03 +0300 Subject: [PATCH 123/377] chore: lint using putout --- addons/xterm-addon-attach/src/AttachAddon.ts | 4 +- .../test/AttachAddon.api.ts | 2 +- addons/xterm-addon-fit/test/FitAddon.api.ts | 6 +-- addons/xterm-addon-ligatures/src/parse.ts | 6 +-- addons/xterm-addon-search/src/SearchAddon.ts | 6 +-- .../test/SearchAddon.api.ts | 2 +- .../test/SerializeAddon.api.ts | 2 +- .../test/Unicode11Addon.api.ts | 2 +- .../src/WebLinkProvider.ts | 4 +- .../test/WebLinksAddon.api.ts | 2 +- addons/xterm-addon-webgl/src/WebglRenderer.ts | 40 ++++++++++++++----- .../test/WebglRenderer.api.ts | 4 +- src/browser/MouseZoneManager.ts | 4 +- src/browser/Terminal.ts | 6 +-- src/common/CoreTerminal.ts | 2 +- src/common/InputHandler.test.ts | 4 +- src/common/InputHandler.ts | 2 +- 17 files changed, 59 insertions(+), 39 deletions(-) diff --git a/addons/xterm-addon-attach/src/AttachAddon.ts b/addons/xterm-addon-attach/src/AttachAddon.ts index 279d1b2e..035807ae 100644 --- a/addons/xterm-addon-attach/src/AttachAddon.ts +++ b/addons/xterm-addon-attach/src/AttachAddon.ts @@ -41,7 +41,9 @@ export class AttachAddon implements ITerminalAddon { } public dispose(): void { - this._disposables.forEach(d => d.dispose()); + for (const d of this._disposables) { + d.dispose(); + } } private _sendData(data: string): void { diff --git a/addons/xterm-addon-attach/test/AttachAddon.api.ts b/addons/xterm-addon-attach/test/AttachAddon.api.ts index 41e579f5..2dea645f 100644 --- a/addons/xterm-addon-attach/test/AttachAddon.api.ts +++ b/addons/xterm-addon-attach/test/AttachAddon.api.ts @@ -18,7 +18,7 @@ describe('AttachAddon', () => { before(async function(): Promise { const browserType = getBrowserType(); browser = await browserType.launch({ - headless: process.argv.indexOf('--headless') !== -1 + headless: process.argv.includes('--headless') }); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); diff --git a/addons/xterm-addon-fit/test/FitAddon.api.ts b/addons/xterm-addon-fit/test/FitAddon.api.ts index 1111dff0..5a5b3264 100644 --- a/addons/xterm-addon-fit/test/FitAddon.api.ts +++ b/addons/xterm-addon-fit/test/FitAddon.api.ts @@ -18,7 +18,7 @@ describe('FitAddon', () => { before(async function(): Promise { const browserType = getBrowserType(); browser = await browserType.launch({ - headless: process.argv.indexOf('--headless') !== -1 + headless: process.argv.includes('--headless') }); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); @@ -45,7 +45,7 @@ describe('FitAddon', () => { describe('proposeDimensions', () => { afterEach(async () => { - return unloadFit(); + return await unloadFit(); }); it('default', async function(): Promise { @@ -84,7 +84,7 @@ describe('FitAddon', () => { describe('fit', () => { afterEach(async () => { - return unloadFit(); + return await unloadFit(); }); it('default', async function(): Promise { diff --git a/addons/xterm-addon-ligatures/src/parse.ts b/addons/xterm-addon-ligatures/src/parse.ts index 5ad7747f..6289e468 100644 --- a/addons/xterm-addon-ligatures/src/parse.ts +++ b/addons/xterm-addon-ligatures/src/parse.ts @@ -68,7 +68,7 @@ function parseString(context: IParseContext, quoteChar: '\'' | '"'): string { while (context.offset < context.input.length) { const char = context.input[context.offset++]; if (escaped) { - if (/[0-9a-fA-F]/.test(char)) { + if (/[\dA-Fa-f]/.test(char)) { // Unicode escape context.offset--; str += parseUnicode(context); @@ -107,7 +107,7 @@ function parseIdentifier(context: IParseContext): string { while (context.offset < context.input.length) { const char = context.input[context.offset++]; if (escaped) { - if (/[0-9a-fA-F]/.test(char)) { + if (/[\dA-Fa-f]/.test(char)) { // Unicode escape context.offset--; str += parseUnicode(context); @@ -156,7 +156,7 @@ function parseUnicode(context: IParseContext): string { // of the escape and is swallowed. return unicodeToString(str); } - if (str.length >= 6 || !/[0-9a-fA-F]/.test(char)) { + if (str.length >= 6 || !/[\dA-Fa-f]/.test(char)) { // If the next character is not a valid hex digit or we have reached the // maximum of 6 digits in the escape, terminate the escape. context.offset--; diff --git a/addons/xterm-addon-search/src/SearchAddon.ts b/addons/xterm-addon-search/src/SearchAddon.ts index efc12662..64e89bb3 100644 --- a/addons/xterm-addon-search/src/SearchAddon.ts +++ b/addons/xterm-addon-search/src/SearchAddon.ts @@ -240,8 +240,8 @@ export class SearchAddon implements ITerminalAddon { * @param term the substring that starts at searchIndex */ private _isWholeWord(searchIndex: number, line: string, term: string): boolean { - return (((searchIndex === 0) || (NON_WORD_CHARACTERS.indexOf(line[searchIndex - 1]) !== -1)) && - (((searchIndex + term.length) === line.length) || (NON_WORD_CHARACTERS.indexOf(line[searchIndex + term.length]) !== -1))); + return ((searchIndex === 0) || (NON_WORD_CHARACTERS.includes(line[searchIndex - 1]))) && + (((searchIndex + term.length) === line.length) || (NON_WORD_CHARACTERS.includes(line[searchIndex + term.length]))); } /** @@ -262,7 +262,7 @@ export class SearchAddon implements ITerminalAddon { // Ignore wrapped lines, only consider on unwrapped line (first row of command string). const firstLine = terminal.buffer.active.getLine(row); - if (firstLine && firstLine.isWrapped) { + if (firstLine?.isWrapped) { if (isReverseSearch) { searchPosition.startCol += terminal.cols; return; diff --git a/addons/xterm-addon-search/test/SearchAddon.api.ts b/addons/xterm-addon-search/test/SearchAddon.api.ts index 3707aecd..b92dbc3a 100644 --- a/addons/xterm-addon-search/test/SearchAddon.api.ts +++ b/addons/xterm-addon-search/test/SearchAddon.api.ts @@ -20,7 +20,7 @@ describe('Search Tests', function(): void { before(async function(): Promise { const browserType = getBrowserType(); browser = await browserType.launch({ - headless: process.argv.indexOf('--headless') !== -1 + headless: process.argv.includes('--headless') }); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index 47af9d91..d472d753 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -34,7 +34,7 @@ describe('SerializeAddon', () => { before(async function(): Promise { const browserType = getBrowserType(); browser = await browserType.launch({ - headless: process.argv.indexOf('--headless') !== -1 + headless: process.argv.includes('--headless') }); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); diff --git a/addons/xterm-addon-unicode11/test/Unicode11Addon.api.ts b/addons/xterm-addon-unicode11/test/Unicode11Addon.api.ts index d0e09da2..7369eeaa 100644 --- a/addons/xterm-addon-unicode11/test/Unicode11Addon.api.ts +++ b/addons/xterm-addon-unicode11/test/Unicode11Addon.api.ts @@ -18,7 +18,7 @@ describe('Unicode11Addon', () => { before(async function(): Promise { const browserType = getBrowserType(); browser = await browserType.launch({ - headless: process.argv.indexOf('--headless') !== -1 + headless: process.argv.includes('--headless') }); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); diff --git a/addons/xterm-addon-web-links/src/WebLinkProvider.ts b/addons/xterm-addon-web-links/src/WebLinkProvider.ts index 487d5fe6..f0caf974 100644 --- a/addons/xterm-addon-web-links/src/WebLinkProvider.ts +++ b/addons/xterm-addon-web-links/src/WebLinkProvider.ts @@ -41,7 +41,7 @@ export class WebLinkProvider implements ILinkProvider { } export class LinkComputer { - public static computeLink(y: number, regex: RegExp, terminal: Terminal, handler: (event: MouseEvent, uri: string) => void): ILink[] { + public static computeLink(y: number, regex: RegExp, terminal: Terminal, activate: (event: MouseEvent, uri: string) => void): ILink[] { const rex = new RegExp(regex.source, (regex.flags || '') + 'g'); const [line, startLineIndex] = LinkComputer._translateBufferLineToStringWithWrap(y - 1, false, terminal); @@ -89,7 +89,7 @@ export class LinkComputer { } }; - result.push({ range, text, activate: handler }); + result.push({ range, text, activate }); } return result; diff --git a/addons/xterm-addon-web-links/test/WebLinksAddon.api.ts b/addons/xterm-addon-web-links/test/WebLinksAddon.api.ts index 6e42ff96..47fd7911 100644 --- a/addons/xterm-addon-web-links/test/WebLinksAddon.api.ts +++ b/addons/xterm-addon-web-links/test/WebLinksAddon.api.ts @@ -18,7 +18,7 @@ describe('WebLinksAddon', () => { before(async function(): Promise { const browserType = getBrowserType(); browser = await browserType.launch({ - headless: process.argv.indexOf('--headless') !== -1 + headless: process.argv.includes('--headless') }); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index 3bf74242..fecd5742 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -94,7 +94,9 @@ export class WebglRenderer extends Disposable implements IRenderer { } public dispose(): void { - this._renderLayers.forEach(l => l.dispose()); + for (const l of this._renderLayers) { + l.dispose(); + } this._core.screenElement!.removeChild(this._canvas); super.dispose(); } @@ -106,10 +108,10 @@ export class WebglRenderer extends Disposable implements IRenderer { public setColors(colors: IColorSet): void { this._colors = colors; // Clear layers and force a full render - this._renderLayers.forEach(l => { + for (const l of this._renderLayers) { l.setColors(this._terminal, this._colors); l.reset(this._terminal); - }); + } this._rectangleRenderer.setColors(); this._glyphRenderer.setColors(); @@ -136,7 +138,9 @@ export class WebglRenderer extends Disposable implements IRenderer { this._model.resize(this._terminal.cols, this._terminal.rows); // Resize all render layers - this._renderLayers.forEach(l => l.resize(this._terminal, this.dimensions)); + for (const l of this._renderLayers) { + l.resize(this._terminal, this.dimensions); + } // Resize the canvas this._canvas.width = this.dimensions.scaledCanvasWidth; @@ -168,15 +172,21 @@ export class WebglRenderer extends Disposable implements IRenderer { } public onBlur(): void { - this._renderLayers.forEach(l => l.onBlur(this._terminal)); + for (const l of this._renderLayers) { + l.onBlur(this._terminal); + } } public onFocus(): void { - this._renderLayers.forEach(l => l.onFocus(this._terminal)); + for (const l of this._renderLayers) { + l.onFocus(this._terminal); + } } public onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void { - this._renderLayers.forEach(l => l.onSelectionChanged(this._terminal, start, end, columnSelectMode)); + for (const l of this._renderLayers) { + l.onSelectionChanged(this._terminal, start, end, columnSelectMode); + } this._updateSelectionModel(start, end, columnSelectMode); @@ -184,11 +194,15 @@ export class WebglRenderer extends Disposable implements IRenderer { } public onCursorMove(): void { - this._renderLayers.forEach(l => l.onCursorMove(this._terminal)); + for (const l of this._renderLayers) { + l.onCursorMove(this._terminal); + } } public onOptionsChanged(): void { - this._renderLayers.forEach(l => l.onOptionsChanged(this._terminal)); + for (const l of this._renderLayers) { + l.onOptionsChanged(this._terminal); + } this._updateDimensions(); this._refreshCharAtlas(); } @@ -222,7 +236,9 @@ export class WebglRenderer extends Disposable implements IRenderer { } public clear(): void { - this._renderLayers.forEach(l => l.reset(this._terminal)); + for (const l of this._renderLayers) { + l.reset(this._terminal); + } } public registerCharacterJoiner(handler: (text: string) => [number, number][]): number { @@ -245,7 +261,9 @@ export class WebglRenderer extends Disposable implements IRenderer { } // Update render layers - this._renderLayers.forEach(l => l.onGridChanged(this._terminal, start, end)); + for (const l of this._renderLayers) { + l.onGridChanged(this._terminal, start, end); + } // Tell renderer the frame is beginning if (this._glyphRenderer.beginFrame()) { diff --git a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts index 558605e2..e0aa68e7 100644 --- a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts +++ b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts @@ -18,7 +18,7 @@ const height = 600; describe('WebGL Renderer Integration Tests', async () => { const browserType = getBrowserType(); - const isHeadless = process.argv.indexOf('--headless') !== -1; + const isHeadless = process.argv.includes('--headless'); // Firefox works only in non-headless mode https://github.com/microsoft/playwright/issues/1032 const areTestsEnabled = browserType.name() === 'chromium' || (browserType.name() === 'firefox' && !isHeadless); const itWebgl = areTestsEnabled ? it : it.skip; @@ -893,7 +893,7 @@ async function getCellColor(col: number, row: number): Promise { async function setupBrowser(options: ITerminalOptions = { rendererType: 'dom' }): Promise { const browserType = getBrowserType(); browser = await browserType.launch({ - headless: process.argv.indexOf('--headless') !== -1 + headless: process.argv.includes('--headless') }); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); diff --git a/src/browser/MouseZoneManager.ts b/src/browser/MouseZoneManager.ts index 59b6b0f1..b6740157 100644 --- a/src/browser/MouseZoneManager.ts +++ b/src/browser/MouseZoneManager.ts @@ -156,9 +156,7 @@ export class MouseZoneManager extends Disposable implements IMouseZoneManager { private _onTooltip(e: MouseEvent): void { this._tooltipTimeout = undefined; const zone = this._findZoneEventAt(e); - if (zone && zone.tooltipCallback) { - zone.tooltipCallback(e); - } + zone?.tooltipCallback(e); } private _onMouseDown(e: MouseEvent): void { diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index b0964c21..686ae68d 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -162,11 +162,11 @@ export class Terminal extends CoreTerminal implements ITerminal { private _changeAnsiColor(event: IAnsiColorChangeEvent): void { if (!this._colorManager) { return; } - event.colors.forEach(ansiColor => { + for (const ansiColor of event.colors) { const color = rgba.toColor(ansiColor.red, ansiColor.green, ansiColor.blue); this._colorManager!.colors.ansi[ansiColor.colorIndex] = color; - }); + } this._renderService?.setColors(this._colorManager!.colors); this.viewport?.onThemeChange(this._colorManager!.colors); @@ -834,7 +834,7 @@ export class Terminal extends CoreTerminal implements ITerminal { * Change the cursor style for different selection modes */ public updateCursorStyle(ev: KeyboardEvent): void { - if (this._selectionService && this._selectionService.shouldColumnSelect(ev)) { + if (this._selectionService?.shouldColumnSelect(ev)) { this.element!.classList.add('column-select'); } else { this.element!.classList.remove('column-select'); diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index c11554f1..384691ed 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -41,7 +41,7 @@ import { InputHandler } from 'common/InputHandler'; import { WriteBuffer } from 'common/input/WriteBuffer'; // Only trigger this warning a single time per session -let hasWriteSyncWarnHappened: boolean = false; +let hasWriteSyncWarnHappened = false; export abstract class CoreTerminal extends Disposable implements ICoreTerminal { protected readonly _instantiationService: IInstantiationService; diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index 0402f262..b5067193 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -1759,7 +1759,8 @@ describe('InputHandler', () => { assert.isNotNull(event); assert.deepEqual(event!.colors[0], { colorIndex: 19, red: 0xa1, green: 0xb2, blue: 0xc3 }); - }), + }); + it('4: should ignore incorrect Ansi color change data', () => { // this is testing a private method assert.isNull(inputHandler.parseAnsiColorChange('17;rgb:a/b/c')); @@ -1767,6 +1768,7 @@ describe('InputHandler', () => { assert.isNull(inputHandler.parseAnsiColorChange('17;rgba:aa/bb/cc')); assert.isNull(inputHandler.parseAnsiColorChange('rgb:aa/bb/cc')); }); + it('4: should parse a list of Ansi color changes', () => { // this is testing a private method const event = inputHandler.parseAnsiColorChange('19;rgb:a1/b2/c3;17;rgb:00/11/22;255;rgb:01/ef/2d'); diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index a35f7981..13b0a0e7 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -2856,7 +2856,7 @@ export class InputHandler extends Disposable implements IInputHandler { protected _parseAnsiColorChange(data: string): IAnsiColorChangeEvent | null { const result: IAnsiColorChangeEvent = { colors: [] }; // example data: 5;rgb:aa/bb/cc - const regex = /(\d+);rgb:([0-9a-f]{2})\/([0-9a-f]{2})\/([0-9a-f]{2})/gi; + const regex = /(\d+);rgb:([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})/gi; let match; while ((match = regex.exec(data)) !== null) { From cbe056c27e14820c7f24aee5b5742a27e3267d28 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 29 Mar 2021 18:46:53 +0000 Subject: [PATCH 124/377] [Security] Bump y18n from 4.0.0 to 4.0.1 Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1. **This update includes a security fix.** - [Release notes](https://github.com/yargs/y18n/releases) - [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md) - [Commits](https://github.com/yargs/y18n/commits) Signed-off-by: dependabot-preview[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 8d8c9dd3..9b49f8db 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4820,9 +4820,9 @@ xterm-benchmark@^0.1.3: typescript "^3.5.1" y18n@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" - integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== + version "4.0.1" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.1.tgz#8db2b83c31c5d75099bb890b23f3094891e247d4" + integrity sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ== yargs-parser@13.1.2, yargs-parser@^13.1.2: version "13.1.2" From dafe7ea3daeba3bd53e56b4f82ad4da0fdd81901 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 30 Mar 2021 04:45:41 -0700 Subject: [PATCH 125/377] Remove experimental note from webgl renderer Fixes #2033 --- addons/xterm-addon-webgl/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/addons/xterm-addon-webgl/README.md b/addons/xterm-addon-webgl/README.md index 026a738e..756999db 100644 --- a/addons/xterm-addon-webgl/README.md +++ b/addons/xterm-addon-webgl/README.md @@ -1,8 +1,6 @@ ## xterm-addon-webgl -An addon for [xterm.js](https://github.com/xtermjs/xterm.js) that enables a WebGL-based renderer. This addon requires xterm.js v4+. - -⚠️ This is an experimental addon that is [missing some features and may be unstable](https://github.com/xtermjs/xterm.js/issues?q=is%3Aopen+is%3Aissue+label%3Aarea%2Faddon%2Fwebgl) ⚠️ +An addon for [xterm.js](https://github.com/xtermjs/xterm.js) that enables a WebGL2-based renderer. This addon requires xterm.js v4+. ### Install From b7e0489a53e649e51aac91db96d30b8e4780d969 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 30 Mar 2021 06:17:28 -0700 Subject: [PATCH 126/377] Remove offset from link The link range is absolute, not relative to viewport --- src/browser/services/SelectionService.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/browser/services/SelectionService.ts b/src/browser/services/SelectionService.ts index 547bba4a..8f7caeb3 100644 --- a/src/browser/services/SelectionService.ts +++ b/src/browser/services/SelectionService.ts @@ -321,9 +321,8 @@ export class SelectionService extends Disposable implements ISelectionService { private _selectWordAtCursor(event: MouseEvent, allowWhitespaceOnlySelection: boolean): boolean { const range = this._linkifier.currentLink?.link?.range; if (range) { - const scrollOffset = this._bufferService.buffer.ydisp; - this._model.selectionStart = [range.start.x - 1, range.start.y - scrollOffset - 1]; - this._model.selectionEnd = [range.end.x, range.end.y - scrollOffset - 1]; + this._model.selectionStart = [range.start.x - 1, range.start.y - 1]; + this._model.selectionEnd = [range.end.x, range.end.y - 1]; return true; } From 04092c80e80bd47467b16f07e6c06c71ad92b08a Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 30 Mar 2021 06:19:34 -0700 Subject: [PATCH 127/377] Update src/browser/services/SelectionService.ts --- src/browser/services/SelectionService.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/browser/services/SelectionService.ts b/src/browser/services/SelectionService.ts index 8f7caeb3..4806ef91 100644 --- a/src/browser/services/SelectionService.ts +++ b/src/browser/services/SelectionService.ts @@ -319,6 +319,7 @@ export class SelectionService extends Disposable implements ISelectionService { * @param event The mouse event. */ private _selectWordAtCursor(event: MouseEvent, allowWhitespaceOnlySelection: boolean): boolean { + // Check if there is a link under the cursor first and select that if so const range = this._linkifier.currentLink?.link?.range; if (range) { this._model.selectionStart = [range.start.x - 1, range.start.y - 1]; From d2471b43012b5639ae00cbbd1b6764a6983ee700 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 30 Mar 2021 06:19:39 -0700 Subject: [PATCH 128/377] Update src/browser/Types.d.ts --- src/browser/Types.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/Types.d.ts b/src/browser/Types.d.ts index 29b489aa..f743934e 100644 --- a/src/browser/Types.d.ts +++ b/src/browser/Types.d.ts @@ -217,7 +217,7 @@ export interface ILinkWithState { export interface ILinkifier2 { onShowLinkUnderline: IEvent; onHideLinkUnderline: IEvent; - currentLink: ILinkWithState | undefined; + readonly currentLink: ILinkWithState | undefined; attachToDom(element: HTMLElement, mouseService: IMouseService, renderService: IRenderService): void; registerLinkProvider(linkProvider: ILinkProvider): IDisposable; From de334ea116efbfe8badd940a4ab808619835e3f1 Mon Sep 17 00:00:00 2001 From: kena0ki Date: Wed, 31 Mar 2021 23:32:53 +0900 Subject: [PATCH 129/377] Use RenderService.dimensions instead of CharSizeService for textarea position --- src/browser/Terminal.ts | 32 ++++++++++++--------- src/browser/input/CompositionHelper.test.ts | 4 +-- src/browser/input/CompositionHelper.ts | 17 +++++++---- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 2eba4027..95d74254 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -297,19 +297,23 @@ export class Terminal extends CoreTerminal implements ITerminal { } private _syncTextArea(): void { - if (!this.textarea || !this.buffer.isCursorInViewport || this._compositionHelper!.isComposing) { + if (!this.textarea || !this.buffer.isCursorInViewport || this._compositionHelper!.isComposing || !this._renderService) { return; } - - const cellHeight = Math.ceil(this._charSizeService!.height * this.optionsService.options.lineHeight); - const cursorTop = this._bufferService.buffer.y * cellHeight; - const cursorLeft = this._bufferService.buffer.x * this._charSizeService!.width; + const cursorY = this.buffer.ybase + this.buffer.y; + const viewportRelativeCursorY = cursorY - this.buffer.ydisp; + const cursorX = Math.min(this.buffer.x, this.cols - 1); + const cellHeight = this._renderService.dimensions.actualCellHeight; + const width = this.buffer.lines.get(cursorY)!.getWidth(cursorX); + const cellWidth = this._renderService.dimensions.actualCellWidth * width; + const cursorTop = viewportRelativeCursorY * this._renderService.dimensions.actualCellHeight; + const cursorLeft = cursorX * this._renderService.dimensions.actualCellWidth; // Sync the textarea to the exact position of the composition view so the IME knows where the // text is. this.textarea.style.left = cursorLeft + 'px'; this.textarea.style.top = cursorTop + 'px'; - this.textarea.style.width = this._charSizeService!.width + 'px'; + this.textarea.style.width = cellWidth +'px'; this.textarea.style.height = cellHeight + 'px'; this.textarea.style.lineHeight = cellHeight + 'px'; this.textarea.style.zIndex = '-5'; @@ -438,14 +442,6 @@ export class Terminal extends CoreTerminal implements ITerminal { this._charSizeService = this._instantiationService.createInstance(CharSizeService, this._document, this._helperContainer); this._instantiationService.setService(ICharSizeService, this._charSizeService); - this._compositionView = document.createElement('div'); - this._compositionView.classList.add('composition-view'); - this._compositionHelper = this._instantiationService.createInstance(CompositionHelper, this.textarea, this._compositionView); - this._helperContainer.appendChild(this._compositionView); - - // Performance: Add viewport and helper elements from the fragment - this.element.appendChild(fragment); - this._theme = this.options.theme || this._theme; this._colorManager = new ColorManager(document, this.options.allowTransparency); this.register(this.optionsService.onOptionChange(e => this._colorManager!.onOptionsChange(e))); @@ -457,6 +453,14 @@ export class Terminal extends CoreTerminal implements ITerminal { this.register(this._renderService.onRenderedBufferChange(e => this._onRender.fire(e))); this.onResize(e => this._renderService!.resize(e.cols, e.rows)); + this._compositionView = document.createElement('div'); + this._compositionView.classList.add('composition-view'); + this._compositionHelper = this._instantiationService.createInstance(CompositionHelper, this.textarea, this._compositionView); + this._helperContainer.appendChild(this._compositionView); + + // Performance: Add viewport and helper elements from the fragment + this.element.appendChild(fragment); + this._soundService = this._instantiationService.createInstance(SoundService); this._instantiationService.setService(ISoundService, this._soundService); this._mouseService = this._instantiationService.createInstance(MouseService); diff --git a/src/browser/input/CompositionHelper.test.ts b/src/browser/input/CompositionHelper.test.ts index b9a4f668..080c9c47 100644 --- a/src/browser/input/CompositionHelper.test.ts +++ b/src/browser/input/CompositionHelper.test.ts @@ -5,7 +5,7 @@ import { assert } from 'chai'; import { CompositionHelper } from 'browser/input/CompositionHelper'; -import { MockCharSizeService } from 'browser/TestUtils.test'; +import { MockCharSizeService, MockRenderService } from 'browser/TestUtils.test'; import { MockCoreService, MockBufferService, MockOptionsService } from 'common/TestUtils.test'; describe('CompositionHelper', () => { @@ -42,7 +42,7 @@ describe('CompositionHelper', () => { }; handledText = ''; const bufferService = new MockBufferService(10, 5); - compositionHelper = new CompositionHelper(textarea, compositionView, bufferService, new MockOptionsService(), new MockCharSizeService(10, 10), coreService); + compositionHelper = new CompositionHelper(textarea, compositionView, bufferService, new MockOptionsService(), new MockCharSizeService(10, 10), coreService, new MockRenderService()); }); describe('Input', () => { diff --git a/src/browser/input/CompositionHelper.ts b/src/browser/input/CompositionHelper.ts index 85cfc3b6..e5389af4 100644 --- a/src/browser/input/CompositionHelper.ts +++ b/src/browser/input/CompositionHelper.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { ICharSizeService } from 'browser/services/Services'; +import { ICharSizeService, IRenderService } from 'browser/services/Services'; import { IBufferService, ICoreService, IOptionsService } from 'common/services/Services'; interface IPosition { @@ -46,7 +46,8 @@ export class CompositionHelper { @IBufferService private readonly _bufferService: IBufferService, @IOptionsService private readonly _optionsService: IOptionsService, @ICharSizeService private readonly _charSizeService: ICharSizeService, - @ICoreService private readonly _coreService: ICoreService + @ICoreService private readonly _coreService: ICoreService, + @IRenderService private readonly _renderService: IRenderService ) { this._isComposing = false; this._isSendingComposition = false; @@ -202,14 +203,18 @@ export class CompositionHelper { * necessary as the IME events across browsers are not consistently triggered. */ public updateCompositionElements(dontRecurse?: boolean): void { - if (!this._isComposing) { + if (!this._isComposing || !this._renderService) { return; } if (this._bufferService.buffer.isCursorInViewport) { - const cellHeight = Math.ceil(this._charSizeService.height * this._optionsService.options.lineHeight); - const cursorTop = this._bufferService.buffer.y * cellHeight; - const cursorLeft = this._bufferService.buffer.x * this._charSizeService.width; + const cursorY = this._bufferService.buffer.ybase + this._bufferService.buffer.y; + const viewportRelativeCursorY = cursorY - this._bufferService.buffer.ydisp; + const cursorX = Math.min(this._bufferService.buffer.x, this._bufferService.cols - 1); + + const cellHeight = this._renderService.dimensions.actualCellHeight; + const cursorTop = viewportRelativeCursorY * this._renderService.dimensions.actualCellHeight; + const cursorLeft = cursorX * this._renderService.dimensions.actualCellWidth; this._compositionView.style.left = cursorLeft + 'px'; this._compositionView.style.top = cursorTop + 'px'; From a15f61bb8540cd7817170b735bee9a454eaf12a5 Mon Sep 17 00:00:00 2001 From: kena0ki Date: Thu, 1 Apr 2021 00:11:30 +0900 Subject: [PATCH 130/377] Remove non-null assertion --- src/browser/Terminal.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 95d74254..371f5549 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -304,7 +304,9 @@ export class Terminal extends CoreTerminal implements ITerminal { const viewportRelativeCursorY = cursorY - this.buffer.ydisp; const cursorX = Math.min(this.buffer.x, this.cols - 1); const cellHeight = this._renderService.dimensions.actualCellHeight; - const width = this.buffer.lines.get(cursorY)!.getWidth(cursorX); + const bufferLine = this.buffer.lines.get(cursorY); + if (!bufferLine) return; + const width = bufferLine.getWidth(cursorX); const cellWidth = this._renderService.dimensions.actualCellWidth * width; const cursorTop = viewportRelativeCursorY * this._renderService.dimensions.actualCellHeight; const cursorLeft = cursorX * this._renderService.dimensions.actualCellWidth; From e9e716964e1a24758132ac92e22276147ced54ed Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 1 Apr 2021 08:19:12 -0700 Subject: [PATCH 131/377] Remove now unneeded CharSizeService --- src/browser/input/CompositionHelper.test.ts | 4 ++-- src/browser/input/CompositionHelper.ts | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/browser/input/CompositionHelper.test.ts b/src/browser/input/CompositionHelper.test.ts index 080c9c47..c722570b 100644 --- a/src/browser/input/CompositionHelper.test.ts +++ b/src/browser/input/CompositionHelper.test.ts @@ -5,7 +5,7 @@ import { assert } from 'chai'; import { CompositionHelper } from 'browser/input/CompositionHelper'; -import { MockCharSizeService, MockRenderService } from 'browser/TestUtils.test'; +import { MockRenderService } from 'browser/TestUtils.test'; import { MockCoreService, MockBufferService, MockOptionsService } from 'common/TestUtils.test'; describe('CompositionHelper', () => { @@ -42,7 +42,7 @@ describe('CompositionHelper', () => { }; handledText = ''; const bufferService = new MockBufferService(10, 5); - compositionHelper = new CompositionHelper(textarea, compositionView, bufferService, new MockOptionsService(), new MockCharSizeService(10, 10), coreService, new MockRenderService()); + compositionHelper = new CompositionHelper(textarea, compositionView, bufferService, new MockOptionsService(), coreService, new MockRenderService()); }); describe('Input', () => { diff --git a/src/browser/input/CompositionHelper.ts b/src/browser/input/CompositionHelper.ts index e5389af4..d2626e2c 100644 --- a/src/browser/input/CompositionHelper.ts +++ b/src/browser/input/CompositionHelper.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { ICharSizeService, IRenderService } from 'browser/services/Services'; +import { IRenderService } from 'browser/services/Services'; import { IBufferService, ICoreService, IOptionsService } from 'common/services/Services'; interface IPosition { @@ -45,7 +45,6 @@ export class CompositionHelper { private readonly _compositionView: HTMLElement, @IBufferService private readonly _bufferService: IBufferService, @IOptionsService private readonly _optionsService: IOptionsService, - @ICharSizeService private readonly _charSizeService: ICharSizeService, @ICoreService private readonly _coreService: ICoreService, @IRenderService private readonly _renderService: IRenderService ) { From b62a64519f567081f327c34c01a056eb9edcdcd4 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 1 Apr 2021 08:23:18 -0700 Subject: [PATCH 132/377] Use buffer y for relative cursor pos --- src/browser/input/CompositionHelper.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/browser/input/CompositionHelper.ts b/src/browser/input/CompositionHelper.ts index d2626e2c..65a5d672 100644 --- a/src/browser/input/CompositionHelper.ts +++ b/src/browser/input/CompositionHelper.ts @@ -207,12 +207,10 @@ export class CompositionHelper { } if (this._bufferService.buffer.isCursorInViewport) { - const cursorY = this._bufferService.buffer.ybase + this._bufferService.buffer.y; - const viewportRelativeCursorY = cursorY - this._bufferService.buffer.ydisp; const cursorX = Math.min(this._bufferService.buffer.x, this._bufferService.cols - 1); const cellHeight = this._renderService.dimensions.actualCellHeight; - const cursorTop = viewportRelativeCursorY * this._renderService.dimensions.actualCellHeight; + const cursorTop = this._bufferService.buffer.y * this._renderService.dimensions.actualCellHeight; const cursorLeft = cursorX * this._renderService.dimensions.actualCellWidth; this._compositionView.style.left = cursorLeft + 'px'; From 05516750b5ac832147c7153f5db1f79d7f941508 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 1 Apr 2021 08:23:35 -0700 Subject: [PATCH 133/377] Remove RenderService check, it must be passed to ctor --- src/browser/input/CompositionHelper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/input/CompositionHelper.ts b/src/browser/input/CompositionHelper.ts index 65a5d672..8a204831 100644 --- a/src/browser/input/CompositionHelper.ts +++ b/src/browser/input/CompositionHelper.ts @@ -202,7 +202,7 @@ export class CompositionHelper { * necessary as the IME events across browsers are not consistently triggered. */ public updateCompositionElements(dontRecurse?: boolean): void { - if (!this._isComposing || !this._renderService) { + if (!this._isComposing) { return; } From 7b920adbe9ace642e4188a7c60412c9cd7d620d5 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 1 Apr 2021 08:26:35 -0700 Subject: [PATCH 134/377] Tidy up syncTextArea --- src/browser/Terminal.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 371f5549..f95013cd 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -301,21 +301,22 @@ export class Terminal extends CoreTerminal implements ITerminal { return; } const cursorY = this.buffer.ybase + this.buffer.y; - const viewportRelativeCursorY = cursorY - this.buffer.ydisp; + const bufferLine = this.buffer.lines.get(cursorY); + if (!bufferLine) { + return; + } const cursorX = Math.min(this.buffer.x, this.cols - 1); const cellHeight = this._renderService.dimensions.actualCellHeight; - const bufferLine = this.buffer.lines.get(cursorY); - if (!bufferLine) return; const width = bufferLine.getWidth(cursorX); const cellWidth = this._renderService.dimensions.actualCellWidth * width; - const cursorTop = viewportRelativeCursorY * this._renderService.dimensions.actualCellHeight; + const cursorTop = this.buffer.y * this._renderService.dimensions.actualCellHeight; const cursorLeft = cursorX * this._renderService.dimensions.actualCellWidth; // Sync the textarea to the exact position of the composition view so the IME knows where the // text is. this.textarea.style.left = cursorLeft + 'px'; this.textarea.style.top = cursorTop + 'px'; - this.textarea.style.width = cellWidth +'px'; + this.textarea.style.width = cellWidth + 'px'; this.textarea.style.height = cellHeight + 'px'; this.textarea.style.lineHeight = cellHeight + 'px'; this.textarea.style.zIndex = '-5'; From 1925f1f442132919e109fdce21f6d30f8053c471 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 1 Apr 2021 08:41:29 -0700 Subject: [PATCH 135/377] Improve whitespace --- src/browser/Terminal.ts | 2 +- src/common/CoreTerminal.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 44ea9eb0..1ab207c7 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -1194,7 +1194,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this.buffer.lines.push(this.buffer.getBlankLine(DEFAULT_ATTR_DATA)); } this.refresh(0, this.rows - 1); - this._onScroll.fire({position: this.buffer.ydisp, source: ScrollSource.TERMINAL }); + this._onScroll.fire({ position: this.buffer.ydisp, source: ScrollSource.TERMINAL }); } /** diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 253cd4c1..50a43bf1 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -224,7 +224,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { // Flag rows that need updating this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); - this._onScroll.fire({position: buffer.ydisp, source: ScrollSource.TERMINAL}); + this._onScroll.fire({ position: buffer.ydisp, source: ScrollSource.TERMINAL }); } /** @@ -254,7 +254,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { } if (!suppressScrollEvent) { - this._onScroll.fire({position: buffer.ydisp, source}); + this._onScroll.fire({ position: buffer.ydisp, source }); } } From f4861aa74a4e98eb06cc139dd6c8c1f10744cd89 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 1 Apr 2021 08:54:29 -0700 Subject: [PATCH 136/377] Move onScroll next to _onScroll --- src/common/CoreTerminal.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 50a43bf1..936aa0c8 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -71,10 +71,19 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { public get onResize(): IEvent<{ cols: number, rows: number }> { return this._onResize.event; } protected _onScroll = new EventEmitter(); /** - * An emitter for legacy on scroll events that just included the position, and not the source. - * Used to maintain API consistency for the onScroll method. + * Internally we track the source of the scroll but this is meaningless outside the library so + * it's filtered out. */ - protected _legacyOnScroll?: EventEmitter; + protected _onScrollApi?: EventEmitter; + public get onScroll(): IEvent { + if (!this._onScrollApi) { + this._onScrollApi = new EventEmitter(); + this.register(this._onScroll.event(ev => { + this._onScrollApi?.fire(ev.position); + })); + } + return this._onScrollApi.event; + } public get cols(): number { return this._bufferService.cols; } public get rows(): number { return this._bufferService.rows; } @@ -287,16 +296,6 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { } } - public get onScroll(): IEvent { - if (!this._legacyOnScroll) { - this._legacyOnScroll = new EventEmitter(); - this.register(this._onScroll.event(ev => { - this._legacyOnScroll?.fire(ev.position); - })); - } - return this._legacyOnScroll.event; - } - /** Add handler for ESC escape sequence. See xterm.d.ts for details. */ public registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise): IDisposable { return this._inputHandler.registerEscHandler(id, callback); From d4a93fe7e44c4d6931d4adf0d1b99011b7ca8d44 Mon Sep 17 00:00:00 2001 From: kena0ki Date: Wed, 31 Mar 2021 23:32:53 +0900 Subject: [PATCH 137/377] Use RenderService.dimensions instead of CharSizeService for textarea position --- src/browser/Terminal.ts | 32 ++++++++++++--------- src/browser/input/CompositionHelper.test.ts | 4 +-- src/browser/input/CompositionHelper.ts | 17 +++++++---- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 2eba4027..95d74254 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -297,19 +297,23 @@ export class Terminal extends CoreTerminal implements ITerminal { } private _syncTextArea(): void { - if (!this.textarea || !this.buffer.isCursorInViewport || this._compositionHelper!.isComposing) { + if (!this.textarea || !this.buffer.isCursorInViewport || this._compositionHelper!.isComposing || !this._renderService) { return; } - - const cellHeight = Math.ceil(this._charSizeService!.height * this.optionsService.options.lineHeight); - const cursorTop = this._bufferService.buffer.y * cellHeight; - const cursorLeft = this._bufferService.buffer.x * this._charSizeService!.width; + const cursorY = this.buffer.ybase + this.buffer.y; + const viewportRelativeCursorY = cursorY - this.buffer.ydisp; + const cursorX = Math.min(this.buffer.x, this.cols - 1); + const cellHeight = this._renderService.dimensions.actualCellHeight; + const width = this.buffer.lines.get(cursorY)!.getWidth(cursorX); + const cellWidth = this._renderService.dimensions.actualCellWidth * width; + const cursorTop = viewportRelativeCursorY * this._renderService.dimensions.actualCellHeight; + const cursorLeft = cursorX * this._renderService.dimensions.actualCellWidth; // Sync the textarea to the exact position of the composition view so the IME knows where the // text is. this.textarea.style.left = cursorLeft + 'px'; this.textarea.style.top = cursorTop + 'px'; - this.textarea.style.width = this._charSizeService!.width + 'px'; + this.textarea.style.width = cellWidth +'px'; this.textarea.style.height = cellHeight + 'px'; this.textarea.style.lineHeight = cellHeight + 'px'; this.textarea.style.zIndex = '-5'; @@ -438,14 +442,6 @@ export class Terminal extends CoreTerminal implements ITerminal { this._charSizeService = this._instantiationService.createInstance(CharSizeService, this._document, this._helperContainer); this._instantiationService.setService(ICharSizeService, this._charSizeService); - this._compositionView = document.createElement('div'); - this._compositionView.classList.add('composition-view'); - this._compositionHelper = this._instantiationService.createInstance(CompositionHelper, this.textarea, this._compositionView); - this._helperContainer.appendChild(this._compositionView); - - // Performance: Add viewport and helper elements from the fragment - this.element.appendChild(fragment); - this._theme = this.options.theme || this._theme; this._colorManager = new ColorManager(document, this.options.allowTransparency); this.register(this.optionsService.onOptionChange(e => this._colorManager!.onOptionsChange(e))); @@ -457,6 +453,14 @@ export class Terminal extends CoreTerminal implements ITerminal { this.register(this._renderService.onRenderedBufferChange(e => this._onRender.fire(e))); this.onResize(e => this._renderService!.resize(e.cols, e.rows)); + this._compositionView = document.createElement('div'); + this._compositionView.classList.add('composition-view'); + this._compositionHelper = this._instantiationService.createInstance(CompositionHelper, this.textarea, this._compositionView); + this._helperContainer.appendChild(this._compositionView); + + // Performance: Add viewport and helper elements from the fragment + this.element.appendChild(fragment); + this._soundService = this._instantiationService.createInstance(SoundService); this._instantiationService.setService(ISoundService, this._soundService); this._mouseService = this._instantiationService.createInstance(MouseService); diff --git a/src/browser/input/CompositionHelper.test.ts b/src/browser/input/CompositionHelper.test.ts index b9a4f668..080c9c47 100644 --- a/src/browser/input/CompositionHelper.test.ts +++ b/src/browser/input/CompositionHelper.test.ts @@ -5,7 +5,7 @@ import { assert } from 'chai'; import { CompositionHelper } from 'browser/input/CompositionHelper'; -import { MockCharSizeService } from 'browser/TestUtils.test'; +import { MockCharSizeService, MockRenderService } from 'browser/TestUtils.test'; import { MockCoreService, MockBufferService, MockOptionsService } from 'common/TestUtils.test'; describe('CompositionHelper', () => { @@ -42,7 +42,7 @@ describe('CompositionHelper', () => { }; handledText = ''; const bufferService = new MockBufferService(10, 5); - compositionHelper = new CompositionHelper(textarea, compositionView, bufferService, new MockOptionsService(), new MockCharSizeService(10, 10), coreService); + compositionHelper = new CompositionHelper(textarea, compositionView, bufferService, new MockOptionsService(), new MockCharSizeService(10, 10), coreService, new MockRenderService()); }); describe('Input', () => { diff --git a/src/browser/input/CompositionHelper.ts b/src/browser/input/CompositionHelper.ts index 85cfc3b6..e5389af4 100644 --- a/src/browser/input/CompositionHelper.ts +++ b/src/browser/input/CompositionHelper.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { ICharSizeService } from 'browser/services/Services'; +import { ICharSizeService, IRenderService } from 'browser/services/Services'; import { IBufferService, ICoreService, IOptionsService } from 'common/services/Services'; interface IPosition { @@ -46,7 +46,8 @@ export class CompositionHelper { @IBufferService private readonly _bufferService: IBufferService, @IOptionsService private readonly _optionsService: IOptionsService, @ICharSizeService private readonly _charSizeService: ICharSizeService, - @ICoreService private readonly _coreService: ICoreService + @ICoreService private readonly _coreService: ICoreService, + @IRenderService private readonly _renderService: IRenderService ) { this._isComposing = false; this._isSendingComposition = false; @@ -202,14 +203,18 @@ export class CompositionHelper { * necessary as the IME events across browsers are not consistently triggered. */ public updateCompositionElements(dontRecurse?: boolean): void { - if (!this._isComposing) { + if (!this._isComposing || !this._renderService) { return; } if (this._bufferService.buffer.isCursorInViewport) { - const cellHeight = Math.ceil(this._charSizeService.height * this._optionsService.options.lineHeight); - const cursorTop = this._bufferService.buffer.y * cellHeight; - const cursorLeft = this._bufferService.buffer.x * this._charSizeService.width; + const cursorY = this._bufferService.buffer.ybase + this._bufferService.buffer.y; + const viewportRelativeCursorY = cursorY - this._bufferService.buffer.ydisp; + const cursorX = Math.min(this._bufferService.buffer.x, this._bufferService.cols - 1); + + const cellHeight = this._renderService.dimensions.actualCellHeight; + const cursorTop = viewportRelativeCursorY * this._renderService.dimensions.actualCellHeight; + const cursorLeft = cursorX * this._renderService.dimensions.actualCellWidth; this._compositionView.style.left = cursorLeft + 'px'; this._compositionView.style.top = cursorTop + 'px'; From 49cb6f74bc1d106e1b68374a3b5d040b6a1b281d Mon Sep 17 00:00:00 2001 From: kena0ki Date: Thu, 1 Apr 2021 00:11:30 +0900 Subject: [PATCH 138/377] Remove non-null assertion --- src/browser/Terminal.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 95d74254..371f5549 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -304,7 +304,9 @@ export class Terminal extends CoreTerminal implements ITerminal { const viewportRelativeCursorY = cursorY - this.buffer.ydisp; const cursorX = Math.min(this.buffer.x, this.cols - 1); const cellHeight = this._renderService.dimensions.actualCellHeight; - const width = this.buffer.lines.get(cursorY)!.getWidth(cursorX); + const bufferLine = this.buffer.lines.get(cursorY); + if (!bufferLine) return; + const width = bufferLine.getWidth(cursorX); const cellWidth = this._renderService.dimensions.actualCellWidth * width; const cursorTop = viewportRelativeCursorY * this._renderService.dimensions.actualCellHeight; const cursorLeft = cursorX * this._renderService.dimensions.actualCellWidth; From 085a2b545f465508bf823549bf49081a2826e62b Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 1 Apr 2021 08:19:12 -0700 Subject: [PATCH 139/377] Remove now unneeded CharSizeService --- src/browser/input/CompositionHelper.test.ts | 4 ++-- src/browser/input/CompositionHelper.ts | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/browser/input/CompositionHelper.test.ts b/src/browser/input/CompositionHelper.test.ts index 080c9c47..c722570b 100644 --- a/src/browser/input/CompositionHelper.test.ts +++ b/src/browser/input/CompositionHelper.test.ts @@ -5,7 +5,7 @@ import { assert } from 'chai'; import { CompositionHelper } from 'browser/input/CompositionHelper'; -import { MockCharSizeService, MockRenderService } from 'browser/TestUtils.test'; +import { MockRenderService } from 'browser/TestUtils.test'; import { MockCoreService, MockBufferService, MockOptionsService } from 'common/TestUtils.test'; describe('CompositionHelper', () => { @@ -42,7 +42,7 @@ describe('CompositionHelper', () => { }; handledText = ''; const bufferService = new MockBufferService(10, 5); - compositionHelper = new CompositionHelper(textarea, compositionView, bufferService, new MockOptionsService(), new MockCharSizeService(10, 10), coreService, new MockRenderService()); + compositionHelper = new CompositionHelper(textarea, compositionView, bufferService, new MockOptionsService(), coreService, new MockRenderService()); }); describe('Input', () => { diff --git a/src/browser/input/CompositionHelper.ts b/src/browser/input/CompositionHelper.ts index e5389af4..d2626e2c 100644 --- a/src/browser/input/CompositionHelper.ts +++ b/src/browser/input/CompositionHelper.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { ICharSizeService, IRenderService } from 'browser/services/Services'; +import { IRenderService } from 'browser/services/Services'; import { IBufferService, ICoreService, IOptionsService } from 'common/services/Services'; interface IPosition { @@ -45,7 +45,6 @@ export class CompositionHelper { private readonly _compositionView: HTMLElement, @IBufferService private readonly _bufferService: IBufferService, @IOptionsService private readonly _optionsService: IOptionsService, - @ICharSizeService private readonly _charSizeService: ICharSizeService, @ICoreService private readonly _coreService: ICoreService, @IRenderService private readonly _renderService: IRenderService ) { From 3ae61fc1dd783957ea12fc22b9e8b422f505cb38 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 1 Apr 2021 08:23:18 -0700 Subject: [PATCH 140/377] Use buffer y for relative cursor pos --- src/browser/input/CompositionHelper.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/browser/input/CompositionHelper.ts b/src/browser/input/CompositionHelper.ts index d2626e2c..65a5d672 100644 --- a/src/browser/input/CompositionHelper.ts +++ b/src/browser/input/CompositionHelper.ts @@ -207,12 +207,10 @@ export class CompositionHelper { } if (this._bufferService.buffer.isCursorInViewport) { - const cursorY = this._bufferService.buffer.ybase + this._bufferService.buffer.y; - const viewportRelativeCursorY = cursorY - this._bufferService.buffer.ydisp; const cursorX = Math.min(this._bufferService.buffer.x, this._bufferService.cols - 1); const cellHeight = this._renderService.dimensions.actualCellHeight; - const cursorTop = viewportRelativeCursorY * this._renderService.dimensions.actualCellHeight; + const cursorTop = this._bufferService.buffer.y * this._renderService.dimensions.actualCellHeight; const cursorLeft = cursorX * this._renderService.dimensions.actualCellWidth; this._compositionView.style.left = cursorLeft + 'px'; From 07499380d18c771ddaa70f84f6daaf63ec392afa Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 1 Apr 2021 08:23:35 -0700 Subject: [PATCH 141/377] Remove RenderService check, it must be passed to ctor --- src/browser/input/CompositionHelper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/input/CompositionHelper.ts b/src/browser/input/CompositionHelper.ts index 65a5d672..8a204831 100644 --- a/src/browser/input/CompositionHelper.ts +++ b/src/browser/input/CompositionHelper.ts @@ -202,7 +202,7 @@ export class CompositionHelper { * necessary as the IME events across browsers are not consistently triggered. */ public updateCompositionElements(dontRecurse?: boolean): void { - if (!this._isComposing || !this._renderService) { + if (!this._isComposing) { return; } From 87ed4f07cdad13123f9fb09d40b7e4651f0e4633 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 1 Apr 2021 08:26:35 -0700 Subject: [PATCH 142/377] Tidy up syncTextArea --- src/browser/Terminal.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 371f5549..f95013cd 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -301,21 +301,22 @@ export class Terminal extends CoreTerminal implements ITerminal { return; } const cursorY = this.buffer.ybase + this.buffer.y; - const viewportRelativeCursorY = cursorY - this.buffer.ydisp; + const bufferLine = this.buffer.lines.get(cursorY); + if (!bufferLine) { + return; + } const cursorX = Math.min(this.buffer.x, this.cols - 1); const cellHeight = this._renderService.dimensions.actualCellHeight; - const bufferLine = this.buffer.lines.get(cursorY); - if (!bufferLine) return; const width = bufferLine.getWidth(cursorX); const cellWidth = this._renderService.dimensions.actualCellWidth * width; - const cursorTop = viewportRelativeCursorY * this._renderService.dimensions.actualCellHeight; + const cursorTop = this.buffer.y * this._renderService.dimensions.actualCellHeight; const cursorLeft = cursorX * this._renderService.dimensions.actualCellWidth; // Sync the textarea to the exact position of the composition view so the IME knows where the // text is. this.textarea.style.left = cursorLeft + 'px'; this.textarea.style.top = cursorTop + 'px'; - this.textarea.style.width = cellWidth +'px'; + this.textarea.style.width = cellWidth + 'px'; this.textarea.style.height = cellHeight + 'px'; this.textarea.style.lineHeight = cellHeight + 'px'; this.textarea.style.zIndex = '-5'; From fa7889cdd02436f40e1c581f135900d5fedb9f21 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Thu, 1 Apr 2021 12:17:34 -0700 Subject: [PATCH 143/377] add onRecovercontext event --- addons/xterm-addon-webgl/src/WebglAddon.ts | 6 +++++- addons/xterm-addon-webgl/src/WebglRenderer.ts | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/addons/xterm-addon-webgl/src/WebglAddon.ts b/addons/xterm-addon-webgl/src/WebglAddon.ts index aef1301e..8eeda832 100644 --- a/addons/xterm-addon-webgl/src/WebglAddon.ts +++ b/addons/xterm-addon-webgl/src/WebglAddon.ts @@ -3,14 +3,17 @@ * @license MIT */ -import { Terminal, ITerminalAddon } from 'xterm'; +import { Terminal, ITerminalAddon, IEvent } from 'xterm'; import { WebglRenderer } from './WebglRenderer'; import { IRenderService } from 'browser/services/Services'; import { IColorSet } from 'browser/Types'; +import { EventEmitter } from 'common/EventEmitter'; export class WebglAddon implements ITerminalAddon { private _terminal?: Terminal; private _renderer?: WebglRenderer; + private _onRecoverContext = new EventEmitter(); + public get onRecoverContext(): IEvent { return this._onRecoverContext.event; } constructor( private _preserveDrawingBuffer?: boolean @@ -24,6 +27,7 @@ export class WebglAddon implements ITerminalAddon { const renderService: IRenderService = (terminal)._core._renderService; const colors: IColorSet = (terminal)._core._colorManager.colors; this._renderer = new WebglRenderer(terminal, colors, this._preserveDrawingBuffer); + this._renderer.onRecoverContext(() => this._onRecoverContext.fire()); renderService.setRenderer(this._renderer); } diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index fecd5742..86e2900d 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -19,6 +19,7 @@ import { IRenderDimensions, IRenderer, IRequestRedrawEvent } from 'browser/rende import { ITerminal, IColorSet } from 'browser/Types'; import { EventEmitter } from 'common/EventEmitter'; import { CellData } from 'common/buffer/CellData'; +import { addDisposableDomListener } from 'browser/Lifecycle'; export class WebglRenderer extends Disposable implements IRenderer { private _renderLayers: IRenderLayer[]; @@ -41,6 +42,9 @@ export class WebglRenderer extends Disposable implements IRenderer { private _onRequestRedraw = new EventEmitter(); public get onRequestRedraw(): IEvent { return this._onRequestRedraw.event; } + private _onRecoverContext = new EventEmitter(); + public get onRecoverContext(): IEvent { return this._onRecoverContext.event; } + constructor( private _terminal: Terminal, private _colors: IColorSet, @@ -82,6 +86,9 @@ export class WebglRenderer extends Disposable implements IRenderer { if (!this._gl) { throw new Error('WebGL2 not supported ' + this._gl); } + + this.register(addDisposableDomListener(this._canvas, 'webglcontextlost', (e) => { this._onContextLost(e); })); + this._core.screenElement!.appendChild(this._canvas); this._rectangleRenderer = new RectangleRenderer(this._terminal, this._colors, this._gl, this.dimensions); @@ -93,6 +100,11 @@ export class WebglRenderer extends Disposable implements IRenderer { this._isAttached = document.body.contains(this._core.screenElement!); } + private _onContextLost(e: Event): void { + e.preventDefault(); + this._onRecoverContext.fire(); + } + public dispose(): void { for (const l of this._renderLayers) { l.dispose(); From e2885f3a3877c36564195dd3fe0d9c24d924dc3d Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 31 Mar 2021 20:07:54 -0700 Subject: [PATCH 144/377] move stuff to inputHandler and move scroll to bufferService --- src/browser/Terminal.test.ts | 2245 +++++++++++--------------- src/browser/Terminal.ts | 4 +- src/common/CoreTerminal.ts | 37 +- src/common/InputHandler.test.ts | 184 ++- src/common/TestUtils.test.ts | 59 +- src/common/services/BufferService.ts | 141 +- src/common/services/Services.ts | 11 +- 7 files changed, 1328 insertions(+), 1353 deletions(-) diff --git a/src/browser/Terminal.test.ts b/src/browser/Terminal.test.ts index 5724715f..f3bcdfda 100644 --- a/src/browser/Terminal.test.ts +++ b/src/browser/Terminal.test.ts @@ -117,13 +117,6 @@ describe('Terminal', () => { }); term.resize(1, 1); }); - it('should fire the onScroll event', (done) => { - term.onScroll(e => { - assert.equal(typeof e, 'number'); - done(); - }); - term.scroll(DEFAULT_ATTR_DATA.clone()); - }); it('should fire the onTitleChange event', (done) => { term.onTitleChange(e => { assert.equal(e, 'title'); @@ -280,1359 +273,991 @@ describe('Terminal', () => { }); }); - describe('scrollPages', () => { - let startYDisp: number; - beforeEach(async () => { - for (let i = 0; i < term.rows * 3; i++) { - await term.writeP('test\r\n'); - } - startYDisp = (term.rows * 2) + 1; - }); - it('should scroll a single page', () => { - assert.equal(term.buffer.ydisp, startYDisp); - term.scrollPages(-1); - assert.equal(term.buffer.ydisp, startYDisp - (term.rows - 1)); - term.scrollPages(1); - assert.equal(term.buffer.ydisp, startYDisp); - }); - it('should scroll a multiple pages', () => { - assert.equal(term.buffer.ydisp, startYDisp); - term.scrollPages(-2); - assert.equal(term.buffer.ydisp, startYDisp - (term.rows - 1) * 2); - term.scrollPages(2); - assert.equal(term.buffer.ydisp, startYDisp); - }); - }); + describe('Third level shift', () => { + let evKeyDown: any; + let evKeyPress: any; - describe('scrollToTop', () => { - beforeEach(async () => { - for (let i = 0; i < term.rows * 3; i++) { - await term.writeP('test\r\n'); - } - }); - it('should scroll to the top', () => { - assert.notEqual(term.buffer.ydisp, 0); - term.scrollToTop(); - assert.equal(term.buffer.ydisp, 0); - }); - }); - - describe('scrollToBottom', () => { - let startYDisp: number; - beforeEach(async () => { - for (let i = 0; i < term.rows * 3; i++) { - await term.writeP('test\r\n'); - } - startYDisp = (term.rows * 2) + 1; - }); - it('should scroll to the bottom', () => { - term.scrollLines(-1); - term.scrollToBottom(); - assert.equal(term.buffer.ydisp, startYDisp); - term.scrollPages(-1); - term.scrollToBottom(); - assert.equal(term.buffer.ydisp, startYDisp); - term.scrollToTop(); - term.scrollToBottom(); - assert.equal(term.buffer.ydisp, startYDisp); - }); - }); - - describe('scrollToLine', () => { - let startYDisp: number; - beforeEach(async () => { - for (let i = 0; i < term.rows * 3; i++) { - await term.writeP('test\r\n'); - } - startYDisp = (term.rows * 2) + 1; - }); - it('should scroll to requested line', () => { - assert.equal(term.buffer.ydisp, startYDisp); - term.scrollToLine(0); - assert.equal(term.buffer.ydisp, 0); - term.scrollToLine(10); - assert.equal(term.buffer.ydisp, 10); - term.scrollToLine(startYDisp); - assert.equal(term.buffer.ydisp, startYDisp); - term.scrollToLine(20); - assert.equal(term.buffer.ydisp, 20); - }); - it('should not scroll beyond boundary lines', () => { - assert.equal(term.buffer.ydisp, startYDisp); - term.scrollToLine(-1); - assert.equal(term.buffer.ydisp, 0); - term.scrollToLine(startYDisp + 1); - assert.equal(term.buffer.ydisp, startYDisp); - }); - }); - - describe('keyPress', () => { - it('should scroll down, when a key is pressed and terminal is scrolled up', () => { - const event = { - type: 'keydown', - key: 'a', - keyCode: 65, + beforeEach(() => { + term.clearSelection = () => { }; + // term.compositionHelper = { + // isComposing: false, + // keydown: { + // bind: () => { + // return () => { return true; }; + // } + // } + // }; + evKeyDown = { preventDefault: () => { }, - stopPropagation: () => { } + stopPropagation: () => { }, + type: 'keydown', + altKey: null, + keyCode: null + }; + evKeyPress = { + preventDefault: () => { }, + stopPropagation: () => { }, + type: 'keypress', + altKey: null, + charCode: null, + keyCode: null }; - - term.buffer.ydisp = 0; - term.buffer.ybase = 40; - term.keyPress(event); - - // Ensure that now the terminal is scrolled to bottom - assert.equal(term.buffer.ydisp, term.buffer.ybase); }); - it('should not scroll down, when a custom keydown handler prevents the event', async () => { - // Add some output to the terminal - for (let i = 0; i < term.rows * 3; i++) { - await term.writeP('test\r\n'); - } - const startYDisp = (term.rows * 2) + 1; - term.attachCustomKeyEventHandler(() => { - return false; - }); - - assert.equal(term.buffer.ydisp, startYDisp); - term.scrollLines(-1); - assert.equal(term.buffer.ydisp, startYDisp - 1); - term.keyPress({ keyCode: 0 }); - assert.equal(term.buffer.ydisp, startYDisp - 1); - }); - }); - - describe('scroll() function', () => { - describe('when scrollback > 0', () => { - it('should create a new line and scroll', () => { - term.buffer.lines.get(0)!.setCell(0, CellData.fromCharData([0, 'a', 0, 'a'.charCodeAt(0)])); - term.buffer.lines.get(INIT_ROWS - 1)!.setCell(0, CellData.fromCharData([0, 'b', 0, 'b'.charCodeAt(0)])); - term.buffer.y = INIT_ROWS - 1; // Move cursor to last line - term.scroll(DEFAULT_ATTR_DATA.clone()); - assert.equal(term.buffer.lines.length, INIT_ROWS + 1); - assert.equal(term.buffer.lines.get(0)!.loadCell(0, new CellData()).getChars(), 'a'); - assert.equal(term.buffer.lines.get(INIT_ROWS - 1)!.loadCell(0, new CellData()).getChars(), 'b'); - assert.equal(term.buffer.lines.get(INIT_ROWS)!.loadCell(0, new CellData()).getChars(), ''); - }); - - it('should properly scroll inside a scroll region (scrollTop set)', () => { - term.buffer.lines.get(0)!.setCell(0, CellData.fromCharData([0, 'a', 0, 'a'.charCodeAt(0)])); - term.buffer.lines.get(1)!.setCell(0, CellData.fromCharData([0, 'b', 0, 'b'.charCodeAt(0)])); - term.buffer.lines.get(2)!.setCell(0, CellData.fromCharData([0, 'c', 0, 'c'.charCodeAt(0)])); - term.buffer.y = INIT_ROWS - 1; // Move cursor to last line - term.buffer.scrollTop = 1; - term.scroll(DEFAULT_ATTR_DATA.clone()); - assert.equal(term.buffer.lines.length, INIT_ROWS); - assert.equal(term.buffer.lines.get(0)!.loadCell(0, new CellData()).getChars(), 'a'); - assert.equal(term.buffer.lines.get(1)!.loadCell(0, new CellData()).getChars(), 'c'); - }); - - it('should properly scroll inside a scroll region (scrollBottom set)', () => { - term.buffer.lines.get(0)!.setCell(0, CellData.fromCharData([0, 'a', 0, 'a'.charCodeAt(0)])); - term.buffer.lines.get(1)!.setCell(0, CellData.fromCharData([0, 'b', 0, 'b'.charCodeAt(0)])); - term.buffer.lines.get(2)!.setCell(0, CellData.fromCharData([0, 'c', 0, 'c'.charCodeAt(0)])); - term.buffer.lines.get(3)!.setCell(0, CellData.fromCharData([0, 'd', 0, 'd'.charCodeAt(0)])); - term.buffer.lines.get(4)!.setCell(0, CellData.fromCharData([0, 'e', 0, 'e'.charCodeAt(0)])); - term.buffer.y = 3; - term.buffer.scrollBottom = 3; - term.scroll(DEFAULT_ATTR_DATA.clone()); - assert.equal(term.buffer.lines.length, INIT_ROWS + 1); - assert.equal(term.buffer.lines.get(0)!.loadCell(0, new CellData()).getChars(), 'a', '\'a\' should be pushed to the scrollback'); - assert.equal(term.buffer.lines.get(1)!.loadCell(0, new CellData()).getChars(), 'b'); - assert.equal(term.buffer.lines.get(2)!.loadCell(0, new CellData()).getChars(), 'c'); - assert.equal(term.buffer.lines.get(3)!.loadCell(0, new CellData()).getChars(), 'd'); - assert.equal(term.buffer.lines.get(4)!.loadCell(0, new CellData()).getChars(), '', 'a blank line should be added at scrollBottom\'s index'); - assert.equal(term.buffer.lines.get(5)!.loadCell(0, new CellData()).getChars(), 'e'); - }); - - it('should properly scroll inside a scroll region (scrollTop and scrollBottom set)', () => { - term.buffer.lines.get(0)!.setCell(0, CellData.fromCharData([0, 'a', 0, 'a'.charCodeAt(0)])); - term.buffer.lines.get(1)!.setCell(0, CellData.fromCharData([0, 'b', 0, 'b'.charCodeAt(0)])); - term.buffer.lines.get(2)!.setCell(0, CellData.fromCharData([0, 'c', 0, 'c'.charCodeAt(0)])); - term.buffer.lines.get(3)!.setCell(0, CellData.fromCharData([0, 'd', 0, 'd'.charCodeAt(0)])); - term.buffer.lines.get(4)!.setCell(0, CellData.fromCharData([0, 'e', 0, 'e'.charCodeAt(0)])); - term.buffer.y = INIT_ROWS - 1; // Move cursor to last line - term.buffer.scrollTop = 1; - term.buffer.scrollBottom = 3; - term.scroll(DEFAULT_ATTR_DATA.clone()); - assert.equal(term.buffer.lines.length, INIT_ROWS); - assert.equal(term.buffer.lines.get(0)!.loadCell(0, new CellData()).getChars(), 'a'); - assert.equal(term.buffer.lines.get(1)!.loadCell(0, new CellData()).getChars(), 'c', '\'b\' should be removed from the buffer'); - assert.equal(term.buffer.lines.get(2)!.loadCell(0, new CellData()).getChars(), 'd'); - assert.equal(term.buffer.lines.get(3)!.loadCell(0, new CellData()).getChars(), '', 'a blank line should be added at scrollBottom\'s index'); - assert.equal(term.buffer.lines.get(4)!.loadCell(0, new CellData()).getChars(), 'e'); - }); - }); - - describe('when scrollback === 0', () => { + describe('with macOptionIsMeta', () => { + let originalIsMac: boolean; beforeEach(() => { - term.optionsService.setOption('scrollback', 0); - assert.equal(term.buffer.lines.maxLength, INIT_ROWS); + originalIsMac = term.browser.isMac; + term.options.macOptionIsMeta = true; + }); + afterEach(() => term.browser.isMac = originalIsMac); + + it('should interfere with the alt key on keyDown', () => { + evKeyDown.altKey = true; + evKeyDown.keyCode = 81; + assert.equal(term.keyDown(evKeyDown), false); + evKeyDown.altKey = true; + evKeyDown.keyCode = 192; + assert.equal(term.keyDown(evKeyDown), false); + }); + }); + + describe('On Mac OS', () => { + let originalIsMac: boolean; + beforeEach(() => { + originalIsMac = term.browser.isMac; + term.browser.isMac = true; + }); + afterEach(() => term.browser.isMac = originalIsMac); + + it('should not interfere with the alt key on keyDown', () => { + evKeyDown.altKey = true; + evKeyDown.keyCode = 81; + assert.equal(term.keyDown(evKeyDown), true); + evKeyDown.altKey = true; + evKeyDown.keyCode = 192; + term.keyDown(evKeyDown); + assert.equal(term.keyDown(evKeyDown), true); }); - it('should create a new line and shift everything up', () => { - term.buffer.lines.get(0)!.setCell(0, CellData.fromCharData([0, 'a', 0, 'a'.charCodeAt(0)])); - term.buffer.lines.get(1)!.setCell(0, CellData.fromCharData([0, 'b', 0, 'b'.charCodeAt(0)])); - term.buffer.lines.get(INIT_ROWS - 1)!.setCell(0, CellData.fromCharData([0, 'c', 0, 'c'.charCodeAt(0)])); - term.buffer.y = INIT_ROWS - 1; // Move cursor to last line - assert.equal(term.buffer.lines.length, INIT_ROWS); - term.scroll(DEFAULT_ATTR_DATA.clone()); - assert.equal(term.buffer.lines.length, INIT_ROWS); - // 'a' gets pushed out of buffer - assert.equal(term.buffer.lines.get(0)!.loadCell(0, new CellData()).getChars(), 'b'); - assert.equal(term.buffer.lines.get(1)!.loadCell(0, new CellData()).getChars(), ''); - assert.equal(term.buffer.lines.get(INIT_ROWS - 2)!.loadCell(0, new CellData()).getChars(), 'c'); - assert.equal(term.buffer.lines.get(INIT_ROWS - 1)!.loadCell(0, new CellData()).getChars(), ''); + it('should interfere with the alt + arrow keys', () => { + evKeyDown.altKey = true; + evKeyDown.keyCode = 37; + assert.equal(term.keyDown(evKeyDown), false); + evKeyDown.altKey = true; + evKeyDown.keyCode = 39; + assert.equal(term.keyDown(evKeyDown), false); }); - it('should properly scroll inside a scroll region (scrollTop set)', () => { - term.buffer.lines.get(0)!.setCell(0, CellData.fromCharData([0, 'a', 0, 'a'.charCodeAt(0)])); - term.buffer.lines.get(1)!.setCell(0, CellData.fromCharData([0, 'b', 0, 'b'.charCodeAt(0)])); - term.buffer.lines.get(2)!.setCell(0, CellData.fromCharData([0, 'c', 0, 'c'.charCodeAt(0)])); - term.buffer.y = INIT_ROWS - 1; // Move cursor to last line - term.buffer.scrollTop = 1; - term.scroll(DEFAULT_ATTR_DATA.clone()); - assert.equal(term.buffer.lines.length, INIT_ROWS); - assert.equal(term.buffer.lines.get(0)!.loadCell(0, new CellData()).getChars(), 'a'); - assert.equal(term.buffer.lines.get(1)!.loadCell(0, new CellData()).getChars(), 'c'); + it('should emit key with alt + key on keyPress', (done) => { + const keys = ['@', '@', '\\', '\\', '|', '|']; + + term.onKey(e => { + if (e.key) { + const index = keys.indexOf(e.key); + assert(index !== -1, 'Emitted wrong key: ' + e.key); + keys.splice(index, 1); + } + if (keys.length === 0) done(); + }); + + evKeyPress.altKey = true; + // @ + evKeyPress.charCode = null; + evKeyPress.keyCode = 64; + term.keyPress(evKeyPress); + // Firefox @ + evKeyPress.charCode = 64; + evKeyPress.keyCode = 0; + term.keyPress(evKeyPress); + // \ + evKeyPress.charCode = null; + evKeyPress.keyCode = 92; + term.keyPress(evKeyPress); + // Firefox \ + evKeyPress.charCode = 92; + evKeyPress.keyCode = 0; + term.keyPress(evKeyPress); + // | + evKeyPress.charCode = null; + evKeyPress.keyCode = 124; + term.keyPress(evKeyPress); + // Firefox | + evKeyPress.charCode = 124; + evKeyPress.keyCode = 0; + term.keyPress(evKeyPress); + }); + }); + + describe('On MS Windows', () => { + let originalIsWindows: boolean; + beforeEach(() => { + originalIsWindows = term.browser.isWindows; + term.browser.isWindows = true; + }); + afterEach(() => term.browser.isWindows = originalIsWindows); + + it('should not interfere with the alt + ctrl key on keyDown', () => { + evKeyPress.altKey = true; + evKeyPress.ctrlKey = true; + evKeyPress.keyCode = 81; + assert.equal(term.keyDown(evKeyPress), true); + evKeyDown.altKey = true; + evKeyDown.ctrlKey = true; + evKeyDown.keyCode = 81; + term.keyDown(evKeyDown); + assert.equal(term.keyDown(evKeyPress), true); }); - it('should properly scroll inside a scroll region (scrollBottom set)', () => { - term.buffer.lines.get(0)!.setCell(0, CellData.fromCharData([0, 'a', 0, 'a'.charCodeAt(0)])); - term.buffer.lines.get(1)!.setCell(0, CellData.fromCharData([0, 'b', 0, 'b'.charCodeAt(0)])); - term.buffer.lines.get(2)!.setCell(0, CellData.fromCharData([0, 'c', 0, 'c'.charCodeAt(0)])); - term.buffer.lines.get(3)!.setCell(0, CellData.fromCharData([0, 'd', 0, 'd'.charCodeAt(0)])); - term.buffer.lines.get(4)!.setCell(0, CellData.fromCharData([0, 'e', 0, 'e'.charCodeAt(0)])); - term.buffer.y = 3; - term.buffer.scrollBottom = 3; - term.scroll(DEFAULT_ATTR_DATA.clone()); - assert.equal(term.buffer.lines.length, INIT_ROWS); - assert.equal(term.buffer.lines.get(0)!.loadCell(0, new CellData()).getChars(), 'b'); - assert.equal(term.buffer.lines.get(1)!.loadCell(0, new CellData()).getChars(), 'c'); - assert.equal(term.buffer.lines.get(2)!.loadCell(0, new CellData()).getChars(), 'd'); - assert.equal(term.buffer.lines.get(3)!.loadCell(0, new CellData()).getChars(), '', 'a blank line should be added at scrollBottom\'s index'); - assert.equal(term.buffer.lines.get(4)!.loadCell(0, new CellData()).getChars(), 'e'); + it('should interfere with the alt + ctrl + arrow keys', () => { + evKeyDown.altKey = true; + evKeyDown.ctrlKey = true; + + evKeyDown.keyCode = 37; + assert.equal(term.keyDown(evKeyDown), false); + evKeyDown.keyCode = 39; + term.keyDown(evKeyDown); + assert.equal(term.keyDown(evKeyDown), false); }); - it('should properly scroll inside a scroll region (scrollTop and scrollBottom set)', () => { - term.buffer.lines.get(0)!.setCell(0, CellData.fromCharData([0, 'a', 0, 'a'.charCodeAt(0)])); - term.buffer.lines.get(1)!.setCell(0, CellData.fromCharData([0, 'b', 0, 'b'.charCodeAt(0)])); - term.buffer.lines.get(2)!.setCell(0, CellData.fromCharData([0, 'c', 0, 'c'.charCodeAt(0)])); - term.buffer.lines.get(3)!.setCell(0, CellData.fromCharData([0, 'd', 0, 'd'.charCodeAt(0)])); - term.buffer.lines.get(4)!.setCell(0, CellData.fromCharData([0, 'e', 0, 'e'.charCodeAt(0)])); - term.buffer.y = INIT_ROWS - 1; // Move cursor to last line - term.buffer.scrollTop = 1; - term.buffer.scrollBottom = 3; - term.scroll(DEFAULT_ATTR_DATA.clone()); - assert.equal(term.buffer.lines.length, INIT_ROWS); - assert.equal(term.buffer.lines.get(0)!.loadCell(0, new CellData()).getChars(), 'a'); - assert.equal(term.buffer.lines.get(1)!.loadCell(0, new CellData()).getChars(), 'c', '\'b\' should be removed from the buffer'); - assert.equal(term.buffer.lines.get(2)!.loadCell(0, new CellData()).getChars(), 'd'); - assert.equal(term.buffer.lines.get(3)!.loadCell(0, new CellData()).getChars(), '', 'a blank line should be added at scrollBottom\'s index'); - assert.equal(term.buffer.lines.get(4)!.loadCell(0, new CellData()).getChars(), 'e'); + it('should emit key with alt + ctrl + key on keyPress', (done) => { + const keys = ['@', '@', '\\', '\\', '|', '|']; + + term.onKey(e => { + if (e.key) { + const index = keys.indexOf(e.key); + assert(index !== -1, 'Emitted wrong key: ' + e.key); + keys.splice(index, 1); + } + if (keys.length === 0) done(); + }); + + evKeyPress.altKey = true; + evKeyPress.ctrlKey = true; + + // @ + evKeyPress.charCode = null; + evKeyPress.keyCode = 64; + term.keyPress(evKeyPress); + // Firefox @ + evKeyPress.charCode = 64; + evKeyPress.keyCode = 0; + term.keyPress(evKeyPress); + // \ + evKeyPress.charCode = null; + evKeyPress.keyCode = 92; + term.keyPress(evKeyPress); + // Firefox \ + evKeyPress.charCode = 92; + evKeyPress.keyCode = 0; + term.keyPress(evKeyPress); + // | + evKeyPress.charCode = null; + evKeyPress.keyCode = 124; + term.keyPress(evKeyPress); + // Firefox | + evKeyPress.charCode = 124; + evKeyPress.keyCode = 0; + term.keyPress(evKeyPress); }); }); }); - }); - describe('Third level shift', () => { - let evKeyDown: any; - let evKeyPress: any; - - beforeEach(() => { - term.clearSelection = () => { }; - // term.compositionHelper = { - // isComposing: false, - // keydown: { - // bind: () => { - // return () => { return true; }; - // } - // } - // }; - evKeyDown = { - preventDefault: () => { }, - stopPropagation: () => { }, - type: 'keydown', - altKey: null, - keyCode: null - }; - evKeyPress = { - preventDefault: () => { }, - stopPropagation: () => { }, - type: 'keypress', - altKey: null, - charCode: null, - keyCode: null - }; - }); - - describe('with macOptionIsMeta', () => { - let originalIsMac: boolean; - beforeEach(() => { - originalIsMac = term.browser.isMac; - term.options.macOptionIsMeta = true; - }); - afterEach(() => term.browser.isMac = originalIsMac); - - it('should interfere with the alt key on keyDown', () => { - evKeyDown.altKey = true; - evKeyDown.keyCode = 81; - assert.equal(term.keyDown(evKeyDown), false); - evKeyDown.altKey = true; - evKeyDown.keyCode = 192; - assert.equal(term.keyDown(evKeyDown), false); - }); - }); - - describe('On Mac OS', () => { - let originalIsMac: boolean; - beforeEach(() => { - originalIsMac = term.browser.isMac; - term.browser.isMac = true; - }); - afterEach(() => term.browser.isMac = originalIsMac); - - it('should not interfere with the alt key on keyDown', () => { - evKeyDown.altKey = true; - evKeyDown.keyCode = 81; - assert.equal(term.keyDown(evKeyDown), true); - evKeyDown.altKey = true; - evKeyDown.keyCode = 192; - term.keyDown(evKeyDown); - assert.equal(term.keyDown(evKeyDown), true); - }); - - it('should interfere with the alt + arrow keys', () => { - evKeyDown.altKey = true; - evKeyDown.keyCode = 37; - assert.equal(term.keyDown(evKeyDown), false); - evKeyDown.altKey = true; - evKeyDown.keyCode = 39; - assert.equal(term.keyDown(evKeyDown), false); - }); - - it('should emit key with alt + key on keyPress', (done) => { - const keys = ['@', '@', '\\', '\\', '|', '|']; - - term.onKey(e => { - if (e.key) { - const index = keys.indexOf(e.key); - assert(index !== -1, 'Emitted wrong key: ' + e.key); - keys.splice(index, 1); - } - if (keys.length === 0) done(); - }); - - evKeyPress.altKey = true; - // @ - evKeyPress.charCode = null; - evKeyPress.keyCode = 64; - term.keyPress(evKeyPress); - // Firefox @ - evKeyPress.charCode = 64; - evKeyPress.keyCode = 0; - term.keyPress(evKeyPress); - // \ - evKeyPress.charCode = null; - evKeyPress.keyCode = 92; - term.keyPress(evKeyPress); - // Firefox \ - evKeyPress.charCode = 92; - evKeyPress.keyCode = 0; - term.keyPress(evKeyPress); - // | - evKeyPress.charCode = null; - evKeyPress.keyCode = 124; - term.keyPress(evKeyPress); - // Firefox | - evKeyPress.charCode = 124; - evKeyPress.keyCode = 0; - term.keyPress(evKeyPress); - }); - }); - - describe('On MS Windows', () => { - let originalIsWindows: boolean; - beforeEach(() => { - originalIsWindows = term.browser.isWindows; - term.browser.isWindows = true; - }); - afterEach(() => term.browser.isWindows = originalIsWindows); - - it('should not interfere with the alt + ctrl key on keyDown', () => { - evKeyPress.altKey = true; - evKeyPress.ctrlKey = true; - evKeyPress.keyCode = 81; - assert.equal(term.keyDown(evKeyPress), true); - evKeyDown.altKey = true; - evKeyDown.ctrlKey = true; - evKeyDown.keyCode = 81; - term.keyDown(evKeyDown); - assert.equal(term.keyDown(evKeyPress), true); - }); - - it('should interfere with the alt + ctrl + arrow keys', () => { - evKeyDown.altKey = true; - evKeyDown.ctrlKey = true; - - evKeyDown.keyCode = 37; - assert.equal(term.keyDown(evKeyDown), false); - evKeyDown.keyCode = 39; - term.keyDown(evKeyDown); - assert.equal(term.keyDown(evKeyDown), false); - }); - - it('should emit key with alt + ctrl + key on keyPress', (done) => { - const keys = ['@', '@', '\\', '\\', '|', '|']; - - term.onKey(e => { - if (e.key) { - const index = keys.indexOf(e.key); - assert(index !== -1, 'Emitted wrong key: ' + e.key); - keys.splice(index, 1); - } - if (keys.length === 0) done(); - }); - - evKeyPress.altKey = true; - evKeyPress.ctrlKey = true; - - // @ - evKeyPress.charCode = null; - evKeyPress.keyCode = 64; - term.keyPress(evKeyPress); - // Firefox @ - evKeyPress.charCode = 64; - evKeyPress.keyCode = 0; - term.keyPress(evKeyPress); - // \ - evKeyPress.charCode = null; - evKeyPress.keyCode = 92; - term.keyPress(evKeyPress); - // Firefox \ - evKeyPress.charCode = 92; - evKeyPress.keyCode = 0; - term.keyPress(evKeyPress); - // | - evKeyPress.charCode = null; - evKeyPress.keyCode = 124; - term.keyPress(evKeyPress); - // Firefox | - evKeyPress.charCode = 124; - evKeyPress.keyCode = 0; - term.keyPress(evKeyPress); - }); - }); - }); - - describe('unicode - surrogates', () => { - it('2 characters per cell', async function (): Promise { - this.timeout(10000); // This is needed because istanbul patches code and slows it down - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - await term.writeP(high + String.fromCharCode(i)); - const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); - assert.equal(tchar.getChars(), high + String.fromCharCode(i)); - assert.equal(tchar.getChars().length, 2); - assert.equal(tchar.getWidth(), 1); - assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), ''); - term.reset(); - } - }); - it('2 characters at last cell', async () => { - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - term.buffer.x = term.cols - 1; - await term.writeP(high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars(), high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars().length, 2); - assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), ''); - term.reset(); - } - }); - it('2 characters per cell over line end with autowrap', async function (): Promise { - this.timeout(10000); - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - term.buffer.x = term.cols - 1; - - await term.writeP('a' + high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), 'a'); - assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars().length, 2); - assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), ''); - term.reset(); - } - }); - it('2 characters per cell over line end without autowrap', async function (): Promise { - this.timeout(10000); - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - term.buffer.x = term.cols - 1; - await term.writeP('\x1b[?7l'); // Disable wraparound mode - const width = wcwidth((0xD800 - 0xD800) * 0x400 + i - 0xDC00 + 0x10000); - if (width !== 1) { - continue; + describe('unicode - surrogates', () => { + it('2 characters per cell', async function (): Promise { + this.timeout(10000); // This is needed because istanbul patches code and slows it down + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + for (let i = 0xDC00; i <= 0xDCFF; ++i) { + await term.writeP(high + String.fromCharCode(i)); + const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); + assert.equal(tchar.getChars(), high + String.fromCharCode(i)); + assert.equal(tchar.getChars().length, 2); + assert.equal(tchar.getWidth(), 1); + assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), ''); + term.reset(); } - await term.writeP('a' + high + String.fromCharCode(i)); - // auto wraparound mode should cut off the rest of the line - assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars().length, 2); - assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), ''); - term.reset(); - } - }); - it('splitted surrogates', async function (): Promise { - this.timeout(10000); - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - await term.writeP(high + String.fromCharCode(i)); - const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); - assert.equal(tchar.getChars(), high + String.fromCharCode(i)); - assert.equal(tchar.getChars().length, 2); - assert.equal(tchar.getWidth(), 1); - assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), ''); - term.reset(); - } - }); - }); + }); + it('2 characters at last cell', async () => { + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + for (let i = 0xDC00; i <= 0xDCFF; ++i) { + term.buffer.x = term.cols - 1; + await term.writeP(high + String.fromCharCode(i)); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars(), high + String.fromCharCode(i)); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars().length, 2); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), ''); + term.reset(); + } + }); + it('2 characters per cell over line end with autowrap', async function (): Promise { + this.timeout(10000); + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + for (let i = 0xDC00; i <= 0xDCFF; ++i) { + term.buffer.x = term.cols - 1; - describe('unicode - combining characters', () => { - const cell = new CellData(); - it('café', async () => { - await term.writeP('cafe\u0301'); - term.buffer.lines.get(0)!.loadCell(3, cell); - assert.equal(cell.getChars(), 'e\u0301'); - assert.equal(cell.getChars().length, 2); - assert.equal(cell.getWidth(), 1); + await term.writeP('a' + high + String.fromCharCode(i)); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), 'a'); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), high + String.fromCharCode(i)); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars().length, 2); + assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), ''); + term.reset(); + } + }); + it('2 characters per cell over line end without autowrap', async function (): Promise { + this.timeout(10000); + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + for (let i = 0xDC00; i <= 0xDCFF; ++i) { + term.buffer.x = term.cols - 1; + await term.writeP('\x1b[?7l'); // Disable wraparound mode + const width = wcwidth((0xD800 - 0xD800) * 0x400 + i - 0xDC00 + 0x10000); + if (width !== 1) { + continue; + } + await term.writeP('a' + high + String.fromCharCode(i)); + // auto wraparound mode should cut off the rest of the line + assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), high + String.fromCharCode(i)); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars().length, 2); + assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), ''); + term.reset(); + } + }); + it('splitted surrogates', async function (): Promise { + this.timeout(10000); + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + for (let i = 0xDC00; i <= 0xDCFF; ++i) { + await term.writeP(high + String.fromCharCode(i)); + const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); + assert.equal(tchar.getChars(), high + String.fromCharCode(i)); + assert.equal(tchar.getChars().length, 2); + assert.equal(tchar.getWidth(), 1); + assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), ''); + term.reset(); + } + }); }); - it('café - end of line', async () => { - term.buffer.x = term.cols - 1 - 3; - await term.writeP('cafe\u0301'); - term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); - assert.equal(cell.getChars(), 'e\u0301'); - assert.equal(cell.getChars().length, 2); - assert.equal(cell.getWidth(), 1); - term.buffer.lines.get(0)!.loadCell(1, cell); - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 1); - }); - it('multiple combined é', async () => { - await term.writeP(Array(100).join('e\u0301')); - for (let i = 0; i < term.cols; ++i) { - term.buffer.lines.get(0)!.loadCell(i, cell); + + describe('unicode - combining characters', () => { + const cell = new CellData(); + it('café', async () => { + await term.writeP('cafe\u0301'); + term.buffer.lines.get(0)!.loadCell(3, cell); assert.equal(cell.getChars(), 'e\u0301'); assert.equal(cell.getChars().length, 2); assert.equal(cell.getWidth(), 1); - } - term.buffer.lines.get(1)!.loadCell(0, cell); - assert.equal(cell.getChars(), 'e\u0301'); - assert.equal(cell.getChars().length, 2); - assert.equal(cell.getWidth(), 1); - }); - it('multiple surrogate with combined', async () => { - await term.writeP(Array(100).join('\uD800\uDC00\u0301')); - for (let i = 0; i < term.cols; ++i) { - term.buffer.lines.get(0)!.loadCell(i, cell); + }); + it('café - end of line', async () => { + term.buffer.x = term.cols - 1 - 3; + await term.writeP('cafe\u0301'); + term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); + assert.equal(cell.getChars(), 'e\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 1); + term.buffer.lines.get(0)!.loadCell(1, cell); + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 1); + }); + it('multiple combined é', async () => { + await term.writeP(Array(100).join('e\u0301')); + for (let i = 0; i < term.cols; ++i) { + term.buffer.lines.get(0)!.loadCell(i, cell); + assert.equal(cell.getChars(), 'e\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 1); + } + term.buffer.lines.get(1)!.loadCell(0, cell); + assert.equal(cell.getChars(), 'e\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 1); + }); + it('multiple surrogate with combined', async () => { + await term.writeP(Array(100).join('\uD800\uDC00\u0301')); + for (let i = 0; i < term.cols; ++i) { + term.buffer.lines.get(0)!.loadCell(i, cell); + assert.equal(cell.getChars(), '\uD800\uDC00\u0301'); + assert.equal(cell.getChars().length, 3); + assert.equal(cell.getWidth(), 1); + } + term.buffer.lines.get(1)!.loadCell(0, cell); assert.equal(cell.getChars(), '\uD800\uDC00\u0301'); assert.equal(cell.getChars().length, 3); assert.equal(cell.getWidth(), 1); - } - term.buffer.lines.get(1)!.loadCell(0, cell); - assert.equal(cell.getChars(), '\uD800\uDC00\u0301'); - assert.equal(cell.getChars().length, 3); - assert.equal(cell.getWidth(), 1); - }); - }); - - describe('unicode - fullwidth characters', () => { - const cell = new CellData(); - it('cursor movement even', async () => { - assert.equal(term.buffer.x, 0); - await term.writeP('¥'); - assert.equal(term.buffer.x, 2); - }); - it('cursor movement odd', async () => { - term.buffer.x = 1; - assert.equal(term.buffer.x, 1); - await term.writeP('¥'); - assert.equal(term.buffer.x, 3); - }); - it('line of ¥ even', async () => { - await term.writeP(Array(50).join('¥')); - for (let i = 0; i < term.cols; ++i) { - term.buffer.lines.get(0)!.loadCell(i, cell); - if (i % 2) { - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 0); - } else { - assert.equal(cell.getChars(), '¥'); - assert.equal(cell.getChars().length, 1); - assert.equal(cell.getWidth(), 2); - } - } - term.buffer.lines.get(1)!.loadCell(0, cell); - assert.equal(cell.getChars(), '¥'); - assert.equal(cell.getChars().length, 1); - assert.equal(cell.getWidth(), 2); - }); - it('line of ¥ odd', async () => { - term.buffer.x = 1; - await term.writeP(Array(50).join('¥')); - for (let i = 1; i < term.cols - 1; ++i) { - term.buffer.lines.get(0)!.loadCell(i, cell); - if (!(i % 2)) { - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 0); - } else { - assert.equal(cell.getChars(), '¥'); - assert.equal(cell.getChars().length, 1); - assert.equal(cell.getWidth(), 2); - } - } - term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 1); - term.buffer.lines.get(1)!.loadCell(0, cell); - assert.equal(cell.getChars(), '¥'); - assert.equal(cell.getChars().length, 1); - assert.equal(cell.getWidth(), 2); - }); - it('line of ¥ with combining odd', async () => { - term.buffer.x = 1; - await term.writeP(Array(50).join('¥\u0301')); - for (let i = 1; i < term.cols - 1; ++i) { - term.buffer.lines.get(0)!.loadCell(i, cell); - if (!(i % 2)) { - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 0); - } else { - assert.equal(cell.getChars(), '¥\u0301'); - assert.equal(cell.getChars().length, 2); - assert.equal(cell.getWidth(), 2); - } - } - term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 1); - term.buffer.lines.get(1)!.loadCell(0, cell); - assert.equal(cell.getChars(), '¥\u0301'); - assert.equal(cell.getChars().length, 2); - assert.equal(cell.getWidth(), 2); - }); - it('line of ¥ with combining even', async () => { - await term.writeP(Array(50).join('¥\u0301')); - for (let i = 0; i < term.cols; ++i) { - term.buffer.lines.get(0)!.loadCell(i, cell); - if (i % 2) { - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 0); - } else { - assert.equal(cell.getChars(), '¥\u0301'); - assert.equal(cell.getChars().length, 2); - assert.equal(cell.getWidth(), 2); - } - } - term.buffer.lines.get(1)!.loadCell(0, cell); - assert.equal(cell.getChars(), '¥\u0301'); - assert.equal(cell.getChars().length, 2); - assert.equal(cell.getWidth(), 2); - }); - it('line of surrogate fullwidth with combining odd', async () => { - term.buffer.x = 1; - await term.writeP(Array(50).join('\ud843\ude6d\u0301')); - for (let i = 1; i < term.cols - 1; ++i) { - term.buffer.lines.get(0)!.loadCell(i, cell); - if (!(i % 2)) { - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 0); - } else { - assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); - assert.equal(cell.getChars().length, 3); - assert.equal(cell.getWidth(), 2); - } - } - term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 1); - term.buffer.lines.get(1)!.loadCell(0, cell); - assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); - assert.equal(cell.getChars().length, 3); - assert.equal(cell.getWidth(), 2); - }); - it('line of surrogate fullwidth with combining even', async () => { - await term.writeP(Array(50).join('\ud843\ude6d\u0301')); - for (let i = 0; i < term.cols; ++i) { - term.buffer.lines.get(0)!.loadCell(i, cell); - if (i % 2) { - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 0); - } else { - assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); - assert.equal(cell.getChars().length, 3); - assert.equal(cell.getWidth(), 2); - } - } - term.buffer.lines.get(1)!.loadCell(0, cell); - assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); - assert.equal(cell.getChars().length, 3); - assert.equal(cell.getWidth(), 2); - }); - }); - - describe('insert mode', () => { - const cell = new CellData(); - it('halfwidth - all', async () => { - await term.writeP(Array(9).join('0123456789').slice(-80)); - term.buffer.x = 10; - term.buffer.y = 0; - term.write('\x1b[4h'); - await term.writeP('abcde'); - assert.equal(term.buffer.lines.get(0)!.length, term.cols); - assert.equal(term.buffer.lines.get(0)!.loadCell(10, cell).getChars(), 'a'); - assert.equal(term.buffer.lines.get(0)!.loadCell(14, cell).getChars(), 'e'); - assert.equal(term.buffer.lines.get(0)!.loadCell(15, cell).getChars(), '0'); - assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), '4'); - }); - it('fullwidth - insert', async () => { - await term.writeP(Array(9).join('0123456789').slice(-80)); - term.buffer.x = 10; - term.buffer.y = 0; - term.write('\x1b[4h'); - await term.writeP('¥¥¥'); - assert.equal(term.buffer.lines.get(0)!.length, term.cols); - assert.equal(term.buffer.lines.get(0)!.loadCell(10, cell).getChars(), '¥'); - assert.equal(term.buffer.lines.get(0)!.loadCell(11, cell).getChars(), ''); - assert.equal(term.buffer.lines.get(0)!.loadCell(14, cell).getChars(), '¥'); - assert.equal(term.buffer.lines.get(0)!.loadCell(15, cell).getChars(), ''); - assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), '3'); - }); - it('fullwidth - right border', async () => { - await term.writeP(Array(41).join('¥')); - term.buffer.x = 10; - term.buffer.y = 0; - term.write('\x1b[4h'); - await term.writeP('a'); - assert.equal(term.buffer.lines.get(0)!.length, term.cols); - assert.equal(term.buffer.lines.get(0)!.loadCell(10, cell).getChars(), 'a'); - assert.equal(term.buffer.lines.get(0)!.loadCell(11, cell).getChars(), '¥'); - assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), ''); // fullwidth char got replaced - await term.writeP('b'); - assert.equal(term.buffer.lines.get(0)!.length, term.cols); - assert.equal(term.buffer.lines.get(0)!.loadCell(11, cell).getChars(), 'b'); - assert.equal(term.buffer.lines.get(0)!.loadCell(12, cell).getChars(), '¥'); - assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), ''); // empty cell after fullwidth - }); - }); - - describe('Linkifier unicode handling', () => { - let terminal: TestTerminal; - let linkifier: TestLinkifier; - let mouseZoneManager: TestMouseZoneManager; - - // other than the tests above unicode testing needs the full terminal instance - // to get the special handling of fullwidth, surrogate and combining chars in the input handler - beforeEach(() => { - terminal = new TestTerminal({ cols: 10, rows: 5 }); - linkifier = new TestLinkifier((terminal as any)._bufferService, terminal.unicodeService); - mouseZoneManager = new TestMouseZoneManager(); - linkifier.attachToDom({} as any, mouseZoneManager); - }); - - function assertLinkifiesInTerminal(rowText: string, linkMatcherRegex: RegExp, links: {x1: number, y1: number, x2: number, y2: number}[]): Promise { - return new Promise(async r => { - await terminal.writeP(rowText); - linkifier.registerLinkMatcher(linkMatcherRegex, () => {}); - linkifier.linkifyRows(); - // Allow linkify to happen - setTimeout(() => { - assert.equal(mouseZoneManager.zones.length, links.length); - links.forEach((l, i) => { - assert.equal(mouseZoneManager.zones[i].x1, l.x1 + 1); - assert.equal(mouseZoneManager.zones[i].x2, l.x2 + 1); - assert.equal(mouseZoneManager.zones[i].y1, l.y1 + 1); - assert.equal(mouseZoneManager.zones[i].y2, l.y2 + 1); - }); - r(); - }, 0); - }); - } - - describe('unicode before the match', () => { - it('combining - match within one line', () => { - return assertLinkifiesInTerminal('e\u0301e\u0301e\u0301 foo', /foo/, [{x1: 4, x2: 7, y1: 0, y2: 0}]); - }); - it('combining - match over two lines', () => { - return assertLinkifiesInTerminal('e\u0301e\u0301e\u0301 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}]); - }); - it('surrogate - match within one line', () => { - return assertLinkifiesInTerminal('𝄞𝄞𝄞 foo', /foo/, [{x1: 4, x2: 7, y1: 0, y2: 0}]); - }); - it('surrogate - match over two lines', () => { - return assertLinkifiesInTerminal('𝄞𝄞𝄞 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}]); - }); - it('combining surrogate - match within one line', () => { - return assertLinkifiesInTerminal('𓂀\u0301𓂀\u0301𓂀\u0301 foo', /foo/, [{x1: 4, x2: 7, y1: 0, y2: 0}]); - }); - it('combining surrogate - match over two lines', () => { - return assertLinkifiesInTerminal('𓂀\u0301𓂀\u0301𓂀\u0301 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}]); - }); - it('fullwidth - match within one line', () => { - return assertLinkifiesInTerminal('12 foo', /foo/, [{x1: 5, x2: 8, y1: 0, y2: 0}]); - }); - it('fullwidth - match over two lines', () => { - return assertLinkifiesInTerminal('12 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}]); - }); - it('combining fullwidth - match within one line', () => { - return assertLinkifiesInTerminal('¥\u0301¥\u0301 foo', /foo/, [{x1: 5, x2: 8, y1: 0, y2: 0}]); - }); - it('combining fullwidth - match over two lines', () => { - return assertLinkifiesInTerminal('¥\u0301¥\u0301 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}]); }); }); - describe('unicode within the match', () => { - it('combining - match within one line', () => { - return assertLinkifiesInTerminal('test cafe\u0301', /cafe\u0301/, [{x1: 5, x2: 9, y1: 0, y2: 0}]); + + describe('unicode - fullwidth characters', () => { + const cell = new CellData(); + it('cursor movement even', async () => { + assert.equal(term.buffer.x, 0); + await term.writeP('¥'); + assert.equal(term.buffer.x, 2); }); - it('combining - match over two lines', () => { - return assertLinkifiesInTerminal('testtest cafe\u0301', /cafe\u0301/, [{x1: 9, x2: 3, y1: 0, y2: 1}]); + it('cursor movement odd', async () => { + term.buffer.x = 1; + assert.equal(term.buffer.x, 1); + await term.writeP('¥'); + assert.equal(term.buffer.x, 3); }); - it('surrogate - match within one line', () => { - return assertLinkifiesInTerminal('test a𝄞b', /a𝄞b/, [{x1: 5, x2: 8, y1: 0, y2: 0}]); - }); - it('surrogate - match over two lines', () => { - return assertLinkifiesInTerminal('testtest a𝄞b', /a𝄞b/, [{x1: 9, x2: 2, y1: 0, y2: 1}]); - }); - it('combining surrogate - match within one line', () => { - return assertLinkifiesInTerminal('test a𓂀\u0301b', /a𓂀\u0301b/, [{x1: 5, x2: 8, y1: 0, y2: 0}]); - }); - it('combining surrogate - match over two lines', () => { - return assertLinkifiesInTerminal('testtest a𓂀\u0301b', /a𓂀\u0301b/, [{x1: 9, x2: 2, y1: 0, y2: 1}]); - }); - it('fullwidth - match within one line', () => { - return assertLinkifiesInTerminal('test a1b', /a1b/, [{x1: 5, x2: 9, y1: 0, y2: 0}]); - }); - it('fullwidth - match over two lines', () => { - return assertLinkifiesInTerminal('testtest a1b', /a1b/, [{x1: 9, x2: 3, y1: 0, y2: 1}]); - }); - it('combining fullwidth - match within one line', () => { - return assertLinkifiesInTerminal('test a¥\u0301b', /a¥\u0301b/, [{x1: 5, x2: 9, y1: 0, y2: 0}]); - }); - it('combining fullwidth - match over two lines', () => { - return assertLinkifiesInTerminal('testtest a¥\u0301b', /a¥\u0301b/, [{x1: 9, x2: 3, y1: 0, y2: 1}]); - }); - }); - }); - - describe('Buffer.stringIndexToBufferIndex', () => { - let terminal: TestTerminal; - - beforeEach(() => { - terminal = new TestTerminal({rows: 5, cols: 10, scrollback: 5}); - }); - - it('multiline ascii', async () => { - const input = 'This is ASCII text spanning multiple lines.'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - for (let i = 0; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([(i / terminal.cols) | 0, i % terminal.cols], bufferIndex); - } - }); - - it('combining e\u0301 in a sentence', async () => { - const input = 'Sitting in the cafe\u0301 drinking coffee.'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - for (let i = 0; i < 19; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([(i / terminal.cols) | 0, i % terminal.cols], bufferIndex); - } - // string index 18 & 19 point to combining char e\u0301 ---> same buffer Index - assert.deepEqual( - terminal.buffer.stringIndexToBufferIndex(0, 18), - terminal.buffer.stringIndexToBufferIndex(0, 19)); - // after the combining char every string index has an offset of -1 - for (let i = 19; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([((i - 1) / terminal.cols) | 0, (i - 1) % terminal.cols], bufferIndex); - } - }); - - it('multiline combining e\u0301', async () => { - const input = 'e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - // every buffer cell index contains 2 string indices - for (let i = 0; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([((i >> 1) / terminal.cols) | 0, (i >> 1) % terminal.cols], bufferIndex); - } - }); - - it('surrogate char in a sentence', async () => { - const input = 'The 𝄞 is a clef widely used in modern notation.'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - for (let i = 0; i < 5; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([(i / terminal.cols) | 0, i % terminal.cols], bufferIndex); - } - // string index 4 & 5 point to surrogate char 𝄞 ---> same buffer Index - assert.deepEqual( - terminal.buffer.stringIndexToBufferIndex(0, 4), - terminal.buffer.stringIndexToBufferIndex(0, 5)); - // after the combining char every string index has an offset of -1 - for (let i = 5; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([((i - 1) / terminal.cols) | 0, (i - 1) % terminal.cols], bufferIndex); - } - }); - - it('multiline surrogate char', async () => { - const input = '𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - // every buffer cell index contains 2 string indices - for (let i = 0; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([((i >> 1) / terminal.cols) | 0, (i >> 1) % terminal.cols], bufferIndex); - } - }); - - it('surrogate char with combining', async () => { - // eye of Ra with acute accent - string length of 3 - const input = '𓂀\u0301 - the eye hiroglyph with an acute accent.'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - // index 0..2 should map to 0 - assert.deepEqual([0, 0], terminal.buffer.stringIndexToBufferIndex(0, 1)); - assert.deepEqual([0, 0], terminal.buffer.stringIndexToBufferIndex(0, 2)); - for (let i = 2; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([((i - 2) / terminal.cols) | 0, (i - 2) % terminal.cols], bufferIndex); - } - }); - - it('multiline surrogate with combining', async () => { - const input = '𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - // every buffer cell index contains 3 string indices - for (let i = 0; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([(((i / 3) | 0) / terminal.cols) | 0, ((i / 3) | 0) % terminal.cols], bufferIndex); - } - }); - - it('fullwidth chars', async () => { - const input = 'These 123 are some fat numbers.'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - for (let i = 0; i < 6; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([(i / terminal.cols) | 0, i % terminal.cols], bufferIndex); - } - // string index 6, 7, 8 take 2 cells - assert.deepEqual([0, 8], terminal.buffer.stringIndexToBufferIndex(0, 7)); - assert.deepEqual([1, 0], terminal.buffer.stringIndexToBufferIndex(0, 8)); - // rest of the string has offset of +3 - for (let i = 9; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([((i + 3) / terminal.cols) | 0, (i + 3) % terminal.cols], bufferIndex); - } - }); - - it('multiline fullwidth chars', async () => { - const input = '12345678901234567890'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - for (let i = 9; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([((i << 1) / terminal.cols) | 0, (i << 1) % terminal.cols], bufferIndex); - } - }); - - it('fullwidth combining with emoji - match emoji cell', async () => { - const input = 'Lots of ¥\u0301 make me 😃.'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - const stringIndex = s.match(/😃/)!.index!; - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, stringIndex); - assert(terminal.buffer.lines.get(bufferIndex[0])!.loadCell(bufferIndex[1], new CellData()).getChars(), '😃'); - }); - - it('multiline fullwidth chars with offset 1 (currently tests for broken behavior)', async () => { - const input = 'a12345678901234567890'; - // the 'a' at the beginning moves all fullwidth chars one to the right - // now the end of the line contains a dangling empty cell since - // the next fullwidth char has to wrap early - // the dangling last cell is wrongly added in the string - // --> fixable after resolving #1685 - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - for (let i = 10; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i, true); - const j = (i - 0) << 1; - assert.deepEqual([(j / terminal.cols) | 0, j % terminal.cols], bufferIndex); - } - }); - - it('test fully wrapped buffer up to last char', async () => { - const input = Array(6).join('1234567890'); - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - for (let i = 0; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i, true); - assert.equal(input[i], terminal.buffer.lines.get(bufferIndex[0])!.loadCell(bufferIndex[1], new CellData()).getChars()); - } - }); - - it('test fully wrapped buffer up to last char with full width odd', async () => { - const input = 'a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301' - + 'a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - for (let i = 0; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i, true); - assert.equal( - (!(i % 3)) - ? input[i] - : (i % 3 === 1) - ? input.substr(i, 2) - : input.substr(i - 1, 2), - terminal.buffer.lines.get(bufferIndex[0])!.loadCell(bufferIndex[1], new CellData()).getChars()); - } - }); - - it('should handle \t in lines correctly', async () => { - const input = '\thttps://google.de'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(s, Array(terminal.optionsService.options.tabStopWidth + 1).join(' ') + 'https://google.de'); - }); - }); - - describe('BufferStringIterator', function(): void { - it('iterator does not overflow buffer limits', async () => { - const terminal = new TestTerminal({rows: 5, cols: 10, scrollback: 5}); - const data = [ - 'aaaaaaaaaa', - 'aaaaaaaaa\n', - 'aaaaaaaaaa', - 'aaaaaaaaa\n', - 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaa\n', - 'aaaaaaaaaa', - 'aaaaaaaaaa' - ]; - await terminal.writeP(data.join('')); - // brute force test with insane values - assert.doesNotThrow(() => { - for (let overscan = 0; overscan < 20; ++overscan) { - for (let start = -10; start < 20; ++start) { - for (let end = -10; end < 20; ++end) { - const it = terminal.buffer.iterator(false, start, end, overscan, overscan); - while (it.hasNext()) { - it.next(); - } - } + it('line of ¥ even', async () => { + await term.writeP(Array(50).join('¥')); + for (let i = 0; i < term.cols; ++i) { + term.buffer.lines.get(0)!.loadCell(i, cell); + if (i % 2) { + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 0); + } else { + assert.equal(cell.getChars(), '¥'); + assert.equal(cell.getChars().length, 1); + assert.equal(cell.getWidth(), 2); } } + term.buffer.lines.get(1)!.loadCell(0, cell); + assert.equal(cell.getChars(), '¥'); + assert.equal(cell.getChars().length, 1); + assert.equal(cell.getWidth(), 2); + }); + it('line of ¥ odd', async () => { + term.buffer.x = 1; + await term.writeP(Array(50).join('¥')); + for (let i = 1; i < term.cols - 1; ++i) { + term.buffer.lines.get(0)!.loadCell(i, cell); + if (!(i % 2)) { + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 0); + } else { + assert.equal(cell.getChars(), '¥'); + assert.equal(cell.getChars().length, 1); + assert.equal(cell.getWidth(), 2); + } + } + term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 1); + term.buffer.lines.get(1)!.loadCell(0, cell); + assert.equal(cell.getChars(), '¥'); + assert.equal(cell.getChars().length, 1); + assert.equal(cell.getWidth(), 2); + }); + it('line of ¥ with combining odd', async () => { + term.buffer.x = 1; + await term.writeP(Array(50).join('¥\u0301')); + for (let i = 1; i < term.cols - 1; ++i) { + term.buffer.lines.get(0)!.loadCell(i, cell); + if (!(i % 2)) { + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 0); + } else { + assert.equal(cell.getChars(), '¥\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 2); + } + } + term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 1); + term.buffer.lines.get(1)!.loadCell(0, cell); + assert.equal(cell.getChars(), '¥\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 2); + }); + it('line of ¥ with combining even', async () => { + await term.writeP(Array(50).join('¥\u0301')); + for (let i = 0; i < term.cols; ++i) { + term.buffer.lines.get(0)!.loadCell(i, cell); + if (i % 2) { + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 0); + } else { + assert.equal(cell.getChars(), '¥\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 2); + } + } + term.buffer.lines.get(1)!.loadCell(0, cell); + assert.equal(cell.getChars(), '¥\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 2); + }); + it('line of surrogate fullwidth with combining odd', async () => { + term.buffer.x = 1; + await term.writeP(Array(50).join('\ud843\ude6d\u0301')); + for (let i = 1; i < term.cols - 1; ++i) { + term.buffer.lines.get(0)!.loadCell(i, cell); + if (!(i % 2)) { + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 0); + } else { + assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); + assert.equal(cell.getChars().length, 3); + assert.equal(cell.getWidth(), 2); + } + } + term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 1); + term.buffer.lines.get(1)!.loadCell(0, cell); + assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); + assert.equal(cell.getChars().length, 3); + assert.equal(cell.getWidth(), 2); + }); + it('line of surrogate fullwidth with combining even', async () => { + await term.writeP(Array(50).join('\ud843\ude6d\u0301')); + for (let i = 0; i < term.cols; ++i) { + term.buffer.lines.get(0)!.loadCell(i, cell); + if (i % 2) { + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 0); + } else { + assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); + assert.equal(cell.getChars().length, 3); + assert.equal(cell.getWidth(), 2); + } + } + term.buffer.lines.get(1)!.loadCell(0, cell); + assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); + assert.equal(cell.getChars().length, 3); + assert.equal(cell.getWidth(), 2); }); }); - }); - describe('Windows Mode', () => { - it('should mark lines as wrapped when the line ends in a non-null character after a LF', async () => { - const data = [ - 'aaaaaaaaaa\n\r', // cannot wrap as it's the first - 'aaaaaaaaa\n\r', // wrapped (windows mode only) - 'aaaaaaaaa' // not wrapped - ]; - - const normalTerminal = new TestTerminal({rows: 5, cols: 10, windowsMode: false}); - await normalTerminal.writeP(data.join('')); - assert.equal(normalTerminal.buffer.lines.get(0)!.isWrapped, false); - assert.equal(normalTerminal.buffer.lines.get(1)!.isWrapped, false); - assert.equal(normalTerminal.buffer.lines.get(2)!.isWrapped, false); - - const windowsModeTerminal = new TestTerminal({rows: 5, cols: 10, windowsMode: true}); - await windowsModeTerminal.writeP(data.join('')); - assert.equal(windowsModeTerminal.buffer.lines.get(0)!.isWrapped, false); - assert.equal(windowsModeTerminal.buffer.lines.get(1)!.isWrapped, true, 'This line should wrap in Windows mode as the previous line ends in a non-null character'); - assert.equal(windowsModeTerminal.buffer.lines.get(2)!.isWrapped, false); + describe('insert mode', () => { + const cell = new CellData(); + it('halfwidth - all', async () => { + await term.writeP(Array(9).join('0123456789').slice(-80)); + term.buffer.x = 10; + term.buffer.y = 0; + term.write('\x1b[4h'); + await term.writeP('abcde'); + assert.equal(term.buffer.lines.get(0)!.length, term.cols); + assert.equal(term.buffer.lines.get(0)!.loadCell(10, cell).getChars(), 'a'); + assert.equal(term.buffer.lines.get(0)!.loadCell(14, cell).getChars(), 'e'); + assert.equal(term.buffer.lines.get(0)!.loadCell(15, cell).getChars(), '0'); + assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), '4'); + }); + it('fullwidth - insert', async () => { + await term.writeP(Array(9).join('0123456789').slice(-80)); + term.buffer.x = 10; + term.buffer.y = 0; + term.write('\x1b[4h'); + await term.writeP('¥¥¥'); + assert.equal(term.buffer.lines.get(0)!.length, term.cols); + assert.equal(term.buffer.lines.get(0)!.loadCell(10, cell).getChars(), '¥'); + assert.equal(term.buffer.lines.get(0)!.loadCell(11, cell).getChars(), ''); + assert.equal(term.buffer.lines.get(0)!.loadCell(14, cell).getChars(), '¥'); + assert.equal(term.buffer.lines.get(0)!.loadCell(15, cell).getChars(), ''); + assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), '3'); + }); + it('fullwidth - right border', async () => { + await term.writeP(Array(41).join('¥')); + term.buffer.x = 10; + term.buffer.y = 0; + term.write('\x1b[4h'); + await term.writeP('a'); + assert.equal(term.buffer.lines.get(0)!.length, term.cols); + assert.equal(term.buffer.lines.get(0)!.loadCell(10, cell).getChars(), 'a'); + assert.equal(term.buffer.lines.get(0)!.loadCell(11, cell).getChars(), '¥'); + assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), ''); // fullwidth char got replaced + await term.writeP('b'); + assert.equal(term.buffer.lines.get(0)!.length, term.cols); + assert.equal(term.buffer.lines.get(0)!.loadCell(11, cell).getChars(), 'b'); + assert.equal(term.buffer.lines.get(0)!.loadCell(12, cell).getChars(), '¥'); + assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), ''); // empty cell after fullwidth + }); }); - it('should mark lines as wrapped when the line ends in a non-null character after a CUP', async () => { - const data = [ - 'aaaaaaaaaa\x1b[2;1H', // cannot wrap as it's the first - 'aaaaaaaaa\x1b[3;1H', // wrapped (windows mode only) - 'aaaaaaaaa' // not wrapped - ]; + describe('Linkifier unicode handling', () => { + let terminal: TestTerminal; + let linkifier: TestLinkifier; + let mouseZoneManager: TestMouseZoneManager; - const normalTerminal = new TestTerminal({rows: 5, cols: 10, windowsMode: false}); - await normalTerminal.writeP(data.join('')); - assert.equal(normalTerminal.buffer.lines.get(0)!.isWrapped, false); - assert.equal(normalTerminal.buffer.lines.get(1)!.isWrapped, false); - assert.equal(normalTerminal.buffer.lines.get(2)!.isWrapped, false); + // other than the tests above unicode testing needs the full terminal instance + // to get the special handling of fullwidth, surrogate and combining chars in the input handler + beforeEach(() => { + terminal = new TestTerminal({ cols: 10, rows: 5 }); + linkifier = new TestLinkifier((terminal as any)._bufferService, terminal.unicodeService); + mouseZoneManager = new TestMouseZoneManager(); + linkifier.attachToDom({} as any, mouseZoneManager); + }); - const windowsModeTerminal = new TestTerminal({rows: 5, cols: 10, windowsMode: true}); - await windowsModeTerminal.writeP(data.join('')); - assert.equal(windowsModeTerminal.buffer.lines.get(0)!.isWrapped, false); - assert.equal(windowsModeTerminal.buffer.lines.get(1)!.isWrapped, true, 'This line should wrap in Windows mode as the previous line ends in a non-null character'); - assert.equal(windowsModeTerminal.buffer.lines.get(2)!.isWrapped, false); - }); - }); - it('convertEol setting', async () => { - // not converting - const termNotConverting = new TestTerminal({cols: 15, rows: 10}); - await termNotConverting.writeP('Hello\nWorld'); - assert.equal(termNotConverting.buffer.lines.get(0)!.translateToString(false), 'Hello '); - assert.equal(termNotConverting.buffer.lines.get(1)!.translateToString(false), ' World '); - assert.equal(termNotConverting.buffer.lines.get(0)!.translateToString(true), 'Hello'); - assert.equal(termNotConverting.buffer.lines.get(1)!.translateToString(true), ' World'); - - // converting - const termConverting = new TestTerminal({cols: 15, rows: 10, convertEol: true}); - await termConverting.writeP('Hello\nWorld'); - assert.equal(termConverting.buffer.lines.get(0)!.translateToString(false), 'Hello '); - assert.equal(termConverting.buffer.lines.get(1)!.translateToString(false), 'World '); - assert.equal(termConverting.buffer.lines.get(0)!.translateToString(true), 'Hello'); - assert.equal(termConverting.buffer.lines.get(1)!.translateToString(true), 'World'); - }); - describe('Terminal InputHandler integration', () => { - function getLines(term: TestTerminal, limit: number = term.rows): string[] { - const res: string[] = []; - for (let i = 0; i < limit; ++i) { - res.push(term.buffer.lines.get(i)!.translateToString(true)); + function assertLinkifiesInTerminal(rowText: string, linkMatcherRegex: RegExp, links: { x1: number, y1: number, x2: number, y2: number }[]): Promise { + return new Promise(async r => { + await terminal.writeP(rowText); + linkifier.registerLinkMatcher(linkMatcherRegex, () => { }); + linkifier.linkifyRows(); + // Allow linkify to happen + setTimeout(() => { + assert.equal(mouseZoneManager.zones.length, links.length); + links.forEach((l, i) => { + assert.equal(mouseZoneManager.zones[i].x1, l.x1 + 1); + assert.equal(mouseZoneManager.zones[i].x2, l.x2 + 1); + assert.equal(mouseZoneManager.zones[i].y1, l.y1 + 1); + assert.equal(mouseZoneManager.zones[i].y2, l.y2 + 1); + }); + r(); + }, 0); + }); } - return res; - } - // This suite cannot live in InputHandler unless Terminal.scroll moved into IBufferService - describe('SL/SR/DECIC/DECDC', () => { - let term: TestTerminal; - beforeEach(() => { - term = new TestTerminal({cols: 5, rows: 5, scrollback: 1}); + describe('unicode before the match', () => { + it('combining - match within one line', () => { + return assertLinkifiesInTerminal('e\u0301e\u0301e\u0301 foo', /foo/, [{ x1: 4, x2: 7, y1: 0, y2: 0 }]); + }); + it('combining - match over two lines', () => { + return assertLinkifiesInTerminal('e\u0301e\u0301e\u0301 foo', /foo/, [{ x1: 8, x2: 1, y1: 0, y2: 1 }]); + }); + it('surrogate - match within one line', () => { + return assertLinkifiesInTerminal('𝄞𝄞𝄞 foo', /foo/, [{ x1: 4, x2: 7, y1: 0, y2: 0 }]); + }); + it('surrogate - match over two lines', () => { + return assertLinkifiesInTerminal('𝄞𝄞𝄞 foo', /foo/, [{ x1: 8, x2: 1, y1: 0, y2: 1 }]); + }); + it('combining surrogate - match within one line', () => { + return assertLinkifiesInTerminal('𓂀\u0301𓂀\u0301𓂀\u0301 foo', /foo/, [{ x1: 4, x2: 7, y1: 0, y2: 0 }]); + }); + it('combining surrogate - match over two lines', () => { + return assertLinkifiesInTerminal('𓂀\u0301𓂀\u0301𓂀\u0301 foo', /foo/, [{ x1: 8, x2: 1, y1: 0, y2: 1 }]); + }); + it('fullwidth - match within one line', () => { + return assertLinkifiesInTerminal('12 foo', /foo/, [{ x1: 5, x2: 8, y1: 0, y2: 0 }]); + }); + it('fullwidth - match over two lines', () => { + return assertLinkifiesInTerminal('12 foo', /foo/, [{ x1: 8, x2: 1, y1: 0, y2: 1 }]); + }); + it('combining fullwidth - match within one line', () => { + return assertLinkifiesInTerminal('¥\u0301¥\u0301 foo', /foo/, [{ x1: 5, x2: 8, y1: 0, y2: 0 }]); + }); + it('combining fullwidth - match over two lines', () => { + return assertLinkifiesInTerminal('¥\u0301¥\u0301 foo', /foo/, [{ x1: 8, x2: 1, y1: 0, y2: 1 }]); + }); }); - it('SL (scrollLeft)', async () => { - await term.writeP('12345'.repeat(6)); - await term.writeP('\x1b[ @'); - assert.deepEqual(getLines(term, term.rows + 1), ['12345', '2345', '2345', '2345', '2345', '2345']); - await term.writeP('\x1b[0 @'); - assert.deepEqual(getLines(term, term.rows + 1), ['12345', '345', '345', '345', '345', '345']); - await term.writeP('\x1b[2 @'); - assert.deepEqual(getLines(term, term.rows + 1), ['12345', '5', '5', '5', '5', '5']); - }); - it('SR (scrollRight)', async () => { - await term.writeP('12345'.repeat(6)); - await term.writeP('\x1b[ A'); - assert.deepEqual(getLines(term, term.rows + 1), ['12345', ' 1234', ' 1234', ' 1234', ' 1234', ' 1234']); - await term.writeP('\x1b[0 A'); - assert.deepEqual(getLines(term, term.rows + 1), ['12345', ' 123', ' 123', ' 123', ' 123', ' 123']); - await term.writeP('\x1b[2 A'); - assert.deepEqual(getLines(term, term.rows + 1), ['12345', ' 1', ' 1', ' 1', ' 1', ' 1']); - }); - it('insertColumns (DECIC)', async () => { - await term.writeP('12345'.repeat(6)); - await term.writeP('\x1b[3;3H'); - await term.writeP('\x1b[\'}'); - assert.deepEqual(getLines(term, term.rows + 1), ['12345', '12 34', '12 34', '12 34', '12 34', '12 34']); - term.reset(); - await term.writeP('12345'.repeat(6)); - await term.writeP('\x1b[3;3H'); - await term.writeP('\x1b[1\'}'); - assert.deepEqual(getLines(term, term.rows + 1), ['12345', '12 34', '12 34', '12 34', '12 34', '12 34']); - term.reset(); - await term.writeP('12345'.repeat(6)); - await term.writeP('\x1b[3;3H'); - await term.writeP('\x1b[2\'}'); - assert.deepEqual(getLines(term, term.rows + 1), ['12345', '12 3', '12 3', '12 3', '12 3', '12 3']); - }); - it('deleteColumns (DECDC)', async () => { - await term.writeP('12345'.repeat(6)); - await term.writeP('\x1b[3;3H'); - await term.writeP('\x1b[\'~'); - assert.deepEqual(getLines(term, term.rows + 1), ['12345', '1245', '1245', '1245', '1245', '1245']); - term.reset(); - await term.writeP('12345'.repeat(6)); - await term.writeP('\x1b[3;3H'); - await term.writeP('\x1b[1\'~'); - assert.deepEqual(getLines(term, term.rows + 1), ['12345', '1245', '1245', '1245', '1245', '1245']); - term.reset(); - await term.writeP('12345'.repeat(6)); - await term.writeP('\x1b[3;3H'); - await term.writeP('\x1b[2\'~'); - assert.deepEqual(getLines(term, term.rows + 1), ['12345', '125', '125', '125', '125', '125']); - }); - }); - - describe('BS with reverseWraparound set/unset', () => { - const ttyBS = '\x08 \x08'; // tty ICANON sends on pressing BS - - beforeEach(() => { - term = new TestTerminal({cols: 5, rows: 5, scrollback: 1}); - }); - - describe('reverseWraparound set', () => { - it('should not reverse outside of scroll margins', async () => { - // prepare buffer content - await term.writeP('#####abcdefghijklmnopqrstuvwxy'); - assert.deepEqual(getLines(term, 6), ['#####', 'abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy']); - assert.equal(term.buffer.ydisp, 1); - assert.equal(term.buffer.x, 5); - assert.equal(term.buffer.y, 4); - await term.writeP(ttyBS.repeat(100)); - assert.deepEqual(getLines(term, 6), ['#####', 'abcde', 'fghij', 'klmno', 'pqrst', ' y']); - - await term.writeP('\x1b[?45h'); - await term.writeP('uvwxy'); - - // set top/bottom to 1/3 (0-based) - await term.writeP('\x1b[2;4r'); - // place cursor below scroll bottom - term.buffer.x = 5; - term.buffer.y = 4; - await term.writeP(ttyBS.repeat(100)); - assert.deepEqual(getLines(term, 6), ['#####', 'abcde', 'fghij', 'klmno', 'pqrst', ' ']); - - await term.writeP('uvwxy'); - // place cursor within scroll margins - term.buffer.x = 5; - term.buffer.y = 3; - await term.writeP(ttyBS.repeat(100)); - assert.deepEqual(getLines(term, 6), ['#####', 'abcde', ' ', ' ', ' ', 'uvwxy']); - assert.equal(term.buffer.x, 0); - assert.equal(term.buffer.y, term.buffer.scrollTop); // stops at 0, scrollTop - - await term.writeP('fghijklmnopqrst'); - // place cursor above scroll top - term.buffer.x = 5; - term.buffer.y = 0; - await term.writeP(ttyBS.repeat(100)); - assert.deepEqual(getLines(term, 6), ['#####', ' ', 'fghij', 'klmno', 'pqrst', 'uvwxy']); + describe('unicode within the match', () => { + it('combining - match within one line', () => { + return assertLinkifiesInTerminal('test cafe\u0301', /cafe\u0301/, [{ x1: 5, x2: 9, y1: 0, y2: 0 }]); + }); + it('combining - match over two lines', () => { + return assertLinkifiesInTerminal('testtest cafe\u0301', /cafe\u0301/, [{ x1: 9, x2: 3, y1: 0, y2: 1 }]); + }); + it('surrogate - match within one line', () => { + return assertLinkifiesInTerminal('test a𝄞b', /a𝄞b/, [{ x1: 5, x2: 8, y1: 0, y2: 0 }]); + }); + it('surrogate - match over two lines', () => { + return assertLinkifiesInTerminal('testtest a𝄞b', /a𝄞b/, [{ x1: 9, x2: 2, y1: 0, y2: 1 }]); + }); + it('combining surrogate - match within one line', () => { + return assertLinkifiesInTerminal('test a𓂀\u0301b', /a𓂀\u0301b/, [{ x1: 5, x2: 8, y1: 0, y2: 0 }]); + }); + it('combining surrogate - match over two lines', () => { + return assertLinkifiesInTerminal('testtest a𓂀\u0301b', /a𓂀\u0301b/, [{ x1: 9, x2: 2, y1: 0, y2: 1 }]); + }); + it('fullwidth - match within one line', () => { + return assertLinkifiesInTerminal('test a1b', /a1b/, [{ x1: 5, x2: 9, y1: 0, y2: 0 }]); + }); + it('fullwidth - match over two lines', () => { + return assertLinkifiesInTerminal('testtest a1b', /a1b/, [{ x1: 9, x2: 3, y1: 0, y2: 1 }]); + }); + it('combining fullwidth - match within one line', () => { + return assertLinkifiesInTerminal('test a¥\u0301b', /a¥\u0301b/, [{ x1: 5, x2: 9, y1: 0, y2: 0 }]); + }); + it('combining fullwidth - match over two lines', () => { + return assertLinkifiesInTerminal('testtest a¥\u0301b', /a¥\u0301b/, [{ x1: 9, x2: 3, y1: 0, y2: 1 }]); }); }); }); + + describe('Buffer.stringIndexToBufferIndex', () => { + let terminal: TestTerminal; + + beforeEach(() => { + terminal = new TestTerminal({ rows: 5, cols: 10, scrollback: 5 }); + }); + + it('multiline ascii', async () => { + const input = 'This is ASCII text spanning multiple lines.'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + for (let i = 0; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([(i / terminal.cols) | 0, i % terminal.cols], bufferIndex); + } + }); + + it('combining e\u0301 in a sentence', async () => { + const input = 'Sitting in the cafe\u0301 drinking coffee.'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + for (let i = 0; i < 19; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([(i / terminal.cols) | 0, i % terminal.cols], bufferIndex); + } + // string index 18 & 19 point to combining char e\u0301 ---> same buffer Index + assert.deepEqual( + terminal.buffer.stringIndexToBufferIndex(0, 18), + terminal.buffer.stringIndexToBufferIndex(0, 19)); + // after the combining char every string index has an offset of -1 + for (let i = 19; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([((i - 1) / terminal.cols) | 0, (i - 1) % terminal.cols], bufferIndex); + } + }); + + it('multiline combining e\u0301', async () => { + const input = 'e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + // every buffer cell index contains 2 string indices + for (let i = 0; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([((i >> 1) / terminal.cols) | 0, (i >> 1) % terminal.cols], bufferIndex); + } + }); + + it('surrogate char in a sentence', async () => { + const input = 'The 𝄞 is a clef widely used in modern notation.'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + for (let i = 0; i < 5; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([(i / terminal.cols) | 0, i % terminal.cols], bufferIndex); + } + // string index 4 & 5 point to surrogate char 𝄞 ---> same buffer Index + assert.deepEqual( + terminal.buffer.stringIndexToBufferIndex(0, 4), + terminal.buffer.stringIndexToBufferIndex(0, 5)); + // after the combining char every string index has an offset of -1 + for (let i = 5; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([((i - 1) / terminal.cols) | 0, (i - 1) % terminal.cols], bufferIndex); + } + }); + + it('multiline surrogate char', async () => { + const input = '𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + // every buffer cell index contains 2 string indices + for (let i = 0; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([((i >> 1) / terminal.cols) | 0, (i >> 1) % terminal.cols], bufferIndex); + } + }); + + it('surrogate char with combining', async () => { + // eye of Ra with acute accent - string length of 3 + const input = '𓂀\u0301 - the eye hiroglyph with an acute accent.'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + // index 0..2 should map to 0 + assert.deepEqual([0, 0], terminal.buffer.stringIndexToBufferIndex(0, 1)); + assert.deepEqual([0, 0], terminal.buffer.stringIndexToBufferIndex(0, 2)); + for (let i = 2; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([((i - 2) / terminal.cols) | 0, (i - 2) % terminal.cols], bufferIndex); + } + }); + + it('multiline surrogate with combining', async () => { + const input = '𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + // every buffer cell index contains 3 string indices + for (let i = 0; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([(((i / 3) | 0) / terminal.cols) | 0, ((i / 3) | 0) % terminal.cols], bufferIndex); + } + }); + + it('fullwidth chars', async () => { + const input = 'These 123 are some fat numbers.'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + for (let i = 0; i < 6; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([(i / terminal.cols) | 0, i % terminal.cols], bufferIndex); + } + // string index 6, 7, 8 take 2 cells + assert.deepEqual([0, 8], terminal.buffer.stringIndexToBufferIndex(0, 7)); + assert.deepEqual([1, 0], terminal.buffer.stringIndexToBufferIndex(0, 8)); + // rest of the string has offset of +3 + for (let i = 9; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([((i + 3) / terminal.cols) | 0, (i + 3) % terminal.cols], bufferIndex); + } + }); + + it('multiline fullwidth chars', async () => { + const input = '12345678901234567890'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + for (let i = 9; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([((i << 1) / terminal.cols) | 0, (i << 1) % terminal.cols], bufferIndex); + } + }); + + it('fullwidth combining with emoji - match emoji cell', async () => { + const input = 'Lots of ¥\u0301 make me 😃.'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + const stringIndex = s.match(/😃/)!.index!; + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, stringIndex); + assert(terminal.buffer.lines.get(bufferIndex[0])!.loadCell(bufferIndex[1], new CellData()).getChars(), '😃'); + }); + + it('multiline fullwidth chars with offset 1 (currently tests for broken behavior)', async () => { + const input = 'a12345678901234567890'; + // the 'a' at the beginning moves all fullwidth chars one to the right + // now the end of the line contains a dangling empty cell since + // the next fullwidth char has to wrap early + // the dangling last cell is wrongly added in the string + // --> fixable after resolving #1685 + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + for (let i = 10; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i, true); + const j = (i - 0) << 1; + assert.deepEqual([(j / terminal.cols) | 0, j % terminal.cols], bufferIndex); + } + }); + + it('test fully wrapped buffer up to last char', async () => { + const input = Array(6).join('1234567890'); + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + for (let i = 0; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i, true); + assert.equal(input[i], terminal.buffer.lines.get(bufferIndex[0])!.loadCell(bufferIndex[1], new CellData()).getChars()); + } + }); + + it('test fully wrapped buffer up to last char with full width odd', async () => { + const input = 'a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301' + + 'a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + for (let i = 0; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i, true); + assert.equal( + (!(i % 3)) + ? input[i] + : (i % 3 === 1) + ? input.substr(i, 2) + : input.substr(i - 1, 2), + terminal.buffer.lines.get(bufferIndex[0])!.loadCell(bufferIndex[1], new CellData()).getChars()); + } + }); + + it('should handle \t in lines correctly', async () => { + const input = '\thttps://google.de'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(s, Array(terminal.optionsService.options.tabStopWidth + 1).join(' ') + 'https://google.de'); + }); + }); + + describe('BufferStringIterator', function (): void { + it('iterator does not overflow buffer limits', async () => { + const terminal = new TestTerminal({ rows: 5, cols: 10, scrollback: 5 }); + const data = [ + 'aaaaaaaaaa', + 'aaaaaaaaa\n', + 'aaaaaaaaaa', + 'aaaaaaaaa\n', + 'aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaa\n', + 'aaaaaaaaaa', + 'aaaaaaaaaa' + ]; + await terminal.writeP(data.join('')); + // brute force test with insane values + assert.doesNotThrow(() => { + for (let overscan = 0; overscan < 20; ++overscan) { + for (let start = -10; start < 20; ++start) { + for (let end = -10; end < 20; ++end) { + const it = terminal.buffer.iterator(false, start, end, overscan, overscan); + while (it.hasNext()) { + it.next(); + } + } + } + } + }); + }); + }); + + describe('Windows Mode', () => { + it('should mark lines as wrapped when the line ends in a non-null character after a LF', async () => { + const data = [ + 'aaaaaaaaaa\n\r', // cannot wrap as it's the first + 'aaaaaaaaa\n\r', // wrapped (windows mode only) + 'aaaaaaaaa' // not wrapped + ]; + + const normalTerminal = new TestTerminal({ rows: 5, cols: 10, windowsMode: false }); + await normalTerminal.writeP(data.join('')); + assert.equal(normalTerminal.buffer.lines.get(0)!.isWrapped, false); + assert.equal(normalTerminal.buffer.lines.get(1)!.isWrapped, false); + assert.equal(normalTerminal.buffer.lines.get(2)!.isWrapped, false); + + const windowsModeTerminal = new TestTerminal({ rows: 5, cols: 10, windowsMode: true }); + await windowsModeTerminal.writeP(data.join('')); + assert.equal(windowsModeTerminal.buffer.lines.get(0)!.isWrapped, false); + assert.equal(windowsModeTerminal.buffer.lines.get(1)!.isWrapped, true, 'This line should wrap in Windows mode as the previous line ends in a non-null character'); + assert.equal(windowsModeTerminal.buffer.lines.get(2)!.isWrapped, false); + }); + + it('should mark lines as wrapped when the line ends in a non-null character after a CUP', async () => { + const data = [ + 'aaaaaaaaaa\x1b[2;1H', // cannot wrap as it's the first + 'aaaaaaaaa\x1b[3;1H', // wrapped (windows mode only) + 'aaaaaaaaa' // not wrapped + ]; + + const normalTerminal = new TestTerminal({ rows: 5, cols: 10, windowsMode: false }); + await normalTerminal.writeP(data.join('')); + assert.equal(normalTerminal.buffer.lines.get(0)!.isWrapped, false); + assert.equal(normalTerminal.buffer.lines.get(1)!.isWrapped, false); + assert.equal(normalTerminal.buffer.lines.get(2)!.isWrapped, false); + + const windowsModeTerminal = new TestTerminal({ rows: 5, cols: 10, windowsMode: true }); + await windowsModeTerminal.writeP(data.join('')); + assert.equal(windowsModeTerminal.buffer.lines.get(0)!.isWrapped, false); + assert.equal(windowsModeTerminal.buffer.lines.get(1)!.isWrapped, true, 'This line should wrap in Windows mode as the previous line ends in a non-null character'); + assert.equal(windowsModeTerminal.buffer.lines.get(2)!.isWrapped, false); + }); + }); + it('convertEol setting', async () => { + // not converting + const termNotConverting = new TestTerminal({ cols: 15, rows: 10 }); + await termNotConverting.writeP('Hello\nWorld'); + assert.equal(termNotConverting.buffer.lines.get(0)!.translateToString(false), 'Hello '); + assert.equal(termNotConverting.buffer.lines.get(1)!.translateToString(false), ' World '); + assert.equal(termNotConverting.buffer.lines.get(0)!.translateToString(true), 'Hello'); + assert.equal(termNotConverting.buffer.lines.get(1)!.translateToString(true), ' World'); + + // converting + const termConverting = new TestTerminal({ cols: 15, rows: 10, convertEol: true }); + await termConverting.writeP('Hello\nWorld'); + assert.equal(termConverting.buffer.lines.get(0)!.translateToString(false), 'Hello '); + assert.equal(termConverting.buffer.lines.get(1)!.translateToString(false), 'World '); + assert.equal(termConverting.buffer.lines.get(0)!.translateToString(true), 'Hello'); + assert.equal(termConverting.buffer.lines.get(1)!.translateToString(true), 'World'); + }); + + // FIXME: move to common/CoreTerminal.test once the trimming is moved over + describe('marker lifecycle', () => { + // create a 10x5 terminal with markers on every line + // to test marker lifecycle under various terminal actions + let markers: IMarker[]; + let disposeStack: IMarker[]; + let term: TestTerminal; + beforeEach(async () => { + term = new TestTerminal({}); + markers = []; + disposeStack = []; + term.optionsService.setOption('scrollback', 1); + term.resize(10, 5); + markers.push(term.buffers.active.addMarker(term.buffers.active.y)); + await term.writeP('\x1b[r0\r\n'); + markers.push(term.buffers.active.addMarker(term.buffers.active.y)); + await term.writeP('1\r\n'); + markers.push(term.buffers.active.addMarker(term.buffers.active.y)); + await term.writeP('2\r\n'); + markers.push(term.buffers.active.addMarker(term.buffers.active.y)); + await term.writeP('3\r\n'); + markers.push(term.buffers.active.addMarker(term.buffers.active.y)); + await term.writeP('4'); + for (let i = 0; i < markers.length; ++i) { + const marker = markers[i]; + marker.onDispose(() => disposeStack.push(marker)); + } + }); + it('initial', () => { + assert.deepEqual(markers.map(m => m.line), [0, 1, 2, 3, 4]); + }); + it('should dispose on normal trim off the top', async () => { + // moves top line into scrollback + await term.writeP('\n'); + assert.deepEqual(disposeStack, []); + // trims first marker + await term.writeP('\n'); + assert.deepEqual(disposeStack, [markers[0]]); + // trims second marker + await term.writeP('\n'); + assert.deepEqual(disposeStack, [markers[0], markers[1]]); + // trimmed marker objs should be disposed + assert.deepEqual(disposeStack.map(el => el.isDisposed), [true, true]); + assert.deepEqual(disposeStack.map(el => (el as any)._isDisposed), [true, true]); + // trimmed markers should contain line -1 + assert.deepEqual(disposeStack.map(el => el.line), [-1, -1]); + }); + it('should dispose on DL', async () => { + await term.writeP('\x1b[3;1H'); // move cursor to 0, 2 + await term.writeP('\x1b[2M'); // delete 2 lines + assert.deepEqual(disposeStack, [markers[2], markers[3]]); + }); + it('should dispose on IL', async () => { + await term.writeP('\x1b[3;1H'); // move cursor to 0, 2 + await term.writeP('\x1b[2L'); // insert 2 lines + assert.deepEqual(disposeStack, [markers[4], markers[3]]); + assert.deepEqual(markers.map(el => el.line), [0, 1, 4, -1, -1]); + }); + it('should dispose on resize', () => { + term.resize(10, 2); + assert.deepEqual(disposeStack, [markers[0], markers[1]]); + assert.deepEqual(markers.map(el => el.line), [-1, -1, 0, 1, 2]); + }); + }); }); - // FIXME: move to common/CoreTerminal.test once the trimming is moved over - describe('marker lifecycle', () => { - // create a 10x5 terminal with markers on every line - // to test marker lifecycle under various terminal actions - let markers: IMarker[]; - let disposeStack: IMarker[]; - let term: TestTerminal; - beforeEach(async () => { - term = new TestTerminal({}); - markers = []; - disposeStack = []; - term.optionsService.setOption('scrollback', 1); - term.resize(10, 5); - markers.push(term.buffers.active.addMarker(term.buffers.active.y)); - await term.writeP('\x1b[r0\r\n'); - markers.push(term.buffers.active.addMarker(term.buffers.active.y)); - await term.writeP('1\r\n'); - markers.push(term.buffers.active.addMarker(term.buffers.active.y)); - await term.writeP('2\r\n'); - markers.push(term.buffers.active.addMarker(term.buffers.active.y)); - await term.writeP('3\r\n'); - markers.push(term.buffers.active.addMarker(term.buffers.active.y)); - await term.writeP('4'); - for (let i = 0; i < markers.length; ++i) { - const marker = markers[i]; - marker.onDispose(() => disposeStack.push(marker)); - } - }); - it('initial', () => { - assert.deepEqual(markers.map(m => m.line), [0, 1, 2, 3, 4]); - }); - it('should dispose on normal trim off the top', async () => { - // moves top line into scrollback - await term.writeP('\n'); - assert.deepEqual(disposeStack, []); - // trims first marker - await term.writeP('\n'); - assert.deepEqual(disposeStack, [markers[0]]); - // trims second marker - await term.writeP('\n'); - assert.deepEqual(disposeStack, [markers[0], markers[1]]); - // trimmed marker objs should be disposed - assert.deepEqual(disposeStack.map(el => el.isDisposed), [true, true]); - assert.deepEqual(disposeStack.map(el => (el as any)._isDisposed), [true, true]); - // trimmed markers should contain line -1 - assert.deepEqual(disposeStack.map(el => el.line), [-1, -1]); - }); - it('should dispose on DL', async () => { - await term.writeP('\x1b[3;1H'); // move cursor to 0, 2 - await term.writeP('\x1b[2M'); // delete 2 lines - assert.deepEqual(disposeStack, [markers[2], markers[3]]); - }); - it('should dispose on IL', async () => { - await term.writeP('\x1b[3;1H'); // move cursor to 0, 2 - await term.writeP('\x1b[2L'); // insert 2 lines - assert.deepEqual(disposeStack, [markers[4], markers[3]]); - assert.deepEqual(markers.map(el => el.line), [0, 1, 4, -1, -1]); - }); - it('should dispose on resize', () => { - term.resize(10, 2); - assert.deepEqual(disposeStack, [markers[0], markers[1]]); - assert.deepEqual(markers.map(el => el.line), [-1, -1, 0, 1, 2]); - }); - }); -}); + class TestLinkifier extends Linkifier { + constructor(bufferService: IBufferService, unicodeService: IUnicodeService) { + super(bufferService, new MockLogService(), unicodeService); + Linkifier._timeBeforeLatency = 0; + } -class TestLinkifier extends Linkifier { - constructor(bufferService: IBufferService, unicodeService: IUnicodeService) { - super(bufferService, new MockLogService(), unicodeService); - Linkifier._timeBeforeLatency = 0; + public get linkMatchers(): IRegisteredLinkMatcher[] { return this._linkMatchers; } + public linkifyRows(): void { super.linkifyRows(0, this._bufferService.buffer.lines.length - 1); } } - public get linkMatchers(): IRegisteredLinkMatcher[] { return this._linkMatchers; } - public linkifyRows(): void { super.linkifyRows(0, this._bufferService.buffer.lines.length - 1); } -} - -class TestMouseZoneManager implements IMouseZoneManager { - public dispose(): void { - } - public clears: number = 0; - public zones: IMouseZone[] = []; - public add(zone: IMouseZone): void { - this.zones.push(zone); - } - public clearAll(): void { - this.clears++; + class TestMouseZoneManager implements IMouseZoneManager { + public dispose(): void { + } + public clears: number = 0; + public zones: IMouseZone[] = []; + public add(zone: IMouseZone): void { + this.zones.push(zone); + } + public clearAll(): void { + this.clears++; + } } } +); diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 1ab207c7..9d9246e3 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -147,7 +147,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this.register(this._inputHandler.onRequestBell(() => this.bell())); this.register(this._inputHandler.onRequestRefreshRows((start, end) => this.refresh(start, end))); this.register(this._inputHandler.onRequestReset(() => this.reset())); - this.register(this._inputHandler.onRequestScroll((eraseAttr, isWrapped) => this.scroll(eraseAttr, isWrapped || undefined))); + this.register(this._inputHandler.onRequestScroll((eraseAttr, isWrapped) => this._bufferService.scroll(eraseAttr, isWrapped || undefined))); this.register(this._inputHandler.onRequestWindowsOptionsReport(type => this._reportWindowsOptions(type))); this.register(this._inputHandler.onAnsiColorChange((event) => this._changeAnsiColor(event))); this.register(forwardEvent(this._inputHandler.onCursorMove, this._onCursorMove)); @@ -1010,7 +1010,7 @@ export class Terminal extends CoreTerminal implements ITerminal { if (!this._compositionHelper!.keydown(event)) { if (this.buffer.ybase !== this.buffer.ydisp) { - this.scrollToBottom(); + this._bufferService.scrollToBottom(); } return false; } diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 936aa0c8..9f855845 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -58,8 +58,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { protected _inputHandler: InputHandler; private _writeBuffer: WriteBuffer; private _windowsMode: IDisposable | undefined; - /** An IBufferline to clone/copy from for new blank lines */ - private _cachedBlankLine: IBufferLine | undefined; + private _onBinary = new EventEmitter(); public get onBinary(): IEvent { return this._onBinary.event; } @@ -98,21 +97,20 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this._instantiationService = new InstantiationService(); this.optionsService = new OptionsService(options); this._instantiationService.setService(IOptionsService, this.optionsService); - this._bufferService = this.register(this._instantiationService.createInstance(BufferService)); - this._instantiationService.setService(IBufferService, this._bufferService); this._logService = this._instantiationService.createInstance(LogService); this._instantiationService.setService(ILogService, this._logService); - this._coreService = this.register(this._instantiationService.createInstance(CoreService, () => this.scrollToBottom())); - this._instantiationService.setService(ICoreService, this._coreService); - this._coreMouseService = this._instantiationService.createInstance(CoreMouseService); - this._instantiationService.setService(ICoreMouseService, this._coreMouseService); - this._dirtyRowService = this._instantiationService.createInstance(DirtyRowService); - this._instantiationService.setService(IDirtyRowService, this._dirtyRowService); this.unicodeService = this._instantiationService.createInstance(UnicodeService); this._instantiationService.setService(IUnicodeService, this.unicodeService); this._charsetService = this._instantiationService.createInstance(CharsetService); this._instantiationService.setService(ICharsetService, this._charsetService); - + this._bufferService = this.register(this._instantiationService.createInstance(BufferService)); + this._instantiationService.setService(IBufferService, this._bufferService); + this._dirtyRowService = this._instantiationService.createInstance(DirtyRowService); + this._instantiationService.setService(IDirtyRowService, this._dirtyRowService); + this._coreService = this.register(this._instantiationService.createInstance(CoreService, () => this._bufferService.scrollToBottom())); + this._instantiationService.setService(ICoreService, this._coreService); + this._coreMouseService = this._instantiationService.createInstance(CoreMouseService); + this._instantiationService.setService(ICoreMouseService, this._coreMouseService); // Register input handler and handle/forward events this._inputHandler = new InputHandler(this._bufferService, this._charsetService, this._coreService, this._dirtyRowService, this._logService, this.optionsService, this._coreMouseService, this.unicodeService); this.register(forwardEvent(this._inputHandler.onLineFeed, this._onLineFeed)); @@ -137,6 +135,23 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this._windowsMode = undefined; } + public scrollLines(disp: number, suppressScrollEvent?: boolean): void { + this._bufferService.scrollLines(disp, suppressScrollEvent); + } + + public scrollPages(pageCount: number): void { + this._bufferService.scrollPages(pageCount); + } + public scrollToTop(): void { + this._bufferService.scrollToTop(); + } + public scrollToBottom(): void { + this._bufferService.scrollToBottom(); + } + public scrollToLine(line: number): void { + this._bufferService.scrollToLine(line); + } + public write(data: string | Uint8Array, callback?: () => void): void { this._writeBuffer.write(data, callback); } diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index b5067193..93de6562 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -18,6 +18,7 @@ import { clone } from 'common/Clone'; import { BufferService } from 'common/services/BufferService'; import { CoreService } from 'common/services/CoreService'; import { OscHandler } from 'common/parser/OscParser'; +import { DirtyRowService } from 'common/services/DirtyRowService'; function getCursor(bufferService: IBufferService): number[] { return [ @@ -66,11 +67,119 @@ describe('InputHandler', () => { optionsService = new MockOptionsService(); bufferService = new BufferService(optionsService); bufferService.resize(80, 30); - coreService = new CoreService(() => {}, bufferService, new MockLogService(), optionsService); + coreService = new CoreService(() => { }, bufferService, new MockLogService(), optionsService); inputHandler = new TestInputHandler(bufferService, new MockCharsetService(), coreService, new MockDirtyRowService(), new MockLogService(), optionsService, new MockCoreMouseService(), new MockUnicodeService()); }); + describe('Terminal InputHandler integration', () => { + function getLines(limit: number): string[] { + const res: string[] = []; + for (let i = 0; i < limit; ++i) { + res.push(bufferService.buffers.active.lines.get(i)!.translateToString(true)); + } + return res; + } + + // This suite cannot live in InputHandler unless Terminal.scroll moved into IBufferService + describe('SL/SR/DECIC/DECDC', () => { + + it('SL (scrollLeft)', async () => { + inputHandler.parseP('12345'.repeat(6)); + assert.deepEqual(getLines(5), ['12345', '2345', '2345', '2345', '2345', '2345']); + inputHandler.parseP('\x1b[0 @'); + assert.deepEqual(getLines(5), ['12345', '345', '345', '345', '345', '345']); + inputHandler.parseP('\x1b[2 @'); + assert.deepEqual(getLines(5), ['12345', '5', '5', '5', '5', '5']); + }); + it('SR (scrollRight)', async () => { + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[ A'); + assert.deepEqual(getLines(5), ['12345', ' 1234', ' 1234', ' 1234', ' 1234', ' 1234']); + inputHandler.parseP('\x1b[0 A'); + assert.deepEqual(getLines(5), ['12345', ' 123', ' 123', ' 123', ' 123', ' 123']); + inputHandler.parseP('\x1b[2 A'); + assert.deepEqual(getLines(5), ['12345', ' 1', ' 1', ' 1', ' 1', ' 1']); + }); + it('insertColumns (DECIC)', async () => { + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[3;3H'); + inputHandler.parseP('\x1b[\'}'); + assert.deepEqual(getLines(5), ['12345', '12 34', '12 34', '12 34', '12 34', '12 34']); + inputHandler.reset(); + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[3;3H'); + inputHandler.parseP('\x1b[1\'}'); + assert.deepEqual(getLines(5), ['12345', '12 34', '12 34', '12 34', '12 34', '12 34']); + inputHandler.reset(); + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[3;3H'); + inputHandler.parseP('\x1b[2\'}'); + assert.deepEqual(getLines(5), ['12345', '12 3', '12 3', '12 3', '12 3', '12 3']); + }); + it('deleteColumns (DECDC)', async () => { + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[3;3H'); + inputHandler.parseP('\x1b[\'~'); + assert.deepEqual(getLines(5), ['12345', '1245', '1245', '1245', '1245', '1245']); + inputHandler.reset(); + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[3;3H'); + inputHandler.parseP('\x1b[1\'~'); + assert.deepEqual(getLines(5), ['12345', '1245', '1245', '1245', '1245', '1245']); + inputHandler.reset(); + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[3;3H'); + inputHandler.parseP('\x1b[2\'~'); + assert.deepEqual(getLines(5), ['12345', '125', '125', '125', '125', '125']); + }); + }); + + describe('BS with reverseWraparound set/unset', () => { + const ttyBS = '\x08 \x08'; // tty ICANON sends on pressing BS + + describe('reverseWraparound set', () => { + it('should not reverse outside of scroll margins', async () => { + // prepare buffer content + inputHandler.parseP('#####abcdefghijklmnopqrstuvwxy'); + assert.deepEqual(getLines(5), ['#####', 'abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy']); + assert.equal(bufferService.buffers.active.ydisp, 1); + assert.equal(bufferService.buffers.active.x, 5); + assert.equal(bufferService.buffers.active.y, 4); + inputHandler.parseP(ttyBS.repeat(100)); + assert.deepEqual(getLines(5), ['#####', 'abcde', 'fghij', 'klmno', 'pqrst', ' y']); + + inputHandler.parseP('\x1b[?45h'); + inputHandler.parseP('uvwxy'); + + // set top/bottom to 1/3 (0-based) + inputHandler.parseP('\x1b[2;4r'); + // place cursor below scroll bottom + bufferService.buffers.active.x = 5; + bufferService.buffers.active.y = 4; + inputHandler.parseP(ttyBS.repeat(100)); + assert.deepEqual(getLines(5), ['#####', 'abcde', 'fghij', 'klmno', 'pqrst', ' ']); + + inputHandler.parseP('uvwxy'); + // place cursor within scroll margins + bufferService.buffers.active.x = 5; + bufferService.buffers.active.y = 3; + inputHandler.parseP(ttyBS.repeat(100)); + assert.deepEqual(getLines(5), ['#####', 'abcde', ' ', ' ', ' ', 'uvwxy']); + assert.equal(bufferService.buffers.active.x, 0); + assert.equal(bufferService.buffers.active.y, bufferService.buffers.active.scrollTop); // stops at 0, scrollTop + + inputHandler.parseP('fghijklmnopqrst'); + // place cursor above scroll top + bufferService.buffers.active.x = 5; + bufferService.buffers.active.y = 0; + inputHandler.parseP(ttyBS.repeat(100)); + assert.deepEqual(getLines(5), ['#####', ' ', 'fghij', 'klmno', 'pqrst', 'uvwxy']); + }); + }); + }); + }); + it('save and restore cursor', () => { bufferService.buffer.x = 1; bufferService.buffer.y = 2; @@ -140,7 +249,7 @@ describe('InputHandler', () => { assert.equal(coreService.decPrivateModes.bracketedPasteMode, false); }); }); - describe('regression tests', function(): void { + describe('regression tests', function (): void { function termContent(bufferService: IBufferService, trim: boolean): string[] { const result = []; for (let i = 0; i < bufferService.rows; ++i) result.push(bufferService.buffer.lines.get(i)!.translateToString(trim)); @@ -430,6 +539,68 @@ describe('InputHandler', () => { await inputHandler.parseP('¥¥¥'); assert.deepEqual(getLines(bufferService, 2), ['¥¥', '¥']); }); + + + // This suite cannot live in InputHandler unless Terminal.scroll moved into IBufferService + describe('SL/SR/DECIC/DECDC', () => { + it('SL (scrollLeft)', async () => { + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[ @'); + assert.deepEqual(getLines(bufferService, 5), ['12345', '2345', '2345', '2345', '2345', '2345']); + inputHandler.parseP('\x1b[0 @'); + assert.deepEqual(getLines(bufferService, 5), ['12345', '345', '345', '345', '345', '345']); + inputHandler.parseP('\x1b[2 @'); + assert.deepEqual(getLines(bufferService, 5), ['12345', '5', '5', '5', '5', '5']); + }); + it('SR (scrollRight)', async () => { + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[ A'); + assert.deepEqual(getLines(bufferService, 5), ['12345', ' 1234', ' 1234', ' 1234', ' 1234', ' 1234']); + inputHandler.parseP('\x1b[0 A'); + assert.deepEqual(getLines(bufferService, 5), ['12345', ' 123', ' 123', ' 123', ' 123', ' 123']); + inputHandler.parseP('\x1b[2 A'); + assert.deepEqual(getLines(bufferService, 5), ['12345', ' 1', ' 1', ' 1', ' 1', ' 1']); + }); + it('insertColumns (DECIC)', async () => { + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[3;3H'); + inputHandler.parseP('\x1b[\'}'); + assert.deepEqual(getLines(bufferService, 5), ['12345', '12 34', '12 34', '12 34', '12 34', '12 34']); + inputHandler.reset(); + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[3;3H'); + inputHandler.parseP('\x1b[1\'}'); + assert.deepEqual(getLines(bufferService, 5), ['12345', '12 34', '12 34', '12 34', '12 34', '12 34']); + inputHandler.reset(); + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[3;3H'); + inputHandler.parseP('\x1b[2\'}'); + assert.deepEqual(getLines(bufferService, 5), ['12345', '12 3', '12 3', '12 3', '12 3', '12 3']); + }); + it('deleteColumns (DECDC)', async () => { + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[3;3H'); + inputHandler.parseP('\x1b[\'~'); + assert.deepEqual(getLines(bufferService, 5), ['12345', '1245', '1245', '1245', '1245', '1245']); + inputHandler.reset(); + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[3;3H'); + inputHandler.parseP('\x1b[1\'~'); + assert.deepEqual(getLines(bufferService, 5), ['12345', '1245', '1245', '1245', '1245', '1245']); + inputHandler.reset(); + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[3;3H'); + inputHandler.parseP('\x1b[2\'~'); + assert.deepEqual(getLines(bufferService, 5), ['12345', '125', '125', '125', '125', '125']); + }); + }); + it('should fire the onScroll event', (done) => { + bufferService.onScroll(e => { + assert.equal(typeof e, 'number'); + done(); + }); + bufferService.scroll(DEFAULT_ATTR_DATA.clone()); + }); }); describe('alt screen', () => { @@ -1240,7 +1411,7 @@ describe('InputHandler', () => { await inputHandler.parseP('\x1b[6H\x1b[2Mm'); assert.deepEqual(getLines(bufferService), ['0', '1', '2', '3', '4', 'm', '6', '7', '8', '9']); await inputHandler.parseP('\x1b[3H\x1b[2Mn'); - assert.deepEqual(getLines(bufferService), ['0', '1', 'n', 'm', '', '', '6', '7', '8', '9']); + assert.deepEqual(getLines(bufferService), ['0', '1', 'n', 'm', '', '', '6', '7', '8', '9']); }); }); it('should parse big chunks in smaller subchunks', async () => { @@ -1814,13 +1985,14 @@ describe('InputHandler - async handlers', () => { let bufferService: IBufferService; let coreService: ICoreService; let optionsService: MockOptionsService; + let dirtyRowService: MockDirtyRowService; let inputHandler: TestInputHandler; beforeEach(() => { optionsService = new MockOptionsService(); bufferService = new BufferService(optionsService); bufferService.resize(80, 30); - coreService = new CoreService(() => {}, bufferService, new MockLogService(), optionsService); + coreService = new CoreService(() => { }, bufferService, new MockLogService(), optionsService); coreService.onData(data => { console.log(data); }); inputHandler = new TestInputHandler(bufferService, new MockCharsetService(), coreService, new MockDirtyRowService(), new MockLogService(), optionsService, new MockCoreMouseService(), new MockUnicodeService()); @@ -1829,7 +2001,7 @@ describe('InputHandler - async handlers', () => { it('async CUP with CPR check', async () => { const cup: number[][] = []; const cpr: number[][] = []; - inputHandler.registerCsiHandler({final: 'H'}, async params => { + inputHandler.registerCsiHandler({ final: 'H' }, async params => { cup.push(params.toArray() as number[]); await new Promise(res => setTimeout(res, 50)); // late call of real repositioning @@ -1855,7 +2027,7 @@ describe('InputHandler - async handlers', () => { assert.deepEqual(getLines(bufferService, 2), ['hello world!', 'second line']); }); it('async DCS between', async () => { - inputHandler.registerDcsHandler({final: 'a'}, async (data, params) => { + inputHandler.registerDcsHandler({ final: 'a' }, async (data, params) => { await new Promise(res => setTimeout(res, 50)); assert.deepEqual(getLines(bufferService, 2), ['hello world!', '']); assert.equal(data, 'some data'); diff --git a/src/common/TestUtils.test.ts b/src/common/TestUtils.test.ts index 01ceacbd..dce0f570 100644 --- a/src/common/TestUtils.test.ts +++ b/src/common/TestUtils.test.ts @@ -9,7 +9,7 @@ import { clone } from 'common/Clone'; import { DEFAULT_OPTIONS } from 'common/services/OptionsService'; import { IBufferSet, IBuffer } from 'common/buffer/Types'; import { BufferSet } from 'common/buffer/BufferSet'; -import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEventType, ICharset, IModes } from 'common/Types'; +import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEventType, ICharset, IModes, IAttributeData } from 'common/Types'; import { UnicodeV6 } from 'common/input/UnicodeV6'; export class MockBufferService implements IBufferService { @@ -17,6 +17,7 @@ export class MockBufferService implements IBufferService { public get buffer(): IBuffer { return this.buffers.active; } public buffers: IBufferSet = {} as any; public onResize: IEvent<{ cols: number, rows: number }> = new EventEmitter<{ cols: number, rows: number }>().event; + public onScroll: IEvent = new EventEmitter().event; public isUserScrolling: boolean = false; constructor( public cols: number, @@ -25,23 +26,41 @@ export class MockBufferService implements IBufferService { ) { this.buffers = new BufferSet(optionsService, this); } + public scrollPages(pageCount: number): void { + throw new Error('Method not implemented.'); + } + public scrollToTop(): void { + throw new Error('Method not implemented.'); + } + public scrollToLine(line: number): void { + throw new Error('Method not implemented.'); + } + public scroll(eraseAttr: IAttributeData, isWrapped: boolean): void { + throw new Error('Method not implemented.'); + } + public scrollToBottom(): void { + throw new Error('Method not implemented.'); + } + public scrollLines(disp: number, suppressScrollEvent?: boolean): void { + throw new Error('Method not implemented.'); + } public resize(cols: number, rows: number): void { this.cols = cols; this.rows = rows; } - public reset(): void {} + public reset(): void { } } export class MockCoreMouseService implements ICoreMouseService { public areMouseEventsActive: boolean = false; public activeEncoding: string = ''; public activeProtocol: string = ''; - public addEncoding(name: string): void {} - public addProtocol(name: string): void {} - public reset(): void {} + public addEncoding(name: string): void { } + public addProtocol(name: string): void { } + public reset(): void { } public triggerMouseEvent(event: ICoreMouseEvent): boolean { return false; } public onProtocolChange: IEvent = new EventEmitter().event; - public explainEvents(events: CoreMouseEventType): {[event: string]: boolean} { + public explainEvents(events: CoreMouseEventType): { [event: string]: boolean } { throw new Error('Method not implemented.'); } } @@ -50,9 +69,9 @@ export class MockCharsetService implements ICharsetService { public serviceBrand: any; public charset: ICharset | undefined; public glevel: number = 0; - public reset(): void {} - public setgLevel(g: number): void {} - public setgCharset(g: number, charset: ICharset): void {} + public reset(): void { } + public setgLevel(g: number): void { } + public setgCharset(g: number, charset: ICharset): void { } } export class MockCoreService implements ICoreService { @@ -75,28 +94,28 @@ export class MockCoreService implements ICoreService { public onData: IEvent = new EventEmitter().event; public onUserInput: IEvent = new EventEmitter().event; public onBinary: IEvent = new EventEmitter().event; - public reset(): void {} - public triggerDataEvent(data: string, wasUserInput?: boolean): void {} - public triggerBinaryEvent(data: string): void {} + public reset(): void { } + public triggerDataEvent(data: string, wasUserInput?: boolean): void { } + public triggerBinaryEvent(data: string): void { } } export class MockDirtyRowService implements IDirtyRowService { public serviceBrand: any; public start: number = 0; public end: number = 0; - public clearRange(): void {} - public markDirty(y: number): void {} - public markRangeDirty(y1: number, y2: number): void {} - public markAllDirty(): void {} + public clearRange(): void { } + public markDirty(y: number): void { } + public markRangeDirty(y1: number, y2: number): void { } + public markAllDirty(): void { } } export class MockLogService implements ILogService { public serviceBrand: any; public logLevel = LogLevelEnum.DEBUG; - public debug(message: any, ...optionalParams: any[]): void {} - public info(message: any, ...optionalParams: any[]): void {} - public warn(message: any, ...optionalParams: any[]): void {} - public error(message: any, ...optionalParams: any[]): void {} + public debug(message: any, ...optionalParams: any[]): void { } + public info(message: any, ...optionalParams: any[]): void { } + public warn(message: any, ...optionalParams: any[]): void { } + public error(message: any, ...optionalParams: any[]): void { } } export class MockOptionsService implements IOptionsService { diff --git a/src/common/services/BufferService.ts b/src/common/services/BufferService.ts index 47e54729..7fe0cdc3 100644 --- a/src/common/services/BufferService.ts +++ b/src/common/services/BufferService.ts @@ -3,11 +3,13 @@ * @license MIT */ -import { IBufferService, IOptionsService } from 'common/services/Services'; +import { IBufferService, IDirtyRowService, IInstantiationService, IOptionsService } from 'common/services/Services'; import { BufferSet } from 'common/buffer/BufferSet'; import { IBufferSet, IBuffer } from 'common/buffer/Types'; import { EventEmitter, IEvent } from 'common/EventEmitter'; import { Disposable } from 'common/Lifecycle'; +import { IAttributeData, IBufferLine } from 'common/Types'; +import { DirtyRowService } from 'common/services/DirtyRowService'; export const MINIMUM_COLS = 2; // Less than 2 can mess with wide chars export const MINIMUM_ROWS = 1; @@ -23,9 +25,16 @@ export class BufferService extends Disposable implements IBufferService { private _onResize = new EventEmitter<{ cols: number, rows: number }>(); public get onResize(): IEvent<{ cols: number, rows: number }> { return this._onResize.event; } + private _onScroll = new EventEmitter(); + public get onScroll(): IEvent { return this._onScroll.event; } public get buffer(): IBuffer { return this.buffers.active; } + /** An IBufferline to clone/copy from for new blank lines */ + private _cachedBlankLine: IBufferLine | undefined; + + private _dirtyRowService: IDirtyRowService | undefined; + constructor( @IOptionsService private _optionsService: IOptionsService ) { @@ -52,4 +61,134 @@ export class BufferService extends Disposable implements IBufferService { this.buffers.reset(); this.isUserScrolling = false; } + + /** + * Scroll the terminal down 1 row, creating a blank line. + * @param isWrapped Whether the new line is wrapped from the previous line. + */ + public scroll(eraseAttr: IAttributeData, isWrapped: boolean = false): void { + const buffer = this.buffer; + + let newLine: IBufferLine | undefined; + newLine = this._cachedBlankLine; + if (!newLine || newLine.length !== this.cols || newLine.getFg(0) !== eraseAttr.fg || newLine.getBg(0) !== eraseAttr.bg) { + newLine = buffer.getBlankLine(eraseAttr, isWrapped); + this._cachedBlankLine = newLine; + } + newLine.isWrapped = isWrapped; + + const topRow = buffer.ybase + buffer.scrollTop; + const bottomRow = buffer.ybase + buffer.scrollBottom; + + if (buffer.scrollTop === 0) { + // Determine whether the buffer is going to be trimmed after insertion. + const willBufferBeTrimmed = buffer.lines.isFull; + + // Insert the line using the fastest method + if (bottomRow === buffer.lines.length - 1) { + if (willBufferBeTrimmed) { + buffer.lines.recycle().copyFrom(newLine); + } else { + buffer.lines.push(newLine.clone()); + } + } else { + buffer.lines.splice(bottomRow + 1, 0, newLine.clone()); + } + + // Only adjust ybase and ydisp when the buffer is not trimmed + if (!willBufferBeTrimmed) { + buffer.ybase++; + // Only scroll the ydisp with ybase if the user has not scrolled up + if (!this.isUserScrolling) { + buffer.ydisp++; + } + } else { + // When the buffer is full and the user has scrolled up, keep the text + // stable unless ydisp is right at the top + if (this.isUserScrolling) { + buffer.ydisp = Math.max(buffer.ydisp - 1, 0); + } + } + } else { + // scrollTop is non-zero which means no line will be going to the + // scrollback, instead we can just shift them in-place. + const scrollRegionHeight = bottomRow - topRow + 1 /* as it's zero-based */; + buffer.lines.shiftElements(topRow + 1, scrollRegionHeight - 1, -1); + buffer.lines.set(bottomRow, newLine.clone()); + } + + // Move the viewport to the bottom of the buffer unless the user is + // scrolling. + if (!this.isUserScrolling) { + buffer.ydisp = buffer.ybase; + } + + // Flag rows that need updating + if (!this._dirtyRowService) { + this._dirtyRowService = new DirtyRowService(this); + } + this._dirtyRowService?.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + + this._onScroll.fire(buffer.ydisp); + } + + /** + * Scroll the display of the terminal + * @param disp The number of lines to scroll down (negative scroll up). + * @param suppressScrollEvent Don't emit the scroll event as scrollLines. This is used + * to avoid unwanted events being handled by the viewport when the event was triggered from the + * viewport originally. + */ + public scrollLines(disp: number, suppressScrollEvent?: boolean): void { + const buffer = this.buffer; + if (disp < 0) { + if (buffer.ydisp === 0) { + return; + } + this.isUserScrolling = true; + } else if (disp + buffer.ydisp >= buffer.ybase) { + this.isUserScrolling = false; + } + + const oldYdisp = buffer.ydisp; + buffer.ydisp = Math.max(Math.min(buffer.ydisp + disp, buffer.ybase), 0); + + // No change occurred, don't trigger scroll/refresh + if (oldYdisp === buffer.ydisp) { + return; + } + + if (!suppressScrollEvent) { + this._onScroll.fire(buffer.ydisp); + } + } + + /** + * Scroll the display of the terminal by a number of pages. + * @param pageCount The number of pages to scroll (negative scrolls up). + */ + public scrollPages(pageCount: number): void { + this.scrollLines(pageCount * (this.rows - 1)); + } + + /** + * Scrolls the display of the terminal to the top. + */ + public scrollToTop(): void { + this.scrollLines(-this.buffer.ydisp); + } + + /** + * Scrolls the display of the terminal to the bottom. + */ + public scrollToBottom(): void { + this.scrollLines(this.buffer.ybase - this.buffer.ydisp); + } + + public scrollToLine(line: number): void { + const scrollAmount = line - this.buffer.ydisp; + if (scrollAmount !== 0) { + this.scrollLines(scrollAmount); + } + } } diff --git a/src/common/services/Services.ts b/src/common/services/Services.ts index 1fbf57fb..40c0c1b2 100644 --- a/src/common/services/Services.ts +++ b/src/common/services/Services.ts @@ -5,7 +5,7 @@ import { IEvent } from 'common/EventEmitter'; import { IBuffer, IBufferSet } from 'common/buffer/Types'; -import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEncoding, ICoreMouseProtocol, CoreMouseEventType, ICharset, IWindowOptions, IModes } from 'common/Types'; +import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEncoding, ICoreMouseProtocol, CoreMouseEventType, ICharset, IWindowOptions, IModes, IAttributeData } from 'common/Types'; import { createDecorator } from 'common/services/ServiceRegistry'; export const IBufferService = createDecorator('BufferService'); @@ -17,9 +17,14 @@ export interface IBufferService { readonly buffer: IBuffer; readonly buffers: IBufferSet; isUserScrolling: boolean; - onResize: IEvent<{ cols: number, rows: number }>; - + onScroll: IEvent; + scroll(eraseAttr: IAttributeData, isWrapped?: boolean): void; + scrollToBottom(): void; + scrollToTop(): void; + scrollToLine(line: number): void; + scrollLines(disp: number, suppressScrollEvent?: boolean): void; + scrollPages(pageCount: number): void; resize(cols: number, rows: number): void; reset(): void; } From b074c2552a2cb71a2bc161c3c760043512418a98 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Thu, 1 Apr 2021 09:49:01 -0700 Subject: [PATCH 145/377] use bufferService in terminal to reduce code a bunch --- src/browser/Terminal.test.ts | 2202 +++++++++++++++++-------------- src/common/CoreTerminal.ts | 137 +- src/common/InputHandler.test.ts | 103 +- 3 files changed, 1275 insertions(+), 1167 deletions(-) diff --git a/src/browser/Terminal.test.ts b/src/browser/Terminal.test.ts index f3bcdfda..8f10e622 100644 --- a/src/browser/Terminal.test.ts +++ b/src/browser/Terminal.test.ts @@ -117,6 +117,13 @@ describe('Terminal', () => { }); term.resize(1, 1); }); + it('should fire the onScroll event', (done) => { + term.onScroll(e => { + assert.equal(typeof e, 'number'); + done(); + }); + term.scroll(DEFAULT_ATTR_DATA.clone()); + }); it('should fire the onTitleChange event', (done) => { term.onTitleChange(e => { assert.equal(e, 'title'); @@ -273,991 +280,1244 @@ describe('Terminal', () => { }); }); - describe('Third level shift', () => { - let evKeyDown: any; - let evKeyPress: any; - - beforeEach(() => { - term.clearSelection = () => { }; - // term.compositionHelper = { - // isComposing: false, - // keydown: { - // bind: () => { - // return () => { return true; }; - // } - // } - // }; - evKeyDown = { - preventDefault: () => { }, - stopPropagation: () => { }, - type: 'keydown', - altKey: null, - keyCode: null - }; - evKeyPress = { - preventDefault: () => { }, - stopPropagation: () => { }, - type: 'keypress', - altKey: null, - charCode: null, - keyCode: null - }; - }); - - describe('with macOptionIsMeta', () => { - let originalIsMac: boolean; - beforeEach(() => { - originalIsMac = term.browser.isMac; - term.options.macOptionIsMeta = true; - }); - afterEach(() => term.browser.isMac = originalIsMac); - - it('should interfere with the alt key on keyDown', () => { - evKeyDown.altKey = true; - evKeyDown.keyCode = 81; - assert.equal(term.keyDown(evKeyDown), false); - evKeyDown.altKey = true; - evKeyDown.keyCode = 192; - assert.equal(term.keyDown(evKeyDown), false); - }); - }); - - describe('On Mac OS', () => { - let originalIsMac: boolean; - beforeEach(() => { - originalIsMac = term.browser.isMac; - term.browser.isMac = true; - }); - afterEach(() => term.browser.isMac = originalIsMac); - - it('should not interfere with the alt key on keyDown', () => { - evKeyDown.altKey = true; - evKeyDown.keyCode = 81; - assert.equal(term.keyDown(evKeyDown), true); - evKeyDown.altKey = true; - evKeyDown.keyCode = 192; - term.keyDown(evKeyDown); - assert.equal(term.keyDown(evKeyDown), true); - }); - - it('should interfere with the alt + arrow keys', () => { - evKeyDown.altKey = true; - evKeyDown.keyCode = 37; - assert.equal(term.keyDown(evKeyDown), false); - evKeyDown.altKey = true; - evKeyDown.keyCode = 39; - assert.equal(term.keyDown(evKeyDown), false); - }); - - it('should emit key with alt + key on keyPress', (done) => { - const keys = ['@', '@', '\\', '\\', '|', '|']; - - term.onKey(e => { - if (e.key) { - const index = keys.indexOf(e.key); - assert(index !== -1, 'Emitted wrong key: ' + e.key); - keys.splice(index, 1); - } - if (keys.length === 0) done(); - }); - - evKeyPress.altKey = true; - // @ - evKeyPress.charCode = null; - evKeyPress.keyCode = 64; - term.keyPress(evKeyPress); - // Firefox @ - evKeyPress.charCode = 64; - evKeyPress.keyCode = 0; - term.keyPress(evKeyPress); - // \ - evKeyPress.charCode = null; - evKeyPress.keyCode = 92; - term.keyPress(evKeyPress); - // Firefox \ - evKeyPress.charCode = 92; - evKeyPress.keyCode = 0; - term.keyPress(evKeyPress); - // | - evKeyPress.charCode = null; - evKeyPress.keyCode = 124; - term.keyPress(evKeyPress); - // Firefox | - evKeyPress.charCode = 124; - evKeyPress.keyCode = 0; - term.keyPress(evKeyPress); - }); - }); - - describe('On MS Windows', () => { - let originalIsWindows: boolean; - beforeEach(() => { - originalIsWindows = term.browser.isWindows; - term.browser.isWindows = true; - }); - afterEach(() => term.browser.isWindows = originalIsWindows); - - it('should not interfere with the alt + ctrl key on keyDown', () => { - evKeyPress.altKey = true; - evKeyPress.ctrlKey = true; - evKeyPress.keyCode = 81; - assert.equal(term.keyDown(evKeyPress), true); - evKeyDown.altKey = true; - evKeyDown.ctrlKey = true; - evKeyDown.keyCode = 81; - term.keyDown(evKeyDown); - assert.equal(term.keyDown(evKeyPress), true); - }); - - it('should interfere with the alt + ctrl + arrow keys', () => { - evKeyDown.altKey = true; - evKeyDown.ctrlKey = true; - - evKeyDown.keyCode = 37; - assert.equal(term.keyDown(evKeyDown), false); - evKeyDown.keyCode = 39; - term.keyDown(evKeyDown); - assert.equal(term.keyDown(evKeyDown), false); - }); - - it('should emit key with alt + ctrl + key on keyPress', (done) => { - const keys = ['@', '@', '\\', '\\', '|', '|']; - - term.onKey(e => { - if (e.key) { - const index = keys.indexOf(e.key); - assert(index !== -1, 'Emitted wrong key: ' + e.key); - keys.splice(index, 1); - } - if (keys.length === 0) done(); - }); - - evKeyPress.altKey = true; - evKeyPress.ctrlKey = true; - - // @ - evKeyPress.charCode = null; - evKeyPress.keyCode = 64; - term.keyPress(evKeyPress); - // Firefox @ - evKeyPress.charCode = 64; - evKeyPress.keyCode = 0; - term.keyPress(evKeyPress); - // \ - evKeyPress.charCode = null; - evKeyPress.keyCode = 92; - term.keyPress(evKeyPress); - // Firefox \ - evKeyPress.charCode = 92; - evKeyPress.keyCode = 0; - term.keyPress(evKeyPress); - // | - evKeyPress.charCode = null; - evKeyPress.keyCode = 124; - term.keyPress(evKeyPress); - // Firefox | - evKeyPress.charCode = 124; - evKeyPress.keyCode = 0; - term.keyPress(evKeyPress); - }); - }); - }); - - describe('unicode - surrogates', () => { - it('2 characters per cell', async function (): Promise { - this.timeout(10000); // This is needed because istanbul patches code and slows it down - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - await term.writeP(high + String.fromCharCode(i)); - const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); - assert.equal(tchar.getChars(), high + String.fromCharCode(i)); - assert.equal(tchar.getChars().length, 2); - assert.equal(tchar.getWidth(), 1); - assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), ''); - term.reset(); - } - }); - it('2 characters at last cell', async () => { - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - term.buffer.x = term.cols - 1; - await term.writeP(high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars(), high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars().length, 2); - assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), ''); - term.reset(); - } - }); - it('2 characters per cell over line end with autowrap', async function (): Promise { - this.timeout(10000); - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - term.buffer.x = term.cols - 1; - - await term.writeP('a' + high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), 'a'); - assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars().length, 2); - assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), ''); - term.reset(); - } - }); - it('2 characters per cell over line end without autowrap', async function (): Promise { - this.timeout(10000); - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - term.buffer.x = term.cols - 1; - await term.writeP('\x1b[?7l'); // Disable wraparound mode - const width = wcwidth((0xD800 - 0xD800) * 0x400 + i - 0xDC00 + 0x10000); - if (width !== 1) { - continue; - } - await term.writeP('a' + high + String.fromCharCode(i)); - // auto wraparound mode should cut off the rest of the line - assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars().length, 2); - assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), ''); - term.reset(); - } - }); - it('splitted surrogates', async function (): Promise { - this.timeout(10000); - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - await term.writeP(high + String.fromCharCode(i)); - const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); - assert.equal(tchar.getChars(), high + String.fromCharCode(i)); - assert.equal(tchar.getChars().length, 2); - assert.equal(tchar.getWidth(), 1); - assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), ''); - term.reset(); - } - }); - }); - - describe('unicode - combining characters', () => { - const cell = new CellData(); - it('café', async () => { - await term.writeP('cafe\u0301'); - term.buffer.lines.get(0)!.loadCell(3, cell); - assert.equal(cell.getChars(), 'e\u0301'); - assert.equal(cell.getChars().length, 2); - assert.equal(cell.getWidth(), 1); - }); - it('café - end of line', async () => { - term.buffer.x = term.cols - 1 - 3; - await term.writeP('cafe\u0301'); - term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); - assert.equal(cell.getChars(), 'e\u0301'); - assert.equal(cell.getChars().length, 2); - assert.equal(cell.getWidth(), 1); - term.buffer.lines.get(0)!.loadCell(1, cell); - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 1); - }); - it('multiple combined é', async () => { - await term.writeP(Array(100).join('e\u0301')); - for (let i = 0; i < term.cols; ++i) { - term.buffer.lines.get(0)!.loadCell(i, cell); - assert.equal(cell.getChars(), 'e\u0301'); - assert.equal(cell.getChars().length, 2); - assert.equal(cell.getWidth(), 1); - } - term.buffer.lines.get(1)!.loadCell(0, cell); - assert.equal(cell.getChars(), 'e\u0301'); - assert.equal(cell.getChars().length, 2); - assert.equal(cell.getWidth(), 1); - }); - it('multiple surrogate with combined', async () => { - await term.writeP(Array(100).join('\uD800\uDC00\u0301')); - for (let i = 0; i < term.cols; ++i) { - term.buffer.lines.get(0)!.loadCell(i, cell); - assert.equal(cell.getChars(), '\uD800\uDC00\u0301'); - assert.equal(cell.getChars().length, 3); - assert.equal(cell.getWidth(), 1); - } - term.buffer.lines.get(1)!.loadCell(0, cell); - assert.equal(cell.getChars(), '\uD800\uDC00\u0301'); - assert.equal(cell.getChars().length, 3); - assert.equal(cell.getWidth(), 1); - }); - }); - - describe('unicode - fullwidth characters', () => { - const cell = new CellData(); - it('cursor movement even', async () => { - assert.equal(term.buffer.x, 0); - await term.writeP('¥'); - assert.equal(term.buffer.x, 2); - }); - it('cursor movement odd', async () => { - term.buffer.x = 1; - assert.equal(term.buffer.x, 1); - await term.writeP('¥'); - assert.equal(term.buffer.x, 3); - }); - it('line of ¥ even', async () => { - await term.writeP(Array(50).join('¥')); - for (let i = 0; i < term.cols; ++i) { - term.buffer.lines.get(0)!.loadCell(i, cell); - if (i % 2) { - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 0); - } else { - assert.equal(cell.getChars(), '¥'); - assert.equal(cell.getChars().length, 1); - assert.equal(cell.getWidth(), 2); - } - } - term.buffer.lines.get(1)!.loadCell(0, cell); - assert.equal(cell.getChars(), '¥'); - assert.equal(cell.getChars().length, 1); - assert.equal(cell.getWidth(), 2); - }); - it('line of ¥ odd', async () => { - term.buffer.x = 1; - await term.writeP(Array(50).join('¥')); - for (let i = 1; i < term.cols - 1; ++i) { - term.buffer.lines.get(0)!.loadCell(i, cell); - if (!(i % 2)) { - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 0); - } else { - assert.equal(cell.getChars(), '¥'); - assert.equal(cell.getChars().length, 1); - assert.equal(cell.getWidth(), 2); - } - } - term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 1); - term.buffer.lines.get(1)!.loadCell(0, cell); - assert.equal(cell.getChars(), '¥'); - assert.equal(cell.getChars().length, 1); - assert.equal(cell.getWidth(), 2); - }); - it('line of ¥ with combining odd', async () => { - term.buffer.x = 1; - await term.writeP(Array(50).join('¥\u0301')); - for (let i = 1; i < term.cols - 1; ++i) { - term.buffer.lines.get(0)!.loadCell(i, cell); - if (!(i % 2)) { - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 0); - } else { - assert.equal(cell.getChars(), '¥\u0301'); - assert.equal(cell.getChars().length, 2); - assert.equal(cell.getWidth(), 2); - } - } - term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 1); - term.buffer.lines.get(1)!.loadCell(0, cell); - assert.equal(cell.getChars(), '¥\u0301'); - assert.equal(cell.getChars().length, 2); - assert.equal(cell.getWidth(), 2); - }); - it('line of ¥ with combining even', async () => { - await term.writeP(Array(50).join('¥\u0301')); - for (let i = 0; i < term.cols; ++i) { - term.buffer.lines.get(0)!.loadCell(i, cell); - if (i % 2) { - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 0); - } else { - assert.equal(cell.getChars(), '¥\u0301'); - assert.equal(cell.getChars().length, 2); - assert.equal(cell.getWidth(), 2); - } - } - term.buffer.lines.get(1)!.loadCell(0, cell); - assert.equal(cell.getChars(), '¥\u0301'); - assert.equal(cell.getChars().length, 2); - assert.equal(cell.getWidth(), 2); - }); - it('line of surrogate fullwidth with combining odd', async () => { - term.buffer.x = 1; - await term.writeP(Array(50).join('\ud843\ude6d\u0301')); - for (let i = 1; i < term.cols - 1; ++i) { - term.buffer.lines.get(0)!.loadCell(i, cell); - if (!(i % 2)) { - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 0); - } else { - assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); - assert.equal(cell.getChars().length, 3); - assert.equal(cell.getWidth(), 2); - } - } - term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 1); - term.buffer.lines.get(1)!.loadCell(0, cell); - assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); - assert.equal(cell.getChars().length, 3); - assert.equal(cell.getWidth(), 2); - }); - it('line of surrogate fullwidth with combining even', async () => { - await term.writeP(Array(50).join('\ud843\ude6d\u0301')); - for (let i = 0; i < term.cols; ++i) { - term.buffer.lines.get(0)!.loadCell(i, cell); - if (i % 2) { - assert.equal(cell.getChars(), ''); - assert.equal(cell.getChars().length, 0); - assert.equal(cell.getWidth(), 0); - } else { - assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); - assert.equal(cell.getChars().length, 3); - assert.equal(cell.getWidth(), 2); - } - } - term.buffer.lines.get(1)!.loadCell(0, cell); - assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); - assert.equal(cell.getChars().length, 3); - assert.equal(cell.getWidth(), 2); - }); - }); - - describe('insert mode', () => { - const cell = new CellData(); - it('halfwidth - all', async () => { - await term.writeP(Array(9).join('0123456789').slice(-80)); - term.buffer.x = 10; - term.buffer.y = 0; - term.write('\x1b[4h'); - await term.writeP('abcde'); - assert.equal(term.buffer.lines.get(0)!.length, term.cols); - assert.equal(term.buffer.lines.get(0)!.loadCell(10, cell).getChars(), 'a'); - assert.equal(term.buffer.lines.get(0)!.loadCell(14, cell).getChars(), 'e'); - assert.equal(term.buffer.lines.get(0)!.loadCell(15, cell).getChars(), '0'); - assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), '4'); - }); - it('fullwidth - insert', async () => { - await term.writeP(Array(9).join('0123456789').slice(-80)); - term.buffer.x = 10; - term.buffer.y = 0; - term.write('\x1b[4h'); - await term.writeP('¥¥¥'); - assert.equal(term.buffer.lines.get(0)!.length, term.cols); - assert.equal(term.buffer.lines.get(0)!.loadCell(10, cell).getChars(), '¥'); - assert.equal(term.buffer.lines.get(0)!.loadCell(11, cell).getChars(), ''); - assert.equal(term.buffer.lines.get(0)!.loadCell(14, cell).getChars(), '¥'); - assert.equal(term.buffer.lines.get(0)!.loadCell(15, cell).getChars(), ''); - assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), '3'); - }); - it('fullwidth - right border', async () => { - await term.writeP(Array(41).join('¥')); - term.buffer.x = 10; - term.buffer.y = 0; - term.write('\x1b[4h'); - await term.writeP('a'); - assert.equal(term.buffer.lines.get(0)!.length, term.cols); - assert.equal(term.buffer.lines.get(0)!.loadCell(10, cell).getChars(), 'a'); - assert.equal(term.buffer.lines.get(0)!.loadCell(11, cell).getChars(), '¥'); - assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), ''); // fullwidth char got replaced - await term.writeP('b'); - assert.equal(term.buffer.lines.get(0)!.length, term.cols); - assert.equal(term.buffer.lines.get(0)!.loadCell(11, cell).getChars(), 'b'); - assert.equal(term.buffer.lines.get(0)!.loadCell(12, cell).getChars(), '¥'); - assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), ''); // empty cell after fullwidth - }); - }); - - describe('Linkifier unicode handling', () => { - let terminal: TestTerminal; - let linkifier: TestLinkifier; - let mouseZoneManager: TestMouseZoneManager; - - // other than the tests above unicode testing needs the full terminal instance - // to get the special handling of fullwidth, surrogate and combining chars in the input handler - beforeEach(() => { - terminal = new TestTerminal({ cols: 10, rows: 5 }); - linkifier = new TestLinkifier((terminal as any)._bufferService, terminal.unicodeService); - mouseZoneManager = new TestMouseZoneManager(); - linkifier.attachToDom({} as any, mouseZoneManager); - }); - - function assertLinkifiesInTerminal(rowText: string, linkMatcherRegex: RegExp, links: { x1: number, y1: number, x2: number, y2: number }[]): Promise { - return new Promise(async r => { - await terminal.writeP(rowText); - linkifier.registerLinkMatcher(linkMatcherRegex, () => { }); - linkifier.linkifyRows(); - // Allow linkify to happen - setTimeout(() => { - assert.equal(mouseZoneManager.zones.length, links.length); - links.forEach((l, i) => { - assert.equal(mouseZoneManager.zones[i].x1, l.x1 + 1); - assert.equal(mouseZoneManager.zones[i].x2, l.x2 + 1); - assert.equal(mouseZoneManager.zones[i].y1, l.y1 + 1); - assert.equal(mouseZoneManager.zones[i].y2, l.y2 + 1); - }); - r(); - }, 0); - }); - } - - describe('unicode before the match', () => { - it('combining - match within one line', () => { - return assertLinkifiesInTerminal('e\u0301e\u0301e\u0301 foo', /foo/, [{ x1: 4, x2: 7, y1: 0, y2: 0 }]); - }); - it('combining - match over two lines', () => { - return assertLinkifiesInTerminal('e\u0301e\u0301e\u0301 foo', /foo/, [{ x1: 8, x2: 1, y1: 0, y2: 1 }]); - }); - it('surrogate - match within one line', () => { - return assertLinkifiesInTerminal('𝄞𝄞𝄞 foo', /foo/, [{ x1: 4, x2: 7, y1: 0, y2: 0 }]); - }); - it('surrogate - match over two lines', () => { - return assertLinkifiesInTerminal('𝄞𝄞𝄞 foo', /foo/, [{ x1: 8, x2: 1, y1: 0, y2: 1 }]); - }); - it('combining surrogate - match within one line', () => { - return assertLinkifiesInTerminal('𓂀\u0301𓂀\u0301𓂀\u0301 foo', /foo/, [{ x1: 4, x2: 7, y1: 0, y2: 0 }]); - }); - it('combining surrogate - match over two lines', () => { - return assertLinkifiesInTerminal('𓂀\u0301𓂀\u0301𓂀\u0301 foo', /foo/, [{ x1: 8, x2: 1, y1: 0, y2: 1 }]); - }); - it('fullwidth - match within one line', () => { - return assertLinkifiesInTerminal('12 foo', /foo/, [{ x1: 5, x2: 8, y1: 0, y2: 0 }]); - }); - it('fullwidth - match over two lines', () => { - return assertLinkifiesInTerminal('12 foo', /foo/, [{ x1: 8, x2: 1, y1: 0, y2: 1 }]); - }); - it('combining fullwidth - match within one line', () => { - return assertLinkifiesInTerminal('¥\u0301¥\u0301 foo', /foo/, [{ x1: 5, x2: 8, y1: 0, y2: 0 }]); - }); - it('combining fullwidth - match over two lines', () => { - return assertLinkifiesInTerminal('¥\u0301¥\u0301 foo', /foo/, [{ x1: 8, x2: 1, y1: 0, y2: 1 }]); - }); - }); - describe('unicode within the match', () => { - it('combining - match within one line', () => { - return assertLinkifiesInTerminal('test cafe\u0301', /cafe\u0301/, [{ x1: 5, x2: 9, y1: 0, y2: 0 }]); - }); - it('combining - match over two lines', () => { - return assertLinkifiesInTerminal('testtest cafe\u0301', /cafe\u0301/, [{ x1: 9, x2: 3, y1: 0, y2: 1 }]); - }); - it('surrogate - match within one line', () => { - return assertLinkifiesInTerminal('test a𝄞b', /a𝄞b/, [{ x1: 5, x2: 8, y1: 0, y2: 0 }]); - }); - it('surrogate - match over two lines', () => { - return assertLinkifiesInTerminal('testtest a𝄞b', /a𝄞b/, [{ x1: 9, x2: 2, y1: 0, y2: 1 }]); - }); - it('combining surrogate - match within one line', () => { - return assertLinkifiesInTerminal('test a𓂀\u0301b', /a𓂀\u0301b/, [{ x1: 5, x2: 8, y1: 0, y2: 0 }]); - }); - it('combining surrogate - match over two lines', () => { - return assertLinkifiesInTerminal('testtest a𓂀\u0301b', /a𓂀\u0301b/, [{ x1: 9, x2: 2, y1: 0, y2: 1 }]); - }); - it('fullwidth - match within one line', () => { - return assertLinkifiesInTerminal('test a1b', /a1b/, [{ x1: 5, x2: 9, y1: 0, y2: 0 }]); - }); - it('fullwidth - match over two lines', () => { - return assertLinkifiesInTerminal('testtest a1b', /a1b/, [{ x1: 9, x2: 3, y1: 0, y2: 1 }]); - }); - it('combining fullwidth - match within one line', () => { - return assertLinkifiesInTerminal('test a¥\u0301b', /a¥\u0301b/, [{ x1: 5, x2: 9, y1: 0, y2: 0 }]); - }); - it('combining fullwidth - match over two lines', () => { - return assertLinkifiesInTerminal('testtest a¥\u0301b', /a¥\u0301b/, [{ x1: 9, x2: 3, y1: 0, y2: 1 }]); - }); - }); - }); - - describe('Buffer.stringIndexToBufferIndex', () => { - let terminal: TestTerminal; - - beforeEach(() => { - terminal = new TestTerminal({ rows: 5, cols: 10, scrollback: 5 }); - }); - - it('multiline ascii', async () => { - const input = 'This is ASCII text spanning multiple lines.'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - for (let i = 0; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([(i / terminal.cols) | 0, i % terminal.cols], bufferIndex); - } - }); - - it('combining e\u0301 in a sentence', async () => { - const input = 'Sitting in the cafe\u0301 drinking coffee.'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - for (let i = 0; i < 19; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([(i / terminal.cols) | 0, i % terminal.cols], bufferIndex); - } - // string index 18 & 19 point to combining char e\u0301 ---> same buffer Index - assert.deepEqual( - terminal.buffer.stringIndexToBufferIndex(0, 18), - terminal.buffer.stringIndexToBufferIndex(0, 19)); - // after the combining char every string index has an offset of -1 - for (let i = 19; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([((i - 1) / terminal.cols) | 0, (i - 1) % terminal.cols], bufferIndex); - } - }); - - it('multiline combining e\u0301', async () => { - const input = 'e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - // every buffer cell index contains 2 string indices - for (let i = 0; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([((i >> 1) / terminal.cols) | 0, (i >> 1) % terminal.cols], bufferIndex); - } - }); - - it('surrogate char in a sentence', async () => { - const input = 'The 𝄞 is a clef widely used in modern notation.'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - for (let i = 0; i < 5; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([(i / terminal.cols) | 0, i % terminal.cols], bufferIndex); - } - // string index 4 & 5 point to surrogate char 𝄞 ---> same buffer Index - assert.deepEqual( - terminal.buffer.stringIndexToBufferIndex(0, 4), - terminal.buffer.stringIndexToBufferIndex(0, 5)); - // after the combining char every string index has an offset of -1 - for (let i = 5; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([((i - 1) / terminal.cols) | 0, (i - 1) % terminal.cols], bufferIndex); - } - }); - - it('multiline surrogate char', async () => { - const input = '𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - // every buffer cell index contains 2 string indices - for (let i = 0; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([((i >> 1) / terminal.cols) | 0, (i >> 1) % terminal.cols], bufferIndex); - } - }); - - it('surrogate char with combining', async () => { - // eye of Ra with acute accent - string length of 3 - const input = '𓂀\u0301 - the eye hiroglyph with an acute accent.'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - // index 0..2 should map to 0 - assert.deepEqual([0, 0], terminal.buffer.stringIndexToBufferIndex(0, 1)); - assert.deepEqual([0, 0], terminal.buffer.stringIndexToBufferIndex(0, 2)); - for (let i = 2; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([((i - 2) / terminal.cols) | 0, (i - 2) % terminal.cols], bufferIndex); - } - }); - - it('multiline surrogate with combining', async () => { - const input = '𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - // every buffer cell index contains 3 string indices - for (let i = 0; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([(((i / 3) | 0) / terminal.cols) | 0, ((i / 3) | 0) % terminal.cols], bufferIndex); - } - }); - - it('fullwidth chars', async () => { - const input = 'These 123 are some fat numbers.'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - for (let i = 0; i < 6; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([(i / terminal.cols) | 0, i % terminal.cols], bufferIndex); - } - // string index 6, 7, 8 take 2 cells - assert.deepEqual([0, 8], terminal.buffer.stringIndexToBufferIndex(0, 7)); - assert.deepEqual([1, 0], terminal.buffer.stringIndexToBufferIndex(0, 8)); - // rest of the string has offset of +3 - for (let i = 9; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([((i + 3) / terminal.cols) | 0, (i + 3) % terminal.cols], bufferIndex); - } - }); - - it('multiline fullwidth chars', async () => { - const input = '12345678901234567890'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - for (let i = 9; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); - assert.deepEqual([((i << 1) / terminal.cols) | 0, (i << 1) % terminal.cols], bufferIndex); - } - }); - - it('fullwidth combining with emoji - match emoji cell', async () => { - const input = 'Lots of ¥\u0301 make me 😃.'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - const stringIndex = s.match(/😃/)!.index!; - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, stringIndex); - assert(terminal.buffer.lines.get(bufferIndex[0])!.loadCell(bufferIndex[1], new CellData()).getChars(), '😃'); - }); - - it('multiline fullwidth chars with offset 1 (currently tests for broken behavior)', async () => { - const input = 'a12345678901234567890'; - // the 'a' at the beginning moves all fullwidth chars one to the right - // now the end of the line contains a dangling empty cell since - // the next fullwidth char has to wrap early - // the dangling last cell is wrongly added in the string - // --> fixable after resolving #1685 - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - for (let i = 10; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i, true); - const j = (i - 0) << 1; - assert.deepEqual([(j / terminal.cols) | 0, j % terminal.cols], bufferIndex); - } - }); - - it('test fully wrapped buffer up to last char', async () => { - const input = Array(6).join('1234567890'); - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - for (let i = 0; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i, true); - assert.equal(input[i], terminal.buffer.lines.get(bufferIndex[0])!.loadCell(bufferIndex[1], new CellData()).getChars()); - } - }); - - it('test fully wrapped buffer up to last char with full width odd', async () => { - const input = 'a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301' - + 'a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(input, s); - for (let i = 0; i < input.length; ++i) { - const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i, true); - assert.equal( - (!(i % 3)) - ? input[i] - : (i % 3 === 1) - ? input.substr(i, 2) - : input.substr(i - 1, 2), - terminal.buffer.lines.get(bufferIndex[0])!.loadCell(bufferIndex[1], new CellData()).getChars()); - } - }); - - it('should handle \t in lines correctly', async () => { - const input = '\thttps://google.de'; - await terminal.writeP(input); - const s = terminal.buffer.iterator(true).next().content; - assert.equal(s, Array(terminal.optionsService.options.tabStopWidth + 1).join(' ') + 'https://google.de'); - }); - }); - - describe('BufferStringIterator', function (): void { - it('iterator does not overflow buffer limits', async () => { - const terminal = new TestTerminal({ rows: 5, cols: 10, scrollback: 5 }); - const data = [ - 'aaaaaaaaaa', - 'aaaaaaaaa\n', - 'aaaaaaaaaa', - 'aaaaaaaaa\n', - 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaa\n', - 'aaaaaaaaaa', - 'aaaaaaaaaa' - ]; - await terminal.writeP(data.join('')); - // brute force test with insane values - assert.doesNotThrow(() => { - for (let overscan = 0; overscan < 20; ++overscan) { - for (let start = -10; start < 20; ++start) { - for (let end = -10; end < 20; ++end) { - const it = terminal.buffer.iterator(false, start, end, overscan, overscan); - while (it.hasNext()) { - it.next(); - } - } - } - } - }); - }); - }); - - describe('Windows Mode', () => { - it('should mark lines as wrapped when the line ends in a non-null character after a LF', async () => { - const data = [ - 'aaaaaaaaaa\n\r', // cannot wrap as it's the first - 'aaaaaaaaa\n\r', // wrapped (windows mode only) - 'aaaaaaaaa' // not wrapped - ]; - - const normalTerminal = new TestTerminal({ rows: 5, cols: 10, windowsMode: false }); - await normalTerminal.writeP(data.join('')); - assert.equal(normalTerminal.buffer.lines.get(0)!.isWrapped, false); - assert.equal(normalTerminal.buffer.lines.get(1)!.isWrapped, false); - assert.equal(normalTerminal.buffer.lines.get(2)!.isWrapped, false); - - const windowsModeTerminal = new TestTerminal({ rows: 5, cols: 10, windowsMode: true }); - await windowsModeTerminal.writeP(data.join('')); - assert.equal(windowsModeTerminal.buffer.lines.get(0)!.isWrapped, false); - assert.equal(windowsModeTerminal.buffer.lines.get(1)!.isWrapped, true, 'This line should wrap in Windows mode as the previous line ends in a non-null character'); - assert.equal(windowsModeTerminal.buffer.lines.get(2)!.isWrapped, false); - }); - - it('should mark lines as wrapped when the line ends in a non-null character after a CUP', async () => { - const data = [ - 'aaaaaaaaaa\x1b[2;1H', // cannot wrap as it's the first - 'aaaaaaaaa\x1b[3;1H', // wrapped (windows mode only) - 'aaaaaaaaa' // not wrapped - ]; - - const normalTerminal = new TestTerminal({ rows: 5, cols: 10, windowsMode: false }); - await normalTerminal.writeP(data.join('')); - assert.equal(normalTerminal.buffer.lines.get(0)!.isWrapped, false); - assert.equal(normalTerminal.buffer.lines.get(1)!.isWrapped, false); - assert.equal(normalTerminal.buffer.lines.get(2)!.isWrapped, false); - - const windowsModeTerminal = new TestTerminal({ rows: 5, cols: 10, windowsMode: true }); - await windowsModeTerminal.writeP(data.join('')); - assert.equal(windowsModeTerminal.buffer.lines.get(0)!.isWrapped, false); - assert.equal(windowsModeTerminal.buffer.lines.get(1)!.isWrapped, true, 'This line should wrap in Windows mode as the previous line ends in a non-null character'); - assert.equal(windowsModeTerminal.buffer.lines.get(2)!.isWrapped, false); - }); - }); - it('convertEol setting', async () => { - // not converting - const termNotConverting = new TestTerminal({ cols: 15, rows: 10 }); - await termNotConverting.writeP('Hello\nWorld'); - assert.equal(termNotConverting.buffer.lines.get(0)!.translateToString(false), 'Hello '); - assert.equal(termNotConverting.buffer.lines.get(1)!.translateToString(false), ' World '); - assert.equal(termNotConverting.buffer.lines.get(0)!.translateToString(true), 'Hello'); - assert.equal(termNotConverting.buffer.lines.get(1)!.translateToString(true), ' World'); - - // converting - const termConverting = new TestTerminal({ cols: 15, rows: 10, convertEol: true }); - await termConverting.writeP('Hello\nWorld'); - assert.equal(termConverting.buffer.lines.get(0)!.translateToString(false), 'Hello '); - assert.equal(termConverting.buffer.lines.get(1)!.translateToString(false), 'World '); - assert.equal(termConverting.buffer.lines.get(0)!.translateToString(true), 'Hello'); - assert.equal(termConverting.buffer.lines.get(1)!.translateToString(true), 'World'); - }); - - // FIXME: move to common/CoreTerminal.test once the trimming is moved over - describe('marker lifecycle', () => { - // create a 10x5 terminal with markers on every line - // to test marker lifecycle under various terminal actions - let markers: IMarker[]; - let disposeStack: IMarker[]; - let term: TestTerminal; + describe('scrollPages', () => { + let startYDisp: number; beforeEach(async () => { - term = new TestTerminal({}); - markers = []; - disposeStack = []; - term.optionsService.setOption('scrollback', 1); - term.resize(10, 5); - markers.push(term.buffers.active.addMarker(term.buffers.active.y)); - await term.writeP('\x1b[r0\r\n'); - markers.push(term.buffers.active.addMarker(term.buffers.active.y)); - await term.writeP('1\r\n'); - markers.push(term.buffers.active.addMarker(term.buffers.active.y)); - await term.writeP('2\r\n'); - markers.push(term.buffers.active.addMarker(term.buffers.active.y)); - await term.writeP('3\r\n'); - markers.push(term.buffers.active.addMarker(term.buffers.active.y)); - await term.writeP('4'); - for (let i = 0; i < markers.length; ++i) { - const marker = markers[i]; - marker.onDispose(() => disposeStack.push(marker)); + for (let i = 0; i < term.rows * 3; i++) { + await term.writeP('test\r\n'); + } + startYDisp = (term.rows * 2) + 1; + }); + it('should scroll a single page', () => { + assert.equal(term.buffer.ydisp, startYDisp); + term.scrollPages(-1); + assert.equal(term.buffer.ydisp, startYDisp - (term.rows - 1)); + term.scrollPages(1); + assert.equal(term.buffer.ydisp, startYDisp); + }); + it('should scroll a multiple pages', () => { + assert.equal(term.buffer.ydisp, startYDisp); + term.scrollPages(-2); + assert.equal(term.buffer.ydisp, startYDisp - (term.rows - 1) * 2); + term.scrollPages(2); + assert.equal(term.buffer.ydisp, startYDisp); + }); + }); + + describe('scrollToTop', () => { + beforeEach(async () => { + for (let i = 0; i < term.rows * 3; i++) { + await term.writeP('test\r\n'); } }); - it('initial', () => { - assert.deepEqual(markers.map(m => m.line), [0, 1, 2, 3, 4]); + it('should scroll to the top', () => { + assert.notEqual(term.buffer.ydisp, 0); + term.scrollToTop(); + assert.equal(term.buffer.ydisp, 0); }); - it('should dispose on normal trim off the top', async () => { - // moves top line into scrollback - await term.writeP('\n'); - assert.deepEqual(disposeStack, []); - // trims first marker - await term.writeP('\n'); - assert.deepEqual(disposeStack, [markers[0]]); - // trims second marker - await term.writeP('\n'); - assert.deepEqual(disposeStack, [markers[0], markers[1]]); - // trimmed marker objs should be disposed - assert.deepEqual(disposeStack.map(el => el.isDisposed), [true, true]); - assert.deepEqual(disposeStack.map(el => (el as any)._isDisposed), [true, true]); - // trimmed markers should contain line -1 - assert.deepEqual(disposeStack.map(el => el.line), [-1, -1]); + }); + + describe('scrollToBottom', () => { + let startYDisp: number; + beforeEach(async () => { + for (let i = 0; i < term.rows * 3; i++) { + await term.writeP('test\r\n'); + } + startYDisp = (term.rows * 2) + 1; }); - it('should dispose on DL', async () => { - await term.writeP('\x1b[3;1H'); // move cursor to 0, 2 - await term.writeP('\x1b[2M'); // delete 2 lines - assert.deepEqual(disposeStack, [markers[2], markers[3]]); + it('should scroll to the bottom', () => { + term.scrollLines(-1); + term.scrollToBottom(); + assert.equal(term.buffer.ydisp, startYDisp); + term.scrollPages(-1); + term.scrollToBottom(); + assert.equal(term.buffer.ydisp, startYDisp); + term.scrollToTop(); + term.scrollToBottom(); + assert.equal(term.buffer.ydisp, startYDisp); }); - it('should dispose on IL', async () => { - await term.writeP('\x1b[3;1H'); // move cursor to 0, 2 - await term.writeP('\x1b[2L'); // insert 2 lines - assert.deepEqual(disposeStack, [markers[4], markers[3]]); - assert.deepEqual(markers.map(el => el.line), [0, 1, 4, -1, -1]); + }); + + describe('scrollToLine', () => { + let startYDisp: number; + beforeEach(async () => { + for (let i = 0; i < term.rows * 3; i++) { + await term.writeP('test\r\n'); + } + startYDisp = (term.rows * 2) + 1; }); - it('should dispose on resize', () => { - term.resize(10, 2); - assert.deepEqual(disposeStack, [markers[0], markers[1]]); - assert.deepEqual(markers.map(el => el.line), [-1, -1, 0, 1, 2]); + it('should scroll to requested line', () => { + assert.equal(term.buffer.ydisp, startYDisp); + term.scrollToLine(0); + assert.equal(term.buffer.ydisp, 0); + term.scrollToLine(10); + assert.equal(term.buffer.ydisp, 10); + term.scrollToLine(startYDisp); + assert.equal(term.buffer.ydisp, startYDisp); + term.scrollToLine(20); + assert.equal(term.buffer.ydisp, 20); + }); + it('should not scroll beyond boundary lines', () => { + assert.equal(term.buffer.ydisp, startYDisp); + term.scrollToLine(-1); + assert.equal(term.buffer.ydisp, 0); + term.scrollToLine(startYDisp + 1); + assert.equal(term.buffer.ydisp, startYDisp); + }); + }); + + describe('keyPress', () => { + it('should scroll down, when a key is pressed and terminal is scrolled up', () => { + const event = { + type: 'keydown', + key: 'a', + keyCode: 65, + preventDefault: () => { }, + stopPropagation: () => { } + }; + + term.buffer.ydisp = 0; + term.buffer.ybase = 40; + term.keyPress(event); + + // Ensure that now the terminal is scrolled to bottom + assert.equal(term.buffer.ydisp, term.buffer.ybase); + }); + + it('should not scroll down, when a custom keydown handler prevents the event', async () => { + // Add some output to the terminal + for (let i = 0; i < term.rows * 3; i++) { + await term.writeP('test\r\n'); + } + const startYDisp = (term.rows * 2) + 1; + term.attachCustomKeyEventHandler(() => { + return false; + }); + + assert.equal(term.buffer.ydisp, startYDisp); + term.scrollLines(-1); + assert.equal(term.buffer.ydisp, startYDisp - 1); + term.keyPress({ keyCode: 0 }); + assert.equal(term.buffer.ydisp, startYDisp - 1); + }); + }); + + describe('scroll() function', () => { + describe('when scrollback > 0', () => { + it('should create a new line and scroll', () => { + term.buffer.lines.get(0)!.setCell(0, CellData.fromCharData([0, 'a', 0, 'a'.charCodeAt(0)])); + term.buffer.lines.get(INIT_ROWS - 1)!.setCell(0, CellData.fromCharData([0, 'b', 0, 'b'.charCodeAt(0)])); + term.buffer.y = INIT_ROWS - 1; // Move cursor to last line + term.scroll(DEFAULT_ATTR_DATA.clone()); + assert.equal(term.buffer.lines.length, INIT_ROWS + 1); + assert.equal(term.buffer.lines.get(0)!.loadCell(0, new CellData()).getChars(), 'a'); + assert.equal(term.buffer.lines.get(INIT_ROWS - 1)!.loadCell(0, new CellData()).getChars(), 'b'); + assert.equal(term.buffer.lines.get(INIT_ROWS)!.loadCell(0, new CellData()).getChars(), ''); + }); + + it('should properly scroll inside a scroll region (scrollTop set)', () => { + term.buffer.lines.get(0)!.setCell(0, CellData.fromCharData([0, 'a', 0, 'a'.charCodeAt(0)])); + term.buffer.lines.get(1)!.setCell(0, CellData.fromCharData([0, 'b', 0, 'b'.charCodeAt(0)])); + term.buffer.lines.get(2)!.setCell(0, CellData.fromCharData([0, 'c', 0, 'c'.charCodeAt(0)])); + term.buffer.y = INIT_ROWS - 1; // Move cursor to last line + term.buffer.scrollTop = 1; + term.scroll(DEFAULT_ATTR_DATA.clone()); + assert.equal(term.buffer.lines.length, INIT_ROWS); + assert.equal(term.buffer.lines.get(0)!.loadCell(0, new CellData()).getChars(), 'a'); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, new CellData()).getChars(), 'c'); + }); + + it('should properly scroll inside a scroll region (scrollBottom set)', () => { + term.buffer.lines.get(0)!.setCell(0, CellData.fromCharData([0, 'a', 0, 'a'.charCodeAt(0)])); + term.buffer.lines.get(1)!.setCell(0, CellData.fromCharData([0, 'b', 0, 'b'.charCodeAt(0)])); + term.buffer.lines.get(2)!.setCell(0, CellData.fromCharData([0, 'c', 0, 'c'.charCodeAt(0)])); + term.buffer.lines.get(3)!.setCell(0, CellData.fromCharData([0, 'd', 0, 'd'.charCodeAt(0)])); + term.buffer.lines.get(4)!.setCell(0, CellData.fromCharData([0, 'e', 0, 'e'.charCodeAt(0)])); + term.buffer.y = 3; + term.buffer.scrollBottom = 3; + term.scroll(DEFAULT_ATTR_DATA.clone()); + assert.equal(term.buffer.lines.length, INIT_ROWS + 1); + assert.equal(term.buffer.lines.get(0)!.loadCell(0, new CellData()).getChars(), 'a', '\'a\' should be pushed to the scrollback'); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, new CellData()).getChars(), 'b'); + assert.equal(term.buffer.lines.get(2)!.loadCell(0, new CellData()).getChars(), 'c'); + assert.equal(term.buffer.lines.get(3)!.loadCell(0, new CellData()).getChars(), 'd'); + assert.equal(term.buffer.lines.get(4)!.loadCell(0, new CellData()).getChars(), '', 'a blank line should be added at scrollBottom\'s index'); + assert.equal(term.buffer.lines.get(5)!.loadCell(0, new CellData()).getChars(), 'e'); + }); + + it('should properly scroll inside a scroll region (scrollTop and scrollBottom set)', () => { + term.buffer.lines.get(0)!.setCell(0, CellData.fromCharData([0, 'a', 0, 'a'.charCodeAt(0)])); + term.buffer.lines.get(1)!.setCell(0, CellData.fromCharData([0, 'b', 0, 'b'.charCodeAt(0)])); + term.buffer.lines.get(2)!.setCell(0, CellData.fromCharData([0, 'c', 0, 'c'.charCodeAt(0)])); + term.buffer.lines.get(3)!.setCell(0, CellData.fromCharData([0, 'd', 0, 'd'.charCodeAt(0)])); + term.buffer.lines.get(4)!.setCell(0, CellData.fromCharData([0, 'e', 0, 'e'.charCodeAt(0)])); + term.buffer.y = INIT_ROWS - 1; // Move cursor to last line + term.buffer.scrollTop = 1; + term.buffer.scrollBottom = 3; + term.scroll(DEFAULT_ATTR_DATA.clone()); + assert.equal(term.buffer.lines.length, INIT_ROWS); + assert.equal(term.buffer.lines.get(0)!.loadCell(0, new CellData()).getChars(), 'a'); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, new CellData()).getChars(), 'c', '\'b\' should be removed from the buffer'); + assert.equal(term.buffer.lines.get(2)!.loadCell(0, new CellData()).getChars(), 'd'); + assert.equal(term.buffer.lines.get(3)!.loadCell(0, new CellData()).getChars(), '', 'a blank line should be added at scrollBottom\'s index'); + assert.equal(term.buffer.lines.get(4)!.loadCell(0, new CellData()).getChars(), 'e'); + }); + }); + + describe('when scrollback === 0', () => { + beforeEach(() => { + term.optionsService.setOption('scrollback', 0); + assert.equal(term.buffer.lines.maxLength, INIT_ROWS); + }); + + it('should create a new line and shift everything up', () => { + term.buffer.lines.get(0)!.setCell(0, CellData.fromCharData([0, 'a', 0, 'a'.charCodeAt(0)])); + term.buffer.lines.get(1)!.setCell(0, CellData.fromCharData([0, 'b', 0, 'b'.charCodeAt(0)])); + term.buffer.lines.get(INIT_ROWS - 1)!.setCell(0, CellData.fromCharData([0, 'c', 0, 'c'.charCodeAt(0)])); + term.buffer.y = INIT_ROWS - 1; // Move cursor to last line + assert.equal(term.buffer.lines.length, INIT_ROWS); + term.scroll(DEFAULT_ATTR_DATA.clone()); + assert.equal(term.buffer.lines.length, INIT_ROWS); + // 'a' gets pushed out of buffer + assert.equal(term.buffer.lines.get(0)!.loadCell(0, new CellData()).getChars(), 'b'); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, new CellData()).getChars(), ''); + assert.equal(term.buffer.lines.get(INIT_ROWS - 2)!.loadCell(0, new CellData()).getChars(), 'c'); + assert.equal(term.buffer.lines.get(INIT_ROWS - 1)!.loadCell(0, new CellData()).getChars(), ''); + }); + + it('should properly scroll inside a scroll region (scrollTop set)', () => { + term.buffer.lines.get(0)!.setCell(0, CellData.fromCharData([0, 'a', 0, 'a'.charCodeAt(0)])); + term.buffer.lines.get(1)!.setCell(0, CellData.fromCharData([0, 'b', 0, 'b'.charCodeAt(0)])); + term.buffer.lines.get(2)!.setCell(0, CellData.fromCharData([0, 'c', 0, 'c'.charCodeAt(0)])); + term.buffer.y = INIT_ROWS - 1; // Move cursor to last line + term.buffer.scrollTop = 1; + term.scroll(DEFAULT_ATTR_DATA.clone()); + assert.equal(term.buffer.lines.length, INIT_ROWS); + assert.equal(term.buffer.lines.get(0)!.loadCell(0, new CellData()).getChars(), 'a'); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, new CellData()).getChars(), 'c'); + }); + + it('should properly scroll inside a scroll region (scrollBottom set)', () => { + term.buffer.lines.get(0)!.setCell(0, CellData.fromCharData([0, 'a', 0, 'a'.charCodeAt(0)])); + term.buffer.lines.get(1)!.setCell(0, CellData.fromCharData([0, 'b', 0, 'b'.charCodeAt(0)])); + term.buffer.lines.get(2)!.setCell(0, CellData.fromCharData([0, 'c', 0, 'c'.charCodeAt(0)])); + term.buffer.lines.get(3)!.setCell(0, CellData.fromCharData([0, 'd', 0, 'd'.charCodeAt(0)])); + term.buffer.lines.get(4)!.setCell(0, CellData.fromCharData([0, 'e', 0, 'e'.charCodeAt(0)])); + term.buffer.y = 3; + term.buffer.scrollBottom = 3; + term.scroll(DEFAULT_ATTR_DATA.clone()); + assert.equal(term.buffer.lines.length, INIT_ROWS); + assert.equal(term.buffer.lines.get(0)!.loadCell(0, new CellData()).getChars(), 'b'); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, new CellData()).getChars(), 'c'); + assert.equal(term.buffer.lines.get(2)!.loadCell(0, new CellData()).getChars(), 'd'); + assert.equal(term.buffer.lines.get(3)!.loadCell(0, new CellData()).getChars(), '', 'a blank line should be added at scrollBottom\'s index'); + assert.equal(term.buffer.lines.get(4)!.loadCell(0, new CellData()).getChars(), 'e'); + }); + + it('should properly scroll inside a scroll region (scrollTop and scrollBottom set)', () => { + term.buffer.lines.get(0)!.setCell(0, CellData.fromCharData([0, 'a', 0, 'a'.charCodeAt(0)])); + term.buffer.lines.get(1)!.setCell(0, CellData.fromCharData([0, 'b', 0, 'b'.charCodeAt(0)])); + term.buffer.lines.get(2)!.setCell(0, CellData.fromCharData([0, 'c', 0, 'c'.charCodeAt(0)])); + term.buffer.lines.get(3)!.setCell(0, CellData.fromCharData([0, 'd', 0, 'd'.charCodeAt(0)])); + term.buffer.lines.get(4)!.setCell(0, CellData.fromCharData([0, 'e', 0, 'e'.charCodeAt(0)])); + term.buffer.y = INIT_ROWS - 1; // Move cursor to last line + term.buffer.scrollTop = 1; + term.buffer.scrollBottom = 3; + term.scroll(DEFAULT_ATTR_DATA.clone()); + assert.equal(term.buffer.lines.length, INIT_ROWS); + assert.equal(term.buffer.lines.get(0)!.loadCell(0, new CellData()).getChars(), 'a'); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, new CellData()).getChars(), 'c', '\'b\' should be removed from the buffer'); + assert.equal(term.buffer.lines.get(2)!.loadCell(0, new CellData()).getChars(), 'd'); + assert.equal(term.buffer.lines.get(3)!.loadCell(0, new CellData()).getChars(), '', 'a blank line should be added at scrollBottom\'s index'); + assert.equal(term.buffer.lines.get(4)!.loadCell(0, new CellData()).getChars(), 'e'); + }); }); }); }); - class TestLinkifier extends Linkifier { - constructor(bufferService: IBufferService, unicodeService: IUnicodeService) { - super(bufferService, new MockLogService(), unicodeService); - Linkifier._timeBeforeLatency = 0; + describe('Third level shift', () => { + let evKeyDown: any; + let evKeyPress: any; + + beforeEach(() => { + term.clearSelection = () => { }; + // term.compositionHelper = { + // isComposing: false, + // keydown: { + // bind: () => { + // return () => { return true; }; + // } + // } + // }; + evKeyDown = { + preventDefault: () => { }, + stopPropagation: () => { }, + type: 'keydown', + altKey: null, + keyCode: null + }; + evKeyPress = { + preventDefault: () => { }, + stopPropagation: () => { }, + type: 'keypress', + altKey: null, + charCode: null, + keyCode: null + }; + }); + + describe('with macOptionIsMeta', () => { + let originalIsMac: boolean; + beforeEach(() => { + originalIsMac = term.browser.isMac; + term.options.macOptionIsMeta = true; + }); + afterEach(() => term.browser.isMac = originalIsMac); + + it('should interfere with the alt key on keyDown', () => { + evKeyDown.altKey = true; + evKeyDown.keyCode = 81; + assert.equal(term.keyDown(evKeyDown), false); + evKeyDown.altKey = true; + evKeyDown.keyCode = 192; + assert.equal(term.keyDown(evKeyDown), false); + }); + }); + + describe('On Mac OS', () => { + let originalIsMac: boolean; + beforeEach(() => { + originalIsMac = term.browser.isMac; + term.browser.isMac = true; + }); + afterEach(() => term.browser.isMac = originalIsMac); + + it('should not interfere with the alt key on keyDown', () => { + evKeyDown.altKey = true; + evKeyDown.keyCode = 81; + assert.equal(term.keyDown(evKeyDown), true); + evKeyDown.altKey = true; + evKeyDown.keyCode = 192; + term.keyDown(evKeyDown); + assert.equal(term.keyDown(evKeyDown), true); + }); + + it('should interfere with the alt + arrow keys', () => { + evKeyDown.altKey = true; + evKeyDown.keyCode = 37; + assert.equal(term.keyDown(evKeyDown), false); + evKeyDown.altKey = true; + evKeyDown.keyCode = 39; + assert.equal(term.keyDown(evKeyDown), false); + }); + + it('should emit key with alt + key on keyPress', (done) => { + const keys = ['@', '@', '\\', '\\', '|', '|']; + + term.onKey(e => { + if (e.key) { + const index = keys.indexOf(e.key); + assert(index !== -1, 'Emitted wrong key: ' + e.key); + keys.splice(index, 1); + } + if (keys.length === 0) done(); + }); + + evKeyPress.altKey = true; + // @ + evKeyPress.charCode = null; + evKeyPress.keyCode = 64; + term.keyPress(evKeyPress); + // Firefox @ + evKeyPress.charCode = 64; + evKeyPress.keyCode = 0; + term.keyPress(evKeyPress); + // \ + evKeyPress.charCode = null; + evKeyPress.keyCode = 92; + term.keyPress(evKeyPress); + // Firefox \ + evKeyPress.charCode = 92; + evKeyPress.keyCode = 0; + term.keyPress(evKeyPress); + // | + evKeyPress.charCode = null; + evKeyPress.keyCode = 124; + term.keyPress(evKeyPress); + // Firefox | + evKeyPress.charCode = 124; + evKeyPress.keyCode = 0; + term.keyPress(evKeyPress); + }); + }); + + describe('On MS Windows', () => { + let originalIsWindows: boolean; + beforeEach(() => { + originalIsWindows = term.browser.isWindows; + term.browser.isWindows = true; + }); + afterEach(() => term.browser.isWindows = originalIsWindows); + + it('should not interfere with the alt + ctrl key on keyDown', () => { + evKeyPress.altKey = true; + evKeyPress.ctrlKey = true; + evKeyPress.keyCode = 81; + assert.equal(term.keyDown(evKeyPress), true); + evKeyDown.altKey = true; + evKeyDown.ctrlKey = true; + evKeyDown.keyCode = 81; + term.keyDown(evKeyDown); + assert.equal(term.keyDown(evKeyPress), true); + }); + + it('should interfere with the alt + ctrl + arrow keys', () => { + evKeyDown.altKey = true; + evKeyDown.ctrlKey = true; + + evKeyDown.keyCode = 37; + assert.equal(term.keyDown(evKeyDown), false); + evKeyDown.keyCode = 39; + term.keyDown(evKeyDown); + assert.equal(term.keyDown(evKeyDown), false); + }); + + it('should emit key with alt + ctrl + key on keyPress', (done) => { + const keys = ['@', '@', '\\', '\\', '|', '|']; + + term.onKey(e => { + if (e.key) { + const index = keys.indexOf(e.key); + assert(index !== -1, 'Emitted wrong key: ' + e.key); + keys.splice(index, 1); + } + if (keys.length === 0) done(); + }); + + evKeyPress.altKey = true; + evKeyPress.ctrlKey = true; + + // @ + evKeyPress.charCode = null; + evKeyPress.keyCode = 64; + term.keyPress(evKeyPress); + // Firefox @ + evKeyPress.charCode = 64; + evKeyPress.keyCode = 0; + term.keyPress(evKeyPress); + // \ + evKeyPress.charCode = null; + evKeyPress.keyCode = 92; + term.keyPress(evKeyPress); + // Firefox \ + evKeyPress.charCode = 92; + evKeyPress.keyCode = 0; + term.keyPress(evKeyPress); + // | + evKeyPress.charCode = null; + evKeyPress.keyCode = 124; + term.keyPress(evKeyPress); + // Firefox | + evKeyPress.charCode = 124; + evKeyPress.keyCode = 0; + term.keyPress(evKeyPress); + }); + }); + }); + + describe('unicode - surrogates', () => { + it('2 characters per cell', async function (): Promise { + this.timeout(10000); // This is needed because istanbul patches code and slows it down + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + for (let i = 0xDC00; i <= 0xDCFF; ++i) { + await term.writeP(high + String.fromCharCode(i)); + const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); + assert.equal(tchar.getChars(), high + String.fromCharCode(i)); + assert.equal(tchar.getChars().length, 2); + assert.equal(tchar.getWidth(), 1); + assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), ''); + term.reset(); + } + }); + it('2 characters at last cell', async () => { + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + for (let i = 0xDC00; i <= 0xDCFF; ++i) { + term.buffer.x = term.cols - 1; + await term.writeP(high + String.fromCharCode(i)); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars(), high + String.fromCharCode(i)); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars().length, 2); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), ''); + term.reset(); + } + }); + it('2 characters per cell over line end with autowrap', async function (): Promise { + this.timeout(10000); + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + for (let i = 0xDC00; i <= 0xDCFF; ++i) { + term.buffer.x = term.cols - 1; + + await term.writeP('a' + high + String.fromCharCode(i)); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), 'a'); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), high + String.fromCharCode(i)); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars().length, 2); + assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), ''); + term.reset(); + } + }); + it('2 characters per cell over line end without autowrap', async function (): Promise { + this.timeout(10000); + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + for (let i = 0xDC00; i <= 0xDCFF; ++i) { + term.buffer.x = term.cols - 1; + await term.writeP('\x1b[?7l'); // Disable wraparound mode + const width = wcwidth((0xD800 - 0xD800) * 0x400 + i - 0xDC00 + 0x10000); + if (width !== 1) { + continue; + } + await term.writeP('a' + high + String.fromCharCode(i)); + // auto wraparound mode should cut off the rest of the line + assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), high + String.fromCharCode(i)); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars().length, 2); + assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), ''); + term.reset(); + } + }); + it('splitted surrogates', async function (): Promise { + this.timeout(10000); + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + for (let i = 0xDC00; i <= 0xDCFF; ++i) { + await term.writeP(high + String.fromCharCode(i)); + const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); + assert.equal(tchar.getChars(), high + String.fromCharCode(i)); + assert.equal(tchar.getChars().length, 2); + assert.equal(tchar.getWidth(), 1); + assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), ''); + term.reset(); + } + }); + }); + + describe('unicode - combining characters', () => { + const cell = new CellData(); + it('café', async () => { + await term.writeP('cafe\u0301'); + term.buffer.lines.get(0)!.loadCell(3, cell); + assert.equal(cell.getChars(), 'e\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 1); + }); + it('café - end of line', async () => { + term.buffer.x = term.cols - 1 - 3; + await term.writeP('cafe\u0301'); + term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); + assert.equal(cell.getChars(), 'e\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 1); + term.buffer.lines.get(0)!.loadCell(1, cell); + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 1); + }); + it('multiple combined é', async () => { + await term.writeP(Array(100).join('e\u0301')); + for (let i = 0; i < term.cols; ++i) { + term.buffer.lines.get(0)!.loadCell(i, cell); + assert.equal(cell.getChars(), 'e\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 1); + } + term.buffer.lines.get(1)!.loadCell(0, cell); + assert.equal(cell.getChars(), 'e\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 1); + }); + it('multiple surrogate with combined', async () => { + await term.writeP(Array(100).join('\uD800\uDC00\u0301')); + for (let i = 0; i < term.cols; ++i) { + term.buffer.lines.get(0)!.loadCell(i, cell); + assert.equal(cell.getChars(), '\uD800\uDC00\u0301'); + assert.equal(cell.getChars().length, 3); + assert.equal(cell.getWidth(), 1); + } + term.buffer.lines.get(1)!.loadCell(0, cell); + assert.equal(cell.getChars(), '\uD800\uDC00\u0301'); + assert.equal(cell.getChars().length, 3); + assert.equal(cell.getWidth(), 1); + }); + }); + + describe('unicode - fullwidth characters', () => { + const cell = new CellData(); + it('cursor movement even', async () => { + assert.equal(term.buffer.x, 0); + await term.writeP('¥'); + assert.equal(term.buffer.x, 2); + }); + it('cursor movement odd', async () => { + term.buffer.x = 1; + assert.equal(term.buffer.x, 1); + await term.writeP('¥'); + assert.equal(term.buffer.x, 3); + }); + it('line of ¥ even', async () => { + await term.writeP(Array(50).join('¥')); + for (let i = 0; i < term.cols; ++i) { + term.buffer.lines.get(0)!.loadCell(i, cell); + if (i % 2) { + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 0); + } else { + assert.equal(cell.getChars(), '¥'); + assert.equal(cell.getChars().length, 1); + assert.equal(cell.getWidth(), 2); + } + } + term.buffer.lines.get(1)!.loadCell(0, cell); + assert.equal(cell.getChars(), '¥'); + assert.equal(cell.getChars().length, 1); + assert.equal(cell.getWidth(), 2); + }); + it('line of ¥ odd', async () => { + term.buffer.x = 1; + await term.writeP(Array(50).join('¥')); + for (let i = 1; i < term.cols - 1; ++i) { + term.buffer.lines.get(0)!.loadCell(i, cell); + if (!(i % 2)) { + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 0); + } else { + assert.equal(cell.getChars(), '¥'); + assert.equal(cell.getChars().length, 1); + assert.equal(cell.getWidth(), 2); + } + } + term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 1); + term.buffer.lines.get(1)!.loadCell(0, cell); + assert.equal(cell.getChars(), '¥'); + assert.equal(cell.getChars().length, 1); + assert.equal(cell.getWidth(), 2); + }); + it('line of ¥ with combining odd', async () => { + term.buffer.x = 1; + await term.writeP(Array(50).join('¥\u0301')); + for (let i = 1; i < term.cols - 1; ++i) { + term.buffer.lines.get(0)!.loadCell(i, cell); + if (!(i % 2)) { + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 0); + } else { + assert.equal(cell.getChars(), '¥\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 2); + } + } + term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 1); + term.buffer.lines.get(1)!.loadCell(0, cell); + assert.equal(cell.getChars(), '¥\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 2); + }); + it('line of ¥ with combining even', async () => { + await term.writeP(Array(50).join('¥\u0301')); + for (let i = 0; i < term.cols; ++i) { + term.buffer.lines.get(0)!.loadCell(i, cell); + if (i % 2) { + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 0); + } else { + assert.equal(cell.getChars(), '¥\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 2); + } + } + term.buffer.lines.get(1)!.loadCell(0, cell); + assert.equal(cell.getChars(), '¥\u0301'); + assert.equal(cell.getChars().length, 2); + assert.equal(cell.getWidth(), 2); + }); + it('line of surrogate fullwidth with combining odd', async () => { + term.buffer.x = 1; + await term.writeP(Array(50).join('\ud843\ude6d\u0301')); + for (let i = 1; i < term.cols - 1; ++i) { + term.buffer.lines.get(0)!.loadCell(i, cell); + if (!(i % 2)) { + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 0); + } else { + assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); + assert.equal(cell.getChars().length, 3); + assert.equal(cell.getWidth(), 2); + } + } + term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell); + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 1); + term.buffer.lines.get(1)!.loadCell(0, cell); + assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); + assert.equal(cell.getChars().length, 3); + assert.equal(cell.getWidth(), 2); + }); + it('line of surrogate fullwidth with combining even', async () => { + await term.writeP(Array(50).join('\ud843\ude6d\u0301')); + for (let i = 0; i < term.cols; ++i) { + term.buffer.lines.get(0)!.loadCell(i, cell); + if (i % 2) { + assert.equal(cell.getChars(), ''); + assert.equal(cell.getChars().length, 0); + assert.equal(cell.getWidth(), 0); + } else { + assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); + assert.equal(cell.getChars().length, 3); + assert.equal(cell.getWidth(), 2); + } + } + term.buffer.lines.get(1)!.loadCell(0, cell); + assert.equal(cell.getChars(), '\ud843\ude6d\u0301'); + assert.equal(cell.getChars().length, 3); + assert.equal(cell.getWidth(), 2); + }); + }); + + describe('insert mode', () => { + const cell = new CellData(); + it('halfwidth - all', async () => { + await term.writeP(Array(9).join('0123456789').slice(-80)); + term.buffer.x = 10; + term.buffer.y = 0; + term.write('\x1b[4h'); + await term.writeP('abcde'); + assert.equal(term.buffer.lines.get(0)!.length, term.cols); + assert.equal(term.buffer.lines.get(0)!.loadCell(10, cell).getChars(), 'a'); + assert.equal(term.buffer.lines.get(0)!.loadCell(14, cell).getChars(), 'e'); + assert.equal(term.buffer.lines.get(0)!.loadCell(15, cell).getChars(), '0'); + assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), '4'); + }); + it('fullwidth - insert', async () => { + await term.writeP(Array(9).join('0123456789').slice(-80)); + term.buffer.x = 10; + term.buffer.y = 0; + term.write('\x1b[4h'); + await term.writeP('¥¥¥'); + assert.equal(term.buffer.lines.get(0)!.length, term.cols); + assert.equal(term.buffer.lines.get(0)!.loadCell(10, cell).getChars(), '¥'); + assert.equal(term.buffer.lines.get(0)!.loadCell(11, cell).getChars(), ''); + assert.equal(term.buffer.lines.get(0)!.loadCell(14, cell).getChars(), '¥'); + assert.equal(term.buffer.lines.get(0)!.loadCell(15, cell).getChars(), ''); + assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), '3'); + }); + it('fullwidth - right border', async () => { + await term.writeP(Array(41).join('¥')); + term.buffer.x = 10; + term.buffer.y = 0; + term.write('\x1b[4h'); + await term.writeP('a'); + assert.equal(term.buffer.lines.get(0)!.length, term.cols); + assert.equal(term.buffer.lines.get(0)!.loadCell(10, cell).getChars(), 'a'); + assert.equal(term.buffer.lines.get(0)!.loadCell(11, cell).getChars(), '¥'); + assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), ''); // fullwidth char got replaced + await term.writeP('b'); + assert.equal(term.buffer.lines.get(0)!.length, term.cols); + assert.equal(term.buffer.lines.get(0)!.loadCell(11, cell).getChars(), 'b'); + assert.equal(term.buffer.lines.get(0)!.loadCell(12, cell).getChars(), '¥'); + assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), ''); // empty cell after fullwidth + }); + }); + + describe('Linkifier unicode handling', () => { + let terminal: TestTerminal; + let linkifier: TestLinkifier; + let mouseZoneManager: TestMouseZoneManager; + + // other than the tests above unicode testing needs the full terminal instance + // to get the special handling of fullwidth, surrogate and combining chars in the input handler + beforeEach(() => { + terminal = new TestTerminal({ cols: 10, rows: 5 }); + linkifier = new TestLinkifier((terminal as any)._bufferService, terminal.unicodeService); + mouseZoneManager = new TestMouseZoneManager(); + linkifier.attachToDom({} as any, mouseZoneManager); + }); + + function assertLinkifiesInTerminal(rowText: string, linkMatcherRegex: RegExp, links: { x1: number, y1: number, x2: number, y2: number }[]): Promise { + return new Promise(async r => { + await terminal.writeP(rowText); + linkifier.registerLinkMatcher(linkMatcherRegex, () => { }); + linkifier.linkifyRows(); + // Allow linkify to happen + setTimeout(() => { + assert.equal(mouseZoneManager.zones.length, links.length); + links.forEach((l, i) => { + assert.equal(mouseZoneManager.zones[i].x1, l.x1 + 1); + assert.equal(mouseZoneManager.zones[i].x2, l.x2 + 1); + assert.equal(mouseZoneManager.zones[i].y1, l.y1 + 1); + assert.equal(mouseZoneManager.zones[i].y2, l.y2 + 1); + }); + r(); + }, 0); + }); } - public get linkMatchers(): IRegisteredLinkMatcher[] { return this._linkMatchers; } - public linkifyRows(): void { super.linkifyRows(0, this._bufferService.buffer.lines.length - 1); } + describe('unicode before the match', () => { + it('combining - match within one line', () => { + return assertLinkifiesInTerminal('e\u0301e\u0301e\u0301 foo', /foo/, [{ x1: 4, x2: 7, y1: 0, y2: 0 }]); + }); + it('combining - match over two lines', () => { + return assertLinkifiesInTerminal('e\u0301e\u0301e\u0301 foo', /foo/, [{ x1: 8, x2: 1, y1: 0, y2: 1 }]); + }); + it('surrogate - match within one line', () => { + return assertLinkifiesInTerminal('𝄞𝄞𝄞 foo', /foo/, [{ x1: 4, x2: 7, y1: 0, y2: 0 }]); + }); + it('surrogate - match over two lines', () => { + return assertLinkifiesInTerminal('𝄞𝄞𝄞 foo', /foo/, [{ x1: 8, x2: 1, y1: 0, y2: 1 }]); + }); + it('combining surrogate - match within one line', () => { + return assertLinkifiesInTerminal('𓂀\u0301𓂀\u0301𓂀\u0301 foo', /foo/, [{ x1: 4, x2: 7, y1: 0, y2: 0 }]); + }); + it('combining surrogate - match over two lines', () => { + return assertLinkifiesInTerminal('𓂀\u0301𓂀\u0301𓂀\u0301 foo', /foo/, [{ x1: 8, x2: 1, y1: 0, y2: 1 }]); + }); + it('fullwidth - match within one line', () => { + return assertLinkifiesInTerminal('12 foo', /foo/, [{ x1: 5, x2: 8, y1: 0, y2: 0 }]); + }); + it('fullwidth - match over two lines', () => { + return assertLinkifiesInTerminal('12 foo', /foo/, [{ x1: 8, x2: 1, y1: 0, y2: 1 }]); + }); + it('combining fullwidth - match within one line', () => { + return assertLinkifiesInTerminal('¥\u0301¥\u0301 foo', /foo/, [{ x1: 5, x2: 8, y1: 0, y2: 0 }]); + }); + it('combining fullwidth - match over two lines', () => { + return assertLinkifiesInTerminal('¥\u0301¥\u0301 foo', /foo/, [{ x1: 8, x2: 1, y1: 0, y2: 1 }]); + }); + }); + describe('unicode within the match', () => { + it('combining - match within one line', () => { + return assertLinkifiesInTerminal('test cafe\u0301', /cafe\u0301/, [{ x1: 5, x2: 9, y1: 0, y2: 0 }]); + }); + it('combining - match over two lines', () => { + return assertLinkifiesInTerminal('testtest cafe\u0301', /cafe\u0301/, [{ x1: 9, x2: 3, y1: 0, y2: 1 }]); + }); + it('surrogate - match within one line', () => { + return assertLinkifiesInTerminal('test a𝄞b', /a𝄞b/, [{ x1: 5, x2: 8, y1: 0, y2: 0 }]); + }); + it('surrogate - match over two lines', () => { + return assertLinkifiesInTerminal('testtest a𝄞b', /a𝄞b/, [{ x1: 9, x2: 2, y1: 0, y2: 1 }]); + }); + it('combining surrogate - match within one line', () => { + return assertLinkifiesInTerminal('test a𓂀\u0301b', /a𓂀\u0301b/, [{ x1: 5, x2: 8, y1: 0, y2: 0 }]); + }); + it('combining surrogate - match over two lines', () => { + return assertLinkifiesInTerminal('testtest a𓂀\u0301b', /a𓂀\u0301b/, [{ x1: 9, x2: 2, y1: 0, y2: 1 }]); + }); + it('fullwidth - match within one line', () => { + return assertLinkifiesInTerminal('test a1b', /a1b/, [{ x1: 5, x2: 9, y1: 0, y2: 0 }]); + }); + it('fullwidth - match over two lines', () => { + return assertLinkifiesInTerminal('testtest a1b', /a1b/, [{ x1: 9, x2: 3, y1: 0, y2: 1 }]); + }); + it('combining fullwidth - match within one line', () => { + return assertLinkifiesInTerminal('test a¥\u0301b', /a¥\u0301b/, [{ x1: 5, x2: 9, y1: 0, y2: 0 }]); + }); + it('combining fullwidth - match over two lines', () => { + return assertLinkifiesInTerminal('testtest a¥\u0301b', /a¥\u0301b/, [{ x1: 9, x2: 3, y1: 0, y2: 1 }]); + }); + }); + }); + + describe('Buffer.stringIndexToBufferIndex', () => { + let terminal: TestTerminal; + + beforeEach(() => { + terminal = new TestTerminal({ rows: 5, cols: 10, scrollback: 5 }); + }); + + it('multiline ascii', async () => { + const input = 'This is ASCII text spanning multiple lines.'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + for (let i = 0; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([(i / terminal.cols) | 0, i % terminal.cols], bufferIndex); + } + }); + + it('combining e\u0301 in a sentence', async () => { + const input = 'Sitting in the cafe\u0301 drinking coffee.'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + for (let i = 0; i < 19; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([(i / terminal.cols) | 0, i % terminal.cols], bufferIndex); + } + // string index 18 & 19 point to combining char e\u0301 ---> same buffer Index + assert.deepEqual( + terminal.buffer.stringIndexToBufferIndex(0, 18), + terminal.buffer.stringIndexToBufferIndex(0, 19)); + // after the combining char every string index has an offset of -1 + for (let i = 19; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([((i - 1) / terminal.cols) | 0, (i - 1) % terminal.cols], bufferIndex); + } + }); + + it('multiline combining e\u0301', async () => { + const input = 'e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + // every buffer cell index contains 2 string indices + for (let i = 0; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([((i >> 1) / terminal.cols) | 0, (i >> 1) % terminal.cols], bufferIndex); + } + }); + + it('surrogate char in a sentence', async () => { + const input = 'The 𝄞 is a clef widely used in modern notation.'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + for (let i = 0; i < 5; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([(i / terminal.cols) | 0, i % terminal.cols], bufferIndex); + } + // string index 4 & 5 point to surrogate char 𝄞 ---> same buffer Index + assert.deepEqual( + terminal.buffer.stringIndexToBufferIndex(0, 4), + terminal.buffer.stringIndexToBufferIndex(0, 5)); + // after the combining char every string index has an offset of -1 + for (let i = 5; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([((i - 1) / terminal.cols) | 0, (i - 1) % terminal.cols], bufferIndex); + } + }); + + it('multiline surrogate char', async () => { + const input = '𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + // every buffer cell index contains 2 string indices + for (let i = 0; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([((i >> 1) / terminal.cols) | 0, (i >> 1) % terminal.cols], bufferIndex); + } + }); + + it('surrogate char with combining', async () => { + // eye of Ra with acute accent - string length of 3 + const input = '𓂀\u0301 - the eye hiroglyph with an acute accent.'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + // index 0..2 should map to 0 + assert.deepEqual([0, 0], terminal.buffer.stringIndexToBufferIndex(0, 1)); + assert.deepEqual([0, 0], terminal.buffer.stringIndexToBufferIndex(0, 2)); + for (let i = 2; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([((i - 2) / terminal.cols) | 0, (i - 2) % terminal.cols], bufferIndex); + } + }); + + it('multiline surrogate with combining', async () => { + const input = '𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + // every buffer cell index contains 3 string indices + for (let i = 0; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([(((i / 3) | 0) / terminal.cols) | 0, ((i / 3) | 0) % terminal.cols], bufferIndex); + } + }); + + it('fullwidth chars', async () => { + const input = 'These 123 are some fat numbers.'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + for (let i = 0; i < 6; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([(i / terminal.cols) | 0, i % terminal.cols], bufferIndex); + } + // string index 6, 7, 8 take 2 cells + assert.deepEqual([0, 8], terminal.buffer.stringIndexToBufferIndex(0, 7)); + assert.deepEqual([1, 0], terminal.buffer.stringIndexToBufferIndex(0, 8)); + // rest of the string has offset of +3 + for (let i = 9; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([((i + 3) / terminal.cols) | 0, (i + 3) % terminal.cols], bufferIndex); + } + }); + + it('multiline fullwidth chars', async () => { + const input = '12345678901234567890'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + for (let i = 9; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); + assert.deepEqual([((i << 1) / terminal.cols) | 0, (i << 1) % terminal.cols], bufferIndex); + } + }); + + it('fullwidth combining with emoji - match emoji cell', async () => { + const input = 'Lots of ¥\u0301 make me 😃.'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + const stringIndex = s.match(/😃/)!.index!; + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, stringIndex); + assert(terminal.buffer.lines.get(bufferIndex[0])!.loadCell(bufferIndex[1], new CellData()).getChars(), '😃'); + }); + + it('multiline fullwidth chars with offset 1 (currently tests for broken behavior)', async () => { + const input = 'a12345678901234567890'; + // the 'a' at the beginning moves all fullwidth chars one to the right + // now the end of the line contains a dangling empty cell since + // the next fullwidth char has to wrap early + // the dangling last cell is wrongly added in the string + // --> fixable after resolving #1685 + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + for (let i = 10; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i, true); + const j = (i - 0) << 1; + assert.deepEqual([(j / terminal.cols) | 0, j % terminal.cols], bufferIndex); + } + }); + + it('test fully wrapped buffer up to last char', async () => { + const input = Array(6).join('1234567890'); + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + for (let i = 0; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i, true); + assert.equal(input[i], terminal.buffer.lines.get(bufferIndex[0])!.loadCell(bufferIndex[1], new CellData()).getChars()); + } + }); + + it('test fully wrapped buffer up to last char with full width odd', async () => { + const input = 'a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301' + + 'a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301a¥\u0301'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(input, s); + for (let i = 0; i < input.length; ++i) { + const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i, true); + assert.equal( + (!(i % 3)) + ? input[i] + : (i % 3 === 1) + ? input.substr(i, 2) + : input.substr(i - 1, 2), + terminal.buffer.lines.get(bufferIndex[0])!.loadCell(bufferIndex[1], new CellData()).getChars()); + } + }); + + it('should handle \t in lines correctly', async () => { + const input = '\thttps://google.de'; + await terminal.writeP(input); + const s = terminal.buffer.iterator(true).next().content; + assert.equal(s, Array(terminal.optionsService.options.tabStopWidth + 1).join(' ') + 'https://google.de'); + }); + }); + + describe('BufferStringIterator', function (): void { + it('iterator does not overflow buffer limits', async () => { + const terminal = new TestTerminal({ rows: 5, cols: 10, scrollback: 5 }); + const data = [ + 'aaaaaaaaaa', + 'aaaaaaaaa\n', + 'aaaaaaaaaa', + 'aaaaaaaaa\n', + 'aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaa\n', + 'aaaaaaaaaa', + 'aaaaaaaaaa' + ]; + await terminal.writeP(data.join('')); + // brute force test with insane values + assert.doesNotThrow(() => { + for (let overscan = 0; overscan < 20; ++overscan) { + for (let start = -10; start < 20; ++start) { + for (let end = -10; end < 20; ++end) { + const it = terminal.buffer.iterator(false, start, end, overscan, overscan); + while (it.hasNext()) { + it.next(); + } + } + } + } + }); + }); + }); + + describe('Windows Mode', () => { + it('should mark lines as wrapped when the line ends in a non-null character after a LF', async () => { + const data = [ + 'aaaaaaaaaa\n\r', // cannot wrap as it's the first + 'aaaaaaaaa\n\r', // wrapped (windows mode only) + 'aaaaaaaaa' // not wrapped + ]; + + const normalTerminal = new TestTerminal({ rows: 5, cols: 10, windowsMode: false }); + await normalTerminal.writeP(data.join('')); + assert.equal(normalTerminal.buffer.lines.get(0)!.isWrapped, false); + assert.equal(normalTerminal.buffer.lines.get(1)!.isWrapped, false); + assert.equal(normalTerminal.buffer.lines.get(2)!.isWrapped, false); + + const windowsModeTerminal = new TestTerminal({ rows: 5, cols: 10, windowsMode: true }); + await windowsModeTerminal.writeP(data.join('')); + assert.equal(windowsModeTerminal.buffer.lines.get(0)!.isWrapped, false); + assert.equal(windowsModeTerminal.buffer.lines.get(1)!.isWrapped, true, 'This line should wrap in Windows mode as the previous line ends in a non-null character'); + assert.equal(windowsModeTerminal.buffer.lines.get(2)!.isWrapped, false); + }); + + it('should mark lines as wrapped when the line ends in a non-null character after a CUP', async () => { + const data = [ + 'aaaaaaaaaa\x1b[2;1H', // cannot wrap as it's the first + 'aaaaaaaaa\x1b[3;1H', // wrapped (windows mode only) + 'aaaaaaaaa' // not wrapped + ]; + + const normalTerminal = new TestTerminal({ rows: 5, cols: 10, windowsMode: false }); + await normalTerminal.writeP(data.join('')); + assert.equal(normalTerminal.buffer.lines.get(0)!.isWrapped, false); + assert.equal(normalTerminal.buffer.lines.get(1)!.isWrapped, false); + assert.equal(normalTerminal.buffer.lines.get(2)!.isWrapped, false); + + const windowsModeTerminal = new TestTerminal({ rows: 5, cols: 10, windowsMode: true }); + await windowsModeTerminal.writeP(data.join('')); + assert.equal(windowsModeTerminal.buffer.lines.get(0)!.isWrapped, false); + assert.equal(windowsModeTerminal.buffer.lines.get(1)!.isWrapped, true, 'This line should wrap in Windows mode as the previous line ends in a non-null character'); + assert.equal(windowsModeTerminal.buffer.lines.get(2)!.isWrapped, false); + }); + }); + it('convertEol setting', async () => { + // not converting + const termNotConverting = new TestTerminal({ cols: 15, rows: 10 }); + await termNotConverting.writeP('Hello\nWorld'); + assert.equal(termNotConverting.buffer.lines.get(0)!.translateToString(false), 'Hello '); + assert.equal(termNotConverting.buffer.lines.get(1)!.translateToString(false), ' World '); + assert.equal(termNotConverting.buffer.lines.get(0)!.translateToString(true), 'Hello'); + assert.equal(termNotConverting.buffer.lines.get(1)!.translateToString(true), ' World'); + + // converting + const termConverting = new TestTerminal({ cols: 15, rows: 10, convertEol: true }); + await termConverting.writeP('Hello\nWorld'); + assert.equal(termConverting.buffer.lines.get(0)!.translateToString(false), 'Hello '); + assert.equal(termConverting.buffer.lines.get(1)!.translateToString(false), 'World '); + assert.equal(termConverting.buffer.lines.get(0)!.translateToString(true), 'Hello'); + assert.equal(termConverting.buffer.lines.get(1)!.translateToString(true), 'World'); + }); + + // FIXME: move to common/CoreTerminal.test once the trimming is moved over + describe('marker lifecycle', () => { + // create a 10x5 terminal with markers on every line + // to test marker lifecycle under various terminal actions + let markers: IMarker[]; + let disposeStack: IMarker[]; + let term: TestTerminal; + beforeEach(async () => { + term = new TestTerminal({}); + markers = []; + disposeStack = []; + term.optionsService.setOption('scrollback', 1); + term.resize(10, 5); + markers.push(term.buffers.active.addMarker(term.buffers.active.y)); + await term.writeP('\x1b[r0\r\n'); + markers.push(term.buffers.active.addMarker(term.buffers.active.y)); + await term.writeP('1\r\n'); + markers.push(term.buffers.active.addMarker(term.buffers.active.y)); + await term.writeP('2\r\n'); + markers.push(term.buffers.active.addMarker(term.buffers.active.y)); + await term.writeP('3\r\n'); + markers.push(term.buffers.active.addMarker(term.buffers.active.y)); + await term.writeP('4'); + for (let i = 0; i < markers.length; ++i) { + const marker = markers[i]; + marker.onDispose(() => disposeStack.push(marker)); + } + }); + it('initial', () => { + assert.deepEqual(markers.map(m => m.line), [0, 1, 2, 3, 4]); + }); + it('should dispose on normal trim off the top', async () => { + // moves top line into scrollback + await term.writeP('\n'); + assert.deepEqual(disposeStack, []); + // trims first marker + await term.writeP('\n'); + assert.deepEqual(disposeStack, [markers[0]]); + // trims second marker + await term.writeP('\n'); + assert.deepEqual(disposeStack, [markers[0], markers[1]]); + // trimmed marker objs should be disposed + assert.deepEqual(disposeStack.map(el => el.isDisposed), [true, true]); + assert.deepEqual(disposeStack.map(el => (el as any)._isDisposed), [true, true]); + // trimmed markers should contain line -1 + assert.deepEqual(disposeStack.map(el => el.line), [-1, -1]); + }); + it('should dispose on DL', async () => { + await term.writeP('\x1b[3;1H'); // move cursor to 0, 2 + await term.writeP('\x1b[2M'); // delete 2 lines + assert.deepEqual(disposeStack, [markers[2], markers[3]]); + }); + it('should dispose on IL', async () => { + await term.writeP('\x1b[3;1H'); // move cursor to 0, 2 + await term.writeP('\x1b[2L'); // insert 2 lines + assert.deepEqual(disposeStack, [markers[4], markers[3]]); + assert.deepEqual(markers.map(el => el.line), [0, 1, 4, -1, -1]); + }); + it('should dispose on resize', () => { + term.resize(10, 2); + assert.deepEqual(disposeStack, [markers[0], markers[1]]); + assert.deepEqual(markers.map(el => el.line), [-1, -1, 0, 1, 2]); + }); + }); +}); + +class TestLinkifier extends Linkifier { + constructor(bufferService: IBufferService, unicodeService: IUnicodeService) { + super(bufferService, new MockLogService(), unicodeService); + Linkifier._timeBeforeLatency = 0; } - class TestMouseZoneManager implements IMouseZoneManager { - public dispose(): void { - } - public clears: number = 0; - public zones: IMouseZone[] = []; - public add(zone: IMouseZone): void { - this.zones.push(zone); - } - public clearAll(): void { - this.clears++; - } + public get linkMatchers(): IRegisteredLinkMatcher[] { return this._linkMatchers; } + public linkifyRows(): void { super.linkifyRows(0, this._bufferService.buffer.lines.length - 1); } +} + +class TestMouseZoneManager implements IMouseZoneManager { + public dispose(): void { + } + public clears: number = 0; + public zones: IMouseZone[] = []; + public add(zone: IMouseZone): void { + this.zones.push(zone); + } + public clearAll(): void { + this.clears++; } } -); diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 9f855845..1d076692 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -58,7 +58,8 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { protected _inputHandler: InputHandler; private _writeBuffer: WriteBuffer; private _windowsMode: IDisposable | undefined; - + /** An IBufferline to clone/copy from for new blank lines */ + private _cachedBlankLine: IBufferLine | undefined; private _onBinary = new EventEmitter(); public get onBinary(): IEvent { return this._onBinary.event; } @@ -97,20 +98,21 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this._instantiationService = new InstantiationService(); this.optionsService = new OptionsService(options); this._instantiationService.setService(IOptionsService, this.optionsService); + this._bufferService = this.register(this._instantiationService.createInstance(BufferService)); + this._instantiationService.setService(IBufferService, this._bufferService); this._logService = this._instantiationService.createInstance(LogService); this._instantiationService.setService(ILogService, this._logService); + this._coreService = this.register(this._instantiationService.createInstance(CoreService, () => this.scrollToBottom())); + this._instantiationService.setService(ICoreService, this._coreService); + this._coreMouseService = this._instantiationService.createInstance(CoreMouseService); + this._instantiationService.setService(ICoreMouseService, this._coreMouseService); + this._dirtyRowService = this._instantiationService.createInstance(DirtyRowService); + this._instantiationService.setService(IDirtyRowService, this._dirtyRowService); this.unicodeService = this._instantiationService.createInstance(UnicodeService); this._instantiationService.setService(IUnicodeService, this.unicodeService); this._charsetService = this._instantiationService.createInstance(CharsetService); this._instantiationService.setService(ICharsetService, this._charsetService); - this._bufferService = this.register(this._instantiationService.createInstance(BufferService)); - this._instantiationService.setService(IBufferService, this._bufferService); - this._dirtyRowService = this._instantiationService.createInstance(DirtyRowService); - this._instantiationService.setService(IDirtyRowService, this._dirtyRowService); - this._coreService = this.register(this._instantiationService.createInstance(CoreService, () => this._bufferService.scrollToBottom())); - this._instantiationService.setService(ICoreService, this._coreService); - this._coreMouseService = this._instantiationService.createInstance(CoreMouseService); - this._instantiationService.setService(ICoreMouseService, this._coreMouseService); + // Register input handler and handle/forward events this._inputHandler = new InputHandler(this._bufferService, this._charsetService, this._coreService, this._dirtyRowService, this._logService, this.optionsService, this._coreMouseService, this.unicodeService); this.register(forwardEvent(this._inputHandler.onLineFeed, this._onLineFeed)); @@ -121,6 +123,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this.register(forwardEvent(this._coreService.onData, this._onData)); this.register(forwardEvent(this._coreService.onBinary, this._onBinary)); this.register(this.optionsService.onOptionChange(key => this._updateOptions(key))); + this.register(this._bufferService.onScroll(event => this._onScroll.fire(event))); // Setup WriteBuffer this._writeBuffer = new WriteBuffer((data, promiseResult) => this._inputHandler.parse(data, promiseResult)); @@ -135,23 +138,6 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this._windowsMode = undefined; } - public scrollLines(disp: number, suppressScrollEvent?: boolean): void { - this._bufferService.scrollLines(disp, suppressScrollEvent); - } - - public scrollPages(pageCount: number): void { - this._bufferService.scrollPages(pageCount); - } - public scrollToTop(): void { - this._bufferService.scrollToTop(); - } - public scrollToBottom(): void { - this._bufferService.scrollToBottom(); - } - public scrollToLine(line: number): void { - this._bufferService.scrollToLine(line); - } - public write(data: string | Uint8Array, callback?: () => void): void { this._writeBuffer.write(data, callback); } @@ -189,97 +175,18 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { * @param isWrapped Whether the new line is wrapped from the previous line. */ public scroll(eraseAttr: IAttributeData, isWrapped: boolean = false): void { - const buffer = this._bufferService.buffer; - - let newLine: IBufferLine | undefined; - newLine = this._cachedBlankLine; - if (!newLine || newLine.length !== this.cols || newLine.getFg(0) !== eraseAttr.fg || newLine.getBg(0) !== eraseAttr.bg) { - newLine = buffer.getBlankLine(eraseAttr, isWrapped); - this._cachedBlankLine = newLine; - } - newLine.isWrapped = isWrapped; - - const topRow = buffer.ybase + buffer.scrollTop; - const bottomRow = buffer.ybase + buffer.scrollBottom; - - if (buffer.scrollTop === 0) { - // Determine whether the buffer is going to be trimmed after insertion. - const willBufferBeTrimmed = buffer.lines.isFull; - - // Insert the line using the fastest method - if (bottomRow === buffer.lines.length - 1) { - if (willBufferBeTrimmed) { - buffer.lines.recycle().copyFrom(newLine); - } else { - buffer.lines.push(newLine.clone()); - } - } else { - buffer.lines.splice(bottomRow + 1, 0, newLine.clone()); - } - - // Only adjust ybase and ydisp when the buffer is not trimmed - if (!willBufferBeTrimmed) { - buffer.ybase++; - // Only scroll the ydisp with ybase if the user has not scrolled up - if (!this._bufferService.isUserScrolling) { - buffer.ydisp++; - } - } else { - // When the buffer is full and the user has scrolled up, keep the text - // stable unless ydisp is right at the top - if (this._bufferService.isUserScrolling) { - buffer.ydisp = Math.max(buffer.ydisp - 1, 0); - } - } - } else { - // scrollTop is non-zero which means no line will be going to the - // scrollback, instead we can just shift them in-place. - const scrollRegionHeight = bottomRow - topRow + 1 /* as it's zero-based */; - buffer.lines.shiftElements(topRow + 1, scrollRegionHeight - 1, -1); - buffer.lines.set(bottomRow, newLine.clone()); - } - - // Move the viewport to the bottom of the buffer unless the user is - // scrolling. - if (!this._bufferService.isUserScrolling) { - buffer.ydisp = buffer.ybase; - } - - // Flag rows that need updating - this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); - - this._onScroll.fire({ position: buffer.ydisp, source: ScrollSource.TERMINAL }); + this._bufferService.scroll(eraseAttr, isWrapped); } /** * Scroll the display of the terminal * @param disp The number of lines to scroll down (negative scroll up). - * @param suppressScrollEvent Don't emit an onScroll event. - * @param source The source of the scroll action. Emitted as part of the onScroll event - * to avoid cyclic invocations if the event originated from the Viewport. + * @param suppressScrollEvent Don't emit the scroll event as scrollLines. This is used + * to avoid unwanted events being handled by the viewport when the event was triggered from the + * viewport originally. */ - public scrollLines(disp: number, suppressScrollEvent = false, source = ScrollSource.TERMINAL): void { - const buffer = this._bufferService.buffer; - if (disp < 0) { - if (buffer.ydisp === 0) { - return; - } - this._bufferService.isUserScrolling = true; - } else if (disp + buffer.ydisp >= buffer.ybase) { - this._bufferService.isUserScrolling = false; - } - - const oldYdisp = buffer.ydisp; - buffer.ydisp = Math.max(Math.min(buffer.ydisp + disp, buffer.ybase), 0); - - // No change occurred, don't trigger scroll/refresh - if (oldYdisp === buffer.ydisp) { - return; - } - - if (!suppressScrollEvent) { - this._onScroll.fire({ position: buffer.ydisp, source }); - } + public scrollLines(disp: number, suppressScrollEvent?: boolean): void { + this._bufferService.scrollLines(disp, suppressScrollEvent); } /** @@ -287,27 +194,27 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { * @param pageCount The number of pages to scroll (negative scrolls up). */ public scrollPages(pageCount: number): void { - this.scrollLines(pageCount * (this.rows - 1)); + this._bufferService.scrollPages(pageCount); } /** * Scrolls the display of the terminal to the top. */ public scrollToTop(): void { - this.scrollLines(-this._bufferService.buffer.ydisp); + this._bufferService.scrollToTop(); } /** * Scrolls the display of the terminal to the bottom. */ public scrollToBottom(): void { - this.scrollLines(this._bufferService.buffer.ybase - this._bufferService.buffer.ydisp); + this._bufferService.scrollLines(this._bufferService.buffer.ybase - this._bufferService.buffer.ydisp); } public scrollToLine(line: number): void { const scrollAmount = line - this._bufferService.buffer.ydisp; if (scrollAmount !== 0) { - this.scrollLines(scrollAmount); + this._bufferService.scrollLines(scrollAmount); } } diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index 93de6562..ecd476fc 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -18,7 +18,6 @@ import { clone } from 'common/Clone'; import { BufferService } from 'common/services/BufferService'; import { CoreService } from 'common/services/CoreService'; import { OscHandler } from 'common/parser/OscParser'; -import { DirtyRowService } from 'common/services/DirtyRowService'; function getCursor(bufferService: IBufferService): number[] { return [ @@ -76,62 +75,67 @@ describe('InputHandler', () => { function getLines(limit: number): string[] { const res: string[] = []; for (let i = 0; i < limit; ++i) { - res.push(bufferService.buffers.active.lines.get(i)!.translateToString(true)); + res.push(bufferService.buffer.lines.get(i)!.translateToString(true)); } return res; } + function reset(): void { + bufferService.buffer.y = 0; + bufferService.buffer.x = 0; + } + // This suite cannot live in InputHandler unless Terminal.scroll moved into IBufferService describe('SL/SR/DECIC/DECDC', () => { it('SL (scrollLeft)', async () => { inputHandler.parseP('12345'.repeat(6)); - assert.deepEqual(getLines(5), ['12345', '2345', '2345', '2345', '2345', '2345']); + assert.deepEqual(getLines(6), ['12345', '2345', '2345', '2345', '2345', '2345']); inputHandler.parseP('\x1b[0 @'); - assert.deepEqual(getLines(5), ['12345', '345', '345', '345', '345', '345']); + assert.deepEqual(getLines(6), ['12345', '345', '345', '345', '345', '345']); inputHandler.parseP('\x1b[2 @'); - assert.deepEqual(getLines(5), ['12345', '5', '5', '5', '5', '5']); + assert.deepEqual(getLines(6), ['12345', '5', '5', '5', '5', '5']); }); it('SR (scrollRight)', async () => { inputHandler.parseP('12345'.repeat(6)); inputHandler.parseP('\x1b[ A'); - assert.deepEqual(getLines(5), ['12345', ' 1234', ' 1234', ' 1234', ' 1234', ' 1234']); + assert.deepEqual(getLines(6), ['12345', ' 1234', ' 1234', ' 1234', ' 1234', ' 1234']); inputHandler.parseP('\x1b[0 A'); - assert.deepEqual(getLines(5), ['12345', ' 123', ' 123', ' 123', ' 123', ' 123']); + assert.deepEqual(getLines(6), ['12345', ' 123', ' 123', ' 123', ' 123', ' 123']); inputHandler.parseP('\x1b[2 A'); - assert.deepEqual(getLines(5), ['12345', ' 1', ' 1', ' 1', ' 1', ' 1']); + assert.deepEqual(getLines(6), ['12345', ' 1', ' 1', ' 1', ' 1', ' 1']); }); it('insertColumns (DECIC)', async () => { inputHandler.parseP('12345'.repeat(6)); inputHandler.parseP('\x1b[3;3H'); inputHandler.parseP('\x1b[\'}'); - assert.deepEqual(getLines(5), ['12345', '12 34', '12 34', '12 34', '12 34', '12 34']); - inputHandler.reset(); + assert.deepEqual(getLines(6), ['12345', '12 34', '12 34', '12 34', '12 34', '12 34']); + reset(); inputHandler.parseP('12345'.repeat(6)); inputHandler.parseP('\x1b[3;3H'); inputHandler.parseP('\x1b[1\'}'); - assert.deepEqual(getLines(5), ['12345', '12 34', '12 34', '12 34', '12 34', '12 34']); - inputHandler.reset(); + assert.deepEqual(getLines(6), ['12345', '12 34', '12 34', '12 34', '12 34', '12 34']); + reset(); inputHandler.parseP('12345'.repeat(6)); inputHandler.parseP('\x1b[3;3H'); inputHandler.parseP('\x1b[2\'}'); - assert.deepEqual(getLines(5), ['12345', '12 3', '12 3', '12 3', '12 3', '12 3']); + assert.deepEqual(getLines(6), ['12345', '12 3', '12 3', '12 3', '12 3', '12 3']); }); it('deleteColumns (DECDC)', async () => { inputHandler.parseP('12345'.repeat(6)); inputHandler.parseP('\x1b[3;3H'); inputHandler.parseP('\x1b[\'~'); - assert.deepEqual(getLines(5), ['12345', '1245', '1245', '1245', '1245', '1245']); - inputHandler.reset(); + assert.deepEqual(getLines(6), ['12345', '1245', '1245', '1245', '1245', '1245']); + reset(); inputHandler.parseP('12345'.repeat(6)); inputHandler.parseP('\x1b[3;3H'); inputHandler.parseP('\x1b[1\'~'); - assert.deepEqual(getLines(5), ['12345', '1245', '1245', '1245', '1245', '1245']); - inputHandler.reset(); + assert.deepEqual(getLines(6), ['12345', '1245', '1245', '1245', '1245', '1245']); + reset(); inputHandler.parseP('12345'.repeat(6)); inputHandler.parseP('\x1b[3;3H'); inputHandler.parseP('\x1b[2\'~'); - assert.deepEqual(getLines(5), ['12345', '125', '125', '125', '125', '125']); + assert.deepEqual(getLines(6), ['12345', '125', '125', '125', '125', '125']); }); }); @@ -539,68 +543,6 @@ describe('InputHandler', () => { await inputHandler.parseP('¥¥¥'); assert.deepEqual(getLines(bufferService, 2), ['¥¥', '¥']); }); - - - // This suite cannot live in InputHandler unless Terminal.scroll moved into IBufferService - describe('SL/SR/DECIC/DECDC', () => { - it('SL (scrollLeft)', async () => { - inputHandler.parseP('12345'.repeat(6)); - inputHandler.parseP('\x1b[ @'); - assert.deepEqual(getLines(bufferService, 5), ['12345', '2345', '2345', '2345', '2345', '2345']); - inputHandler.parseP('\x1b[0 @'); - assert.deepEqual(getLines(bufferService, 5), ['12345', '345', '345', '345', '345', '345']); - inputHandler.parseP('\x1b[2 @'); - assert.deepEqual(getLines(bufferService, 5), ['12345', '5', '5', '5', '5', '5']); - }); - it('SR (scrollRight)', async () => { - inputHandler.parseP('12345'.repeat(6)); - inputHandler.parseP('\x1b[ A'); - assert.deepEqual(getLines(bufferService, 5), ['12345', ' 1234', ' 1234', ' 1234', ' 1234', ' 1234']); - inputHandler.parseP('\x1b[0 A'); - assert.deepEqual(getLines(bufferService, 5), ['12345', ' 123', ' 123', ' 123', ' 123', ' 123']); - inputHandler.parseP('\x1b[2 A'); - assert.deepEqual(getLines(bufferService, 5), ['12345', ' 1', ' 1', ' 1', ' 1', ' 1']); - }); - it('insertColumns (DECIC)', async () => { - inputHandler.parseP('12345'.repeat(6)); - inputHandler.parseP('\x1b[3;3H'); - inputHandler.parseP('\x1b[\'}'); - assert.deepEqual(getLines(bufferService, 5), ['12345', '12 34', '12 34', '12 34', '12 34', '12 34']); - inputHandler.reset(); - inputHandler.parseP('12345'.repeat(6)); - inputHandler.parseP('\x1b[3;3H'); - inputHandler.parseP('\x1b[1\'}'); - assert.deepEqual(getLines(bufferService, 5), ['12345', '12 34', '12 34', '12 34', '12 34', '12 34']); - inputHandler.reset(); - inputHandler.parseP('12345'.repeat(6)); - inputHandler.parseP('\x1b[3;3H'); - inputHandler.parseP('\x1b[2\'}'); - assert.deepEqual(getLines(bufferService, 5), ['12345', '12 3', '12 3', '12 3', '12 3', '12 3']); - }); - it('deleteColumns (DECDC)', async () => { - inputHandler.parseP('12345'.repeat(6)); - inputHandler.parseP('\x1b[3;3H'); - inputHandler.parseP('\x1b[\'~'); - assert.deepEqual(getLines(bufferService, 5), ['12345', '1245', '1245', '1245', '1245', '1245']); - inputHandler.reset(); - inputHandler.parseP('12345'.repeat(6)); - inputHandler.parseP('\x1b[3;3H'); - inputHandler.parseP('\x1b[1\'~'); - assert.deepEqual(getLines(bufferService, 5), ['12345', '1245', '1245', '1245', '1245', '1245']); - inputHandler.reset(); - inputHandler.parseP('12345'.repeat(6)); - inputHandler.parseP('\x1b[3;3H'); - inputHandler.parseP('\x1b[2\'~'); - assert.deepEqual(getLines(bufferService, 5), ['12345', '125', '125', '125', '125', '125']); - }); - }); - it('should fire the onScroll event', (done) => { - bufferService.onScroll(e => { - assert.equal(typeof e, 'number'); - done(); - }); - bufferService.scroll(DEFAULT_ATTR_DATA.clone()); - }); }); describe('alt screen', () => { @@ -1985,7 +1927,6 @@ describe('InputHandler - async handlers', () => { let bufferService: IBufferService; let coreService: ICoreService; let optionsService: MockOptionsService; - let dirtyRowService: MockDirtyRowService; let inputHandler: TestInputHandler; beforeEach(() => { From c096633f9132ea4f5b75507ea2015eb6f8ef40a0 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Thu, 1 Apr 2021 11:23:56 -0700 Subject: [PATCH 146/377] get tests to pass Co-authored-by: Daniel Imms --- src/browser/Terminal.test.ts | 10 +- src/browser/Terminal.ts | 1 - src/common/CoreTerminal.ts | 5 +- src/common/InputHandler.test.ts | 199 +++++++++++++-------------- src/common/InputHandler.ts | 8 +- src/common/Types.d.ts | 1 - src/common/services/BufferService.ts | 11 +- 7 files changed, 109 insertions(+), 126 deletions(-) diff --git a/src/browser/Terminal.test.ts b/src/browser/Terminal.test.ts index 8f10e622..b0075d88 100644 --- a/src/browser/Terminal.test.ts +++ b/src/browser/Terminal.test.ts @@ -56,25 +56,25 @@ describe('Terminal', () => { // term.handler('fake'); // }); it('should fire the onCursorMove event', () => { - return new Promise(async r => { + return new Promise(async r => { term.onCursorMove(() => r()); await term.writeP('foo'); }); }); it('should fire the onLineFeed event', () => { - return new Promise(async r => { + return new Promise(async r => { term.onLineFeed(() => r()); await term.writeP('\n'); }); }); it('should fire a scroll event when scrollback is created', () => { - return new Promise(async r => { + return new Promise(async r => { term.onScroll(() => r()); await term.writeP('\n'.repeat(INIT_ROWS)); }); }); it('should fire a scroll event when scrollback is cleared', () => { - return new Promise(async r => { + return new Promise(async r => { await term.writeP('\n'.repeat(INIT_ROWS)); term.onScroll(() => r()); term.clear(); @@ -233,7 +233,7 @@ describe('Terminal', () => { term.paste('\r\nfoo\nbar\r'); }); it('should respect bracketed paste mode', () => { - return new Promise(async r => { + return new Promise(async r => { term.onData(e => { assert.equal(e, '\x1b[200~foo\x1b[201~'); r(); diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 9d9246e3..f14bffe0 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -147,7 +147,6 @@ export class Terminal extends CoreTerminal implements ITerminal { this.register(this._inputHandler.onRequestBell(() => this.bell())); this.register(this._inputHandler.onRequestRefreshRows((start, end) => this.refresh(start, end))); this.register(this._inputHandler.onRequestReset(() => this.reset())); - this.register(this._inputHandler.onRequestScroll((eraseAttr, isWrapped) => this._bufferService.scroll(eraseAttr, isWrapped || undefined))); this.register(this._inputHandler.onRequestWindowsOptionsReport(type => this._reportWindowsOptions(type))); this.register(this._inputHandler.onAnsiColorChange((event) => this._changeAnsiColor(event))); this.register(forwardEvent(this._inputHandler.onCursorMove, this._onCursorMove)); diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 1d076692..555994e4 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -123,7 +123,10 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this.register(forwardEvent(this._coreService.onData, this._onData)); this.register(forwardEvent(this._coreService.onBinary, this._onBinary)); this.register(this.optionsService.onOptionChange(key => this._updateOptions(key))); - this.register(this._bufferService.onScroll(event => this._onScroll.fire(event))); + this.register(this._bufferService.onScroll(event => { + this._onScroll.fire(event); + this._dirtyRowService.markRangeDirty(this._bufferService.buffer.scrollTop, this._bufferService.buffer.scrollBottom); + })); // Setup WriteBuffer this._writeBuffer = new WriteBuffer((data, promiseResult) => this._inputHandler.parse(data, promiseResult)); diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index ecd476fc..cb60aec3 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -71,115 +71,108 @@ describe('InputHandler', () => { inputHandler = new TestInputHandler(bufferService, new MockCharsetService(), coreService, new MockDirtyRowService(), new MockLogService(), optionsService, new MockCoreMouseService(), new MockUnicodeService()); }); - describe('Terminal InputHandler integration', () => { - function getLines(limit: number): string[] { - const res: string[] = []; - for (let i = 0; i < limit; ++i) { - res.push(bufferService.buffer.lines.get(i)!.translateToString(true)); - } - return res; - } - - function reset(): void { - bufferService.buffer.y = 0; - bufferService.buffer.x = 0; - } - - // This suite cannot live in InputHandler unless Terminal.scroll moved into IBufferService - describe('SL/SR/DECIC/DECDC', () => { - - it('SL (scrollLeft)', async () => { - inputHandler.parseP('12345'.repeat(6)); - assert.deepEqual(getLines(6), ['12345', '2345', '2345', '2345', '2345', '2345']); - inputHandler.parseP('\x1b[0 @'); - assert.deepEqual(getLines(6), ['12345', '345', '345', '345', '345', '345']); - inputHandler.parseP('\x1b[2 @'); - assert.deepEqual(getLines(6), ['12345', '5', '5', '5', '5', '5']); - }); - it('SR (scrollRight)', async () => { - inputHandler.parseP('12345'.repeat(6)); - inputHandler.parseP('\x1b[ A'); - assert.deepEqual(getLines(6), ['12345', ' 1234', ' 1234', ' 1234', ' 1234', ' 1234']); - inputHandler.parseP('\x1b[0 A'); - assert.deepEqual(getLines(6), ['12345', ' 123', ' 123', ' 123', ' 123', ' 123']); - inputHandler.parseP('\x1b[2 A'); - assert.deepEqual(getLines(6), ['12345', ' 1', ' 1', ' 1', ' 1', ' 1']); - }); - it('insertColumns (DECIC)', async () => { - inputHandler.parseP('12345'.repeat(6)); - inputHandler.parseP('\x1b[3;3H'); - inputHandler.parseP('\x1b[\'}'); - assert.deepEqual(getLines(6), ['12345', '12 34', '12 34', '12 34', '12 34', '12 34']); - reset(); - inputHandler.parseP('12345'.repeat(6)); - inputHandler.parseP('\x1b[3;3H'); - inputHandler.parseP('\x1b[1\'}'); - assert.deepEqual(getLines(6), ['12345', '12 34', '12 34', '12 34', '12 34', '12 34']); - reset(); - inputHandler.parseP('12345'.repeat(6)); - inputHandler.parseP('\x1b[3;3H'); - inputHandler.parseP('\x1b[2\'}'); - assert.deepEqual(getLines(6), ['12345', '12 3', '12 3', '12 3', '12 3', '12 3']); - }); - it('deleteColumns (DECDC)', async () => { - inputHandler.parseP('12345'.repeat(6)); - inputHandler.parseP('\x1b[3;3H'); - inputHandler.parseP('\x1b[\'~'); - assert.deepEqual(getLines(6), ['12345', '1245', '1245', '1245', '1245', '1245']); - reset(); - inputHandler.parseP('12345'.repeat(6)); - inputHandler.parseP('\x1b[3;3H'); - inputHandler.parseP('\x1b[1\'~'); - assert.deepEqual(getLines(6), ['12345', '1245', '1245', '1245', '1245', '1245']); - reset(); - inputHandler.parseP('12345'.repeat(6)); - inputHandler.parseP('\x1b[3;3H'); - inputHandler.parseP('\x1b[2\'~'); - assert.deepEqual(getLines(6), ['12345', '125', '125', '125', '125', '125']); - }); + describe('SL/SR/DECIC/DECDC', () => { + beforeEach(() => { + bufferService.resize(5, 5); + optionsService.options.scrollback = 1; + bufferService.reset(); }); + it('SL (scrollLeft)', async () => { + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[ @'); + assert.deepEqual(getLines(bufferService, 6), ['12345', '2345', '2345', '2345', '2345', '2345']); + inputHandler.parseP('\x1b[0 @'); + assert.deepEqual(getLines(bufferService, 6), ['12345', '345', '345', '345', '345', '345']); + inputHandler.parseP('\x1b[2 @'); + assert.deepEqual(getLines(bufferService, 6), ['12345', '5', '5', '5', '5', '5']); + }); + it('SR (scrollRight)', async () => { + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[ A'); + assert.deepEqual(getLines(bufferService, 6), ['12345', ' 1234', ' 1234', ' 1234', ' 1234', ' 1234']); + inputHandler.parseP('\x1b[0 A'); + assert.deepEqual(getLines(bufferService, 6), ['12345', ' 123', ' 123', ' 123', ' 123', ' 123']); + inputHandler.parseP('\x1b[2 A'); + assert.deepEqual(getLines(bufferService, 6), ['12345', ' 1', ' 1', ' 1', ' 1', ' 1']); + }); + it('insertColumns (DECIC)', async () => { + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[3;3H'); + inputHandler.parseP('\x1b[\'}'); + assert.deepEqual(getLines(bufferService, 6), ['12345', '12 34', '12 34', '12 34', '12 34', '12 34']); + bufferService.reset(); + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[3;3H'); + inputHandler.parseP('\x1b[1\'}'); + assert.deepEqual(getLines(bufferService, 6), ['12345', '12 34', '12 34', '12 34', '12 34', '12 34']); + bufferService.reset(); + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[3;3H'); + inputHandler.parseP('\x1b[2\'}'); + assert.deepEqual(getLines(bufferService, 6), ['12345', '12 3', '12 3', '12 3', '12 3', '12 3']); + }); + it('deleteColumns (DECDC)', async () => { + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[3;3H'); + inputHandler.parseP('\x1b[\'~'); + assert.deepEqual(getLines(bufferService, 6), ['12345', '1245', '1245', '1245', '1245', '1245']); + bufferService.reset(); + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[3;3H'); + inputHandler.parseP('\x1b[1\'~'); + assert.deepEqual(getLines(bufferService, 6), ['12345', '1245', '1245', '1245', '1245', '1245']); + bufferService.reset(); + inputHandler.parseP('12345'.repeat(6)); + inputHandler.parseP('\x1b[3;3H'); + inputHandler.parseP('\x1b[2\'~'); + assert.deepEqual(getLines(bufferService, 6), ['12345', '125', '125', '125', '125', '125']); + }); + }); - describe('BS with reverseWraparound set/unset', () => { - const ttyBS = '\x08 \x08'; // tty ICANON sends on pressing BS + describe('BS with reverseWraparound set/unset', () => { + const ttyBS = '\x08 \x08'; // tty ICANON sends on pressing BS + beforeEach(() => { + bufferService.resize(5, 5); + optionsService.options.scrollback = 1; + bufferService.reset(); + }); + describe('reverseWraparound set', () => { + it('should not reverse outside of scroll margins', async () => { + // prepare buffer content + inputHandler.parseP('#####abcdefghijklmnopqrstuvwxy'); + assert.deepEqual(getLines(bufferService, 6), ['#####', 'abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy']); + assert.equal(bufferService.buffers.active.ydisp, 1); + assert.equal(bufferService.buffers.active.x, 5); + assert.equal(bufferService.buffers.active.y, 4); + inputHandler.parseP(ttyBS.repeat(100)); + assert.deepEqual(getLines(bufferService, 6), ['#####', 'abcde', 'fghij', 'klmno', 'pqrst', ' y']); - describe('reverseWraparound set', () => { - it('should not reverse outside of scroll margins', async () => { - // prepare buffer content - inputHandler.parseP('#####abcdefghijklmnopqrstuvwxy'); - assert.deepEqual(getLines(5), ['#####', 'abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy']); - assert.equal(bufferService.buffers.active.ydisp, 1); - assert.equal(bufferService.buffers.active.x, 5); - assert.equal(bufferService.buffers.active.y, 4); - inputHandler.parseP(ttyBS.repeat(100)); - assert.deepEqual(getLines(5), ['#####', 'abcde', 'fghij', 'klmno', 'pqrst', ' y']); + inputHandler.parseP('\x1b[?45h'); + inputHandler.parseP('uvwxy'); - inputHandler.parseP('\x1b[?45h'); - inputHandler.parseP('uvwxy'); + // set top/bottom to 1/3 (0-based) + inputHandler.parseP('\x1b[2;4r'); + // place cursor below scroll bottom + bufferService.buffers.active.x = 5; + bufferService.buffers.active.y = 4; + inputHandler.parseP(ttyBS.repeat(100)); + assert.deepEqual(getLines(bufferService, 6), ['#####', 'abcde', 'fghij', 'klmno', 'pqrst', ' ']); - // set top/bottom to 1/3 (0-based) - inputHandler.parseP('\x1b[2;4r'); - // place cursor below scroll bottom - bufferService.buffers.active.x = 5; - bufferService.buffers.active.y = 4; - inputHandler.parseP(ttyBS.repeat(100)); - assert.deepEqual(getLines(5), ['#####', 'abcde', 'fghij', 'klmno', 'pqrst', ' ']); + inputHandler.parseP('uvwxy'); + // place cursor within scroll margins + bufferService.buffers.active.x = 5; + bufferService.buffers.active.y = 3; + inputHandler.parseP(ttyBS.repeat(100)); + assert.deepEqual(getLines(bufferService, 6), ['#####', 'abcde', ' ', ' ', ' ', 'uvwxy']); + assert.equal(bufferService.buffers.active.x, 0); + assert.equal(bufferService.buffers.active.y, bufferService.buffers.active.scrollTop); // stops at 0, scrollTop - inputHandler.parseP('uvwxy'); - // place cursor within scroll margins - bufferService.buffers.active.x = 5; - bufferService.buffers.active.y = 3; - inputHandler.parseP(ttyBS.repeat(100)); - assert.deepEqual(getLines(5), ['#####', 'abcde', ' ', ' ', ' ', 'uvwxy']); - assert.equal(bufferService.buffers.active.x, 0); - assert.equal(bufferService.buffers.active.y, bufferService.buffers.active.scrollTop); // stops at 0, scrollTop - - inputHandler.parseP('fghijklmnopqrst'); - // place cursor above scroll top - bufferService.buffers.active.x = 5; - bufferService.buffers.active.y = 0; - inputHandler.parseP(ttyBS.repeat(100)); - assert.deepEqual(getLines(5), ['#####', ' ', 'fghij', 'klmno', 'pqrst', 'uvwxy']); - }); + inputHandler.parseP('fghijklmnopqrst'); + // place cursor above scroll top + bufferService.buffers.active.x = 5; + bufferService.buffers.active.y = 0; + inputHandler.parseP(ttyBS.repeat(100)); + assert.deepEqual(getLines(bufferService, 6), ['#####', ' ', 'fghij', 'klmno', 'pqrst', 'uvwxy']); }); }); }); diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 13b0a0e7..3af2f9d7 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -240,8 +240,6 @@ export class InputHandler extends Disposable implements IInputHandler { public get onRequestRefreshRows(): IEvent { return this._onRequestRefreshRows.event; } private _onRequestReset = new EventEmitter(); public get onRequestReset(): IEvent { return this._onRequestReset.event; } - private _onRequestScroll = new EventEmitter(); - public get onRequestScroll(): IEvent { return this._onRequestScroll.event; } private _onRequestSyncScrollBar = new EventEmitter(); public get onRequestSyncScrollBar(): IEvent { return this._onRequestSyncScrollBar.event; } private _onRequestWindowsOptionsReport = new EventEmitter(); @@ -651,7 +649,7 @@ export class InputHandler extends Disposable implements IInputHandler { buffer.y++; if (buffer.y === buffer.scrollBottom + 1) { buffer.y--; - this._onRequestScroll.fire(this._eraseAttrData(), true); + this._bufferService.scroll(this._eraseAttrData(), true); } else { if (buffer.y >= this._bufferService.rows) { buffer.y = this._bufferService.rows - 1; @@ -791,7 +789,7 @@ export class InputHandler extends Disposable implements IInputHandler { buffer.y++; if (buffer.y === buffer.scrollBottom + 1) { buffer.y--; - this._onRequestScroll.fire(this._eraseAttrData()); + this._bufferService.scroll(this._eraseAttrData()); } else if (buffer.y >= this._bufferService.rows) { buffer.y = this._bufferService.rows - 1; } @@ -2987,7 +2985,7 @@ export class InputHandler extends Disposable implements IInputHandler { this._bufferService.buffer.y++; if (buffer.y === buffer.scrollBottom + 1) { buffer.y--; - this._onRequestScroll.fire(this._eraseAttrData()); + this._bufferService.scroll(this._eraseAttrData()); } else if (buffer.y >= this._bufferService.rows) { buffer.y = this._bufferService.rows - 1; } diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index 2dd3f4b8..df299195 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -357,7 +357,6 @@ export interface IAnsiColorChangeEvent { */ export interface IInputHandler { onTitleChange: IEvent; - onRequestScroll: IEvent; parse(data: string | Uint8Array, promiseResult?: boolean): void | Promise; print(data: Uint32Array, start: number, end: number): void; diff --git a/src/common/services/BufferService.ts b/src/common/services/BufferService.ts index 7fe0cdc3..3833bb44 100644 --- a/src/common/services/BufferService.ts +++ b/src/common/services/BufferService.ts @@ -3,13 +3,12 @@ * @license MIT */ -import { IBufferService, IDirtyRowService, IInstantiationService, IOptionsService } from 'common/services/Services'; +import { IBufferService, IOptionsService } from 'common/services/Services'; import { BufferSet } from 'common/buffer/BufferSet'; import { IBufferSet, IBuffer } from 'common/buffer/Types'; import { EventEmitter, IEvent } from 'common/EventEmitter'; import { Disposable } from 'common/Lifecycle'; import { IAttributeData, IBufferLine } from 'common/Types'; -import { DirtyRowService } from 'common/services/DirtyRowService'; export const MINIMUM_COLS = 2; // Less than 2 can mess with wide chars export const MINIMUM_ROWS = 1; @@ -33,8 +32,6 @@ export class BufferService extends Disposable implements IBufferService { /** An IBufferline to clone/copy from for new blank lines */ private _cachedBlankLine: IBufferLine | undefined; - private _dirtyRowService: IDirtyRowService | undefined; - constructor( @IOptionsService private _optionsService: IOptionsService ) { @@ -123,12 +120,6 @@ export class BufferService extends Disposable implements IBufferService { buffer.ydisp = buffer.ybase; } - // Flag rows that need updating - if (!this._dirtyRowService) { - this._dirtyRowService = new DirtyRowService(this); - } - this._dirtyRowService?.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); - this._onScroll.fire(buffer.ydisp); } From e40f340036f7cf8b463bec88c60dea796c932269 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Thu, 1 Apr 2021 11:28:41 -0700 Subject: [PATCH 147/377] use bufferService methods --- src/common/CoreTerminal.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 555994e4..4f1c8a57 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -211,14 +211,11 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { * Scrolls the display of the terminal to the bottom. */ public scrollToBottom(): void { - this._bufferService.scrollLines(this._bufferService.buffer.ybase - this._bufferService.buffer.ydisp); + this._bufferService.scrollToBottom(); } public scrollToLine(line: number): void { - const scrollAmount = line - this._bufferService.buffer.ydisp; - if (scrollAmount !== 0) { - this._bufferService.scrollLines(scrollAmount); - } + this._bufferService.scrollToLine(line); } /** Add handler for ESC escape sequence. See xterm.d.ts for details. */ From 1c087f6bcd510ba3ce34f72397dc156d8fc5003d Mon Sep 17 00:00:00 2001 From: meganrogge Date: Thu, 1 Apr 2021 13:24:02 -0700 Subject: [PATCH 148/377] cherry picked commits and scrollSource --- src/common/CoreTerminal.ts | 6 +++--- src/common/services/BufferService.ts | 4 ++-- src/common/services/Services.ts | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 4f1c8a57..72ad7d81 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -124,7 +124,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this.register(forwardEvent(this._coreService.onBinary, this._onBinary)); this.register(this.optionsService.onOptionChange(key => this._updateOptions(key))); this.register(this._bufferService.onScroll(event => { - this._onScroll.fire(event); + this._onScroll.fire({position: this._bufferService.buffer.ydisp, source: ScrollSource.TERMINAL}); this._dirtyRowService.markRangeDirty(this._bufferService.buffer.scrollTop, this._bufferService.buffer.scrollBottom); })); @@ -188,8 +188,8 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { * to avoid unwanted events being handled by the viewport when the event was triggered from the * viewport originally. */ - public scrollLines(disp: number, suppressScrollEvent?: boolean): void { - this._bufferService.scrollLines(disp, suppressScrollEvent); + public scrollLines(disp: number, suppressScrollEvent?: boolean, source?: ScrollSource): void { + this._bufferService.scrollLines(disp, suppressScrollEvent, source); } /** diff --git a/src/common/services/BufferService.ts b/src/common/services/BufferService.ts index 3833bb44..99594d22 100644 --- a/src/common/services/BufferService.ts +++ b/src/common/services/BufferService.ts @@ -8,7 +8,7 @@ import { BufferSet } from 'common/buffer/BufferSet'; import { IBufferSet, IBuffer } from 'common/buffer/Types'; import { EventEmitter, IEvent } from 'common/EventEmitter'; import { Disposable } from 'common/Lifecycle'; -import { IAttributeData, IBufferLine } from 'common/Types'; +import { IAttributeData, IBufferLine, ScrollSource } from 'common/Types'; export const MINIMUM_COLS = 2; // Less than 2 can mess with wide chars export const MINIMUM_ROWS = 1; @@ -130,7 +130,7 @@ export class BufferService extends Disposable implements IBufferService { * to avoid unwanted events being handled by the viewport when the event was triggered from the * viewport originally. */ - public scrollLines(disp: number, suppressScrollEvent?: boolean): void { + public scrollLines(disp: number, suppressScrollEvent?: boolean, source?: ScrollSource): void { const buffer = this.buffer; if (disp < 0) { if (buffer.ydisp === 0) { diff --git a/src/common/services/Services.ts b/src/common/services/Services.ts index 40c0c1b2..8b21f100 100644 --- a/src/common/services/Services.ts +++ b/src/common/services/Services.ts @@ -5,7 +5,7 @@ import { IEvent } from 'common/EventEmitter'; import { IBuffer, IBufferSet } from 'common/buffer/Types'; -import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEncoding, ICoreMouseProtocol, CoreMouseEventType, ICharset, IWindowOptions, IModes, IAttributeData } from 'common/Types'; +import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEncoding, ICoreMouseProtocol, CoreMouseEventType, ICharset, IWindowOptions, IModes, IAttributeData, ScrollSource } from 'common/Types'; import { createDecorator } from 'common/services/ServiceRegistry'; export const IBufferService = createDecorator('BufferService'); @@ -23,7 +23,7 @@ export interface IBufferService { scrollToBottom(): void; scrollToTop(): void; scrollToLine(line: number): void; - scrollLines(disp: number, suppressScrollEvent?: boolean): void; + scrollLines(disp: number, suppressScrollEvent?: boolean, source?: ScrollSource): void; scrollPages(pageCount: number): void; resize(cols: number, rows: number): void; reset(): void; From b1877b4dc7b903fabaf9edbba116887ce0e83474 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Thu, 1 Apr 2021 13:32:35 -0700 Subject: [PATCH 149/377] onRecoverContext -> onContextLoss --- addons/xterm-addon-webgl/src/WebglAddon.ts | 6 +++--- addons/xterm-addon-webgl/src/WebglRenderer.ts | 11 +++-------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/addons/xterm-addon-webgl/src/WebglAddon.ts b/addons/xterm-addon-webgl/src/WebglAddon.ts index 8eeda832..c07bc0d7 100644 --- a/addons/xterm-addon-webgl/src/WebglAddon.ts +++ b/addons/xterm-addon-webgl/src/WebglAddon.ts @@ -12,8 +12,8 @@ import { EventEmitter } from 'common/EventEmitter'; export class WebglAddon implements ITerminalAddon { private _terminal?: Terminal; private _renderer?: WebglRenderer; - private _onRecoverContext = new EventEmitter(); - public get onRecoverContext(): IEvent { return this._onRecoverContext.event; } + private _onContextLoss = new EventEmitter(); + public get onContextLoss(): IEvent { return this._onContextLoss.event; } constructor( private _preserveDrawingBuffer?: boolean @@ -27,7 +27,7 @@ export class WebglAddon implements ITerminalAddon { const renderService: IRenderService = (terminal)._core._renderService; const colors: IColorSet = (terminal)._core._colorManager.colors; this._renderer = new WebglRenderer(terminal, colors, this._preserveDrawingBuffer); - this._renderer.onRecoverContext(() => this._onRecoverContext.fire()); + this._renderer.onContextLoss(() => this._onContextLoss.fire()); renderService.setRenderer(this._renderer); } diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index 86e2900d..08f83b52 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -42,8 +42,8 @@ export class WebglRenderer extends Disposable implements IRenderer { private _onRequestRedraw = new EventEmitter(); public get onRequestRedraw(): IEvent { return this._onRequestRedraw.event; } - private _onRecoverContext = new EventEmitter(); - public get onRecoverContext(): IEvent { return this._onRecoverContext.event; } + private _onContextLoss = new EventEmitter(); + public get onContextLoss(): IEvent { return this._onContextLoss.event; } constructor( private _terminal: Terminal, @@ -87,7 +87,7 @@ export class WebglRenderer extends Disposable implements IRenderer { throw new Error('WebGL2 not supported ' + this._gl); } - this.register(addDisposableDomListener(this._canvas, 'webglcontextlost', (e) => { this._onContextLost(e); })); + this.register(addDisposableDomListener(this._canvas, 'webglcontextlost', (e) => { this._onContextLoss.fire(e); })); this._core.screenElement!.appendChild(this._canvas); @@ -100,11 +100,6 @@ export class WebglRenderer extends Disposable implements IRenderer { this._isAttached = document.body.contains(this._core.screenElement!); } - private _onContextLost(e: Event): void { - e.preventDefault(); - this._onRecoverContext.fire(); - } - public dispose(): void { for (const l of this._renderLayers) { l.dispose(); From c5339116b5685042afaed3fb31cd7114fc0a094f Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 1 Apr 2021 15:45:10 -0700 Subject: [PATCH 150/377] Add note to readme on handling context loss --- addons/xterm-addon-webgl/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/addons/xterm-addon-webgl/README.md b/addons/xterm-addon-webgl/README.md index 756999db..7927a513 100644 --- a/addons/xterm-addon-webgl/README.md +++ b/addons/xterm-addon-webgl/README.md @@ -19,3 +19,18 @@ terminal.loadAddon(new WebglAddon()); ``` See the full [API](https://github.com/xtermjs/xterm.js/blob/master/addons/xterm-addon-webgl/typings/xterm-addon-webgl.d.ts) for more advanced usage. + +### Handling Context Loss + +The browser may drop WebGL contexts for various reasons like OOM or after the system has been suspended. There is an API exposed that fires the `webglcontextlost` event fires on the canvas so embedders can handle it however they wish. An easy way but suboptimal way to handle this is by disposing of WebglAddon when the event fires: + +```ts +const terminal = new Terminal(); +const addon = new WebglAddon(); +addon.onContextLoss(e => { + addon.dispose(); +}); +terminal.loadAddon(addon); +``` + +Read more about handling WebGL context losses on the [Khronos wiki](https://www.khronos.org/webgl/wiki/HandlingContextLost). From ecb485d2f58f215fb5a1d90d96f691287837bdbf Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 1 Apr 2021 15:54:47 -0700 Subject: [PATCH 151/377] Remove _cachedBlankLine --- src/common/CoreTerminal.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 72ad7d81..699a1b1c 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -58,8 +58,6 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { protected _inputHandler: InputHandler; private _writeBuffer: WriteBuffer; private _windowsMode: IDisposable | undefined; - /** An IBufferline to clone/copy from for new blank lines */ - private _cachedBlankLine: IBufferLine | undefined; private _onBinary = new EventEmitter(); public get onBinary(): IEvent { return this._onBinary.event; } From 117f990055b3f0eee5890cce3be90d0902804f58 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 1 Apr 2021 16:39:59 -0700 Subject: [PATCH 152/377] Don't pad powerline glyphs Fixes #3278 --- .../src/atlas/WebglCharAtlas.ts | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 223ec16a..6a0f9a67 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -367,8 +367,20 @@ export class WebglCharAtlas implements IDisposable { this._tmpCtx.globalAlpha = DIM_OPACITY; } + // Check if the char is a powerline glyph + let isPowerlineGlyph = false; + if (chars.length === 1) { + const code = chars.charCodeAt(0); + if (code >= 0xE0A0 && code <= 0xE0D6) { + isPowerlineGlyph = true; + } + } + + // For powerline glyphs left/top padding is excluded (https://github.com/microsoft/vscode/issues/120129) + const padding = isPowerlineGlyph ? 0 : TMP_CANVAS_GLYPH_PADDING; + // Draw the character - this._tmpCtx.fillText(chars, TMP_CANVAS_GLYPH_PADDING, TMP_CANVAS_GLYPH_PADDING + this._config.scaledCharHeight / 2); + this._tmpCtx.fillText(chars, padding, padding + this._config.scaledCharHeight / 2); this._tmpCtx.restore(); // clear the background from the character to avoid issues with drawing over the previous @@ -391,7 +403,7 @@ export class WebglCharAtlas implements IDisposable { return NULL_RASTERIZED_GLYPH; } - const rasterizedGlyph = this._findGlyphBoundingBox(imageData, this._workBoundingBox); + const rasterizedGlyph = this._findGlyphBoundingBox(imageData, this._workBoundingBox, padding); const clippedImageData = this._clipImageData(imageData, this._workBoundingBox); // Check if there is enough room in the current row and go to next if needed @@ -424,7 +436,7 @@ export class WebglCharAtlas implements IDisposable { * @param imageData The image data to read. * @param boundingBox An IBoundingBox to put the clipped bounding box values. */ - private _findGlyphBoundingBox(imageData: ImageData, boundingBox: IBoundingBox): IRasterizedGlyph { + private _findGlyphBoundingBox(imageData: ImageData, boundingBox: IBoundingBox, padding: number): IRasterizedGlyph { boundingBox.top = 0; let found = false; for (let y = 0; y < this._tmpCanvas.height; y++) { @@ -497,8 +509,8 @@ export class WebglCharAtlas implements IDisposable { y: (boundingBox.bottom - boundingBox.top + 1) / TEXTURE_HEIGHT }, offset: { - x: -boundingBox.left + TMP_CANVAS_GLYPH_PADDING, - y: -boundingBox.top + TMP_CANVAS_GLYPH_PADDING + x: -boundingBox.left + padding, + y: -boundingBox.top + padding } }; } From b6d3120086d8b5fda0e42b5fb05f719cb836da5c Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 1 Apr 2021 16:55:27 -0700 Subject: [PATCH 153/377] Restrict all sides of powerline glyphs --- .../src/atlas/WebglCharAtlas.ts | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 6a0f9a67..d368405b 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -367,7 +367,9 @@ export class WebglCharAtlas implements IDisposable { this._tmpCtx.globalAlpha = DIM_OPACITY; } - // Check if the char is a powerline glyph + // Check if the char is a powerline glyph, these will be restricted to a single cell glyph, no + // padding on either side that are allowed for other glyphs since they are designed to be pixel + // perfect but may render with "bad" anti-aliasing let isPowerlineGlyph = false; if (chars.length === 1) { const code = chars.charCodeAt(0); @@ -403,7 +405,7 @@ export class WebglCharAtlas implements IDisposable { return NULL_RASTERIZED_GLYPH; } - const rasterizedGlyph = this._findGlyphBoundingBox(imageData, this._workBoundingBox, padding); + const rasterizedGlyph = this._findGlyphBoundingBox(imageData, this._workBoundingBox, isPowerlineGlyph); const clippedImageData = this._clipImageData(imageData, this._workBoundingBox); // Check if there is enough room in the current row and go to next if needed @@ -436,12 +438,14 @@ export class WebglCharAtlas implements IDisposable { * @param imageData The image data to read. * @param boundingBox An IBoundingBox to put the clipped bounding box values. */ - private _findGlyphBoundingBox(imageData: ImageData, boundingBox: IBoundingBox, padding: number): IRasterizedGlyph { + private _findGlyphBoundingBox(imageData: ImageData, boundingBox: IBoundingBox, restrictedGlyph: boolean): IRasterizedGlyph { boundingBox.top = 0; + const height = restrictedGlyph ? this._config.scaledCharHeight : this._tmpCanvas.height; + const width = restrictedGlyph ? this._config.scaledCharWidth : this._tmpCanvas.width; let found = false; - for (let y = 0; y < this._tmpCanvas.height; y++) { - for (let x = 0; x < this._tmpCanvas.width; x++) { - const alphaOffset = y * this._tmpCanvas.width * 4 + x * 4 + 3; + for (let y = 0; y < height; y++) { + for (let x = 0; x < width; x++) { + const alphaOffset = y * width * 4 + x * 4 + 3; if (imageData.data[alphaOffset] !== 0) { boundingBox.top = y; found = true; @@ -454,9 +458,9 @@ export class WebglCharAtlas implements IDisposable { } boundingBox.left = 0; found = false; - for (let x = 0; x < this._tmpCanvas.width; x++) { - for (let y = 0; y < this._tmpCanvas.height; y++) { - const alphaOffset = y * this._tmpCanvas.width * 4 + x * 4 + 3; + for (let x = 0; x < width; x++) { + for (let y = 0; y < height; y++) { + const alphaOffset = y * width * 4 + x * 4 + 3; if (imageData.data[alphaOffset] !== 0) { boundingBox.left = x; found = true; @@ -467,11 +471,11 @@ export class WebglCharAtlas implements IDisposable { break; } } - boundingBox.right = this._tmpCanvas.width; + boundingBox.right = width; found = false; - for (let x = this._tmpCanvas.width - 1; x >= 0; x--) { - for (let y = 0; y < this._tmpCanvas.height; y++) { - const alphaOffset = y * this._tmpCanvas.width * 4 + x * 4 + 3; + for (let x = width - 1; x >= 0; x--) { + for (let y = 0; y < height; y++) { + const alphaOffset = y * width * 4 + x * 4 + 3; if (imageData.data[alphaOffset] !== 0) { boundingBox.right = x; found = true; @@ -482,11 +486,11 @@ export class WebglCharAtlas implements IDisposable { break; } } - boundingBox.bottom = this._tmpCanvas.height; + boundingBox.bottom = height; found = false; - for (let y = this._tmpCanvas.height - 1; y >= 0; y--) { - for (let x = 0; x < this._tmpCanvas.width; x++) { - const alphaOffset = y * this._tmpCanvas.width * 4 + x * 4 + 3; + for (let y = height - 1; y >= 0; y--) { + for (let x = 0; x < width; x++) { + const alphaOffset = y * width * 4 + x * 4 + 3; if (imageData.data[alphaOffset] !== 0) { boundingBox.bottom = y; found = true; @@ -509,8 +513,8 @@ export class WebglCharAtlas implements IDisposable { y: (boundingBox.bottom - boundingBox.top + 1) / TEXTURE_HEIGHT }, offset: { - x: -boundingBox.left + padding, - y: -boundingBox.top + padding + x: -boundingBox.left + (restrictedGlyph ? TMP_CANVAS_GLYPH_PADDING : 0), + y: -boundingBox.top + (restrictedGlyph ? TMP_CANVAS_GLYPH_PADDING : 0) } }; } From 113086f97ad767d0d78a7fdd2b0e25a09c69534b Mon Sep 17 00:00:00 2001 From: meganrogge Date: Thu, 1 Apr 2021 16:57:19 -0700 Subject: [PATCH 154/377] tweak readme, expose API --- addons/xterm-addon-webgl/README.md | 2 +- addons/xterm-addon-webgl/typings/xterm-addon-webgl.d.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/xterm-addon-webgl/README.md b/addons/xterm-addon-webgl/README.md index 7927a513..67fafe7b 100644 --- a/addons/xterm-addon-webgl/README.md +++ b/addons/xterm-addon-webgl/README.md @@ -22,7 +22,7 @@ See the full [API](https://github.com/xtermjs/xterm.js/blob/master/addons/xterm- ### Handling Context Loss -The browser may drop WebGL contexts for various reasons like OOM or after the system has been suspended. There is an API exposed that fires the `webglcontextlost` event fires on the canvas so embedders can handle it however they wish. An easy way but suboptimal way to handle this is by disposing of WebglAddon when the event fires: +The browser may drop WebGL contexts for various reasons like OOM or after the system has been suspended. There is an API exposed that fires the `webglcontextlost` event fired on the canvas so embedders can handle it however they wish. An easy, but suboptimal way, to handle this is by disposing of WebglAddon when the event fires: ```ts const terminal = new Terminal(); diff --git a/addons/xterm-addon-webgl/typings/xterm-addon-webgl.d.ts b/addons/xterm-addon-webgl/typings/xterm-addon-webgl.d.ts index 5c15aa17..d95d8961 100644 --- a/addons/xterm-addon-webgl/typings/xterm-addon-webgl.d.ts +++ b/addons/xterm-addon-webgl/typings/xterm-addon-webgl.d.ts @@ -3,6 +3,7 @@ * @license MIT */ +import { IEvent } from 'node-pty'; import { Terminal, ITerminalAddon } from 'xterm'; declare module 'xterm-addon-webgl' { @@ -29,5 +30,10 @@ declare module 'xterm-addon-webgl' { * Clears the terminal's texture atlas and triggers a redraw. */ public clearTextureAtlas(): void; + + /** + * Fired when the WebglRenderer loses context + */ + public get onContextLoss(): IEvent; } } From 62ca4b7e137ec6f8c5845fd4a5ab28846d190f5b Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 1 Apr 2021 17:00:02 -0700 Subject: [PATCH 155/377] Correct restricted glyph padding --- addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index d368405b..a1995faa 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -513,8 +513,8 @@ export class WebglCharAtlas implements IDisposable { y: (boundingBox.bottom - boundingBox.top + 1) / TEXTURE_HEIGHT }, offset: { - x: -boundingBox.left + (restrictedGlyph ? TMP_CANVAS_GLYPH_PADDING : 0), - y: -boundingBox.top + (restrictedGlyph ? TMP_CANVAS_GLYPH_PADDING : 0) + x: -boundingBox.left + (restrictedGlyph ? 0 : TMP_CANVAS_GLYPH_PADDING), + y: -boundingBox.top + (restrictedGlyph ? 0 : TMP_CANVAS_GLYPH_PADDING) } }; } From 62f5b8291d89e45879070df9f246abcb5f764820 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 1 Apr 2021 17:05:29 -0700 Subject: [PATCH 156/377] Use ideographic over middle This seems to correctly center the glyphs within the cell, making powerline fonts appear perfectly aligned. Fixes #3281 --- addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index a1995faa..1396d09f 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -358,7 +358,7 @@ export class WebglCharAtlas implements IDisposable { const fontStyle = italic ? 'italic' : ''; this._tmpCtx.font = `${fontStyle} ${fontWeight} ${this._config.fontSize * this._config.devicePixelRatio}px ${this._config.fontFamily}`; - this._tmpCtx.textBaseline = 'middle'; + this._tmpCtx.textBaseline = 'ideographic'; this._tmpCtx.fillStyle = this._getForegroundCss(bg, bgColorMode, bgColor, fg, fgColorMode, fgColor, inverse, bold); @@ -382,7 +382,7 @@ export class WebglCharAtlas implements IDisposable { const padding = isPowerlineGlyph ? 0 : TMP_CANVAS_GLYPH_PADDING; // Draw the character - this._tmpCtx.fillText(chars, padding, padding + this._config.scaledCharHeight / 2); + this._tmpCtx.fillText(chars, padding, padding + this._config.scaledCharHeight); this._tmpCtx.restore(); // clear the background from the character to avoid issues with drawing over the previous From a510ffb3c03c2db160579bea6fded2191ee59f0b Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 1 Apr 2021 17:10:14 -0700 Subject: [PATCH 157/377] Use ideographic baseline for canvas --- .../xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts | 4 ++-- src/browser/renderer/BaseRenderLayer.ts | 8 ++++---- src/browser/renderer/atlas/DynamicCharAtlas.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts b/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts index da3b4d41..6229fb7f 100644 --- a/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts +++ b/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts @@ -224,12 +224,12 @@ export abstract class BaseRenderLayer implements IRenderLayer { */ protected _fillCharTrueColor(terminal: Terminal, cell: CellData, x: number, y: number): void { this._ctx.font = this._getFont(terminal, false, false); - this._ctx.textBaseline = 'middle'; + this._ctx.textBaseline = 'ideographic'; this._clipRow(terminal, y); this._ctx.fillText( cell.getChars(), x * this._scaledCellWidth + this._scaledCharLeft, - y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight / 2); + y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight); } /** diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 8afec352..b7646bee 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -242,12 +242,12 @@ export abstract class BaseRenderLayer implements IRenderLayer { */ protected _fillCharTrueColor(cell: CellData, x: number, y: number): void { this._ctx.font = this._getFont(false, false); - this._ctx.textBaseline = 'middle'; + this._ctx.textBaseline = 'ideographic'; this._clipRow(y); this._ctx.fillText( cell.getChars(), x * this._scaledCellWidth + this._scaledCharLeft, - y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight / 2); + y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight); } /** @@ -320,7 +320,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { private _drawUncachedChars(cell: ICellData, x: number, y: number, fgOverride?: IColor): void { this._ctx.save(); this._ctx.font = this._getFont(!!cell.isBold(), !!cell.isItalic()); - this._ctx.textBaseline = 'middle'; + this._ctx.textBaseline = 'ideographic'; if (cell.isInverse()) { if (fgOverride) { @@ -362,7 +362,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { this._ctx.fillText( cell.getChars(), x * this._scaledCellWidth + this._scaledCharLeft, - y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight / 2); + y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight); this._ctx.restore(); } diff --git a/src/browser/renderer/atlas/DynamicCharAtlas.ts b/src/browser/renderer/atlas/DynamicCharAtlas.ts index 696fb63c..bf90bab6 100644 --- a/src/browser/renderer/atlas/DynamicCharAtlas.ts +++ b/src/browser/renderer/atlas/DynamicCharAtlas.ts @@ -256,7 +256,7 @@ export class DynamicCharAtlas extends BaseCharAtlas { const fontStyle = glyph.italic ? 'italic' : ''; this._tmpCtx.font = `${fontStyle} ${fontWeight} ${this._config.fontSize * this._config.devicePixelRatio}px ${this._config.fontFamily}`; - this._tmpCtx.textBaseline = 'middle'; + this._tmpCtx.textBaseline = 'ideographic'; this._tmpCtx.fillStyle = this._getForegroundColor(glyph).css; @@ -265,7 +265,7 @@ export class DynamicCharAtlas extends BaseCharAtlas { this._tmpCtx.globalAlpha = DIM_OPACITY; } // Draw the character - this._tmpCtx.fillText(glyph.chars, 0, this._config.scaledCharHeight / 2); + this._tmpCtx.fillText(glyph.chars, 0, this._config.scaledCharHeight); this._tmpCtx.restore(); // clear the background from the character to avoid issues with drawing over the previous From 1e499c7867fe607563fcaa6cc8175cec30a3cb80 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 2 Apr 2021 06:57:11 -0700 Subject: [PATCH 158/377] Disable ligatures addon by default Since it needs a user action to trigger the permissions prompt --- demo/client.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/demo/client.ts b/demo/client.ts index 1f5eb49a..780597e3 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -166,7 +166,6 @@ function createTerminal(): void { addons.serialize.instance = new SerializeAddon(); addons.fit.instance = new FitAddon(); addons.unicode11.instance = new Unicode11Addon(); - addons.ligatures.instance = new LigaturesAddon(); // TODO: Remove arguments when link provider API is the default addons['web-links'].instance = new WebLinksAddon(undefined, undefined, true); typedTerm.loadAddon(addons.fit.instance); @@ -190,7 +189,6 @@ function createTerminal(): void { socketURL = protocol + location.hostname + ((location.port) ? (':' + location.port) : '') + '/terminals/'; term.open(terminalContainer); - typedTerm.loadAddon(addons.ligatures.instance); addons.fit.instance!.fit(); term.focus(); From f19d7f0b705d81da2334381b307ed2f09a6ab4fb Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 2 Apr 2021 07:08:06 -0700 Subject: [PATCH 159/377] Require spacing of objects outside of test files --- .eslintrc.json | 14 +- .../src/atlas/WebglCharAtlas.ts | 4 +- .../src/renderLayer/BaseRenderLayer.ts | 2 +- src/browser/renderer/BaseRenderLayer.ts | 2 +- .../renderer/atlas/DynamicCharAtlas.ts | 4 +- src/common/CircularList.ts | 4 +- src/common/InputHandler.ts | 148 +++++++++--------- src/common/buffer/Buffer.ts | 2 +- 8 files changed, 96 insertions(+), 84 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 8c416f15..114a0f1d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -151,6 +151,10 @@ "warn", "never" ], + "object-curly-spacing": [ + "warn", + "always" + ], "prefer-const": "warn", "spaced-comment": [ "warn", @@ -160,5 +164,13 @@ "exceptions": ["-"] } ] - } + }, + "overrides": [ + { + "files": ["**/*.test.ts"], + "rules": { + "object-curly-spacing": "off" + } + } + ] } diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 223ec16a..d252f065 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -80,12 +80,12 @@ export class WebglCharAtlas implements IDisposable { // The canvas needs alpha because we use clearColor to convert the background color to alpha. // It might also contain some characters with transparent backgrounds if allowTransparency is // set. - this._cacheCtx = throwIfFalsy(this.cacheCanvas.getContext('2d', {alpha: true})); + this._cacheCtx = throwIfFalsy(this.cacheCanvas.getContext('2d', { alpha: true })); this._tmpCanvas = document.createElement('canvas'); this._tmpCanvas.width = this._config.scaledCharWidth * 2 + TMP_CANVAS_GLYPH_PADDING * 2; this._tmpCanvas.height = this._config.scaledCharHeight + TMP_CANVAS_GLYPH_PADDING * 2; - this._tmpCtx = throwIfFalsy(this._tmpCanvas.getContext('2d', {alpha: this._config.allowTransparency})); + this._tmpCtx = throwIfFalsy(this._tmpCanvas.getContext('2d', { alpha: this._config.allowTransparency })); } public dispose(): void { diff --git a/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts b/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts index da3b4d41..afd2b384 100644 --- a/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts +++ b/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts @@ -46,7 +46,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { } private _initCanvas(): void { - this._ctx = throwIfFalsy(this._canvas.getContext('2d', {alpha: this._alpha})); + this._ctx = throwIfFalsy(this._canvas.getContext('2d', { alpha: this._alpha })); // Draw the background if this is an opaque layer if (!this._alpha) { this._clearAll(); diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 8afec352..86e12f48 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -66,7 +66,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { } private _initCanvas(): void { - this._ctx = throwIfFalsy(this._canvas.getContext('2d', {alpha: this._alpha})); + this._ctx = throwIfFalsy(this._canvas.getContext('2d', { alpha: this._alpha })); // Draw the background if this is an opaque layer if (!this._alpha) { this._clearAll(); diff --git a/src/browser/renderer/atlas/DynamicCharAtlas.ts b/src/browser/renderer/atlas/DynamicCharAtlas.ts index 696fb63c..d370fc8f 100644 --- a/src/browser/renderer/atlas/DynamicCharAtlas.ts +++ b/src/browser/renderer/atlas/DynamicCharAtlas.ts @@ -91,12 +91,12 @@ export class DynamicCharAtlas extends BaseCharAtlas { // The canvas needs alpha because we use clearColor to convert the background color to alpha. // It might also contain some characters with transparent backgrounds if allowTransparency is // set. - this._cacheCtx = throwIfFalsy(this._cacheCanvas.getContext('2d', {alpha: true})); + this._cacheCtx = throwIfFalsy(this._cacheCanvas.getContext('2d', { alpha: true })); const tmpCanvas = document.createElement('canvas'); tmpCanvas.width = this._config.scaledCharWidth; tmpCanvas.height = this._config.scaledCharHeight; - this._tmpCtx = throwIfFalsy(tmpCanvas.getContext('2d', {alpha: this._config.allowTransparency})); + this._tmpCtx = throwIfFalsy(tmpCanvas.getContext('2d', { alpha: this._config.allowTransparency })); this._width = Math.floor(TEXTURE_WIDTH / this._config.scaledCharWidth); this._height = Math.floor(TEXTURE_HEIGHT / this._config.scaledCharHeight); diff --git a/src/common/CircularList.ts b/src/common/CircularList.ts index ab00e681..4d2c04ec 100644 --- a/src/common/CircularList.ts +++ b/src/common/CircularList.ts @@ -158,7 +158,7 @@ export class CircularList implements ICircularList { this._array[this._getCyclicIndex(i)] = this._array[this._getCyclicIndex(i + deleteCount)]; } this._length -= deleteCount; - this.onDeleteEmitter.fire({index: start, amount: deleteCount}); + this.onDeleteEmitter.fire({ index: start, amount: deleteCount }); } // Add items @@ -169,7 +169,7 @@ export class CircularList implements ICircularList { this._array[this._getCyclicIndex(start + i)] = items[i]; } if (items.length) { - this.onInsertEmitter.fire({index: start, amount: items.length}); + this.onInsertEmitter.fire({ index: start, amount: items.length }); } // Adjust length as needed diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 13b0a0e7..da315005 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -24,7 +24,7 @@ import { DcsHandler } from 'common/parser/DcsParser'; /** * Map collect to glevel. Used in `selectCharset`. */ -const GLEVEL: {[key: string]: number} = {'(': 0, ')': 1, '*': 2, '+': 3, '-': 1, '.': 2}; +const GLEVEL: {[key: string]: number} = { '(': 0, ')': 1, '*': 2, '+': 3, '-': 1, '.': 2 }; /** * VT commands done by the parser - FIXME: move this to the parser? @@ -174,7 +174,7 @@ class DECRQSS implements IDcsHandler { this._coreService.triggerDataEvent(`${C0.ESC}P1$r0m${C0.ESC}\\`); break; case ' q': // DECSCUSR - const STYLES: {[key: string]: number} = {'block': 2, 'underline': 4, 'bar': 6}; + const STYLES: {[key: string]: number} = { 'block': 2, 'underline': 4, 'bar': 6 }; let style = STYLES[this._optionsService.options.cursorStyle]; style -= this._optionsService.options.cursorBlink ? 1 : 0; this._coreService.triggerDataEvent(`${C0.ESC}P1$r${style} q${C0.ESC}\\`); @@ -314,53 +314,53 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI handler */ - this._parser.registerCsiHandler({final: '@'}, params => this.insertChars(params)); - this._parser.registerCsiHandler({intermediates: ' ', final: '@'}, params => this.scrollLeft(params)); - this._parser.registerCsiHandler({final: 'A'}, params => this.cursorUp(params)); - this._parser.registerCsiHandler({intermediates: ' ', final: 'A'}, params => this.scrollRight(params)); - this._parser.registerCsiHandler({final: 'B'}, params => this.cursorDown(params)); - this._parser.registerCsiHandler({final: 'C'}, params => this.cursorForward(params)); - this._parser.registerCsiHandler({final: 'D'}, params => this.cursorBackward(params)); - this._parser.registerCsiHandler({final: 'E'}, params => this.cursorNextLine(params)); - this._parser.registerCsiHandler({final: 'F'}, params => this.cursorPrecedingLine(params)); - this._parser.registerCsiHandler({final: 'G'}, params => this.cursorCharAbsolute(params)); - this._parser.registerCsiHandler({final: 'H'}, params => this.cursorPosition(params)); - this._parser.registerCsiHandler({final: 'I'}, params => this.cursorForwardTab(params)); - this._parser.registerCsiHandler({final: 'J'}, params => this.eraseInDisplay(params)); - this._parser.registerCsiHandler({prefix: '?', final: 'J'}, params => this.eraseInDisplay(params)); - this._parser.registerCsiHandler({final: 'K'}, params => this.eraseInLine(params)); - this._parser.registerCsiHandler({prefix: '?', final: 'K'}, params => this.eraseInLine(params)); - this._parser.registerCsiHandler({final: 'L'}, params => this.insertLines(params)); - this._parser.registerCsiHandler({final: 'M'}, params => this.deleteLines(params)); - this._parser.registerCsiHandler({final: 'P'}, params => this.deleteChars(params)); - this._parser.registerCsiHandler({final: 'S'}, params => this.scrollUp(params)); - this._parser.registerCsiHandler({final: 'T'}, params => this.scrollDown(params)); - this._parser.registerCsiHandler({final: 'X'}, params => this.eraseChars(params)); - this._parser.registerCsiHandler({final: 'Z'}, params => this.cursorBackwardTab(params)); - this._parser.registerCsiHandler({final: '`'}, params => this.charPosAbsolute(params)); - this._parser.registerCsiHandler({final: 'a'}, params => this.hPositionRelative(params)); - this._parser.registerCsiHandler({final: 'b'}, params => this.repeatPrecedingCharacter(params)); - this._parser.registerCsiHandler({final: 'c'}, params => this.sendDeviceAttributesPrimary(params)); - this._parser.registerCsiHandler({prefix: '>', final: 'c'}, params => this.sendDeviceAttributesSecondary(params)); - this._parser.registerCsiHandler({final: 'd'}, params => this.linePosAbsolute(params)); - this._parser.registerCsiHandler({final: 'e'}, params => this.vPositionRelative(params)); - this._parser.registerCsiHandler({final: 'f'}, params => this.hVPosition(params)); - this._parser.registerCsiHandler({final: 'g'}, params => this.tabClear(params)); - this._parser.registerCsiHandler({final: 'h'}, params => this.setMode(params)); - this._parser.registerCsiHandler({prefix: '?', final: 'h'}, params => this.setModePrivate(params)); - this._parser.registerCsiHandler({final: 'l'}, params => this.resetMode(params)); - this._parser.registerCsiHandler({prefix: '?', final: 'l'}, params => this.resetModePrivate(params)); - this._parser.registerCsiHandler({final: 'm'}, params => this.charAttributes(params)); - this._parser.registerCsiHandler({final: 'n'}, params => this.deviceStatus(params)); - this._parser.registerCsiHandler({prefix: '?', final: 'n'}, params => this.deviceStatusPrivate(params)); - this._parser.registerCsiHandler({intermediates: '!', final: 'p'}, params => this.softReset(params)); - this._parser.registerCsiHandler({intermediates: ' ', final: 'q'}, params => this.setCursorStyle(params)); - this._parser.registerCsiHandler({final: 'r'}, params => this.setScrollRegion(params)); - this._parser.registerCsiHandler({final: 's'}, params => this.saveCursor(params)); - this._parser.registerCsiHandler({final: 't'}, params => this.windowOptions(params)); - this._parser.registerCsiHandler({final: 'u'}, params => this.restoreCursor(params)); - this._parser.registerCsiHandler({intermediates: '\'', final: '}'}, params => this.insertColumns(params)); - this._parser.registerCsiHandler({intermediates: '\'', final: '~'}, params => this.deleteColumns(params)); + this._parser.registerCsiHandler({ final: '@' }, params => this.insertChars(params)); + this._parser.registerCsiHandler({ intermediates: ' ', final: '@' }, params => this.scrollLeft(params)); + this._parser.registerCsiHandler({ final: 'A' }, params => this.cursorUp(params)); + this._parser.registerCsiHandler({ intermediates: ' ', final: 'A' }, params => this.scrollRight(params)); + this._parser.registerCsiHandler({ final: 'B' }, params => this.cursorDown(params)); + this._parser.registerCsiHandler({ final: 'C' }, params => this.cursorForward(params)); + this._parser.registerCsiHandler({ final: 'D' }, params => this.cursorBackward(params)); + this._parser.registerCsiHandler({ final: 'E' }, params => this.cursorNextLine(params)); + this._parser.registerCsiHandler({ final: 'F' }, params => this.cursorPrecedingLine(params)); + this._parser.registerCsiHandler({ final: 'G' }, params => this.cursorCharAbsolute(params)); + this._parser.registerCsiHandler({ final: 'H' }, params => this.cursorPosition(params)); + this._parser.registerCsiHandler({ final: 'I' }, params => this.cursorForwardTab(params)); + this._parser.registerCsiHandler({ final: 'J' }, params => this.eraseInDisplay(params)); + this._parser.registerCsiHandler({ prefix: '?', final: 'J' }, params => this.eraseInDisplay(params)); + this._parser.registerCsiHandler({ final: 'K' }, params => this.eraseInLine(params)); + this._parser.registerCsiHandler({ prefix: '?', final: 'K' }, params => this.eraseInLine(params)); + this._parser.registerCsiHandler({ final: 'L' }, params => this.insertLines(params)); + this._parser.registerCsiHandler({ final: 'M' }, params => this.deleteLines(params)); + this._parser.registerCsiHandler({ final: 'P' }, params => this.deleteChars(params)); + this._parser.registerCsiHandler({ final: 'S' }, params => this.scrollUp(params)); + this._parser.registerCsiHandler({ final: 'T' }, params => this.scrollDown(params)); + this._parser.registerCsiHandler({ final: 'X' }, params => this.eraseChars(params)); + this._parser.registerCsiHandler({ final: 'Z' }, params => this.cursorBackwardTab(params)); + this._parser.registerCsiHandler({ final: '`' }, params => this.charPosAbsolute(params)); + this._parser.registerCsiHandler({ final: 'a' }, params => this.hPositionRelative(params)); + this._parser.registerCsiHandler({ final: 'b' }, params => this.repeatPrecedingCharacter(params)); + this._parser.registerCsiHandler({ final: 'c' }, params => this.sendDeviceAttributesPrimary(params)); + this._parser.registerCsiHandler({ prefix: '>', final: 'c' }, params => this.sendDeviceAttributesSecondary(params)); + this._parser.registerCsiHandler({ final: 'd' }, params => this.linePosAbsolute(params)); + this._parser.registerCsiHandler({ final: 'e' }, params => this.vPositionRelative(params)); + this._parser.registerCsiHandler({ final: 'f' }, params => this.hVPosition(params)); + this._parser.registerCsiHandler({ final: 'g' }, params => this.tabClear(params)); + this._parser.registerCsiHandler({ final: 'h' }, params => this.setMode(params)); + this._parser.registerCsiHandler({ prefix: '?', final: 'h' }, params => this.setModePrivate(params)); + this._parser.registerCsiHandler({ final: 'l' }, params => this.resetMode(params)); + this._parser.registerCsiHandler({ prefix: '?', final: 'l' }, params => this.resetModePrivate(params)); + this._parser.registerCsiHandler({ final: 'm' }, params => this.charAttributes(params)); + this._parser.registerCsiHandler({ final: 'n' }, params => this.deviceStatus(params)); + this._parser.registerCsiHandler({ prefix: '?', final: 'n' }, params => this.deviceStatusPrivate(params)); + this._parser.registerCsiHandler({ intermediates: '!', final: 'p' }, params => this.softReset(params)); + this._parser.registerCsiHandler({ intermediates: ' ', final: 'q' }, params => this.setCursorStyle(params)); + this._parser.registerCsiHandler({ final: 'r' }, params => this.setScrollRegion(params)); + this._parser.registerCsiHandler({ final: 's' }, params => this.saveCursor(params)); + this._parser.registerCsiHandler({ final: 't' }, params => this.windowOptions(params)); + this._parser.registerCsiHandler({ final: 'u' }, params => this.restoreCursor(params)); + this._parser.registerCsiHandler({ intermediates: '\'', final: '}' }, params => this.insertColumns(params)); + this._parser.registerCsiHandler({ intermediates: '\'', final: '~' }, params => this.deleteColumns(params)); /** * execute handler @@ -426,32 +426,32 @@ export class InputHandler extends Disposable implements IInputHandler { /** * ESC handlers */ - this._parser.registerEscHandler({final: '7'}, () => this.saveCursor()); - this._parser.registerEscHandler({final: '8'}, () => this.restoreCursor()); - this._parser.registerEscHandler({final: 'D'}, () => this.index()); - this._parser.registerEscHandler({final: 'E'}, () => this.nextLine()); - this._parser.registerEscHandler({final: 'H'}, () => this.tabSet()); - this._parser.registerEscHandler({final: 'M'}, () => this.reverseIndex()); - this._parser.registerEscHandler({final: '='}, () => this.keypadApplicationMode()); - this._parser.registerEscHandler({final: '>'}, () => this.keypadNumericMode()); - this._parser.registerEscHandler({final: 'c'}, () => this.fullReset()); - this._parser.registerEscHandler({final: 'n'}, () => this.setgLevel(2)); - this._parser.registerEscHandler({final: 'o'}, () => this.setgLevel(3)); - this._parser.registerEscHandler({final: '|'}, () => this.setgLevel(3)); - this._parser.registerEscHandler({final: '}'}, () => this.setgLevel(2)); - this._parser.registerEscHandler({final: '~'}, () => this.setgLevel(1)); - this._parser.registerEscHandler({intermediates: '%', final: '@'}, () => this.selectDefaultCharset()); - this._parser.registerEscHandler({intermediates: '%', final: 'G'}, () => this.selectDefaultCharset()); + this._parser.registerEscHandler({ final: '7' }, () => this.saveCursor()); + this._parser.registerEscHandler({ final: '8' }, () => this.restoreCursor()); + this._parser.registerEscHandler({ final: 'D' }, () => this.index()); + this._parser.registerEscHandler({ final: 'E' }, () => this.nextLine()); + this._parser.registerEscHandler({ final: 'H' }, () => this.tabSet()); + this._parser.registerEscHandler({ final: 'M' }, () => this.reverseIndex()); + this._parser.registerEscHandler({ final: '=' }, () => this.keypadApplicationMode()); + this._parser.registerEscHandler({ final: '>' }, () => this.keypadNumericMode()); + this._parser.registerEscHandler({ final: 'c' }, () => this.fullReset()); + this._parser.registerEscHandler({ final: 'n' }, () => this.setgLevel(2)); + this._parser.registerEscHandler({ final: 'o' }, () => this.setgLevel(3)); + this._parser.registerEscHandler({ final: '|' }, () => this.setgLevel(3)); + this._parser.registerEscHandler({ final: '}' }, () => this.setgLevel(2)); + this._parser.registerEscHandler({ final: '~' }, () => this.setgLevel(1)); + this._parser.registerEscHandler({ intermediates: '%', final: '@' }, () => this.selectDefaultCharset()); + this._parser.registerEscHandler({ intermediates: '%', final: 'G' }, () => this.selectDefaultCharset()); for (const flag in CHARSETS) { - this._parser.registerEscHandler({intermediates: '(', final: flag}, () => this.selectCharset('(' + flag)); - this._parser.registerEscHandler({intermediates: ')', final: flag}, () => this.selectCharset(')' + flag)); - this._parser.registerEscHandler({intermediates: '*', final: flag}, () => this.selectCharset('*' + flag)); - this._parser.registerEscHandler({intermediates: '+', final: flag}, () => this.selectCharset('+' + flag)); - this._parser.registerEscHandler({intermediates: '-', final: flag}, () => this.selectCharset('-' + flag)); - this._parser.registerEscHandler({intermediates: '.', final: flag}, () => this.selectCharset('.' + flag)); - this._parser.registerEscHandler({intermediates: '/', final: flag}, () => this.selectCharset('/' + flag)); // TODO: supported? + this._parser.registerEscHandler({ intermediates: '(', final: flag }, () => this.selectCharset('(' + flag)); + this._parser.registerEscHandler({ intermediates: ')', final: flag }, () => this.selectCharset(')' + flag)); + this._parser.registerEscHandler({ intermediates: '*', final: flag }, () => this.selectCharset('*' + flag)); + this._parser.registerEscHandler({ intermediates: '+', final: flag }, () => this.selectCharset('+' + flag)); + this._parser.registerEscHandler({ intermediates: '-', final: flag }, () => this.selectCharset('-' + flag)); + this._parser.registerEscHandler({ intermediates: '.', final: flag }, () => this.selectCharset('.' + flag)); + this._parser.registerEscHandler({ intermediates: '/', final: flag }, () => this.selectCharset('/' + flag)); // TODO: supported? } - this._parser.registerEscHandler({intermediates: '#', final: '8'}, () => this.screenAlignmentPattern()); + this._parser.registerEscHandler({ intermediates: '#', final: '8' }, () => this.screenAlignmentPattern()); /** * error handler @@ -464,7 +464,7 @@ export class InputHandler extends Disposable implements IInputHandler { /** * DCS handler */ - this._parser.registerDcsHandler({intermediates: '$', final: 'q'}, new DECRQSS(this._bufferService, this._coreService, this._logService, this._optionsService)); + this._parser.registerDcsHandler({ intermediates: '$', final: 'q' }, new DECRQSS(this._bufferService, this._coreService, this._logService, this._optionsService)); } public dispose(): void { diff --git a/src/common/buffer/Buffer.ts b/src/common/buffer/Buffer.ts index e06ffb01..c788bf36 100644 --- a/src/common/buffer/Buffer.ts +++ b/src/common/buffer/Buffer.ts @@ -671,6 +671,6 @@ export class BufferStringIterator implements IBufferStringIterator { content += this._buffer.translateBufferLineToString(i, this._trimRight); } this._current = range.last + 1; - return {range, content}; + return { range, content }; } } From 999116c5367cfd643fa4aca5cdd395c5f8628133 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 2 Apr 2021 07:43:39 -0700 Subject: [PATCH 160/377] Convert CharacterJoinerRegistry to a service Part of #3094, #3283 --- src/browser/Terminal.ts | 17 ++- src/browser/TestUtils.test.ts | 12 +- src/browser/Types.d.ts | 7 + src/browser/renderer/CursorRenderLayer.ts | 8 +- src/browser/renderer/LinkRenderLayer.ts | 4 +- src/browser/renderer/Renderer.ts | 26 +--- src/browser/renderer/SelectionRenderLayer.ts | 4 +- src/browser/renderer/TextRenderLayer.ts | 20 ++- src/browser/renderer/Types.d.ts | 25 --- src/browser/renderer/dom/DomRenderer.ts | 5 +- .../CharacterJoinerService.test.ts} | 142 +++++++++--------- .../CharacterJoinerService.ts} | 16 +- src/browser/services/RenderService.ts | 10 +- src/browser/services/Services.ts | 14 +- 14 files changed, 138 insertions(+), 172 deletions(-) rename src/browser/{renderer/CharacterJoinerRegistry.test.ts => services/CharacterJoinerService.test.ts} (60%) rename src/browser/{renderer/CharacterJoinerRegistry.ts => services/CharacterJoinerService.ts} (95%) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 1ab207c7..d04f9e38 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -21,8 +21,8 @@ * http://linux.die.net/man/7/urxvt */ -import { ICompositionHelper, ITerminal, IBrowser, CustomKeyEventHandler, ILinkifier, IMouseZoneManager, LinkMatcherHandler, ILinkMatcherOptions, IViewport, ILinkifier2 } from 'browser/Types'; -import { IRenderer, CharacterJoinerHandler } from 'browser/renderer/Types'; +import { ICompositionHelper, ITerminal, IBrowser, CustomKeyEventHandler, ILinkifier, IMouseZoneManager, LinkMatcherHandler, ILinkMatcherOptions, IViewport, ILinkifier2, CharacterJoinerHandler } from 'browser/Types'; +import { IRenderer } from 'browser/renderer/Types'; import { CompositionHelper } from 'browser/input/CompositionHelper'; import { Viewport } from 'browser/Viewport'; import { rightClickHandler, moveTextAreaUnderMouseCursor, handlePasteEvent, copyHandler, paste } from 'browser/Clipboard'; @@ -45,7 +45,7 @@ import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter'; import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; import { ColorManager } from 'browser/ColorManager'; import { RenderService } from 'browser/services/RenderService'; -import { ICharSizeService, IRenderService, IMouseService, ISelectionService, ISoundService, ICoreBrowserService } from 'browser/services/Services'; +import { ICharSizeService, IRenderService, IMouseService, ISelectionService, ISoundService, ICoreBrowserService, ICharacterJoinerService } from 'browser/services/Services'; import { CharSizeService } from 'browser/services/CharSizeService'; import { IBuffer } from 'common/buffer/Types'; import { MouseService } from 'browser/services/MouseService'; @@ -54,6 +54,7 @@ import { CoreBrowserService } from 'browser/services/CoreBrowserService'; import { CoreTerminal } from 'common/CoreTerminal'; import { ITerminalOptions as IInitializedTerminalOptions } from 'common/services/Services'; import { rgba } from 'browser/Color'; +import { CharacterJoinerService } from 'browser/services/CharacterJoinerService'; // Let it work inside Node.js for automated testing purposes. const document: Document = (typeof window !== 'undefined') ? window.document : null as any; @@ -82,6 +83,7 @@ export class Terminal extends CoreTerminal implements ITerminal { private _charSizeService: ICharSizeService | undefined; private _mouseService: IMouseService | undefined; private _renderService: IRenderService | undefined; + private _characterJoinerService: ICharacterJoinerService | undefined; private _selectionService: ISelectionService | undefined; private _soundService: ISoundService | undefined; @@ -450,6 +452,9 @@ export class Terminal extends CoreTerminal implements ITerminal { this.register(this.optionsService.onOptionChange(e => this._colorManager!.onOptionsChange(e))); this._colorManager.setTheme(this._theme); + this._characterJoinerService = this._instantiationService.createInstance(CharacterJoinerService); + this._instantiationService.setService(ICharacterJoinerService, this._characterJoinerService); + const renderer = this._createRenderer(); this._renderService = this.register(this._instantiationService.createInstance(RenderService, renderer, this.rows, this.screenElement)); this._instantiationService.setService(IRenderService, this._renderService); @@ -551,7 +556,7 @@ export class Terminal extends CoreTerminal implements ITerminal { private _createRenderer(): IRenderer { switch (this.options.rendererType) { - case 'canvas': return this._instantiationService.createInstance(Renderer, this._colorManager!.colors, this.screenElement!, this.linkifier, this.linkifier2); + case 'canvas': return this._instantiationService.createInstance(Renderer, this._colorManager!.colors, this.screenElement!, this.linkifier, this.linkifier2, this._instantiationService); case 'dom': return this._instantiationService.createInstance(DomRenderer, this._colorManager!.colors, this.element!, this.screenElement!, this._viewportElement!, this.linkifier, this.linkifier2); default: throw new Error(`Unrecognized rendererType "${this.options.rendererType}"`); } @@ -915,13 +920,13 @@ export class Terminal extends CoreTerminal implements ITerminal { } public registerCharacterJoiner(handler: CharacterJoinerHandler): number { - const joinerId = this._renderService!.registerCharacterJoiner(handler); + const joinerId = this._characterJoinerService!.register(handler); this.refresh(0, this.rows - 1); return joinerId; } public deregisterCharacterJoiner(joinerId: number): void { - if (this._renderService!.deregisterCharacterJoiner(joinerId)) { + if (this._characterJoinerService!.deregister(joinerId)) { this.refresh(0, this.rows - 1); } } diff --git a/src/browser/TestUtils.test.ts b/src/browser/TestUtils.test.ts index a2140aa5..7ab7d9b1 100644 --- a/src/browser/TestUtils.test.ts +++ b/src/browser/TestUtils.test.ts @@ -6,8 +6,8 @@ import { IDisposable, IMarker, ISelectionPosition, ILinkProvider } from 'xterm'; import { IEvent, EventEmitter } from 'common/EventEmitter'; import { ICharSizeService, IMouseService, IRenderService, ISelectionService } from 'browser/services/Services'; -import { IRenderDimensions, IRenderer, CharacterJoinerHandler, IRequestRedrawEvent } from 'browser/renderer/Types'; -import { IColorSet, ILinkMatcherOptions, ITerminal, ILinkifier, ILinkifier2, IBrowser, IViewport, IColorManager, ICompositionHelper } from 'browser/Types'; +import { IRenderDimensions, IRenderer, IRequestRedrawEvent } from 'browser/renderer/Types'; +import { IColorSet, ILinkMatcherOptions, ITerminal, ILinkifier, ILinkifier2, IBrowser, IViewport, IColorManager, ICompositionHelper, CharacterJoinerHandler } from 'browser/Types'; import { IBuffer, IBufferStringIterator, IBufferSet } from 'common/buffer/Types'; import { IBufferLine, ICellData, IAttributeData, ICircularList, XtermListener, ICharset, ITerminalOptions } from 'common/Types'; import { Buffer } from 'common/buffer/Buffer'; @@ -284,8 +284,6 @@ export class MockRenderer implements IRenderer { public onDevicePixelRatioChange(): void { } public clear(): void { } public renderRows(start: number, end: number): void { } - public registerCharacterJoiner(handler: CharacterJoinerHandler): number { return 0; } - public deregisterCharacterJoiner(): boolean { return true; } } export class MockViewport implements IViewport { @@ -409,12 +407,6 @@ export class MockRenderService implements IRenderService { public clear(): void { throw new Error('Method not implemented.'); } - public registerCharacterJoiner(handler: CharacterJoinerHandler): number { - throw new Error('Method not implemented.'); - } - public deregisterCharacterJoiner(joinerId: number): boolean { - throw new Error('Method not implemented.'); - } public dispose(): void { throw new Error('Method not implemented.'); } diff --git a/src/browser/Types.d.ts b/src/browser/Types.d.ts index f743934e..15eef804 100644 --- a/src/browser/Types.d.ts +++ b/src/browser/Types.d.ts @@ -302,3 +302,10 @@ interface IBufferCellPosition { x: number; y: number; } + +export type CharacterJoinerHandler = (text: string) => [number, number][]; + +export interface ICharacterJoiner { + id: number; + handler: CharacterJoinerHandler; +} diff --git a/src/browser/renderer/CursorRenderLayer.ts b/src/browser/renderer/CursorRenderLayer.ts index d358d580..a78b2048 100644 --- a/src/browser/renderer/CursorRenderLayer.ts +++ b/src/browser/renderer/CursorRenderLayer.ts @@ -37,10 +37,10 @@ export class CursorRenderLayer extends BaseRenderLayer { colors: IColorSet, rendererId: number, private _onRequestRedraw: IEventEmitter, - bufferService: IBufferService, - optionsService: IOptionsService, - private readonly _coreService: ICoreService, - private readonly _coreBrowserService: ICoreBrowserService + @IBufferService bufferService: IBufferService, + @IOptionsService optionsService: IOptionsService, + @ICoreService private readonly _coreService: ICoreService, + @ICoreBrowserService private readonly _coreBrowserService: ICoreBrowserService ) { super(container, 'cursor', zIndex, true, colors, rendererId, bufferService, optionsService); this._state = { diff --git a/src/browser/renderer/LinkRenderLayer.ts b/src/browser/renderer/LinkRenderLayer.ts index c41955d9..2492f921 100644 --- a/src/browser/renderer/LinkRenderLayer.ts +++ b/src/browser/renderer/LinkRenderLayer.ts @@ -20,8 +20,8 @@ export class LinkRenderLayer extends BaseRenderLayer { rendererId: number, linkifier: ILinkifier, linkifier2: ILinkifier2, - bufferService: IBufferService, - optionsService: IOptionsService + @IBufferService bufferService: IBufferService, + @IOptionsService optionsService: IOptionsService ) { super(container, 'link', zIndex, true, colors, rendererId, bufferService, optionsService); linkifier.onShowLinkUnderline(e => this._onShowLinkUnderline(e)); diff --git a/src/browser/renderer/Renderer.ts b/src/browser/renderer/Renderer.ts index b9d02ff8..bcfae266 100644 --- a/src/browser/renderer/Renderer.ts +++ b/src/browser/renderer/Renderer.ts @@ -6,13 +6,12 @@ import { TextRenderLayer } from 'browser/renderer/TextRenderLayer'; import { SelectionRenderLayer } from 'browser/renderer/SelectionRenderLayer'; import { CursorRenderLayer } from 'browser/renderer/CursorRenderLayer'; -import { IRenderLayer, IRenderer, IRenderDimensions, CharacterJoinerHandler, ICharacterJoinerRegistry, IRequestRedrawEvent } from 'browser/renderer/Types'; +import { IRenderLayer, IRenderer, IRenderDimensions, IRequestRedrawEvent } from 'browser/renderer/Types'; import { LinkRenderLayer } from 'browser/renderer/LinkRenderLayer'; -import { CharacterJoinerRegistry } from 'browser/renderer/CharacterJoinerRegistry'; import { Disposable } from 'common/Lifecycle'; import { IColorSet, ILinkifier, ILinkifier2 } from 'browser/Types'; import { ICharSizeService, ICoreBrowserService } from 'browser/services/Services'; -import { IBufferService, IOptionsService, ICoreService } from 'common/services/Services'; +import { IBufferService, IOptionsService, ICoreService, IInstantiationService } from 'common/services/Services'; import { removeTerminalFromCache } from 'browser/renderer/atlas/CharAtlasCache'; import { EventEmitter, IEvent } from 'common/EventEmitter'; @@ -23,7 +22,6 @@ export class Renderer extends Disposable implements IRenderer { private _renderLayers: IRenderLayer[]; private _devicePixelRatio: number; - private _characterJoinerRegistry: ICharacterJoinerRegistry; public dimensions: IRenderDimensions; @@ -35,20 +33,18 @@ export class Renderer extends Disposable implements IRenderer { private readonly _screenElement: HTMLElement, linkifier: ILinkifier, linkifier2: ILinkifier2, + instantiationService: IInstantiationService, @IBufferService private readonly _bufferService: IBufferService, @ICharSizeService private readonly _charSizeService: ICharSizeService, @IOptionsService private readonly _optionsService: IOptionsService, - @ICoreService coreService: ICoreService, - @ICoreBrowserService coreBrowserService: ICoreBrowserService ) { super(); const allowTransparency = this._optionsService.options.allowTransparency; - this._characterJoinerRegistry = new CharacterJoinerRegistry(this._bufferService); this._renderLayers = [ - new TextRenderLayer(this._screenElement, 0, this._colors, this._characterJoinerRegistry, allowTransparency, this._id, this._bufferService, _optionsService), - new SelectionRenderLayer(this._screenElement, 1, this._colors, this._id, this._bufferService, _optionsService), - new LinkRenderLayer(this._screenElement, 2, this._colors, this._id, linkifier, linkifier2, this._bufferService, _optionsService), - new CursorRenderLayer(this._screenElement, 3, this._colors, this._id, this._onRequestRedraw, this._bufferService, _optionsService, coreService, coreBrowserService) + instantiationService.createInstance(TextRenderLayer, this._screenElement, 0, this._colors, allowTransparency, this._id), + instantiationService.createInstance(SelectionRenderLayer, this._screenElement, 1, this._colors, this._id), + instantiationService.createInstance(LinkRenderLayer, this._screenElement, 2, this._colors, this._id, linkifier, linkifier2), + instantiationService.createInstance(CursorRenderLayer, this._screenElement, 3, this._colors, this._id, this._onRequestRedraw) ]; this.dimensions = { scaledCharWidth: 0, @@ -210,12 +206,4 @@ export class Renderer extends Disposable implements IRenderer { this.dimensions.actualCellHeight = this.dimensions.canvasHeight / this._bufferService.rows; this.dimensions.actualCellWidth = this.dimensions.canvasWidth / this._bufferService.cols; } - - public registerCharacterJoiner(handler: CharacterJoinerHandler): number { - return this._characterJoinerRegistry.registerCharacterJoiner(handler); - } - - public deregisterCharacterJoiner(joinerId: number): boolean { - return this._characterJoinerRegistry.deregisterCharacterJoiner(joinerId); - } } diff --git a/src/browser/renderer/SelectionRenderLayer.ts b/src/browser/renderer/SelectionRenderLayer.ts index 80022f01..9054e3ca 100644 --- a/src/browser/renderer/SelectionRenderLayer.ts +++ b/src/browser/renderer/SelectionRenderLayer.ts @@ -23,8 +23,8 @@ export class SelectionRenderLayer extends BaseRenderLayer { zIndex: number, colors: IColorSet, rendererId: number, - bufferService: IBufferService, - optionsService: IOptionsService + @IBufferService bufferService: IBufferService, + @IOptionsService optionsService: IOptionsService ) { super(container, 'selection', zIndex, true, colors, rendererId, bufferService, optionsService); this._clearState(); diff --git a/src/browser/renderer/TextRenderLayer.ts b/src/browser/renderer/TextRenderLayer.ts index 1f35fae1..48bf848e 100644 --- a/src/browser/renderer/TextRenderLayer.ts +++ b/src/browser/renderer/TextRenderLayer.ts @@ -3,16 +3,17 @@ * @license MIT */ -import { ICharacterJoinerRegistry, IRenderDimensions } from 'browser/renderer/Types'; +import { IRenderDimensions } from 'browser/renderer/Types'; import { CharData, ICellData } from 'common/Types'; import { GridCache } from 'browser/renderer/GridCache'; import { BaseRenderLayer } from 'browser/renderer/BaseRenderLayer'; import { AttributeData } from 'common/buffer/AttributeData'; import { NULL_CELL_CODE, Content } from 'common/buffer/Constants'; -import { JoinedCellData } from 'browser/renderer/CharacterJoinerRegistry'; import { IColorSet } from 'browser/Types'; import { CellData } from 'common/buffer/CellData'; import { IOptionsService, IBufferService } from 'common/services/Services'; +import { ICharacterJoinerService } from 'browser/services/Services'; +import { JoinedCellData } from 'browser/services/CharacterJoinerService'; /** * This CharData looks like a null character, which will forc a clear and render @@ -26,22 +27,20 @@ export class TextRenderLayer extends BaseRenderLayer { private _characterWidth: number = 0; private _characterFont: string = ''; private _characterOverlapCache: { [key: string]: boolean } = {}; - private _characterJoinerRegistry: ICharacterJoinerRegistry; private _workCell = new CellData(); constructor( container: HTMLElement, zIndex: number, colors: IColorSet, - characterJoinerRegistry: ICharacterJoinerRegistry, alpha: boolean, rendererId: number, - bufferService: IBufferService, - optionsService: IOptionsService + @IBufferService bufferService: IBufferService, + @IOptionsService optionsService: IOptionsService, + @ICharacterJoinerService private readonly _characterJoinerService: ICharacterJoinerService ) { super(container, 'text', zIndex, alpha, colors, rendererId, bufferService, optionsService); this._state = new GridCache(); - this._characterJoinerRegistry = characterJoinerRegistry; } public resize(dim: IRenderDimensions): void { @@ -67,7 +66,6 @@ export class TextRenderLayer extends BaseRenderLayer { private _forEachCell( firstRow: number, lastRow: number, - joinerRegistry: ICharacterJoinerRegistry | null, callback: ( cell: ICellData, x: number, @@ -77,7 +75,7 @@ export class TextRenderLayer extends BaseRenderLayer { for (let y = firstRow; y <= lastRow; y++) { const row = y + this._bufferService.buffer.ydisp; const line = this._bufferService.buffer.lines.get(row); - const joinedRanges = joinerRegistry ? joinerRegistry.getJoinedCharacters(row) : []; + const joinedRanges = this._characterJoinerService.getJoinedCharacters(row); for (let x = 0; x < this._bufferService.cols; x++) { line!.loadCell(x, this._workCell); let cell = this._workCell; @@ -160,7 +158,7 @@ export class TextRenderLayer extends BaseRenderLayer { ctx.save(); - this._forEachCell(firstRow, lastRow, null, (cell, x, y) => { + this._forEachCell(firstRow, lastRow, (cell, x, y) => { // libvte and xterm both draw the background (but not foreground) of invisible characters, // so we should too. let nextFillStyle = null; // null represents default background color @@ -213,7 +211,7 @@ export class TextRenderLayer extends BaseRenderLayer { } private _drawForeground(firstRow: number, lastRow: number): void { - this._forEachCell(firstRow, lastRow, this._characterJoinerRegistry, (cell, x, y) => { + this._forEachCell(firstRow, lastRow, (cell, x, y) => { if (cell.isInvisible()) { return; } diff --git a/src/browser/renderer/Types.d.ts b/src/browser/renderer/Types.d.ts index cab14b88..fc137bc8 100644 --- a/src/browser/renderer/Types.d.ts +++ b/src/browser/renderer/Types.d.ts @@ -7,8 +7,6 @@ import { IDisposable } from 'common/Types'; import { IColorSet } from 'browser/Types'; import { IEvent } from 'common/EventEmitter'; -export type CharacterJoinerHandler = (text: string) => [number, number][]; - export interface IRenderDimensions { scaledCharWidth: number; scaledCharHeight: number; @@ -54,19 +52,6 @@ export interface IRenderer extends IDisposable { onOptionsChanged(): void; clear(): void; renderRows(start: number, end: number): void; - registerCharacterJoiner(handler: CharacterJoinerHandler): number; - deregisterCharacterJoiner(joinerId: number): boolean; -} - -export interface ICharacterJoiner { - id: number; - handler: CharacterJoinerHandler; -} - -export interface ICharacterJoinerRegistry { - registerCharacterJoiner(handler: (text: string) => [number, number][]): number; - deregisterCharacterJoiner(joinerId: number): boolean; - getJoinedCharacters(row: number): [number, number][]; } export interface IRenderLayer extends IDisposable { @@ -106,16 +91,6 @@ export interface IRenderLayer extends IDisposable { */ onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void; - /** - * Registers a handler to join characters to render as a group - */ - registerCharacterJoiner?(joiner: ICharacterJoiner): void; - - /** - * Deregisters the specified character joiner handler - */ - deregisterCharacterJoiner?(joinerId: number): void; - /** * Resize the render layer. */ diff --git a/src/browser/renderer/dom/DomRenderer.ts b/src/browser/renderer/dom/DomRenderer.ts index f0a92259..8dd1ac0e 100644 --- a/src/browser/renderer/dom/DomRenderer.ts +++ b/src/browser/renderer/dom/DomRenderer.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { IRenderer, IRenderDimensions, CharacterJoinerHandler, IRequestRedrawEvent } from 'browser/renderer/Types'; +import { IRenderer, IRenderDimensions, IRequestRedrawEvent } from 'browser/renderer/Types'; import { BOLD_CLASS, ITALIC_CLASS, CURSOR_CLASS, CURSOR_STYLE_BLOCK_CLASS, CURSOR_BLINK_CLASS, CURSOR_STYLE_BAR_CLASS, CURSOR_STYLE_UNDERLINE_CLASS, DomRendererRowFactory } from 'browser/renderer/dom/DomRendererRowFactory'; import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants'; import { Disposable } from 'common/Lifecycle'; @@ -372,9 +372,6 @@ export class DomRenderer extends Disposable implements IRenderer { return `.${TERMINAL_CLASS_PREFIX}${this._terminalClass}`; } - public registerCharacterJoiner(handler: CharacterJoinerHandler): number { return -1; } - public deregisterCharacterJoiner(joinerId: number): boolean { return false; } - private _onLinkHover(e: ILinkifierEvent): void { this._setCellUnderline(e.x1, e.x2, e.y1, e.y2, e.cols, true); } diff --git a/src/browser/renderer/CharacterJoinerRegistry.test.ts b/src/browser/services/CharacterJoinerService.test.ts similarity index 60% rename from src/browser/renderer/CharacterJoinerRegistry.test.ts rename to src/browser/services/CharacterJoinerService.test.ts index bca12d6b..94abc4d5 100644 --- a/src/browser/renderer/CharacterJoinerRegistry.test.ts +++ b/src/browser/services/CharacterJoinerService.test.ts @@ -4,15 +4,15 @@ */ import { assert } from 'chai'; -import { ICharacterJoinerRegistry } from 'browser/renderer/Types'; -import { CharacterJoinerRegistry } from 'browser/renderer/CharacterJoinerRegistry'; +import { ICharacterJoinerService } from 'browser/services/Services'; +import { CharacterJoinerService } from 'browser/services/CharacterJoinerService'; import { BufferLine } from 'common/buffer/BufferLine'; import { IBufferLine } from 'common/Types'; import { CellData } from 'common/buffer/CellData'; import { MockBufferService } from 'common/TestUtils.test'; -describe('CharacterJoinerRegistry', () => { - let registry: ICharacterJoinerRegistry; +describe('CharacterJoinerService', () => { + let service: ICharacterJoinerService; beforeEach(() => { const bufferService = new MockBufferService(16, 10); @@ -39,225 +39,225 @@ describe('CharacterJoinerRegistry', () => { for (let i = 0; i < sub.length; ++i) line6.setCell(i + oldSize, sub.loadCell(i, new CellData())); lines.set(6, line6); - registry = new CharacterJoinerRegistry(bufferService); + service = new CharacterJoinerService(bufferService); }); it('has no joiners upon creation', () => { - assert.deepEqual(registry.getJoinedCharacters(0), []); + assert.deepEqual(service.getJoinedCharacters(0), []); }); it('returns ranges matched by the registered joiners', () => { - registry.registerCharacterJoiner(substringJoiner('->')); + service.register(substringJoiner('->')); assert.deepEqual( - registry.getJoinedCharacters(0), + service.getJoinedCharacters(0), [[2, 4], [7, 9], [12, 14]] ); }); it('processes the input using all provided joiners', () => { - registry.registerCharacterJoiner(substringJoiner('->')); + service.register(substringJoiner('->')); assert.deepEqual( - registry.getJoinedCharacters(1), + service.getJoinedCharacters(1), [[2, 4], [12, 14]] ); - registry.registerCharacterJoiner(substringJoiner('=>')); + service.register(substringJoiner('=>')); assert.deepEqual( - registry.getJoinedCharacters(1), + service.getJoinedCharacters(1), [[2, 4], [7, 9], [12, 14]] ); }); it('removes deregistered joiners from future calls', () => { - const joiner1 = registry.registerCharacterJoiner(substringJoiner('->')); - const joiner2 = registry.registerCharacterJoiner(substringJoiner('=>')); + const joiner1 = service.register(substringJoiner('->')); + const joiner2 = service.register(substringJoiner('=>')); assert.deepEqual( - registry.getJoinedCharacters(1), + service.getJoinedCharacters(1), [[2, 4], [7, 9], [12, 14]] ); - registry.deregisterCharacterJoiner(joiner1); + service.deregister(joiner1); assert.deepEqual( - registry.getJoinedCharacters(1), + service.getJoinedCharacters(1), [[7, 9]] ); - registry.deregisterCharacterJoiner(joiner2); + service.deregister(joiner2); assert.deepEqual( - registry.getJoinedCharacters(1), + service.getJoinedCharacters(1), [] ); }); it('doesn\'t process joins on differently-styled characters', () => { - registry.registerCharacterJoiner(substringJoiner('->')); + service.register(substringJoiner('->')); assert.deepEqual( - registry.getJoinedCharacters(2), + service.getJoinedCharacters(2), [[2, 4], [12, 14]] ); }); it('returns an empty list of ranges if there is nothing to be joined', () => { - registry.registerCharacterJoiner(substringJoiner('->')); + service.register(substringJoiner('->')); assert.deepEqual( - registry.getJoinedCharacters(3), + service.getJoinedCharacters(3), [] ); }); it('returns an empty list of ranges if the line is empty', () => { - registry.registerCharacterJoiner(substringJoiner('->')); + service.register(substringJoiner('->')); assert.deepEqual( - registry.getJoinedCharacters(4), + service.getJoinedCharacters(4), [] ); }); it('returns false when trying to deregister a joiner that does not exist', () => { - registry.registerCharacterJoiner(substringJoiner('->')); - assert.deepEqual(registry.deregisterCharacterJoiner(123), false); + service.register(substringJoiner('->')); + assert.deepEqual(service.deregister(123), false); assert.deepEqual( - registry.getJoinedCharacters(0), + service.getJoinedCharacters(0), [[2, 4], [7, 9], [12, 14]] ); }); it('doesn\'t process same-styled ranges that only have one character', () => { - registry.registerCharacterJoiner(substringJoiner('a')); - registry.registerCharacterJoiner(substringJoiner('b')); - registry.registerCharacterJoiner(substringJoiner('d')); + service.register(substringJoiner('a')); + service.register(substringJoiner('b')); + service.register(substringJoiner('d')); assert.deepEqual( - registry.getJoinedCharacters(5), + service.getJoinedCharacters(5), [[5, 6]] ); }); it('handles ranges that extend all the way to the end of the line', () => { - registry.registerCharacterJoiner(substringJoiner('-> d')); + service.register(substringJoiner('-> d')); assert.deepEqual( - registry.getJoinedCharacters(2), + service.getJoinedCharacters(2), [[12, 16]] ); }); it('handles adjacent ranges', () => { - registry.registerCharacterJoiner(substringJoiner('->')); - registry.registerCharacterJoiner(substringJoiner('> c ')); + service.register(substringJoiner('->')); + service.register(substringJoiner('> c ')); assert.deepEqual( - registry.getJoinedCharacters(2), + service.getJoinedCharacters(2), [[2, 4], [8, 12], [12, 14]] ); }); it('handles fullwidth characters in the middle of ranges', () => { - registry.registerCharacterJoiner(substringJoiner('wi¥de')); + service.register(substringJoiner('wi¥de')); assert.deepEqual( - registry.getJoinedCharacters(6), + service.getJoinedCharacters(6), [[0, 6]] ); }); it('handles fullwidth characters at the end of ranges', () => { - registry.registerCharacterJoiner(substringJoiner('wi¥')); + service.register(substringJoiner('wi¥')); assert.deepEqual( - registry.getJoinedCharacters(6), + service.getJoinedCharacters(6), [[0, 4]] ); }); it('handles emojis in the middle of ranges', () => { - registry.registerCharacterJoiner(substringJoiner('emo\xf0\x9f\x98\x81 ji')); + service.register(substringJoiner('emo\xf0\x9f\x98\x81 ji')); assert.deepEqual( - registry.getJoinedCharacters(6), + service.getJoinedCharacters(6), [[6, 13]] ); }); it('handles emojis at the end of ranges', () => { - registry.registerCharacterJoiner(substringJoiner('emo\xf0\x9f\x98\x81 ')); + service.register(substringJoiner('emo\xf0\x9f\x98\x81 ')); assert.deepEqual( - registry.getJoinedCharacters(6), + service.getJoinedCharacters(6), [[6, 11]] ); }); it('handles ranges after wide and emoji characters', () => { - registry.registerCharacterJoiner(substringJoiner('abc')); + service.register(substringJoiner('abc')); assert.deepEqual( - registry.getJoinedCharacters(6), + service.getJoinedCharacters(6), [[13, 16]] ); }); describe('range merging', () => { it('inserts a new range before the existing ones', () => { - registry.registerCharacterJoiner(() => [[1, 2], [2, 3]]); - registry.registerCharacterJoiner(() => [[0, 1]]); + service.register(() => [[1, 2], [2, 3]]); + service.register(() => [[0, 1]]); assert.deepEqual( - registry.getJoinedCharacters(0), + service.getJoinedCharacters(0), [[0, 1], [1, 2], [2, 3]] ); }); it('inserts in between two ranges', () => { - registry.registerCharacterJoiner(() => [[0, 2], [4, 6]]); - registry.registerCharacterJoiner(() => [[2, 4]]); + service.register(() => [[0, 2], [4, 6]]); + service.register(() => [[2, 4]]); assert.deepEqual( - registry.getJoinedCharacters(0), + service.getJoinedCharacters(0), [[0, 2], [2, 4], [4, 6]] ); }); it('inserts after the last range', () => { - registry.registerCharacterJoiner(() => [[0, 2], [4, 6]]); - registry.registerCharacterJoiner(() => [[6, 8]]); + service.register(() => [[0, 2], [4, 6]]); + service.register(() => [[6, 8]]); assert.deepEqual( - registry.getJoinedCharacters(0), + service.getJoinedCharacters(0), [[0, 2], [4, 6], [6, 8]] ); }); it('extends the beginning of a range', () => { - registry.registerCharacterJoiner(() => [[0, 2], [4, 6]]); - registry.registerCharacterJoiner(() => [[3, 5]]); + service.register(() => [[0, 2], [4, 6]]); + service.register(() => [[3, 5]]); assert.deepEqual( - registry.getJoinedCharacters(0), + service.getJoinedCharacters(0), [[0, 2], [3, 6]] ); }); it('extends the end of a range', () => { - registry.registerCharacterJoiner(() => [[0, 2], [4, 6]]); - registry.registerCharacterJoiner(() => [[1, 4]]); + service.register(() => [[0, 2], [4, 6]]); + service.register(() => [[1, 4]]); assert.deepEqual( - registry.getJoinedCharacters(0), + service.getJoinedCharacters(0), [[0, 4], [4, 6]] ); }); it('extends the last range', () => { - registry.registerCharacterJoiner(() => [[0, 2], [4, 6]]); - registry.registerCharacterJoiner(() => [[5, 7]]); + service.register(() => [[0, 2], [4, 6]]); + service.register(() => [[5, 7]]); assert.deepEqual( - registry.getJoinedCharacters(0), + service.getJoinedCharacters(0), [[0, 2], [4, 7]] ); }); it('connects two ranges', () => { - registry.registerCharacterJoiner(() => [[0, 2], [4, 6]]); - registry.registerCharacterJoiner(() => [[1, 5]]); + service.register(() => [[0, 2], [4, 6]]); + service.register(() => [[1, 5]]); assert.deepEqual( - registry.getJoinedCharacters(0), + service.getJoinedCharacters(0), [[0, 6]] ); }); it('connects more than two ranges', () => { - registry.registerCharacterJoiner(() => [[0, 2], [4, 6], [8, 10], [12, 14]]); - registry.registerCharacterJoiner(() => [[1, 10]]); + service.register(() => [[0, 2], [4, 6], [8, 10], [12, 14]]); + service.register(() => [[1, 10]]); assert.deepEqual( - registry.getJoinedCharacters(0), + service.getJoinedCharacters(0), [[0, 10], [12, 14]] ); }); diff --git a/src/browser/renderer/CharacterJoinerRegistry.ts b/src/browser/services/CharacterJoinerService.ts similarity index 95% rename from src/browser/renderer/CharacterJoinerRegistry.ts rename to src/browser/services/CharacterJoinerService.ts index 5385b76b..ea65c29b 100644 --- a/src/browser/renderer/CharacterJoinerRegistry.ts +++ b/src/browser/services/CharacterJoinerService.ts @@ -4,11 +4,12 @@ */ import { IBufferLine, ICellData, CharData } from 'common/Types'; -import { ICharacterJoinerRegistry, ICharacterJoiner } from 'browser/renderer/Types'; +import { ICharacterJoiner } from 'browser/Types'; import { AttributeData } from 'common/buffer/AttributeData'; import { WHITESPACE_CELL_CHAR, Content } from 'common/buffer/Constants'; import { CellData } from 'common/buffer/CellData'; import { IBufferService } from 'common/services/Services'; +import { ICharacterJoinerService } from 'browser/services/Services'; export class JoinedCellData extends AttributeData implements ICellData { private _width: number; @@ -55,15 +56,18 @@ export class JoinedCellData extends AttributeData implements ICellData { } } -export class CharacterJoinerRegistry implements ICharacterJoinerRegistry { +export class CharacterJoinerService implements ICharacterJoinerService { + public serviceBrand: undefined; private _characterJoiners: ICharacterJoiner[] = []; private _nextCharacterJoinerId: number = 0; private _workCell: CellData = new CellData(); - constructor(private _bufferService: IBufferService) { } + constructor( + @IBufferService private _bufferService: IBufferService + ) { } - public registerCharacterJoiner(handler: (text: string) => [number, number][]): number { + public register(handler: (text: string) => [number, number][]): number { const joiner: ICharacterJoiner = { id: this._nextCharacterJoinerId++, handler @@ -73,7 +77,7 @@ export class CharacterJoinerRegistry implements ICharacterJoinerRegistry { return joiner.id; } - public deregisterCharacterJoiner(joinerId: number): boolean { + public deregister(joinerId: number): boolean { for (let i = 0; i < this._characterJoiners.length; i++) { if (this._characterJoiners[i].id === joinerId) { this._characterJoiners.splice(i, 1); @@ -177,7 +181,7 @@ export class CharacterJoinerRegistry implements ICharacterJoinerRegistry { // We merge any overlapping ranges across the different joiners const joinerRanges = this._characterJoiners[i].handler(text); for (let j = 0; j < joinerRanges.length; j++) { - CharacterJoinerRegistry._mergeRanges(joinedRanges, joinerRanges[j]); + CharacterJoinerService._mergeRanges(joinedRanges, joinerRanges[j]); } } this._stringRangesToCellRanges(joinedRanges, lineData, startCol); diff --git a/src/browser/services/RenderService.ts b/src/browser/services/RenderService.ts index 51971091..fc2eb435 100644 --- a/src/browser/services/RenderService.ts +++ b/src/browser/services/RenderService.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { IRenderer, IRenderDimensions, CharacterJoinerHandler } from 'browser/renderer/Types'; +import { IRenderer, IRenderDimensions } from 'browser/renderer/Types'; import { RenderDebouncer } from 'browser/RenderDebouncer'; import { EventEmitter, IEvent } from 'common/EventEmitter'; import { Disposable } from 'common/Lifecycle'; @@ -214,12 +214,4 @@ export class RenderService extends Disposable implements IRenderService { public clear(): void { this._renderer.clear(); } - - public registerCharacterJoiner(handler: CharacterJoinerHandler): number { - return this._renderer.registerCharacterJoiner(handler); - } - - public deregisterCharacterJoiner(joinerId: number): boolean { - return this._renderer.deregisterCharacterJoiner(joinerId); - } } diff --git a/src/browser/services/Services.ts b/src/browser/services/Services.ts index f06e320b..8c8a7bd9 100644 --- a/src/browser/services/Services.ts +++ b/src/browser/services/Services.ts @@ -4,7 +4,7 @@ */ import { IEvent } from 'common/EventEmitter'; -import { IRenderDimensions, IRenderer, CharacterJoinerHandler } from 'browser/renderer/Types'; +import { IRenderDimensions, IRenderer } from 'browser/renderer/Types'; import { IColorSet } from 'browser/Types'; import { ISelectionRedrawRequestEvent as ISelectionRequestRedrawEvent, ISelectionRequestScrollLinesEvent } from 'browser/selection/Types'; import { createDecorator } from 'common/services/ServiceRegistry'; @@ -66,8 +66,6 @@ export interface IRenderService extends IDisposable { onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void; onCursorMove(): void; clear(): void; - registerCharacterJoiner(handler: CharacterJoinerHandler): number; - deregisterCharacterJoiner(joinerId: number): boolean; } export const ISelectionService = createDecorator('SelectionService'); @@ -104,3 +102,13 @@ export interface ISoundService { playBellSound(): void; } + + +export const ICharacterJoinerService = createDecorator('CharacterJoinerService'); +export interface ICharacterJoinerService { + serviceBrand: undefined; + + register(handler: (text: string) => [number, number][]): number; + deregister(joinerId: number): boolean; + getJoinedCharacters(row: number): [number, number][]; +} From b511f1b52aa5e82b817beccc9ac80b300518616c Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 2 Apr 2021 07:46:30 -0700 Subject: [PATCH 161/377] Fix other case of no spacing --- src/common/CoreTerminal.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 699a1b1c..815326d6 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -122,7 +122,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this.register(forwardEvent(this._coreService.onBinary, this._onBinary)); this.register(this.optionsService.onOptionChange(key => this._updateOptions(key))); this.register(this._bufferService.onScroll(event => { - this._onScroll.fire({position: this._bufferService.buffer.ydisp, source: ScrollSource.TERMINAL}); + this._onScroll.fire({ position: this._bufferService.buffer.ydisp, source: ScrollSource.TERMINAL }); this._dirtyRowService.markRangeDirty(this._bufferService.buffer.scrollTop, this._bufferService.buffer.scrollBottom); })); From 5f96f33cf03b739ccb9c7ee339f7eeacabacd3f8 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 2 Apr 2021 07:50:22 -0700 Subject: [PATCH 162/377] Fix dangling comma --- src/browser/renderer/Renderer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/renderer/Renderer.ts b/src/browser/renderer/Renderer.ts index bcfae266..c88ce256 100644 --- a/src/browser/renderer/Renderer.ts +++ b/src/browser/renderer/Renderer.ts @@ -36,7 +36,7 @@ export class Renderer extends Disposable implements IRenderer { instantiationService: IInstantiationService, @IBufferService private readonly _bufferService: IBufferService, @ICharSizeService private readonly _charSizeService: ICharSizeService, - @IOptionsService private readonly _optionsService: IOptionsService, + @IOptionsService private readonly _optionsService: IOptionsService ) { super(); const allowTransparency = this._optionsService.options.allowTransparency; From 1124f8b5139518f06c89d4aa0951fe3922c00f20 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 2 Apr 2021 07:57:24 -0700 Subject: [PATCH 163/377] Improve error when adding char joiner before open --- src/browser/Terminal.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index d0c698a6..2525fd57 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -919,13 +919,19 @@ export class Terminal extends CoreTerminal implements ITerminal { } public registerCharacterJoiner(handler: CharacterJoinerHandler): number { - const joinerId = this._characterJoinerService!.register(handler); + if (!this._characterJoinerService) { + throw new Error('Terminal must be opened first'); + } + const joinerId = this._characterJoinerService.register(handler); this.refresh(0, this.rows - 1); return joinerId; } public deregisterCharacterJoiner(joinerId: number): void { - if (this._characterJoinerService!.deregister(joinerId)) { + if (!this._characterJoinerService) { + throw new Error('Terminal must be opened first'); + } + if (this._characterJoinerService.deregister(joinerId)) { this.refresh(0, this.rows - 1); } } From 4fa58c978b143e337cc7dec5b3b68d544be14c40 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 2 Apr 2021 07:58:59 -0700 Subject: [PATCH 164/377] Fix lint --- addons/xterm-addon-ligatures/src/font.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/xterm-addon-ligatures/src/font.ts b/addons/xterm-addon-ligatures/src/font.ts index 0d01d3cc..7a8e8985 100644 --- a/addons/xterm-addon-ligatures/src/font.ts +++ b/addons/xterm-addon-ligatures/src/font.ts @@ -3,8 +3,8 @@ * @license MIT */ -import {FontList} from 'font-finder'; -import {Font, loadBuffer, loadFile} from 'font-ligatures'; +import { FontList } from 'font-finder'; +import { Font, loadBuffer, loadFile } from 'font-ligatures'; import parse from './parse'; @@ -74,9 +74,9 @@ export default async function load(fontFamily: string, cacheSize: number): Promi if (fonts.hasOwnProperty(family) && fonts[family].length > 0) { const font = fonts[family][0]; if ('blob' in font) { - return loadBuffer(await (await font.blob()).arrayBuffer(), {cacheSize}); + return loadBuffer(await (await font.blob()).arrayBuffer(), { cacheSize }); } - return await loadFile(font.path, {cacheSize}); + return await loadFile(font.path, { cacheSize }); } } From a57910e2fa479d95c7b1d8fe690948ec33ecde17 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 2 Apr 2021 08:33:00 -0700 Subject: [PATCH 165/377] Check navigator safely in node --- addons/xterm-addon-ligatures/src/font.ts | 73 +++++++++++++----------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/addons/xterm-addon-ligatures/src/font.ts b/addons/xterm-addon-ligatures/src/font.ts index 7a8e8985..fca110a4 100644 --- a/addons/xterm-addon-ligatures/src/font.ts +++ b/addons/xterm-addon-ligatures/src/font.ts @@ -24,40 +24,47 @@ let fontsPromise: Promise> | undefine * @param cacheSize The size of the ligature cache to maintain if the font is resolved */ export default async function load(fontFamily: string, cacheSize: number): Promise { - if (!fontsPromise && 'fonts' in navigator) { - try { - const status = await (navigator as any).permissions.request?.({ - name: 'local-fonts' - }); - if (status && status.state !== 'granted') { - throw new Error('Permission to access local fonts not granted.'); - } - } catch (err) { - // A `TypeError` indicates the 'local-fonts' - // permission is not yet implemented, so - // only `throw` if this is _not_ the problem. - if (err.name !== 'TypeError') { - throw err; - } - } - const fonts: Record = {}; - try { - const fontsIterator: AsyncIterableIterator = (navigator as any).fonts.query(); - for await (const metadata of fontsIterator) { - if (!fonts.hasOwnProperty(metadata.family)) { - fonts[metadata.family] = []; - } - fonts[metadata.family].push(metadata); - } - fontsPromise = Promise.resolve(fonts); - } catch (err) { - console.error(err.name, err.message); - } - } if (!fontsPromise) { - try { - fontsPromise = (await import('font-finder')).list(); - } catch (err) { + // Web environment that supports font access API + if (typeof navigator !== 'undefined' && 'fonts' in navigator) { + try { + const status = await (navigator as any).permissions.request?.({ + name: 'local-fonts' + }); + if (status && status.state !== 'granted') { + throw new Error('Permission to access local fonts not granted.'); + } + } catch (err) { + // A `TypeError` indicates the 'local-fonts' + // permission is not yet implemented, so + // only `throw` if this is _not_ the problem. + if (err.name !== 'TypeError') { + throw err; + } + } + const fonts: Record = {}; + try { + const fontsIterator: AsyncIterableIterator = (navigator as any).fonts.query(); + for await (const metadata of fontsIterator) { + if (!fonts.hasOwnProperty(metadata.family)) { + fonts[metadata.family] = []; + } + fonts[metadata.family].push(metadata); + } + fontsPromise = Promise.resolve(fonts); + } catch (err) { + console.error(err.name, err.message); + } + } + // Node environment or no font access API + else { + try { + fontsPromise = (await import('font-finder')).list(); + } catch (err) { + // No-op + } + } + if (!fontsPromise) { fontsPromise = Promise.resolve({}); } } From 0564ad465305a0c105c164fbd15e3aa1d7fbaed4 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 2 Apr 2021 09:42:10 -0700 Subject: [PATCH 166/377] Add comments to webpack configs --- addons/xterm-addon-ligatures/webpack.config.js | 1 + demo/start.js | 1 + 2 files changed, 2 insertions(+) diff --git a/addons/xterm-addon-ligatures/webpack.config.js b/addons/xterm-addon-ligatures/webpack.config.js index 6bdbd156..ea69841e 100644 --- a/addons/xterm-addon-ligatures/webpack.config.js +++ b/addons/xterm-addon-ligatures/webpack.config.js @@ -36,6 +36,7 @@ module.exports = { 'util': 'util' }, resolve: { + // The ligature modules contains fallbacks for node environments, we never want to browserify them fallback: { stream: false, util: false, diff --git a/demo/start.js b/demo/start.js index c4caea77..b40b9bc3 100644 --- a/demo/start.js +++ b/demo/start.js @@ -51,6 +51,7 @@ const clientConfig = { browser: path.resolve('./out/browser') }, fallback: { + // The ligature modules contains fallbacks for node environments, we never want to browserify them stream: false, util: false, os: false, From d8113aa5335134851e01592d87d7179ac372c913 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 2 Apr 2021 10:21:20 -0700 Subject: [PATCH 167/377] Default to Fira Code in demo --- demo/client.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/demo/client.ts b/demo/client.ts index 780597e3..0bb124cd 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -157,7 +157,8 @@ function createTerminal(): void { const isWindows = ['Windows', 'Win16', 'Win32', 'WinCE'].indexOf(navigator.platform) >= 0; term = new Terminal({ - windowsMode: isWindows + windowsMode: isWindows, + fontFamily: 'Fira Code, courier-new, courier, monospace' } as ITerminalOptions); // Load addons From b7320794bbf04914ededf769d2724502f181a019 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 2 Apr 2021 10:34:14 -0700 Subject: [PATCH 168/377] Ligature support for dom renderer Fixes #3283 --- css/xterm.css | 1 - src/browser/Terminal.ts | 2 +- src/browser/TestUtils.test.ts | 15 +++- src/browser/renderer/Renderer.ts | 2 +- src/browser/renderer/dom/DomRenderer.ts | 7 +- .../dom/DomRendererRowFactory.test.ts | 39 ++++----- .../renderer/dom/DomRendererRowFactory.ts | 80 +++++++++++++++---- src/common/services/InstantiationService.ts | 2 + src/common/services/Services.ts | 2 + 9 files changed, 108 insertions(+), 42 deletions(-) diff --git a/css/xterm.css b/css/xterm.css index 7ddcc2d0..831a89c6 100644 --- a/css/xterm.css +++ b/css/xterm.css @@ -36,7 +36,6 @@ */ .xterm { - font-feature-settings: "liga" 0; position: relative; user-select: none; -ms-user-select: none; diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 2525fd57..76c7716f 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -555,7 +555,7 @@ export class Terminal extends CoreTerminal implements ITerminal { private _createRenderer(): IRenderer { switch (this.options.rendererType) { - case 'canvas': return this._instantiationService.createInstance(Renderer, this._colorManager!.colors, this.screenElement!, this.linkifier, this.linkifier2, this._instantiationService); + case 'canvas': return this._instantiationService.createInstance(Renderer, this._colorManager!.colors, this.screenElement!, this.linkifier, this.linkifier2); case 'dom': return this._instantiationService.createInstance(DomRenderer, this._colorManager!.colors, this.element!, this.screenElement!, this._viewportElement!, this.linkifier, this.linkifier2); default: throw new Error(`Unrecognized rendererType "${this.options.rendererType}"`); } diff --git a/src/browser/TestUtils.test.ts b/src/browser/TestUtils.test.ts index 7ab7d9b1..c577b566 100644 --- a/src/browser/TestUtils.test.ts +++ b/src/browser/TestUtils.test.ts @@ -5,7 +5,7 @@ import { IDisposable, IMarker, ISelectionPosition, ILinkProvider } from 'xterm'; import { IEvent, EventEmitter } from 'common/EventEmitter'; -import { ICharSizeService, IMouseService, IRenderService, ISelectionService } from 'browser/services/Services'; +import { ICharacterJoinerService, ICharSizeService, IMouseService, IRenderService, ISelectionService } from 'browser/services/Services'; import { IRenderDimensions, IRenderer, IRequestRedrawEvent } from 'browser/renderer/Types'; import { IColorSet, ILinkMatcherOptions, ITerminal, ILinkifier, ILinkifier2, IBrowser, IViewport, IColorManager, ICompositionHelper, CharacterJoinerHandler } from 'browser/Types'; import { IBuffer, IBufferStringIterator, IBufferSet } from 'common/buffer/Types'; @@ -411,3 +411,16 @@ export class MockRenderService implements IRenderService { throw new Error('Method not implemented.'); } } + +export class MockCharacterJoinerService implements ICharacterJoinerService { + public serviceBrand: undefined; + public register(handler: (text: string) => [number, number][]): number { + return 0; + } + public deregister(joinerId: number): boolean { + return true; + } + public getJoinedCharacters(row: number): [number, number][] { + return []; + } +} diff --git a/src/browser/renderer/Renderer.ts b/src/browser/renderer/Renderer.ts index c88ce256..d5de40db 100644 --- a/src/browser/renderer/Renderer.ts +++ b/src/browser/renderer/Renderer.ts @@ -33,7 +33,7 @@ export class Renderer extends Disposable implements IRenderer { private readonly _screenElement: HTMLElement, linkifier: ILinkifier, linkifier2: ILinkifier2, - instantiationService: IInstantiationService, + @IInstantiationService instantiationService: IInstantiationService, @IBufferService private readonly _bufferService: IBufferService, @ICharSizeService private readonly _charSizeService: ICharSizeService, @IOptionsService private readonly _optionsService: IOptionsService diff --git a/src/browser/renderer/dom/DomRenderer.ts b/src/browser/renderer/dom/DomRenderer.ts index 8dd1ac0e..dccdb877 100644 --- a/src/browser/renderer/dom/DomRenderer.ts +++ b/src/browser/renderer/dom/DomRenderer.ts @@ -9,7 +9,7 @@ import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants'; import { Disposable } from 'common/Lifecycle'; import { IColorSet, ILinkifierEvent, ILinkifier, ILinkifier2 } from 'browser/Types'; import { ICharSizeService } from 'browser/services/Services'; -import { IOptionsService, IBufferService } from 'common/services/Services'; +import { IOptionsService, IBufferService, IInstantiationService } from 'common/services/Services'; import { EventEmitter, IEvent } from 'common/EventEmitter'; import { color } from 'browser/Color'; import { removeElementFromParent } from 'browser/Dom'; @@ -49,6 +49,7 @@ export class DomRenderer extends Disposable implements IRenderer { private readonly _viewportElement: HTMLElement, private readonly _linkifier: ILinkifier, private readonly _linkifier2: ILinkifier2, + @IInstantiationService instantiationService: IInstantiationService, @ICharSizeService private readonly _charSizeService: ICharSizeService, @IOptionsService private readonly _optionsService: IOptionsService, @IBufferService private readonly _bufferService: IBufferService @@ -80,7 +81,7 @@ export class DomRenderer extends Disposable implements IRenderer { this._updateDimensions(); this._injectCss(); - this._rowFactory = new DomRendererRowFactory(document, this._optionsService, this._colors); + this._rowFactory = instantiationService.createInstance(DomRendererRowFactory, document, this._colors); this._element.classList.add(TERMINAL_CLASS_PREFIX + this._terminalClass); this._screenElement.appendChild(this._rowContainer); @@ -364,7 +365,7 @@ export class DomRenderer extends Disposable implements IRenderer { const row = y + this._bufferService.buffer.ydisp; const lineData = this._bufferService.buffer.lines.get(row); const cursorStyle = this._optionsService.options.cursorStyle; - rowElement.appendChild(this._rowFactory.createRow(lineData!, row === cursorAbsoluteY, cursorStyle, cursorX, cursorBlink, this.dimensions.actualCellWidth, this._bufferService.cols)); + rowElement.appendChild(this._rowFactory.createRow(lineData!, row, row === cursorAbsoluteY, cursorStyle, cursorX, cursorBlink, this.dimensions.actualCellWidth, this._bufferService.cols)); } } diff --git a/src/browser/renderer/dom/DomRendererRowFactory.test.ts b/src/browser/renderer/dom/DomRendererRowFactory.test.ts index b6604b14..9eacb97a 100644 --- a/src/browser/renderer/dom/DomRendererRowFactory.test.ts +++ b/src/browser/renderer/dom/DomRendererRowFactory.test.ts @@ -12,6 +12,7 @@ import { IBufferLine } from 'common/Types'; import { CellData } from 'common/buffer/CellData'; import { MockOptionsService } from 'common/TestUtils.test'; import { css } from 'browser/Color'; +import { MockCharacterJoinerService } from 'browser/TestUtils.test'; describe('DomRendererRowFactory', () => { let dom: jsdom.JSDOM; @@ -20,7 +21,7 @@ describe('DomRendererRowFactory', () => { beforeEach(() => { dom = new jsdom.JSDOM(''); - rowFactory = new DomRendererRowFactory(dom.window.document, new MockOptionsService({ drawBoldTextInBrightColors: true }), { + rowFactory = new DomRendererRowFactory(dom.window.document, { background: css.toColor('#010101'), foreground: css.toColor('#020202'), ansi: [ @@ -43,13 +44,13 @@ describe('DomRendererRowFactory', () => { css.toColor('#34e2e2'), css.toColor('#eeeeec') ] - } as any); + } as any, new MockCharacterJoinerService(), new MockOptionsService({ drawBoldTextInBrightColors: true })); lineData = createEmptyLineData(2); }); describe('createRow', () => { it('should not create anything for an empty row', () => { - const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20); + const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20); assert.equal(getFragmentHtml(fragment), '' ); @@ -59,7 +60,7 @@ describe('DomRendererRowFactory', () => { lineData.setCell(0, CellData.fromCharData([DEFAULT_ATTR, '語', 2, '語'.charCodeAt(0)])); // There should be no element for the following "empty" cell lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, '', 0, 0])); - const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20); + const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20); assert.equal(getFragmentHtml(fragment), '' ); @@ -67,7 +68,7 @@ describe('DomRendererRowFactory', () => { it('should add class for cursor and cursor style', () => { for (const style of ['block', 'bar', 'underline']) { - const fragment = rowFactory.createRow(lineData, true, style, 0, false, 5, 20); + const fragment = rowFactory.createRow(lineData, 0, true, style, 0, false, 5, 20); assert.equal(getFragmentHtml(fragment), ` ` ); @@ -75,7 +76,7 @@ describe('DomRendererRowFactory', () => { }); it('should add class for cursor blink', () => { - const fragment = rowFactory.createRow(lineData, true, 'block', 0, true, 5, 20); + const fragment = rowFactory.createRow(lineData, 0, true, 'block', 0, true, 5, 20); assert.equal(getFragmentHtml(fragment), ` ` ); @@ -84,7 +85,7 @@ describe('DomRendererRowFactory', () => { it('should not render cells that go beyond the terminal\'s columns', () => { lineData.setCell(0, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)])); lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, 'b', 1, 'b'.charCodeAt(0)])); - const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 1); + const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 1); assert.equal(getFragmentHtml(fragment), 'a' ); @@ -95,7 +96,7 @@ describe('DomRendererRowFactory', () => { const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]); cell.fg = DEFAULT_ATTR_DATA.fg | FgFlags.BOLD; lineData.setCell(0, cell); - const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20); + const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20); assert.equal(getFragmentHtml(fragment), 'a' ); @@ -105,7 +106,7 @@ describe('DomRendererRowFactory', () => { const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]); cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.ITALIC; lineData.setCell(0, cell); - const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20); + const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20); assert.equal(getFragmentHtml(fragment), 'a' ); @@ -115,7 +116,7 @@ describe('DomRendererRowFactory', () => { const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]); cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.DIM; lineData.setCell(0, cell); - const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20); + const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20); assert.equal(getFragmentHtml(fragment), 'a' ); @@ -125,7 +126,7 @@ describe('DomRendererRowFactory', () => { const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]); cell.fg = DEFAULT_ATTR_DATA.fg | FgFlags.UNDERLINE; lineData.setCell(0, cell); - const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20); + const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20); assert.equal(getFragmentHtml(fragment), 'a' ); @@ -138,7 +139,7 @@ describe('DomRendererRowFactory', () => { cell.fg &= ~Attributes.PCOLOR_MASK; cell.fg |= i; lineData.setCell(0, cell); - const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20); + const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20); assert.equal(getFragmentHtml(fragment), `a` ); @@ -152,7 +153,7 @@ describe('DomRendererRowFactory', () => { cell.bg &= ~Attributes.PCOLOR_MASK; cell.bg |= i; lineData.setCell(0, cell); - const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20); + const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20); assert.equal(getFragmentHtml(fragment), `a` ); @@ -164,7 +165,7 @@ describe('DomRendererRowFactory', () => { cell.fg |= Attributes.CM_P16 | 2 | FgFlags.INVERSE; cell.bg |= Attributes.CM_P16 | 1; lineData.setCell(0, cell); - const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20); + const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20); assert.equal(getFragmentHtml(fragment), 'a' ); @@ -175,7 +176,7 @@ describe('DomRendererRowFactory', () => { cell.fg |= FgFlags.INVERSE; cell.bg |= Attributes.CM_P16 | 1; lineData.setCell(0, cell); - const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20); + const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20); assert.equal(getFragmentHtml(fragment), 'a' ); @@ -185,7 +186,7 @@ describe('DomRendererRowFactory', () => { const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]); cell.fg |= Attributes.CM_P16 | 1 | FgFlags.INVERSE; lineData.setCell(0, cell); - const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20); + const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20); assert.equal(getFragmentHtml(fragment), 'a' ); @@ -198,7 +199,7 @@ describe('DomRendererRowFactory', () => { cell.fg &= ~Attributes.PCOLOR_MASK; cell.fg |= i; lineData.setCell(0, cell); - const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20); + const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20); assert.equal(getFragmentHtml(fragment), `a` ); @@ -210,7 +211,7 @@ describe('DomRendererRowFactory', () => { cell.fg |= Attributes.CM_RGB | 1 << 16 | 2 << 8 | 3; cell.bg |= Attributes.CM_RGB | 4 << 16 | 5 << 8 | 6; lineData.setCell(0, cell); - const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20); + const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20); assert.equal(getFragmentHtml(fragment), 'a' ); @@ -221,7 +222,7 @@ describe('DomRendererRowFactory', () => { cell.fg |= Attributes.CM_RGB | 1 << 16 | 2 << 8 | 3 | FgFlags.INVERSE; cell.bg |= Attributes.CM_RGB | 4 << 16 | 5 << 8 | 6; lineData.setCell(0, cell); - const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20); + const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20); assert.equal(getFragmentHtml(fragment), 'a' ); diff --git a/src/browser/renderer/dom/DomRendererRowFactory.ts b/src/browser/renderer/dom/DomRendererRowFactory.ts index c7c87451..a052db54 100644 --- a/src/browser/renderer/dom/DomRendererRowFactory.ts +++ b/src/browser/renderer/dom/DomRendererRowFactory.ts @@ -10,6 +10,8 @@ import { CellData } from 'common/buffer/CellData'; import { IOptionsService } from 'common/services/Services'; import { color, rgba } from 'browser/Color'; import { IColorSet, IColor } from 'browser/Types'; +import { ICharacterJoinerService } from 'browser/services/Services'; +import { JoinedCellData } from 'browser/services/CharacterJoinerService'; export const BOLD_CLASS = 'xterm-bold'; export const DIM_CLASS = 'xterm-dim'; @@ -26,8 +28,9 @@ export class DomRendererRowFactory { constructor( private readonly _document: Document, - private readonly _optionsService: IOptionsService, - private _colors: IColorSet + private _colors: IColorSet, + @ICharacterJoinerService private readonly _characterJoinerService: ICharacterJoinerService, + @IOptionsService private readonly _optionsService: IOptionsService ) { } @@ -35,9 +38,11 @@ export class DomRendererRowFactory { this._colors = colors; } - public createRow(lineData: IBufferLine, isCursorRow: boolean, cursorStyle: string | undefined, cursorX: number, cursorBlink: boolean, cellWidth: number, cols: number): DocumentFragment { + public createRow(lineData: IBufferLine, row: number, isCursorRow: boolean, cursorStyle: string | undefined, cursorX: number, cursorBlink: boolean, cellWidth: number, cols: number): DocumentFragment { const fragment = this._document.createDocumentFragment(); + const joinedRanges = this._characterJoinerService.getJoinedCharacters(row); + console.log('joinedRanges', joinedRanges.map(e => e[0] + '->' + e[1]).join(',')); // Find the line length first, this prevents the need to output a bunch of // empty cells at the end. This cannot easily be integrated into the main // loop below because of the colCount feature (which can be removed after we @@ -53,18 +58,59 @@ export class DomRendererRowFactory { for (let x = 0; x < lineLength; x++) { lineData.loadCell(x, this._workCell); - const width = this._workCell.getWidth(); + let width = this._workCell.getWidth(); // The character to the left is a wide character, drawing is owned by the char at x-1 if (width === 0) { continue; } + // If true, indicates that the current character(s) to draw were joined. + let isJoined = false; + let lastCharX = x; + + // Process any joined character ranges as needed. Because of how the + // ranges are produced, we know that they are valid for the characters + // and attributes of our input. + let cell = this._workCell; + if (joinedRanges.length > 0 && x === joinedRanges[0][0]) { + isJoined = true; + const range = joinedRanges.shift()!; + + // We already know the exact start and end column of the joined range, + // so we get the string and width representing it directly + + cell = new JoinedCellData( + this._workCell, + lineData.translateToString(true, range[0], range[1]), + range[1] - range[0] + ); + + // Skip over the cells occupied by this range in the loop + lastCharX = range[1] - 1; + + // Recalculate width + width = cell.getWidth(); + } + const charElement = this._document.createElement('span'); if (width > 1) { charElement.style.width = `${cellWidth * width}px`; } + if (isJoined) { + // Ligatures in the DOM renderer must use display inline, as they may not show with + // inline-block if they are outside the bounds of the element + charElement.style.display = 'inline'; + + // The DOM renderer colors the background of the cursor but for ligatures all cells are + // joined. The workaround here is to show a cursor around the whole ligature so it shows up, + // the cursor looks the same when on any character of the ligature though + if (cursorX >= x && cursorX <= lastCharX) { + cursorX = x; + } + } + if (isCursorRow && x === cursorX) { charElement.classList.add(CURSOR_CLASS); @@ -85,33 +131,33 @@ export class DomRendererRowFactory { } } - if (this._workCell.isBold()) { + if (cell.isBold()) { charElement.classList.add(BOLD_CLASS); } - if (this._workCell.isItalic()) { + if (cell.isItalic()) { charElement.classList.add(ITALIC_CLASS); } - if (this._workCell.isDim()) { + if (cell.isDim()) { charElement.classList.add(DIM_CLASS); } - if (this._workCell.isUnderline()) { + if (cell.isUnderline()) { charElement.classList.add(UNDERLINE_CLASS); } - if (this._workCell.isInvisible()) { + if (cell.isInvisible()) { charElement.textContent = WHITESPACE_CELL_CHAR; } else { - charElement.textContent = this._workCell.getChars() || WHITESPACE_CELL_CHAR; + charElement.textContent = cell.getChars() || WHITESPACE_CELL_CHAR; } - let fg = this._workCell.getFgColor(); - let fgColorMode = this._workCell.getFgColorMode(); - let bg = this._workCell.getBgColor(); - let bgColorMode = this._workCell.getBgColorMode(); - const isInverse = !!this._workCell.isInverse(); + let fg = cell.getFgColor(); + let fgColorMode = cell.getFgColorMode(); + let bg = cell.getBgColor(); + let bgColorMode = cell.getBgColorMode(); + const isInverse = !!cell.isInverse(); if (isInverse) { const temp = fg; fg = bg; @@ -125,7 +171,7 @@ export class DomRendererRowFactory { switch (fgColorMode) { case Attributes.CM_P16: case Attributes.CM_P256: - if (this._workCell.isBold() && fg < 8 && this._optionsService.options.drawBoldTextInBrightColors) { + if (cell.isBold() && fg < 8 && this._optionsService.options.drawBoldTextInBrightColors) { fg += 8; } if (!this._applyMinimumContrast(charElement, this._colors.background, this._colors.ansi[fg])) { @@ -168,6 +214,8 @@ export class DomRendererRowFactory { } fragment.appendChild(charElement); + + x = lastCharX; } return fragment; } diff --git a/src/common/services/InstantiationService.ts b/src/common/services/InstantiationService.ts index e5727fa6..8280948a 100644 --- a/src/common/services/InstantiationService.ts +++ b/src/common/services/InstantiationService.ts @@ -42,6 +42,8 @@ export class ServiceCollection { } export class InstantiationService implements IInstantiationService { + public serviceBrand: undefined; + private readonly _services: ServiceCollection = new ServiceCollection(); constructor() { diff --git a/src/common/services/Services.ts b/src/common/services/Services.ts index 8b21f100..ce297322 100644 --- a/src/common/services/Services.ts +++ b/src/common/services/Services.ts @@ -157,6 +157,8 @@ type GetLeadingNonServiceArgs = export const IInstantiationService = createDecorator('InstantiationService'); export interface IInstantiationService { + serviceBrand: undefined; + setService(id: IServiceIdentifier, instance: T): void; getService(id: IServiceIdentifier): T | undefined; createInstance any, R extends InstanceType>(t: Ctor, ...args: GetLeadingNonServiceArgs>): R; From b03a25f4c7df82f6a64408717aa35a2b69333c74 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 2 Apr 2021 11:15:57 -0700 Subject: [PATCH 169/377] Webgl ligature support Fixes #3094 --- addons/xterm-addon-webgl/src/WebglAddon.ts | 5 +- addons/xterm-addon-webgl/src/WebglRenderer.ts | 94 ++++++++++++++++++- .../src/atlas/WebglCharAtlas.ts | 24 +++-- src/browser/renderer/TextRenderLayer.ts | 1 - .../renderer/dom/DomRendererRowFactory.ts | 2 - 5 files changed, 109 insertions(+), 17 deletions(-) diff --git a/addons/xterm-addon-webgl/src/WebglAddon.ts b/addons/xterm-addon-webgl/src/WebglAddon.ts index c07bc0d7..91fa7968 100644 --- a/addons/xterm-addon-webgl/src/WebglAddon.ts +++ b/addons/xterm-addon-webgl/src/WebglAddon.ts @@ -5,7 +5,7 @@ import { Terminal, ITerminalAddon, IEvent } from 'xterm'; import { WebglRenderer } from './WebglRenderer'; -import { IRenderService } from 'browser/services/Services'; +import { ICharacterJoinerService, IRenderService } from 'browser/services/Services'; import { IColorSet } from 'browser/Types'; import { EventEmitter } from 'common/EventEmitter'; @@ -25,8 +25,9 @@ export class WebglAddon implements ITerminalAddon { } this._terminal = terminal; const renderService: IRenderService = (terminal)._core._renderService; + const characterJoinerService: ICharacterJoinerService = (terminal)._core._characterJoinerService; const colors: IColorSet = (terminal)._core._colorManager.colors; - this._renderer = new WebglRenderer(terminal, colors, this._preserveDrawingBuffer); + this._renderer = new WebglRenderer(terminal, colors, characterJoinerService, this._preserveDrawingBuffer); this._renderer.onContextLoss(() => this._onContextLoss.fire()); renderService.setRenderer(this._renderer); } diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index 08f83b52..ff159f70 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -12,7 +12,7 @@ import { RectangleRenderer } from './RectangleRenderer'; import { IWebGL2RenderingContext } from './Types'; import { RenderModel, COMBINED_CHAR_BIT_MASK, RENDER_MODEL_BG_OFFSET, RENDER_MODEL_FG_OFFSET, RENDER_MODEL_INDICIES_PER_CELL } from './RenderModel'; import { Disposable } from 'common/Lifecycle'; -import { NULL_CELL_CODE } from 'common/buffer/Constants'; +import { Content, NULL_CELL_CHAR, NULL_CELL_CODE } from 'common/buffer/Constants'; import { Terminal, IEvent } from 'xterm'; import { IRenderLayer } from './renderLayer/Types'; import { IRenderDimensions, IRenderer, IRequestRedrawEvent } from 'browser/renderer/Types'; @@ -20,6 +20,9 @@ import { ITerminal, IColorSet } from 'browser/Types'; import { EventEmitter } from 'common/EventEmitter'; import { CellData } from 'common/buffer/CellData'; import { addDisposableDomListener } from 'browser/Lifecycle'; +import { ICharacterJoinerService } from 'browser/services/Services'; +import { CharData, ICellData } from 'common/Types'; +import { AttributeData } from 'common/buffer/AttributeData'; export class WebglRenderer extends Disposable implements IRenderer { private _renderLayers: IRenderLayer[]; @@ -48,6 +51,7 @@ export class WebglRenderer extends Disposable implements IRenderer { constructor( private _terminal: Terminal, private _colors: IColorSet, + private readonly _characterJoinerService: ICharacterJoinerService, preserveDrawingBuffer?: boolean ) { super(); @@ -288,16 +292,41 @@ export class WebglRenderer extends Disposable implements IRenderer { private _updateModel(start: number, end: number): void { const terminal = this._core; + let cell: ICellData = this._workCell; for (let y = start; y <= end; y++) { const row = y + terminal.buffer.ydisp; const line = terminal.buffer.lines.get(row)!; this._model.lineLengths[y] = 0; + const joinedRanges = this._characterJoinerService.getJoinedCharacters(row); for (let x = 0; x < terminal.cols; x++) { - line.loadCell(x, this._workCell); + line.loadCell(x, cell); - const chars = this._workCell.getChars(); - let code = this._workCell.getCode(); + // If true, indicates that the current character(s) to draw were joined. + let isJoined = false; + let lastCharX = x; + + // Process any joined character ranges as needed. Because of how the + // ranges are produced, we know that they are valid for the characters + // and attributes of our input. + if (joinedRanges.length > 0 && x === joinedRanges[0][0]) { + isJoined = true; + const range = joinedRanges.shift()!; + + // We already know the exact start and end column of the joined range, + // so we get the string and width representing it directly + cell = new JoinedCellData( + cell, + line!.translateToString(true, range[0], range[1]), + range[1] - range[0] + ); + + // Skip over the cells occupied by this range in the loop + lastCharX = range[1] - 1; + } + + const chars = cell.getChars(); + let code = cell.getCode(); const i = ((y * terminal.cols) + x) * RENDER_MODEL_INDICIES_PER_CELL; if (code !== NULL_CELL_CODE) { @@ -321,7 +350,18 @@ export class WebglRenderer extends Disposable implements IRenderer { this._model.cells[i + RENDER_MODEL_BG_OFFSET] = this._workCell.bg; this._model.cells[i + RENDER_MODEL_FG_OFFSET] = this._workCell.fg; + console.log('updateCell', x, y, code, chars); this._glyphRenderer.updateCell(x, y, code, this._workCell.bg, this._workCell.fg, chars); + + if (isJoined) { + // Restore work cell + cell = this._workCell; + + // Null out non-first cells + for (x++; x < lastCharX; x++) { + this._glyphRenderer.updateCell(x, y, NULL_CELL_CODE, 0, 0, NULL_CELL_CHAR); + } + } } } this._rectangleRenderer.updateBackgrounds(this._model); @@ -438,3 +478,49 @@ export class WebglRenderer extends Disposable implements IRenderer { this.dimensions.actualCellWidth = this.dimensions.scaledCellWidth / this._devicePixelRatio; } } + +// TODO: Share impl with core +export class JoinedCellData extends AttributeData implements ICellData { + private _width: number; + // .content carries no meaning for joined CellData, simply nullify it + // thus we have to overload all other .content accessors + public content: number = 0; + public fg: number; + public bg: number; + public combinedData: string = ''; + + constructor(firstCell: ICellData, chars: string, width: number) { + super(); + this.fg = firstCell.fg; + this.bg = firstCell.bg; + this.combinedData = chars; + this._width = width; + } + + public isCombined(): number { + // always mark joined cell data as combined + return Content.IS_COMBINED_MASK; + } + + public getWidth(): number { + return this._width; + } + + public getChars(): string { + return this.combinedData; + } + + public getCode(): number { + // code always gets the highest possible fake codepoint (read as -1) + // this is needed as code is used by caches as identifier + return 0x1FFFFF; + } + + public setFromCharData(value: CharData): void { + throw new Error('not implemented'); + } + + public getAsCharData(): CharData { + return [this.fg, this.getChars(), this.getWidth(), this.getCode()]; + } +} diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index dfefb339..61a7ae4d 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -83,7 +83,7 @@ export class WebglCharAtlas implements IDisposable { this._cacheCtx = throwIfFalsy(this.cacheCanvas.getContext('2d', { alpha: true })); this._tmpCanvas = document.createElement('canvas'); - this._tmpCanvas.width = this._config.scaledCharWidth * 2 + TMP_CANVAS_GLYPH_PADDING * 2; + this._tmpCanvas.width = this._config.scaledCharWidth * 4 + TMP_CANVAS_GLYPH_PADDING * 2; this._tmpCanvas.height = this._config.scaledCharHeight + TMP_CANVAS_GLYPH_PADDING * 2; this._tmpCtx = throwIfFalsy(this._tmpCanvas.getContext('2d', { alpha: this._config.allowTransparency })); } @@ -317,6 +317,14 @@ export class WebglCharAtlas implements IDisposable { this.hasCanvasChanged = true; + // Allow 1 cell width per character, with a minimum of 2 (CJK), plus some padding. This is used + // to draw the glyph to the canvas as well as to restrict the bounding box search to ensure + // giant ligatures (eg. =====>) don't impact overall performance. + const allowedWidth = this._config.scaledCharWidth * Math.max(chars.length, 2) + TMP_CANVAS_GLYPH_PADDING * 2; + console.log('allowedWidth', allowedWidth); + if (this._tmpCanvas.width < allowedWidth) { + this._tmpCanvas.width = allowedWidth; + } this._tmpCtx.save(); this._workAttributeData.fg = fg; @@ -405,7 +413,7 @@ export class WebglCharAtlas implements IDisposable { return NULL_RASTERIZED_GLYPH; } - const rasterizedGlyph = this._findGlyphBoundingBox(imageData, this._workBoundingBox, isPowerlineGlyph); + const rasterizedGlyph = this._findGlyphBoundingBox(imageData, this._workBoundingBox, allowedWidth, isPowerlineGlyph); const clippedImageData = this._clipImageData(imageData, this._workBoundingBox); // Check if there is enough room in the current row and go to next if needed @@ -438,14 +446,14 @@ export class WebglCharAtlas implements IDisposable { * @param imageData The image data to read. * @param boundingBox An IBoundingBox to put the clipped bounding box values. */ - private _findGlyphBoundingBox(imageData: ImageData, boundingBox: IBoundingBox, restrictedGlyph: boolean): IRasterizedGlyph { + private _findGlyphBoundingBox(imageData: ImageData, boundingBox: IBoundingBox, allowedWidth: number, restrictedGlyph: boolean): IRasterizedGlyph { boundingBox.top = 0; const height = restrictedGlyph ? this._config.scaledCharHeight : this._tmpCanvas.height; - const width = restrictedGlyph ? this._config.scaledCharWidth : this._tmpCanvas.width; + const width = restrictedGlyph ? this._config.scaledCharWidth : allowedWidth; let found = false; for (let y = 0; y < height; y++) { for (let x = 0; x < width; x++) { - const alphaOffset = y * width * 4 + x * 4 + 3; + const alphaOffset = y * this._tmpCanvas.width * 4 + x * 4 + 3; if (imageData.data[alphaOffset] !== 0) { boundingBox.top = y; found = true; @@ -460,7 +468,7 @@ export class WebglCharAtlas implements IDisposable { found = false; for (let x = 0; x < width; x++) { for (let y = 0; y < height; y++) { - const alphaOffset = y * width * 4 + x * 4 + 3; + const alphaOffset = y * this._tmpCanvas.width * 4 + x * 4 + 3; if (imageData.data[alphaOffset] !== 0) { boundingBox.left = x; found = true; @@ -475,7 +483,7 @@ export class WebglCharAtlas implements IDisposable { found = false; for (let x = width - 1; x >= 0; x--) { for (let y = 0; y < height; y++) { - const alphaOffset = y * width * 4 + x * 4 + 3; + const alphaOffset = y * this._tmpCanvas.width * 4 + x * 4 + 3; if (imageData.data[alphaOffset] !== 0) { boundingBox.right = x; found = true; @@ -490,7 +498,7 @@ export class WebglCharAtlas implements IDisposable { found = false; for (let y = height - 1; y >= 0; y--) { for (let x = 0; x < width; x++) { - const alphaOffset = y * width * 4 + x * 4 + 3; + const alphaOffset = y * this._tmpCanvas.width * 4 + x * 4 + 3; if (imageData.data[alphaOffset] !== 0) { boundingBox.bottom = y; found = true; diff --git a/src/browser/renderer/TextRenderLayer.ts b/src/browser/renderer/TextRenderLayer.ts index 48bf848e..ded6c9c6 100644 --- a/src/browser/renderer/TextRenderLayer.ts +++ b/src/browser/renderer/TextRenderLayer.ts @@ -99,7 +99,6 @@ export class TextRenderLayer extends BaseRenderLayer { // We already know the exact start and end column of the joined range, // so we get the string and width representing it directly - cell = new JoinedCellData( this._workCell, line!.translateToString(true, range[0], range[1]), diff --git a/src/browser/renderer/dom/DomRendererRowFactory.ts b/src/browser/renderer/dom/DomRendererRowFactory.ts index a052db54..eb2dd1fc 100644 --- a/src/browser/renderer/dom/DomRendererRowFactory.ts +++ b/src/browser/renderer/dom/DomRendererRowFactory.ts @@ -42,7 +42,6 @@ export class DomRendererRowFactory { const fragment = this._document.createDocumentFragment(); const joinedRanges = this._characterJoinerService.getJoinedCharacters(row); - console.log('joinedRanges', joinedRanges.map(e => e[0] + '->' + e[1]).join(',')); // Find the line length first, this prevents the need to output a bunch of // empty cells at the end. This cannot easily be integrated into the main // loop below because of the colCount feature (which can be removed after we @@ -79,7 +78,6 @@ export class DomRendererRowFactory { // We already know the exact start and end column of the joined range, // so we get the string and width representing it directly - cell = new JoinedCellData( this._workCell, lineData.translateToString(true, range[0], range[1]), From 00fa7bec42b090642197b1169db53668568ffb10 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 2 Apr 2021 11:32:02 -0700 Subject: [PATCH 170/377] Null out secondary ligature chars in cache --- addons/xterm-addon-webgl/src/WebglRenderer.ts | 15 +++++++++------ .../xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 1 - 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index ff159f70..3d25e5b0 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -335,8 +335,8 @@ export class WebglRenderer extends Disposable implements IRenderer { // Nothing has changed, no updates needed if (this._model.cells[i] === code && - this._model.cells[i + RENDER_MODEL_BG_OFFSET] === this._workCell.bg && - this._model.cells[i + RENDER_MODEL_FG_OFFSET] === this._workCell.fg) { + this._model.cells[i + RENDER_MODEL_BG_OFFSET] === cell.bg && + this._model.cells[i + RENDER_MODEL_FG_OFFSET] === cell.fg) { continue; } @@ -347,11 +347,10 @@ export class WebglRenderer extends Disposable implements IRenderer { // Cache the results in the model this._model.cells[i] = code; - this._model.cells[i + RENDER_MODEL_BG_OFFSET] = this._workCell.bg; - this._model.cells[i + RENDER_MODEL_FG_OFFSET] = this._workCell.fg; + this._model.cells[i + RENDER_MODEL_BG_OFFSET] = cell.bg; + this._model.cells[i + RENDER_MODEL_FG_OFFSET] = cell.fg; - console.log('updateCell', x, y, code, chars); - this._glyphRenderer.updateCell(x, y, code, this._workCell.bg, this._workCell.fg, chars); + this._glyphRenderer.updateCell(x, y, code, cell.bg, cell.fg, chars); if (isJoined) { // Restore work cell @@ -359,7 +358,11 @@ export class WebglRenderer extends Disposable implements IRenderer { // Null out non-first cells for (x++; x < lastCharX; x++) { + const j = ((y * terminal.cols) + x) * RENDER_MODEL_INDICIES_PER_CELL; this._glyphRenderer.updateCell(x, y, NULL_CELL_CODE, 0, 0, NULL_CELL_CHAR); + this._model.cells[j] = NULL_CELL_CODE; + this._model.cells[j + RENDER_MODEL_BG_OFFSET] = this._workCell.bg; + this._model.cells[j + RENDER_MODEL_FG_OFFSET] = this._workCell.fg; } } } diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 61a7ae4d..5e1ad195 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -321,7 +321,6 @@ export class WebglCharAtlas implements IDisposable { // to draw the glyph to the canvas as well as to restrict the bounding box search to ensure // giant ligatures (eg. =====>) don't impact overall performance. const allowedWidth = this._config.scaledCharWidth * Math.max(chars.length, 2) + TMP_CANVAS_GLYPH_PADDING * 2; - console.log('allowedWidth', allowedWidth); if (this._tmpCanvas.width < allowedWidth) { this._tmpCanvas.width = allowedWidth; } From 8a1d2cf0f4179c69c30dda5fcd9ff722cbd80b2b Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 2 Apr 2021 14:22:49 -0700 Subject: [PATCH 171/377] Whitespace change to force ligatures publish --- addons/xterm-addon-ligatures/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/xterm-addon-ligatures/README.md b/addons/xterm-addon-ligatures/README.md index 6336bf83..8f869d73 100644 --- a/addons/xterm-addon-ligatures/README.md +++ b/addons/xterm-addon-ligatures/README.md @@ -51,3 +51,4 @@ This package makes use of the following fonts for testing: [Fira Code License]: https://github.com/tonsky/FiraCode/blob/master/LICENSE [Iosevka]: https://github.com/be5invis/Iosevka [Iosevka License]: https://github.com/be5invis/Iosevka/blob/master/LICENSE.md + From 7b7b7a36db1b6d848ad9a41e5e242eecdb3cd43f Mon Sep 17 00:00:00 2001 From: Bruno Ribeiro Date: Sat, 3 Apr 2021 16:34:00 +0100 Subject: [PATCH 172/377] Fix #3014 - Add onBell event listener to allow embeders to hook into it --- src/browser/Terminal.test.ts | 6 ++++++ src/browser/Terminal.ts | 4 ++++ src/browser/TestUtils.test.ts | 1 + src/browser/Types.d.ts | 1 + src/browser/public/Terminal.ts | 1 + src/common/Types.d.ts | 1 + test/api/Terminal.api.ts | 10 ++++++++++ typings/xterm.d.ts | 6 ++++++ 8 files changed, 30 insertions(+) diff --git a/src/browser/Terminal.test.ts b/src/browser/Terminal.test.ts index b0075d88..74b1c975 100644 --- a/src/browser/Terminal.test.ts +++ b/src/browser/Terminal.test.ts @@ -131,6 +131,12 @@ describe('Terminal', () => { }); term.write('\x1b]2;title\x07'); }); + it('should fire the onBell event', (done) => { + term.onBell(e => { + done(); + }); + term.write('\a'); + }); }); describe('attachCustomKeyEventHandler', () => { diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index f14bffe0..d0807b4c 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -111,6 +111,8 @@ export class Terminal extends CoreTerminal implements ITerminal { public get onSelectionChange(): IEvent { return this._onSelectionChange.event; } private _onTitleChange = new EventEmitter(); public get onTitleChange(): IEvent { return this._onTitleChange.event; } + private _onBell = new EventEmitter(); + public get onBell (): IEvent { return this._onBell.event; } private _onFocus = new EventEmitter(); public get onFocus(): IEvent { return this._onFocus.event; } @@ -1141,6 +1143,8 @@ export class Terminal extends CoreTerminal implements ITerminal { this._soundService!.playBellSound(); } + this._onBell.fire(); + // if (this._visualBell()) { // this.element.classList.add('visual-bell-active'); // clearTimeout(this._visualBellTimer); diff --git a/src/browser/TestUtils.test.ts b/src/browser/TestUtils.test.ts index a2140aa5..35c81ad3 100644 --- a/src/browser/TestUtils.test.ts +++ b/src/browser/TestUtils.test.ts @@ -37,6 +37,7 @@ export class MockTerminal implements ITerminal { public onData!: IEvent; public onBinary!: IEvent; public onTitleChange!: IEvent; + public onBell!: IEvent; public onScroll!: IEvent; public onKey!: IEvent<{ key: string, domEvent: KeyboardEvent }>; public onRender!: IEvent<{ start: number, end: number }>; diff --git a/src/browser/Types.d.ts b/src/browser/Types.d.ts index f743934e..dea47468 100644 --- a/src/browser/Types.d.ts +++ b/src/browser/Types.d.ts @@ -47,6 +47,7 @@ export interface IPublicTerminal extends IDisposable { onRender: IEvent<{ start: number, end: number }>; onResize: IEvent<{ cols: number, rows: number }>; onTitleChange: IEvent; + onBell: IEvent; blur(): void; focus(): void; resize(columns: number, rows: number): void; diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index bd0b78f9..14606454 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -38,6 +38,7 @@ export class Terminal implements ITerminalApi { public get onData(): IEvent { return this._core.onData; } public get onBinary(): IEvent { return this._core.onBinary; } public get onTitleChange(): IEvent { return this._core.onTitleChange; } + public get onBell(): IEvent { return this._core.onBell; } public get onScroll(): IEvent { return this._core.onScroll; } public get onKey(): IEvent<{ key: string, domEvent: KeyboardEvent }> { return this._core.onKey; } public get onRender(): IEvent<{ start: number, end: number }> { return this._core.onRender; } diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index df299195..10b3afa4 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -357,6 +357,7 @@ export interface IAnsiColorChangeEvent { */ export interface IInputHandler { onTitleChange: IEvent; + onRequestBell: IEvent; parse(data: string | Uint8Array, promiseResult?: boolean): void | Promise; print(data: Uint32Array, start: number, end: number): void; diff --git a/test/api/Terminal.api.ts b/test/api/Terminal.api.ts index c5ce8f92..0fcb177d 100644 --- a/test/api/Terminal.api.ts +++ b/test/api/Terminal.api.ts @@ -410,6 +410,16 @@ describe('API Integration Tests', function(): void { await page.evaluate(`window.term.write('\\x1b]2;foo\\x9c')`); await pollFor(page, `window.calls`, ['foo']); }); + it('onBell', async () => { + await openTerminal(page); + await page.evaluate(` + window.calls = []; + window.term.onBell(e => window.calls.push(e)); + `); + await pollFor(page, `window.calls`, []); + await page.evaluate(`window.term.write('\\a')`); + await pollFor(page, `window.calls`, ['foo']); + }); }); describe('buffer', () => { diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index cab9bdcc..3fd4ba2d 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -708,6 +708,12 @@ declare module 'xterm' { * @returns an `IDisposable` to stop listening. */ onTitleChange: IEvent; + + /** + * Adds an event listener for when the bell sound. + * @returns an `IDisposable` to stop listening. + */ + onBell: IEvent; /** * Unfocus the terminal. From af26e27e23e3359dfc338441292699e10670e44b Mon Sep 17 00:00:00 2001 From: WhatTheServer Date: Sun, 4 Apr 2021 00:09:10 -0400 Subject: [PATCH 173/377] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d5488125..42e57ca0 100644 --- a/README.md +++ b/README.md @@ -173,6 +173,8 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**Devtron**](https://github.com/devtron-labs/devtron): Software Delivery Workflow For Kubernetes. - [**NxShell**](https://github.com/nxshell/nxshell): An easy to use new terminal for SSH. - [**gifcast**](https://dstein64.github.io/gifcast/): Converts an asciinema cast to an animated GIF. +- [**WizardWebssh**](https://gitlab.com/mikeramsey/wizardwebssh): A terminal with Pyqt5 Widget for embedding which can be used as an ssh client to connect to your ssh servers. It is written in Python, based on tornado, paramiko and xterm.js. +- [**Wizard Assistant**](https://wizardassistant.com/): Wizard Assistant comes with advanced automation tools, preloaded common and special time-saving commands, and a built in SSH terminal. Now you can remotely administer, troubleshoot, and analyze any system with ease. [And much more...](https://github.com/xtermjs/xterm.js/network/dependents) Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it in our list. Note: Please add any new contributions to the end of the list only. From 3d29357d1da4828ffd11eb5d7a196f74e5e1442e Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 6 Apr 2021 05:34:20 -0700 Subject: [PATCH 174/377] Fix test/lint --- src/browser/Terminal.test.ts | 4 ++-- src/browser/Terminal.ts | 2 +- src/common/Types.d.ts | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/browser/Terminal.test.ts b/src/browser/Terminal.test.ts index 74b1c975..140ec6e5 100644 --- a/src/browser/Terminal.test.ts +++ b/src/browser/Terminal.test.ts @@ -132,10 +132,10 @@ describe('Terminal', () => { term.write('\x1b]2;title\x07'); }); it('should fire the onBell event', (done) => { - term.onBell(e => { + term.onBell(e => { done(); }); - term.write('\a'); + term.write('\x07'); }); }); diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index e490d8c2..6400743c 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -1155,7 +1155,7 @@ export class Terminal extends CoreTerminal implements ITerminal { } this._onBell.fire(); - + // if (this._visualBell()) { // this.element.classList.add('visual-bell-active'); // clearTimeout(this._visualBellTimer); diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index 10b3afa4..df299195 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -357,7 +357,6 @@ export interface IAnsiColorChangeEvent { */ export interface IInputHandler { onTitleChange: IEvent; - onRequestBell: IEvent; parse(data: string | Uint8Array, promiseResult?: boolean): void | Promise; print(data: Uint32Array, start: number, end: number): void; From 19716957e4b8abcaf232a87f445cb015749f1c83 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 6 Apr 2021 05:40:29 -0700 Subject: [PATCH 175/377] Fix api test --- test/api/Terminal.api.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/api/Terminal.api.ts b/test/api/Terminal.api.ts index 0fcb177d..8af6842c 100644 --- a/test/api/Terminal.api.ts +++ b/test/api/Terminal.api.ts @@ -297,7 +297,7 @@ describe('API Integration Tests', function(): void { }); }); - describe('Events', () => { + describe.only('Events', () => { it('onCursorMove', async () => { await openTerminal(page); await page.evaluate(` @@ -414,11 +414,11 @@ describe('API Integration Tests', function(): void { await openTerminal(page); await page.evaluate(` window.calls = []; - window.term.onBell(e => window.calls.push(e)); + window.term.onBell(() => window.calls.push(true)); `); await pollFor(page, `window.calls`, []); - await page.evaluate(`window.term.write('\\a')`); - await pollFor(page, `window.calls`, ['foo']); + await page.evaluate(`window.term.write('\\x07')`); + await pollFor(page, `window.calls`, [true]); }); }); From 826493161a174e044c2f40baf5dee442c2a49a45 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 6 Apr 2021 05:40:56 -0700 Subject: [PATCH 176/377] Api polish --- typings/xterm.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 3fd4ba2d..b1995bb2 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -708,9 +708,9 @@ declare module 'xterm' { * @returns an `IDisposable` to stop listening. */ onTitleChange: IEvent; - + /** - * Adds an event listener for when the bell sound. + * Adds an event listener for when the bell is triggered. * @returns an `IDisposable` to stop listening. */ onBell: IEvent; From 2556137b517d3d6714a998eb2cb05891aeec3126 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 6 Apr 2021 05:44:36 -0700 Subject: [PATCH 177/377] Remove only --- test/api/Terminal.api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/api/Terminal.api.ts b/test/api/Terminal.api.ts index 8af6842c..2f388deb 100644 --- a/test/api/Terminal.api.ts +++ b/test/api/Terminal.api.ts @@ -297,7 +297,7 @@ describe('API Integration Tests', function(): void { }); }); - describe.only('Events', () => { + describe('Events', () => { it('onCursorMove', async () => { await openTerminal(page); await page.evaluate(` From 934467d48485465f702ceeeeb6c31f6f46916175 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 6 Apr 2021 06:27:39 -0700 Subject: [PATCH 178/377] Give actionable error when pollFor times out --- test/api/TestUtils.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/api/TestUtils.ts b/test/api/TestUtils.ts index f36d2830..20413565 100644 --- a/test/api/TestUtils.ts +++ b/test/api/TestUtils.ts @@ -6,8 +6,9 @@ import * as playwright from 'playwright'; import deepEqual = require('deep-equal'); import { ITerminalOptions } from 'xterm'; +import { deepStrictEqual, fail } from 'assert'; -export async function pollFor(page: playwright.Page, evalOrFn: string | (() => Promise), val: T, preFn?: () => Promise): Promise { +export async function pollFor(page: playwright.Page, evalOrFn: string | (() => Promise), val: T, preFn?: () => Promise, maxDuration?: number): Promise { if (preFn) { await preFn(); } @@ -18,12 +19,25 @@ export async function pollFor(page: playwright.Page, evalOrFn: string | (() = } if (!deepEqual(result, val)) { + if (maxDuration === undefined) { + maxDuration = 2000; + } + if (maxDuration <= 0) { + deepStrictEqual(result, val, 'pollFor max duration exceeded'); + } return new Promise(r => { - setTimeout(() => r(pollFor(page, evalOrFn, val, preFn)), 1); + setTimeout(() => r(pollFor(page, evalOrFn, val, preFn, maxDuration! - 10)), 10); }); } } +function formatValue(value: any): string { + if (Array.isArray(value) || typeof value === 'object') { + return JSON.stringify(value); + } + return value + ''; +} + export async function writeSync(page: playwright.Page, data: string): Promise { await page.evaluate(` window.ready = false; From 5973e8f0ddebfa0bf0610cfd9d8b7bee5a700f79 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 6 Apr 2021 06:28:49 -0700 Subject: [PATCH 179/377] Remove unused function --- test/api/TestUtils.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/api/TestUtils.ts b/test/api/TestUtils.ts index 20413565..2b1e8828 100644 --- a/test/api/TestUtils.ts +++ b/test/api/TestUtils.ts @@ -31,13 +31,6 @@ export async function pollFor(page: playwright.Page, evalOrFn: string | (() = } } -function formatValue(value: any): string { - if (Array.isArray(value) || typeof value === 'object') { - return JSON.stringify(value); - } - return value + ''; -} - export async function writeSync(page: playwright.Page, data: string): Promise { await page.evaluate(` window.ready = false; From 1422d935d05d49ef773751b1c039feead3ee5c0b Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 6 Apr 2021 06:34:20 -0700 Subject: [PATCH 180/377] Fix whitespace --- typings/xterm.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index b1995bb2..6bfb71ae 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -713,7 +713,7 @@ declare module 'xterm' { * Adds an event listener for when the bell is triggered. * @returns an `IDisposable` to stop listening. */ - onBell: IEvent; + onBell: IEvent; /** * Unfocus the terminal. From c4fc90e3f876b88d40b85b2dd3634d49a7656d8d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 6 Apr 2021 06:50:07 -0700 Subject: [PATCH 181/377] Don't assert on leave events --- test/api/Terminal.api.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/api/Terminal.api.ts b/test/api/Terminal.api.ts index 2f388deb..9de0eb5f 100644 --- a/test/api/Terminal.api.ts +++ b/test/api/Terminal.api.ts @@ -635,11 +635,11 @@ describe('API Integration Tests', function(): void { `); const dims = await getDimensions(); await moveMouseCell(page, dims, 5, 1); - await pollFor(page, `window.calls`, ['provide 1', 'match', 'hover']); + await timeout(100); await moveMouseCell(page, dims, 4, 1); await pollFor(page, `window.calls`, ['provide 1', 'match', 'hover', 'leave' ]); await moveMouseCell(page, dims, 7, 1); - await pollFor(page, `window.calls`, ['provide 1', 'match', 'hover', 'leave', 'hover']); + await timeout(100); await moveMouseCell(page, dims, 8, 1); await pollFor(page, `window.calls`, ['provide 1', 'match', 'hover', 'leave', 'hover', 'leave']); await page.evaluate(`window.disposable.dispose()`); From 27c87319c18ae3619cd2d3dca06f8a223dbb59f7 Mon Sep 17 00:00:00 2001 From: Bruno Ribeiro Date: Tue, 6 Apr 2021 15:48:48 +0100 Subject: [PATCH 182/377] Fix #2714 - Start demo server before running integration tests - Use port 3001 instead of 300 to not conflict with the demo --- addons/xterm-addon-attach/test/AttachAddon.api.ts | 2 +- addons/xterm-addon-fit/test/FitAddon.api.ts | 2 +- addons/xterm-addon-search/test/SearchAddon.api.ts | 2 +- addons/xterm-addon-serialize/test/SerializeAddon.api.ts | 2 +- addons/xterm-addon-unicode11/test/Unicode11Addon.api.ts | 2 +- addons/xterm-addon-web-links/test/WebLinksAddon.api.ts | 2 +- addons/xterm-addon-webgl/test/WebglRenderer.api.ts | 2 +- bin/test_api.js | 7 +++++++ test/api/CharWidth.api.ts | 2 +- test/api/InputHandler.api.ts | 2 +- test/api/MouseTracking.api.ts | 2 +- test/api/Parser.api.ts | 2 +- test/api/Terminal.api.ts | 2 +- 13 files changed, 19 insertions(+), 12 deletions(-) diff --git a/addons/xterm-addon-attach/test/AttachAddon.api.ts b/addons/xterm-addon-attach/test/AttachAddon.api.ts index 2dea645f..ef26cfd2 100644 --- a/addons/xterm-addon-attach/test/AttachAddon.api.ts +++ b/addons/xterm-addon-attach/test/AttachAddon.api.ts @@ -7,7 +7,7 @@ import WebSocket = require('ws'); import { openTerminal, pollFor, getBrowserType } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; -const APP = 'http://127.0.0.1:3000/test'; +const APP = 'http://127.0.0.1:3001/test'; let browser: Browser; let page: Page; diff --git a/addons/xterm-addon-fit/test/FitAddon.api.ts b/addons/xterm-addon-fit/test/FitAddon.api.ts index 5a5b3264..8859b5a6 100644 --- a/addons/xterm-addon-fit/test/FitAddon.api.ts +++ b/addons/xterm-addon-fit/test/FitAddon.api.ts @@ -7,7 +7,7 @@ import { assert } from 'chai'; import { openTerminal, getBrowserType } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; -const APP = 'http://127.0.0.1:3000/test'; +const APP = 'http://127.0.0.1:3001/test'; let browser: Browser; let page: Page; diff --git a/addons/xterm-addon-search/test/SearchAddon.api.ts b/addons/xterm-addon-search/test/SearchAddon.api.ts index b92dbc3a..3c94d416 100644 --- a/addons/xterm-addon-search/test/SearchAddon.api.ts +++ b/addons/xterm-addon-search/test/SearchAddon.api.ts @@ -9,7 +9,7 @@ import { resolve } from 'path'; import { openTerminal, writeSync, getBrowserType } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; -const APP = 'http://127.0.0.1:3000/test'; +const APP = 'http://127.0.0.1:3001/test'; let browser: Browser; let page: Page; diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index d472d753..a7b3b816 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -7,7 +7,7 @@ import { assert } from 'chai'; import { openTerminal, writeSync, getBrowserType } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; -const APP = 'http://127.0.0.1:3000/test'; +const APP = 'http://127.0.0.1:3001/test'; let browser: Browser; let page: Page; diff --git a/addons/xterm-addon-unicode11/test/Unicode11Addon.api.ts b/addons/xterm-addon-unicode11/test/Unicode11Addon.api.ts index 7369eeaa..ba536e90 100644 --- a/addons/xterm-addon-unicode11/test/Unicode11Addon.api.ts +++ b/addons/xterm-addon-unicode11/test/Unicode11Addon.api.ts @@ -7,7 +7,7 @@ import { assert } from 'chai'; import { openTerminal, getBrowserType } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; -const APP = 'http://127.0.0.1:3000/test'; +const APP = 'http://127.0.0.1:3001/test'; let browser: Browser; let page: Page; diff --git a/addons/xterm-addon-web-links/test/WebLinksAddon.api.ts b/addons/xterm-addon-web-links/test/WebLinksAddon.api.ts index 47fd7911..54650f1f 100644 --- a/addons/xterm-addon-web-links/test/WebLinksAddon.api.ts +++ b/addons/xterm-addon-web-links/test/WebLinksAddon.api.ts @@ -7,7 +7,7 @@ import { assert } from 'chai'; import { openTerminal, pollFor, writeSync, getBrowserType } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; -const APP = 'http://127.0.0.1:3000/test'; +const APP = 'http://127.0.0.1:3001/test'; let browser: Browser; let page: Page; diff --git a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts index e0aa68e7..1722e570 100644 --- a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts +++ b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts @@ -9,7 +9,7 @@ import { assert } from 'chai'; import { openTerminal, pollFor, writeSync, getBrowserType } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; -const APP = 'http://127.0.0.1:3000/test'; +const APP = 'http://127.0.0.1:3001/test'; let browser: Browser; let page: Page; diff --git a/bin/test_api.js b/bin/test_api.js index 7afb34bc..6aee0e50 100644 --- a/bin/test_api.js +++ b/bin/test_api.js @@ -34,6 +34,13 @@ if (process.argv.length > 2) { env.DEBUG = flagArgs.indexOf('--debug') >= 0 ? 'debug' : ''; +env.PORT = 3001; + +const server = cp.spawn('node', ['demo/start'], { + cwd: path.resolve(__dirname, '..'), + env, + stdio: 'inherit' +}) const run = cp.spawnSync( npmBinScript('mocha'), diff --git a/test/api/CharWidth.api.ts b/test/api/CharWidth.api.ts index 01d69861..d7cea109 100644 --- a/test/api/CharWidth.api.ts +++ b/test/api/CharWidth.api.ts @@ -6,7 +6,7 @@ import { pollFor, openTerminal, getBrowserType } from './TestUtils'; import { Browser, Page } from 'playwright'; -const APP = 'http://127.0.0.1:3000/test'; +const APP = 'http://127.0.0.1:3001/test'; let browser: Browser; let page: Page; diff --git a/test/api/InputHandler.api.ts b/test/api/InputHandler.api.ts index 16ab2301..a695abdc 100644 --- a/test/api/InputHandler.api.ts +++ b/test/api/InputHandler.api.ts @@ -8,7 +8,7 @@ import { pollFor, openTerminal, getBrowserType } from './TestUtils'; import { Browser, Page } from 'playwright'; import { IRenderDimensions } from 'browser/renderer/Types'; -const APP = 'http://127.0.0.1:3000/test'; +const APP = 'http://127.0.0.1:3001/test'; let browser: Browser; let page: Page; diff --git a/test/api/MouseTracking.api.ts b/test/api/MouseTracking.api.ts index 0bd0cc18..3df21a90 100644 --- a/test/api/MouseTracking.api.ts +++ b/test/api/MouseTracking.api.ts @@ -6,7 +6,7 @@ import { pollFor, writeSync, openTerminal, getBrowserType } from './TestUtils'; import { Browser, Page } from 'playwright'; -const APP = 'http://127.0.0.1:3000/test'; +const APP = 'http://127.0.0.1:3001/test'; let browser: Browser; let page: Page; diff --git a/test/api/Parser.api.ts b/test/api/Parser.api.ts index 7bd55544..0ef57cf1 100644 --- a/test/api/Parser.api.ts +++ b/test/api/Parser.api.ts @@ -7,7 +7,7 @@ import { assert } from 'chai'; import { writeSync, openTerminal, getBrowserType } from './TestUtils'; import { Browser, Page } from 'playwright'; -const APP = 'http://127.0.0.1:3000/test'; +const APP = 'http://127.0.0.1:3001/test'; let browser: Browser; let page: Page; diff --git a/test/api/Terminal.api.ts b/test/api/Terminal.api.ts index 2f388deb..39ca1a3b 100644 --- a/test/api/Terminal.api.ts +++ b/test/api/Terminal.api.ts @@ -7,7 +7,7 @@ import { assert } from 'chai'; import { pollFor, timeout, writeSync, openTerminal, getBrowserType } from './TestUtils'; import { Browser, Page } from 'playwright'; -const APP = 'http://127.0.0.1:3000/test'; +const APP = 'http://127.0.0.1:3001/test'; let browser: Browser; let page: Page; From ab659fda5f02c17c184e49b82cb4876b8f33886a Mon Sep 17 00:00:00 2001 From: Bruno Ribeiro Date: Tue, 6 Apr 2021 16:51:17 +0100 Subject: [PATCH 183/377] Remove Start Test Server from pipelines as it now starts in the tests --- azure-pipelines.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4b2c5f73..98fff711 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -100,10 +100,6 @@ jobs: displayName: 'Install Yarn' - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - - script: | - yarn start & - sleep 10 - displayName: 'Start test server' - script: yarn test-api-chromium --headless --forbid-only displayName: 'Integration tests (Chromium)' - script: xvfb-run --auto-servernum -- bash -c "yarn test-api-firefox --headless --forbid-only" @@ -119,10 +115,6 @@ jobs: displayName: 'Install Node.js' - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - - script: | - yarn start & - sleep 10 - displayName: 'Start test server' - script: yarn test-api-chromium --headless --forbid-only displayName: 'Integration tests (Chromium)' - script: yarn test-api-firefox --headless --forbid-only From b8af0ecf05d53b3174a423db9564770a17014155 Mon Sep 17 00:00:00 2001 From: Bruno Ribeiro Date: Tue, 6 Apr 2021 17:21:39 +0100 Subject: [PATCH 184/377] Await for server to be fully started --- bin/test_api.js | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/bin/test_api.js b/bin/test_api.js index 6aee0e50..9fe4659a 100644 --- a/bin/test_api.js +++ b/bin/test_api.js @@ -39,21 +39,26 @@ env.PORT = 3001; const server = cp.spawn('node', ['demo/start'], { cwd: path.resolve(__dirname, '..'), env, - stdio: 'inherit' + stdio: 'pipe' }) -const run = cp.spawnSync( - npmBinScript('mocha'), - [...testFiles, ...flagArgs], - { - cwd: path.resolve(__dirname, '..'), - env, - stdio: 'inherit' +server.stdout.on('data', (data) => { + // await for the server to fully start + if (data.indexOf("successfully") !== -1) { + const run = cp.spawnSync( + npmBinScript('mocha'), + [...testFiles, ...flagArgs], { + cwd: path.resolve(__dirname, '..'), + env, + stdio: 'inherit' + } + ); + + function npmBinScript(script) { + return path.resolve(__dirname, `../node_modules/.bin/` + (process.platform === 'win32' ? + `${script}.cmd` : script)); + } + + process.exit(run.status); } -); - -function npmBinScript(script) { - return path.resolve(__dirname, `../node_modules/.bin/` + (process.platform === 'win32' ? `${script}.cmd` : script)); -} - -process.exit(run.status); +}); From e686527f878a307c1bfcbc8f4db5afc515ae1637 Mon Sep 17 00:00:00 2001 From: Bruno Ribeiro Date: Tue, 6 Apr 2021 17:47:12 +0100 Subject: [PATCH 185/377] Try to enable windows integration tests --- azure-pipelines.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 98fff711..33da22b2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -122,6 +122,21 @@ jobs: - script: yarn test-api-webkit --headless --forbid-only displayName: 'Integration tests (Webkit)' +- job: Windows_IntegrationTests + pool: + vmImage: 'vs2017-win2016' + steps: + - task: NodeTool@0 + inputs: + versionSpec: '10.x' + displayName: 'Install Node.js' + - script: yarn --frozen-lockfile + displayName: 'Install dependencies and build' + - script: yarn test-api-chromium --headless --forbid-only + displayName: 'Integration tests (Chromium)' + - script: yarn test-api-firefox --headless --forbid-only + displayName: 'Integration tests (Firefox)' + - job: Release dependsOn: - Linux @@ -129,6 +144,7 @@ jobs: - Windows - Linux_IntegrationTests - macOS_IntegrationTests + - Windows_IntegrationTests condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['FORCE_RELEASE'], 'true'))) pool: vmImage: 'ubuntu-16.04' From d616aaa4f8e31cdee04c9cdf1c80b8d905d1d9ff Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 28 Apr 2021 12:51:40 -0700 Subject: [PATCH 186/377] Ensure all viewport scroll events are handled by buffer Some scroll events were never making it to the buffer service when using a trackpad. See microsoft/vscode#121017 Fixes #3311 --- src/browser/Terminal.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 6400743c..e9241a8c 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -476,7 +476,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this._instantiationService.setService(IMouseService, this._mouseService); this.viewport = this._instantiationService.createInstance(Viewport, - (amount: number) => this.scrollLines(amount, false, ScrollSource.VIEWPORT), + (amount: number) => this.scrollLines(amount, true, ScrollSource.VIEWPORT), this._viewportElement, this._viewportScrollArea ); @@ -511,9 +511,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this.textarea!.select(); })); this.register(this._onScroll.event(ev => { - if (ev.source !== ScrollSource.VIEWPORT) { - this.viewport!.syncScrollArea(); - } + this.viewport!.syncScrollArea(); this._selectionService!.refresh(); })); this.register(addDisposableDomListener(this._viewportElement, 'scroll', () => this._selectionService!.refresh())); From 58527bb2ffee5ac81671a3b96e941b865dc3d270 Mon Sep 17 00:00:00 2001 From: jeanp413 Date: Tue, 4 May 2021 11:23:31 -0500 Subject: [PATCH 187/377] Fixes undefined soundService --- src/browser/Terminal.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index e9241a8c..9d3838a6 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -1149,7 +1149,7 @@ export class Terminal extends CoreTerminal implements ITerminal { */ public bell(): void { if (this._soundBell()) { - this._soundService!.playBellSound(); + this._soundService?.playBellSound(); } this._onBell.fire(); From be32590ef0b8b6524aa327348ba342c7827f307c Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 5 May 2021 08:21:26 -0700 Subject: [PATCH 188/377] fix #https://github.com/microsoft/vscode/issues/123000 --- src/browser/services/SelectionService.ts | 6 +++-- src/common/buffer/BufferRange.test.ts | 32 ++++++++++++++++++++++++ src/common/buffer/BufferRange.ts | 16 ++++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 src/common/buffer/BufferRange.test.ts create mode 100644 src/common/buffer/BufferRange.ts diff --git a/src/browser/services/SelectionService.ts b/src/browser/services/SelectionService.ts index 4806ef91..8e3b8809 100644 --- a/src/browser/services/SelectionService.ts +++ b/src/browser/services/SelectionService.ts @@ -10,12 +10,13 @@ import * as Browser from 'common/Platform'; import { SelectionModel } from 'browser/selection/SelectionModel'; import { CellData } from 'common/buffer/CellData'; import { EventEmitter, IEvent } from 'common/EventEmitter'; -import { ICharSizeService, IMouseService, ISelectionService, IRenderService } from 'browser/services/Services'; +import { IMouseService, ISelectionService, IRenderService } from 'browser/services/Services'; import { ILinkifier2 } from 'browser/Types'; import { IBufferService, IOptionsService, ICoreService } from 'common/services/Services'; import { getCoordsRelativeToElement } from 'browser/input/Mouse'; import { moveToCellSequence } from 'browser/input/MoveToCell'; import { Disposable } from 'common/Lifecycle'; +import { getRangeLength } from 'common/buffer/BufferRange'; /** * The number of pixels the mouse needs to be above or below the viewport in @@ -323,7 +324,8 @@ export class SelectionService extends Disposable implements ISelectionService { const range = this._linkifier.currentLink?.link?.range; if (range) { this._model.selectionStart = [range.start.x - 1, range.start.y - 1]; - this._model.selectionEnd = [range.end.x, range.end.y - 1]; + this._model.selectionStartLength = getRangeLength(range, this._bufferService.cols); + this._model.selectionEnd = undefined; return true; } diff --git a/src/common/buffer/BufferRange.test.ts b/src/common/buffer/BufferRange.test.ts new file mode 100644 index 00000000..c48de807 --- /dev/null +++ b/src/common/buffer/BufferRange.test.ts @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2021 The xterm.js authors. All rights reserved. + * @license MIT + */ + +import { assert } from 'chai'; +import { getRangeLength } from 'common/buffer/BufferRange'; +import { IBufferRange } from 'xterm'; + +describe.only('BufferRange', () => { + describe('getRangeLength', () => { + it('should get range for single line', () => { + assert.equal(getRangeLength(createRange(1, 1, 4, 1), 0), 3); + }); + it('should throw for invalid range', () => { + assert.throws(() => getRangeLength(createRange(1, 3, 1, 1), 0)); + }); + it('should get range multiple lines', () => { + assert.equal(getRangeLength(createRange(1, 1, 4, 5), 5), 23); + }); + it('should get range for end line right after start line', () => { + assert.equal(getRangeLength(createRange(1, 1, 7, 2), 5), 11); + }); + }); +}); + +function createRange(x1: number, y1: number, x2: number, y2: number): IBufferRange { + return { + start: { x: x1, y: y1 }, + end: { x: x2, y: y2 } + }; +} diff --git a/src/common/buffer/BufferRange.ts b/src/common/buffer/BufferRange.ts new file mode 100644 index 00000000..0b4902b1 --- /dev/null +++ b/src/common/buffer/BufferRange.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2021 The xterm.js authors. All rights reserved. + * @license MIT + */ + +import { IBufferRange } from 'xterm'; + +export function getRangeLength(range: IBufferRange, cols: number): number { + if (range.start.y === range.end.y) { + return range.end.x - range.start.x; + } + if (range.start.y > range.end.y) { + throw new Error(`Buffer range end (${range.end.x}, ${range.end.y}) cannot be before start (${range.start.x}, ${range.start.y})`); + } + return cols * (range.end.y - range.start.y - 1) + cols - range.start.x + range.end.x; +} From 9a5f85cc2419a21b5f90df7ab7323781a3a6b5e2 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 5 May 2021 12:29:55 -0700 Subject: [PATCH 189/377] remove .only --- src/common/buffer/BufferRange.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/buffer/BufferRange.test.ts b/src/common/buffer/BufferRange.test.ts index c48de807..d5c685c5 100644 --- a/src/common/buffer/BufferRange.test.ts +++ b/src/common/buffer/BufferRange.test.ts @@ -7,7 +7,7 @@ import { assert } from 'chai'; import { getRangeLength } from 'common/buffer/BufferRange'; import { IBufferRange } from 'xterm'; -describe.only('BufferRange', () => { +describe('BufferRange', () => { describe('getRangeLength', () => { it('should get range for single line', () => { assert.equal(getRangeLength(createRange(1, 1, 4, 1), 0), 3); From 20f320327c40096ac752a571f58f9aff83eea066 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 5 May 2021 19:45:36 -0700 Subject: [PATCH 190/377] Tweak range --- src/common/buffer/BufferRange.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/buffer/BufferRange.ts b/src/common/buffer/BufferRange.ts index 0b4902b1..9091c68d 100644 --- a/src/common/buffer/BufferRange.ts +++ b/src/common/buffer/BufferRange.ts @@ -7,7 +7,7 @@ import { IBufferRange } from 'xterm'; export function getRangeLength(range: IBufferRange, cols: number): number { if (range.start.y === range.end.y) { - return range.end.x - range.start.x; + return range.end.x - range.start.x + 1; } if (range.start.y > range.end.y) { throw new Error(`Buffer range end (${range.end.x}, ${range.end.y}) cannot be before start (${range.start.x}, ${range.start.y})`); From 94034780493035178b2009e903ab96fa5f97b47f Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 5 May 2021 19:49:33 -0700 Subject: [PATCH 191/377] tweak test --- src/common/buffer/BufferRange.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/buffer/BufferRange.test.ts b/src/common/buffer/BufferRange.test.ts index d5c685c5..d0f287dc 100644 --- a/src/common/buffer/BufferRange.test.ts +++ b/src/common/buffer/BufferRange.test.ts @@ -10,7 +10,7 @@ import { IBufferRange } from 'xterm'; describe('BufferRange', () => { describe('getRangeLength', () => { it('should get range for single line', () => { - assert.equal(getRangeLength(createRange(1, 1, 4, 1), 0), 3); + assert.equal(getRangeLength(createRange(1, 1, 4, 1), 0), 4); }); it('should throw for invalid range', () => { assert.throws(() => getRangeLength(createRange(1, 3, 1, 1), 0)); From 0ba0845563151dbee5636a87edac00196c9c3415 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 6 May 2021 20:39:34 +0000 Subject: [PATCH 192/377] [Security] Bump lodash from 4.17.20 to 4.17.21 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21. **This update includes a security fix.** - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.20...4.17.21) Signed-off-by: dependabot-preview[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 9b49f8db..51ee8b30 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2928,9 +2928,9 @@ lodash.sortby@^4.7.0: integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg= lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19: - version "4.17.20" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" - integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== log-symbols@2.2.0: version "2.2.0" From d1ce8a05864657271171296b32177ea4ad9dda91 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 May 2021 21:08:45 +0000 Subject: [PATCH 193/377] Bump lodash from 4.17.19 to 4.17.21 in /addons/xterm-addon-ligatures Bumps [lodash](https://github.com/lodash/lodash) from 4.17.19 to 4.17.21. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.19...4.17.21) Signed-off-by: dependabot[bot] --- addons/xterm-addon-ligatures/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/xterm-addon-ligatures/yarn.lock b/addons/xterm-addon-ligatures/yarn.lock index 2191ce37..2aac858b 100644 --- a/addons/xterm-addon-ligatures/yarn.lock +++ b/addons/xterm-addon-ligatures/yarn.lock @@ -128,9 +128,9 @@ lodash.get@^4.4.2: resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" lodash@^4.17.15: - version "4.17.19" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" - integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== lolex@^2.7.5: version "2.7.5" From 6a63be91074f9c96d2d14c42dcb4a427ceee636a Mon Sep 17 00:00:00 2001 From: vlad doster Date: Fri, 7 May 2021 04:38:12 -0500 Subject: [PATCH 194/377] (docs) update README.md - correct spelling - correct grammar - reduce verbiage - correct punctuation --- README.md | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 42e57ca0..33f6b6d4 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,11 @@ Xterm.js is a front-end component written in TypeScript that lets applications b ## Features -- **Terminal apps just work**: Xterm.js works with most terminal apps such as `bash`, `vim` and `tmux`, this includes support for curses-based apps and mouse event support. +- **Terminal apps just work**: Xterm.js works with most terminal apps such as `bash`, `vim`, and `tmux`, including support for curses-based apps and mouse events. - **Performant**: Xterm.js is *really* fast, it even includes a GPU-accelerated renderer. -- **Rich unicode support**: Supports CJK, emojis and IMEs. +- **Rich Unicode support**: Supports CJK, emojis, and IMEs. - **Self-contained**: Requires zero dependencies to work. -- **Accessible**: Screen reader and minimum contrast ratio support can be turned on +- **Accessible**: Screen reader and minimum contrast ratio support can be turned on. - **And much more**: Links, theming, addons, well documented API, etc. ## What xterm.js is not @@ -20,13 +20,13 @@ Xterm.js is a front-end component written in TypeScript that lets applications b ## Getting Started -First you need to install the module, we ship exclusively through [npm](https://www.npmjs.com/) so you need that installed and then add xterm.js as a dependency by running: +First, you need to install the module, we ship exclusively through [npm](https://www.npmjs.com/), so you need that installed and then add xterm.js as a dependency by running: -``` +```bash npm install xterm ``` -To start using xterm.js on your browser, add the `xterm.js` and `xterm.css` to the head of your html page. Then create a `
` onto which xterm can attach itself. Finally instantiate the `Terminal` object and then call the `open` function with the DOM object of the `div`. +To start using xterm.js on your browser, add the `xterm.js` and `xterm.css` to the head of your HTML page. Then create a `
` onto which xterm can attach itself. Finally, instantiate the `Terminal` object and then call the `open` function with the DOM object of the `div`. ```html @@ -58,7 +58,7 @@ import { Terminal } from 'xterm'; ⚠️ *This section describes the new addon format introduced in v3.14.0, see [here](https://github.com/xtermjs/xterm.js/blob/3.14.2/README.md#addons) for the instructions on the old format* -Addons are separate modules that extend the `Terminal` by building on the [xterm.js API](https://github.com/xtermjs/xterm.js/blob/master/typings/xterm.d.ts). To use an addon you first need to install it in your project: +Addons are separate modules that extend the `Terminal` by building on the [xterm.js API](https://github.com/xtermjs/xterm.js/blob/master/typings/xterm.d.ts). To use an addon, you first need to install it in your project: ```bash npm i -S xterm-addon-web-links @@ -76,7 +76,7 @@ const terminal = new Terminal(); terminal.loadAddon(new WebLinksAddon()); ``` -The xterm.js team maintains the following addons but they can be built by anyone: +The xterm.js team maintains the following addons, but anyone can build them: - [`xterm-addon-attach`](https://github.com/xtermjs/xterm.js/tree/master/addons/xterm-addon-attach): Attaches to a server running a process via a websocket - [`xterm-addon-fit`](https://github.com/xtermjs/xterm.js/tree/master/addons/xterm-addon-fit): Fits the terminal to the containing element @@ -85,23 +85,23 @@ The xterm.js team maintains the following addons but they can be built by anyone ## Browser Support -Since xterm.js is typically implemented as a developer tool, only modern browsers are supported officially. Specifically the latest versions of *Chrome*, *Edge*, *Firefox* and *Safari*. +Since xterm.js is typically implemented as a developer tool, only modern browsers are supported officially. Specifically the latest versions of *Chrome*, *Edge*, *Firefox*, and *Safari*. We also partially support *Internet Explorer 11*, meaning xterm.js should work for the most part, but we reserve the right to not provide workarounds specifically for it unless it's absolutely necessary to get the basic input/output flow working. -Xterm.js works seamlessly in [Electron](https://electronjs.org/) apps and may even work on earlier versions of the browsers, these are the versions we strive to keep working. +Xterm.js works seamlessly in [Electron](https://electronjs.org/) apps and may even work on earlier versions of the browsers. These are the versions we strive to keep working. ## API The full API for xterm.js is contained within the [TypeScript declaration file](https://github.com/xtermjs/xterm.js/blob/master/typings/xterm.d.ts), use the branch/tag picker in GitHub (`w`) to navigate to the correct version of the API. -Note that some APIs are marked *experimental*, these are added to enable experimentation with new ideas without committing to support it like a normal [semver](https://semver.org/) API. Note that these APIs can change radically between versions so be sure to read release notes if you plan on using experimental APIs. +Note that some APIs are marked *experimental*, these are added to enable experimentation with new ideas without committing to support it like a normal [semver](https://semver.org/) API. Note that these APIs can change radically between versions, so be sure to read release notes if you plan on using experimental APIs. ## Real-world uses Xterm.js is used in several world-class applications to provide great terminal experiences. - [**SourceLair**](https://www.sourcelair.com/): In-browser IDE that provides its users with fully-featured Linux terminals based on xterm.js. -- [**Microsoft Visual Studio Code**](http://code.visualstudio.com/): Modern, versatile and powerful open source code editor that provides an integrated terminal based on xterm.js. +- [**Microsoft Visual Studio Code**](http://code.visualstudio.com/): Modern, versatile, and powerful open source code editor that provides an integrated terminal based on xterm.js. - [**ttyd**](https://github.com/tsl0922/ttyd): A command-line tool for sharing terminal over the web, with fully-featured terminal emulation based on xterm.js. - [**Katacoda**](https://www.katacoda.com/): Katacoda is an Interactive Learning Platform for software developers, covering the latest Cloud Native technologies. - [**Eclipse Che**](http://www.eclipse.org/che): Developer workspace server, cloud IDE, and Eclipse next-generation IDE. @@ -113,10 +113,10 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**Next Tech**](https://next.tech "Next Tech"): Online platform for interactive coding and web development courses. Live container-backed terminal uses xterm.js. - [**RStudio**](https://www.rstudio.com/products/RStudio "RStudio"): RStudio is an integrated development environment (IDE) for R. - [**Terminal for Atom**](https://github.com/jsmecham/atom-terminal-tab): A simple terminal for the Atom text editor. -- [**Eclipse Orion**](https://orionhub.org): A modern, open source software development environment that runs in the cloud. Code, deploy and run in the cloud. +- [**Eclipse Orion**](https://orionhub.org): A modern, open source software development environment that runs in the cloud. Code, deploy, and run in the cloud. - [**Gravitational Teleport**](https://github.com/gravitational/teleport): Gravitational Teleport is a modern SSH server for remotely accessing clusters of Linux servers via SSH or HTTPS. - [**Hexlet**](https://en.hexlet.io): Practical programming courses (JavaScript, PHP, Unix, databases, functional programming). A steady path from the first line of code to the first job. -- [**Selenoid UI**](https://github.com/aerokube/selenoid-ui): Simple UI for the scallable golang implementation of Selenium Hub named Selenoid. We use XTerm for streaming logs over websockets from docker containers. +- [**Selenoid UI**](https://github.com/aerokube/selenoid-ui): Simple UI for the scalable golang implementation of Selenium Hub named Selenoid. We use XTerm for streaming logs over websockets from docker containers. - [**Portainer**](https://portainer.io): Simple management UI for Docker. - [**SSHy**](https://github.com/stuicey/SSHy): HTML5 Based SSHv2 Web Client with E2E encryption utilising xterm.js, SJCL & websockets. - [**JupyterLab**](https://github.com/jupyterlab/jupyterlab): An extensible computational environment for Jupyter, supporting interactive data science and scientific computing across all programming languages. @@ -167,17 +167,17 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**Laravel Ssh Web Client**](https://github.com/roke22/Laravel-ssh-client): Laravel server inventory with ssh web client to connect at server using xterm.js - [**Repl.it**](https://repl.it): Collaborative browser based IDE with support for 50+ different languages. - [**TeleType**](https://github.com/akshaykmr/TeleType): cli tool that allows you to share your terminal online conveniently. Show off mad cli-fu, help a colleague, teach, or troubleshoot. -- [**Intervue**](https://www.intervue.io): Pair programming for interviews. Multiple programming languages supported, with results displayed by xterm.js. -- [**TRASA**](https://trasa.io): Zero trust access to Web, SSH, RDP and Database services. +- [**Intervue**](https://www.intervue.io): Pair programming for interviews. Multiple programming languages are supported, with results displayed by xterm.js. +- [**TRASA**](https://trasa.io): Zero trust access to Web, SSH, RDP, and Database services. - [**Commas**](https://github.com/CyanSalt/commas): Commas is a hackable terminal and command runner. - [**Devtron**](https://github.com/devtron-labs/devtron): Software Delivery Workflow For Kubernetes. - [**NxShell**](https://github.com/nxshell/nxshell): An easy to use new terminal for SSH. - [**gifcast**](https://dstein64.github.io/gifcast/): Converts an asciinema cast to an animated GIF. -- [**WizardWebssh**](https://gitlab.com/mikeramsey/wizardwebssh): A terminal with Pyqt5 Widget for embedding which can be used as an ssh client to connect to your ssh servers. It is written in Python, based on tornado, paramiko and xterm.js. -- [**Wizard Assistant**](https://wizardassistant.com/): Wizard Assistant comes with advanced automation tools, preloaded common and special time-saving commands, and a built in SSH terminal. Now you can remotely administer, troubleshoot, and analyze any system with ease. +- [**WizardWebssh**](https://gitlab.com/mikeramsey/wizardwebssh): A terminal with Pyqt5 Widget for embedding, which can be used as an ssh client to connect to your ssh servers. It is written in Python, based on tornado, paramiko, and xterm.js. +- [**Wizard Assistant**](https://wizardassistant.com/): Wizard Assistant comes with advanced automation tools, preloaded common and special time-saving commands, and a built-in SSH terminal. Now you can remotely administer, troubleshoot, and analyze any system with ease. [And much more...](https://github.com/xtermjs/xterm.js/network/dependents) -Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it in our list. Note: Please add any new contributions to the end of the list only. +Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it on our list. Note: Please add any new contributions to the end of the list only. ## Releases @@ -187,21 +187,21 @@ All current and past releases are available on this repo's [Releases page](https ### Beta builds -Our CI releases beta builds to npm for every change that goes into master, install the latest beta build with: +Our CI releases beta builds to npm for every change that goes into master. Install the latest beta build with: -``` +```bash npm install -S xterm@beta ``` -These should generally be stable but some bugs may slip in, we recommend using the beta build primarily to test out new features and for verifying bug fixes. +These should generally be stable, but some bugs may slip in. We recommend using the beta build primarily to test out new features and to verify bug fixes. ## Contributing -You can read the [guide on the wiki](https://github.com/xtermjs/xterm.js/wiki/Contributing) to learn how to contribute and setup xterm.js for development. +You can read the [guide on the wiki](https://github.com/xtermjs/xterm.js/wiki/Contributing) to learn how to contribute and set up xterm.js for development. ## License Agreement -If you contribute code to this project, you are implicitly allowing your code to be distributed under the MIT license. You are also implicitly verifying that all code is your original work. +If you contribute code to this project, you implicitly allow your code to be distributed under the MIT license. You are also implicitly verifying that all code is your original work. Copyright (c) 2017-2019, [The xterm.js authors](https://github.com/xtermjs/xterm.js/graphs/contributors) (MIT License)
Copyright (c) 2014-2017, SourceLair, Private Company ([www.sourcelair.com](https://www.sourcelair.com/home)) (MIT License)
From 673695068ee4acc5a680315123f2f7609290e807 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 10 May 2021 05:35:06 -0700 Subject: [PATCH 195/377] Don't start npm start until watch is done --- .vscode/tasks.json | 117 ++++++++++++++++++++++++++------------------- 1 file changed, 68 insertions(+), 49 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 2f752faf..4d268f61 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,51 +1,70 @@ { - "version": "2.0.0", - "presentation": { - "echo": false, - "reveal": "always", - "focus": false, - "panel": "dedicated", - "showReuseMessage": true - }, - "tasks": [ - { - "type": "npm", - "script": "test", - "group": "test", - "problemMatcher": [] - }, - { - "type": "npm", - "script": "watch", - "group": "build", - "isBackground": true, - "problemMatcher": [], - "presentation": { - "group": "vscode" - } - }, - { - "type": "npm", - "script": "start", - "group": "build", - "isBackground": true, - "problemMatcher": [], - "presentation": { - "group": "vscode" - } - }, - { - "label": "Start demo", - "dependsOn": ["npm: watch", "npm: start"], - "group": { - "kind": "build", - "isDefault": true - }, - "isBackground": true, - "problemMatcher": [], - "presentation": { - "group": "vscode" - } - } - ] + "version": "2.0.0", + "presentation": { + "echo": false, + "reveal": "always", + "focus": false, + "panel": "dedicated", + "showReuseMessage": true + }, + "tasks": [ + { + "type": "npm", + "script": "test", + "group": "test", + "problemMatcher": [] + }, + { + "type": "npm", + "script": "watch", + "group": "build", + "isBackground": true, + "problemMatcher": "$tsc-watch", + "presentation": { + "group": "vscode" + } + }, + { + "type": "npm", + "script": "start", + "dependsOn": "npm: watch", + "group": "build", + "isBackground": true, + "problemMatcher": [], + "presentation": { + "group": "vscode" + } + }, + { + "label": "Start demo", + "dependsOn": "npm: start", + "group": { + "kind": "build", + "isDefault": true + }, + "isBackground": true, + "problemMatcher": { + "owner": "typescript", + "fileLocation": [ + "relative", + "${workspaceFolder}" + ], + "pattern": [ + { + "regexp": "^([^\\\\s].*)\\\\((\\\\d+,\\\\d+)\\\\):\\\\s*(.*)$", + "file": 1, + "location": 2, + "message": 3 + } + ], + "background": { + "beginsPattern": "assets by", + "endsPattern": "webpack \\d+\\.\\d+\\.\\d+ compiled successfully" + } + }, + "presentation": { + "group": "vscode" + } + } + ] } From e55b9fe922b519bb9325725886c200d21db50f5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Mon, 10 May 2021 22:35:05 +0200 Subject: [PATCH 196/377] update package dependencies --- .../benchmark/SerializeAddon.benchmark.ts | 2 +- package.json | 48 +- src/browser/Terminal2.test.ts | 2 +- yarn.lock | 2929 ++++++++--------- 4 files changed, 1475 insertions(+), 1506 deletions(-) diff --git a/addons/xterm-addon-serialize/benchmark/SerializeAddon.benchmark.ts b/addons/xterm-addon-serialize/benchmark/SerializeAddon.benchmark.ts index 0147631d..87741b63 100644 --- a/addons/xterm-addon-serialize/benchmark/SerializeAddon.benchmark.ts +++ b/addons/xterm-addon-serialize/benchmark/SerializeAddon.benchmark.ts @@ -35,7 +35,7 @@ perfContext('Terminal: sh -c "dd if=/dev/urandom count=40 bs=1k | hexdump | lolc chunks.push(data as unknown as Buffer); length += data.length; }); - await new Promise(resolve => p.on('exit', () => resolve())); + await new Promise(resolve => p.on('exit', () => resolve())); contentUtf8 = Buffer.concat(chunks, length); // translate to content string const buffer = new Uint32Array(contentUtf8.length); diff --git a/package.json b/package.json index 9134a378..a7de4815 100644 --- a/package.json +++ b/package.json @@ -34,37 +34,37 @@ "vtfeatures": "node bin/extract_vtfeatures.js src/**/*.ts src/*.ts" }, "devDependencies": { - "@types/chai": "^4.2.14", + "@types/chai": "^4.2.18", "@types/debug": "^4.1.5", "@types/deep-equal": "^1.0.1", "@types/glob": "^7.1.3", - "@types/jsdom": "^16.2.5", - "@types/mocha": "^8.0.3", - "@types/node": "^10.17.17", + "@types/jsdom": "^16.2.10", + "@types/mocha": "^8.2.2", + "@types/node": "^12.12.37", "@types/utf8": "^2.1.6", - "@types/webpack": "^4.41.24", - "@types/ws": "^7.2.9", - "@typescript-eslint/eslint-plugin": "^4.0.0", - "@typescript-eslint/parser": "^3.10.1", - "chai": "^4.2.0", - "deep-equal": "^2.0.4", - "eslint": "^7.12.1", + "@types/webpack": "^5.28.0", + "@types/ws": "^7.4.2", + "@typescript-eslint/eslint-plugin": "^4.23.0", + "@typescript-eslint/parser": "^4.23.0", + "chai": "^4.3.4", + "deep-equal": "^2.0.5", + "eslint": "^7.26.0", "express": "^4.17.1", "express-ws": "^4.0.0", - "glob": "^7.0.5", - "jsdom": "^16.4.0", - "mocha": "^8.2.1", - "mustache": "^4.0.1", - "node-pty": "^0.9.0", + "glob": "^7.1.7", + "jsdom": "^16.5.3", + "mocha": "^8.4.0", + "mustache": "^4.2.0", + "node-pty": "^0.10.1", "nyc": "^15.1.0", - "playwright": "^1.5.2", - "source-map-loader": "^1.1.2", - "ts-loader": "^8.0.8", - "typescript": "4.0", + "playwright": "^1.10.0", + "source-map-loader": "^2.0.1", + "ts-loader": "8.2.0", + "typescript": "^4.2.4", "utf8": "^3.0.0", - "webpack": "^5.4.0", - "webpack-cli": "^4.2.0", - "ws": "^7.3.1", - "xterm-benchmark": "^0.1.3" + "webpack": "^5.37.0", + "webpack-cli": "^4.7.0", + "ws": "^7.4.5", + "xterm-benchmark": "^0.2.1" } } diff --git a/src/browser/Terminal2.test.ts b/src/browser/Terminal2.test.ts index 1ad0e905..75832e93 100644 --- a/src/browser/Terminal2.test.ts +++ b/src/browser/Terminal2.test.ts @@ -73,7 +73,7 @@ describe('Escape Sequence Files', function(): void { // register handler to trigger viewport scraping, wait for it to finish let content = ''; const OSC_CODE = 12345; - await new Promise(resolve => { + await new Promise(resolve => { customHandler = term.registerOscHandler(OSC_CODE, () => { // grab terminal viewport content content = terminalToString(term); diff --git a/yarn.lock b/yarn.lock index 51ee8b30..460b36f5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,13 @@ # yarn lockfile v1 +"@babel/code-frame@7.12.11": + version "7.12.11" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.11.tgz#f4ad435aa263db935b8f10f2c552d23fb716a63f" + integrity sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw== + dependencies: + "@babel/highlight" "^7.10.4" + "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.8.3": version "7.8.3" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.8.3.tgz#33e25903d7481181534e12ec0a25f16b6fcf419e" @@ -116,6 +123,11 @@ dependencies: "@babel/types" "^7.8.3" +"@babel/helper-validator-identifier@^7.14.0": + version "7.14.0" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.0.tgz#d26cad8a47c65286b15df1547319a5d0bcf27288" + integrity sha512-V3ts7zMSu5lfiwWDVWzRDGIN+lnCEUdaXgtVHJgLb1rGaA6jMrtB9EmE7L18foXJIE8Un/A/h6NJfGQp/e1J4A== + "@babel/helper-validator-identifier@^7.9.0": version "7.9.0" resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.0.tgz#ad53562a7fc29b3b9a91bbf7d10397fd146346ed" @@ -130,6 +142,15 @@ "@babel/traverse" "^7.9.0" "@babel/types" "^7.9.0" +"@babel/highlight@^7.10.4": + version "7.14.0" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.14.0.tgz#3197e375711ef6bf834e67d0daec88e4f46113cf" + integrity sha512-YSCOwxvTYEIMSGaBQb5kDDsCopDdiUGsqpatp3fOlI4+2HQSkTmEVWnVuySdAC5EWCqSWWTv0ib63RjR7dTBdg== + dependencies: + "@babel/helper-validator-identifier" "^7.14.0" + chalk "^2.0.0" + js-tokens "^4.0.0" + "@babel/highlight@^7.8.3": version "7.9.0" resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.9.0.tgz#4e9b45ccb82b79607271b2979ad82c7b68163079" @@ -177,10 +198,24 @@ lodash "^4.17.13" to-fast-properties "^2.0.0" -"@eslint/eslintrc@^0.2.1": - version "0.2.1" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.2.1.tgz#f72069c330461a06684d119384435e12a5d76e3c" - integrity sha512-XRUeBZ5zBWLYgSANMpThFddrZZkEbGHgUdt5UJjZfnlN9BGCiUBrf+nvbRupSjMvqzwnQN0qwCmOxITt1cfywA== +"@dabh/diagnostics@^2.0.2": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@dabh/diagnostics/-/diagnostics-2.0.2.tgz#290d08f7b381b8f94607dc8f471a12c675f9db31" + integrity sha512-+A1YivoVDNNVCdfozHSR8v/jyuuLTMXwjWuxPFlFlUapXoGc+Gj9mDlTDDfrwl7rXCl2tNZ0kE8sIBO6YOn96Q== + dependencies: + colorspace "1.1.x" + enabled "2.0.x" + kuler "^2.0.0" + +"@discoveryjs/json-ext@^0.5.0": + version "0.5.2" + resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.2.tgz#8f03a22a04de437254e8ce8cc84ba39689288752" + integrity sha512-HyYEUDeIj5rRQU2Hk5HTB2uHsbRQpF70nvMhVzi+VJR0X+xNEhjPui4/kBf3VeH/wqD28PT4sVOm8qqLjBrSZg== + +"@eslint/eslintrc@^0.4.1": + version "0.4.1" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.1.tgz#442763b88cecbe3ee0ec7ca6d6dd6168550cbf14" + integrity sha512-5v7TDE9plVhvxQeWLXDTvFvJBdH6pEsdnl2g/dAptmuFEPedQ4Erq5rsDsX+mvAM610IhNaO2W5V1dOOnDKxkQ== dependencies: ajv "^6.12.4" debug "^4.1.1" @@ -189,7 +224,6 @@ ignore "^4.0.6" import-fresh "^3.2.1" js-yaml "^3.13.1" - lodash "^4.17.19" minimatch "^3.0.4" strip-json-comments "^3.1.1" @@ -208,41 +242,48 @@ resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.2.tgz#26520bf09abe4a5644cd5414e37125a8954241dd" integrity sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw== -"@nodelib/fs.scandir@2.1.3": - version "2.1.3" - resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz#3a582bdb53804c6ba6d146579c46e52130cf4a3b" - integrity sha512-eGmwYQn3gxo4r7jdQnkrrN6bY478C3P+a/y72IJukF8LjB6ZHeB3c+Ehacj3sYeSmUXGlnA67/PmbM9CVwL7Dw== +"@kwsites/file-exists@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@kwsites/file-exists/-/file-exists-1.1.1.tgz#ad1efcac13e1987d8dbaf235ef3be5b0d96faa99" + integrity sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw== dependencies: - "@nodelib/fs.stat" "2.0.3" + debug "^4.1.1" + +"@kwsites/promise-deferred@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@kwsites/promise-deferred/-/promise-deferred-1.1.1.tgz#8ace5259254426ccef57f3175bc64ed7095ed919" + integrity sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw== + +"@nodelib/fs.scandir@2.1.4": + version "2.1.4" + resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz#d4b3549a5db5de2683e0c1071ab4f140904bbf69" + integrity sha512-33g3pMJk3bg5nXbL/+CY6I2eJDzZAni49PfJnL5fghPTggPvBd/pFNSgJsdAgWptuFu7qq/ERvOYFlhvsLTCKA== + dependencies: + "@nodelib/fs.stat" "2.0.4" run-parallel "^1.1.9" -"@nodelib/fs.stat@2.0.3", "@nodelib/fs.stat@^2.0.2": - version "2.0.3" - resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.3.tgz#34dc5f4cabbc720f4e60f75a747e7ecd6c175bd3" - integrity sha512-bQBFruR2TAwoevBEd/NWMoAAtNGzTRgdrqnYCc7dhzfoNvqPzLyqlEQnzZ3kVnNrSp25iyxE00/3h2fqGAGArA== +"@nodelib/fs.stat@2.0.4", "@nodelib/fs.stat@^2.0.2": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.4.tgz#a3f2dd61bab43b8db8fa108a121cfffe4c676655" + integrity sha512-IYlHJA0clt2+Vg7bccq+TzRdJvv19c2INqBSsoOLp1je7xjtr7J26+WXR72MCdvU9q1qTzIWDfhMf+DRvQJK4Q== "@nodelib/fs.walk@^1.2.3": - version "1.2.4" - resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.4.tgz#011b9202a70a6366e436ca5c065844528ab04976" - integrity sha512-1V9XOY4rDW0rehzbrcqAmHnz8e7SKvX27gh8Gt2WgB0+pdzdiLV83p72kZPU+jvMbS1qU5mauP2iOvO8rhmurQ== + version "1.2.6" + resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.6.tgz#cce9396b30aa5afe9e3756608f5831adcb53d063" + integrity sha512-8Broas6vTtW4GIXTAHDoE32hnN2M5ykgCpWGbuXHQ15vEMqr23pB76e/GZcYsZCHALv50ktd24qhEyKr6wBtow== dependencies: - "@nodelib/fs.scandir" "2.1.3" + "@nodelib/fs.scandir" "2.1.4" fastq "^1.6.0" -"@types/anymatch@*": - version "1.3.1" - resolved "https://registry.yarnpkg.com/@types/anymatch/-/anymatch-1.3.1.tgz#336badc1beecb9dacc38bea2cf32adf627a8421a" - integrity sha512-/+CRPXpBDpo2RK9C68N3b2cOvO0Cf5B9aPijHsoDQTHivnGSObdOF2BRQOYjojWTDy6nQvMjmqRXIxH55VjxxA== - "@types/app-root-path@^1.2.4": version "1.2.4" resolved "https://registry.yarnpkg.com/@types/app-root-path/-/app-root-path-1.2.4.tgz#a78b703282b32ac54de768f5512ecc3569919dc7" integrity sha1-p4twMoKzKsVN52j1US7MNWmRncc= -"@types/chai@^4.2.14": - version "4.2.14" - resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.2.14.tgz#44d2dd0b5de6185089375d976b4ec5caf6861193" - integrity sha512-G+ITQPXkwTrslfG5L/BksmbLUA0M1iybEsmCWPqzSxsRRhJZimBKJkoMi8fr/CPygPTj4zO5pJH7I2/cm9M7SQ== +"@types/chai@^4.2.18": + version "4.2.18" + resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.2.18.tgz#0c8e298dbff8205e2266606c1ea5fbdba29b46e4" + integrity sha512-rS27+EkB/RE1Iz3u0XtVL5q36MGDWbgYe7zWiodyKNUnthxY0rukK5V36eiUCtCisB7NN8zKYH6DO2M37qxFEQ== "@types/cli-table@^0.3.0": version "0.3.0" @@ -272,28 +313,23 @@ "@types/eslint" "*" "@types/estree" "*" -"@types/eslint-visitor-keys@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" - integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag== - "@types/eslint@*": - version "7.2.4" - resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-7.2.4.tgz#d12eeed7741d2491b69808576ac2d20c14f74c41" - integrity sha512-YCY4kzHMsHoyKspQH+nwSe+70Kep7Vjt2X+dZe5Vs2vkRudqtoFoUIv1RlJmZB8Hbp7McneupoZij4PadxsK5Q== + version "7.2.10" + resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-7.2.10.tgz#4b7a9368d46c0f8cd5408c23288a59aa2394d917" + integrity sha512-kUEPnMKrqbtpCq/KTaGFFKAcz6Ethm2EjCoKIDaCmfRBWLbFuTcOJfTlorwbnboXBzahqWLgUp1BQeKHiJzPUQ== dependencies: "@types/estree" "*" "@types/json-schema" "*" -"@types/estree@*", "@types/estree@^0.0.45": - version "0.0.45" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.45.tgz#e9387572998e5ecdac221950dab3e8c3b16af884" - integrity sha512-jnqIUKDUqJbDIUxm0Uj7bnlMnRm1T/eZ9N+AVMqhPgzrba2GhGG5o/jCTwmdPK709nEZsGoMzXEDUjcXHa3W0g== +"@types/estree@*", "@types/estree@^0.0.47": + version "0.0.47" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.47.tgz#d7a51db20f0650efec24cd04994f523d93172ed4" + integrity sha512-c5ciR06jK8u9BstrmJyO97m+klJrrhCf9u3rLu3DEAJBirxRqSCvDQoYKmxuYwQI5SZChAWu+tq9oVlGRuzPAg== -"@types/fs-extra@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-7.0.0.tgz#9c4ad9e1339e7448a76698829def1f159c1b636c" - integrity sha512-ndoMMbGyuToTy4qB6Lex/inR98nPiNHacsgMPvy+zqMLgSxbt8VtWpDArpGp69h1fEDQHn1KB+9DWD++wgbwYA== +"@types/fs-extra@9.0.1": + version "9.0.1" + resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.1.tgz#91c8fc4c51f6d5dbe44c2ca9ab09310bd00c7918" + integrity sha512-B42Sxuaz09MhC3DDeW5kubRcQ5by4iuVQ0cRRWM2lggLzAa/KVom0Aft/208NgMvNQQZ86s5rVcqDdn/SH0/mg== dependencies: "@types/node" "*" @@ -305,29 +341,29 @@ "@types/minimatch" "*" "@types/node" "*" -"@types/jsdom@^16.2.5": - version "16.2.5" - resolved "https://registry.yarnpkg.com/@types/jsdom/-/jsdom-16.2.5.tgz#74ebad438741d249ecb416c5486dcde4217eb66c" - integrity sha512-k/ZaTXtReAjwWu0clU0KLS53dyqZnA8mm+jwKFeFrvufXgICp+VNbskETFxKKAguv0pkaEKTax5MaRmvalM+TA== +"@types/jsdom@^16.2.10": + version "16.2.10" + resolved "https://registry.yarnpkg.com/@types/jsdom/-/jsdom-16.2.10.tgz#c05ea94682d035943ae2453b79d56178496b6653" + integrity sha512-q3aIjp3ehhVSXSbvNyuireAfvU2umRiZ2aLumyeZewCnoNaokrRDdTu5IvaeE9pzNtWHXrUnM9lb22Vl3W08EA== dependencies: "@types/node" "*" "@types/parse5" "*" "@types/tough-cookie" "*" -"@types/json-schema@*", "@types/json-schema@^7.0.6": +"@types/json-schema@*", "@types/json-schema@^7.0.3": + version "7.0.7" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad" + integrity sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA== + +"@types/json-schema@^7.0.6": version "7.0.6" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0" integrity sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw== -"@types/json-schema@^7.0.3": - version "7.0.5" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.5.tgz#dcce4430e64b443ba8945f0290fb564ad5bac6dd" - integrity sha512-7+2BITlgjgDhH0vvwZU/HZJVyk+2XUlvxXe8dFMedNX/aMkaOq++rMAFXc0tM7ij15QaWlbdQASBR9dihi+bDQ== - -"@types/mathjs@^5.0.1": - version "5.0.1" - resolved "https://registry.yarnpkg.com/@types/mathjs/-/mathjs-5.0.1.tgz#b98e163ea396b4f27bec20ee25ffb8fe9e656af8" - integrity sha512-EFBuueI+BRed9bnUO6/9my55b4FH+VQIvqMm58h9JGbtaGCkqr3YSDhnmVbM1SJjF//8SURERSypzNwejOk7lA== +"@types/mathjs@^6.0.11": + version "6.0.12" + resolved "https://registry.yarnpkg.com/@types/mathjs/-/mathjs-6.0.12.tgz#1c2a60352852676e10936ce150b9500d36555973" + integrity sha512-bpKs8CDJ0aOiiJguywryE/U6Wre/uftJ89xhp4aCgF4oRb3Yug2VyZ87958gmSeq4WMsvWPMs2Q5TtFv+dJtaA== dependencies: decimal.js "^10.0.0" @@ -336,95 +372,56 @@ resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA== -"@types/mocha@^5.2.7": - version "5.2.7" - resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-5.2.7.tgz#315d570ccb56c53452ff8638738df60726d5b6ea" - integrity sha512-NYrtPht0wGzhwe9+/idPaBB+TqkY9AhTvOLMkThm0IoEfLaiVQZwBwyJ5puCkO3AUCWrmcoePjp2mbFocKy4SQ== - -"@types/mocha@^8.0.3": - version "8.0.3" - resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.0.3.tgz#51b21b6acb6d1b923bbdc7725c38f9f455166402" - integrity sha512-vyxR57nv8NfcU0GZu8EUXZLTbCMupIUwy95LJ6lllN+JRPG25CwMHoB1q5xKh8YKhQnHYRAn4yW2yuHbf/5xgg== +"@types/mocha@^8.2.1", "@types/mocha@^8.2.2": + version "8.2.2" + resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.2.2.tgz#91daa226eb8c2ff261e6a8cbf8c7304641e095e0" + integrity sha512-Lwh0lzzqT5Pqh6z61P3c3P5nm6fzQK/MMHl9UKeneAeInVflBSz1O2EkX6gM6xfJd7FBXBY5purtLx7fUiZ7Hw== "@types/node@*": version "13.9.5" resolved "https://registry.yarnpkg.com/@types/node/-/node-13.9.5.tgz#59738bf30b31aea1faa2df7f4a5f55613750cf00" integrity sha512-hkzMMD3xu6BrJpGVLeQ3htQQNAcOrJjX7WFmtK8zWQpz2UJf13LCFF2ALA7c9OVdvc2vQJeDdjfR35M0sBCxvw== -"@types/node@^10.17.17": - version "10.17.18" - resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.18.tgz#ae364d97382aacdebf583fa4e7132af2dfe56a0c" - integrity sha512-DQ2hl/Jl3g33KuAUOcMrcAOtsbzb+y/ufakzAdeK9z/H/xsvkpbETZZbPNMIiQuk24f5ZRMCcZIViAwyFIiKmg== - -"@types/node@^12.0.4": - version "12.12.32" - resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.32.tgz#0ccc836d273e8a3cddf568daf22729cfa57c1925" - integrity sha512-44/reuCrwiQEsXud3I5X3sqI5jIXAmHB5xoiyKUw965olNHF3IWKjBLKK3F9LOSUZmK+oDt8jmyO637iX+hMgA== +"@types/node@^12.12.37": + version "12.20.12" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.12.tgz#fd9c1c2cfab536a2383ed1ef70f94adea743a226" + integrity sha512-KQZ1al2hKOONAs2MFv+yTQP1LkDWMrRJ9YCVRalXltOfXsBmH5IownLxQaiq0lnAHwAViLnh2aTYqrPcRGEbgg== "@types/parse5@*": - version "5.0.2" - resolved "https://registry.yarnpkg.com/@types/parse5/-/parse5-5.0.2.tgz#a877a4658f8238c8266faef300ae41c84d72ec8a" - integrity sha512-BOl+6KDs4ItndUWUFchy3aEqGdHhw0BC4Uu+qoDonN/f0rbUnJbm71Ulj8Tt9jLFRaAxPLKvdS1bBLfx1qXR9g== + version "6.0.0" + resolved "https://registry.yarnpkg.com/@types/parse5/-/parse5-6.0.0.tgz#38590dc2c3cf5717154064e3ee9b6947ee21b299" + integrity sha512-oPwPSj4a1wu9rsXTEGIJz91ISU725t0BmSnUhb57sI+M8XEmvUop84lzuiYdq0Y5M6xLY8DBPg0C2xEQKLyvBA== -"@types/puppeteer@^1.12.4": - version "1.20.4" - resolved "https://registry.yarnpkg.com/@types/puppeteer/-/puppeteer-1.20.4.tgz#30cb0a4ee5394c420119cbdf9f079d6595a07f67" - integrity sha512-T/kFgyLnYWk0H94hxI0HbOLnqHvzBRpfS0F0oo9ESGI24oiC2fEjDcMbBjuK3wH7VLsaIsp740vVXVzR1dsMNg== +"@types/puppeteer@^5.4.3": + version "5.4.3" + resolved "https://registry.yarnpkg.com/@types/puppeteer/-/puppeteer-5.4.3.tgz#cdca84aa7751d77448d8a477dbfa0af1f11485f2" + integrity sha512-3nE8YgR9DIsgttLW+eJf6mnXxq8Ge+27m5SU3knWmrlfl6+KOG0Bf9f7Ua7K+C4BnaTMAh3/UpySqdAYvrsvjg== dependencies: "@types/node" "*" -"@types/source-list-map@*": - version "0.1.2" - resolved "https://registry.yarnpkg.com/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9" - integrity sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA== - -"@types/tapable@*": - version "1.0.5" - resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.5.tgz#9adbc12950582aa65ead76bffdf39fe0c27a3c02" - integrity sha512-/gG2M/Imw7cQFp8PGvz/SwocNrmKFjFsm5Pb8HdbHkZ1K8pmuPzOX4VeVoiEecFCVf4CsN1r3/BRvx+6sNqwtQ== - "@types/tough-cookie@*": - version "2.3.6" - resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-2.3.6.tgz#c880579e087d7a0db13777ff8af689f4ffc7b0d5" - integrity sha512-wHNBMnkoEBiRAd3s8KTKwIuO9biFtTf0LehITzBhSco+HQI0xkXZbLOD55SW3Aqw3oUkHstkm5SPv58yaAdFPQ== - -"@types/uglify-js@*": - version "3.0.4" - resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.0.4.tgz#96beae23df6f561862a830b4288a49e86baac082" - integrity sha512-SudIN9TRJ+v8g5pTG8RRCqfqTMNqgWCKKd3vtynhGzkIIjxaicNAMuY5TRadJ6tzDu3Dotf3ngaMILtmOdmWEQ== - dependencies: - source-map "^0.6.1" + version "4.0.0" + resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-4.0.0.tgz#fef1904e4668b6e5ecee60c52cc6a078ffa6697d" + integrity sha512-I99sngh224D0M7XgW1s120zxCt3VYQ3IQsuw3P3jbq5GG4yc79+ZjyKznyOGIQrflfylLgcfekeZW/vk0yng6A== "@types/utf8@^2.1.6": version "2.1.6" resolved "https://registry.yarnpkg.com/@types/utf8/-/utf8-2.1.6.tgz#430cabb71a42d0a3613cce5621324fe4f5a25753" integrity sha512-pRs2gYF5yoKYrgSaira0DJqVg2tFuF+Qjp838xS7K+mJyY2jJzjsrl6y17GbIa4uMRogMbxs+ghNCvKg6XyNrA== -"@types/webpack-sources@*": - version "0.1.7" - resolved "https://registry.yarnpkg.com/@types/webpack-sources/-/webpack-sources-0.1.7.tgz#0a330a9456113410c74a5d64180af0cbca007141" - integrity sha512-XyaHrJILjK1VHVC4aVlKsdNN5KBTwufMb43cQs+flGxtPAf/1Qwl8+Q0tp5BwEGaI8D6XT1L+9bSWXckgkjTLw== +"@types/webpack@^5.28.0": + version "5.28.0" + resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-5.28.0.tgz#78dde06212f038d77e54116cfe69e88ae9ed2c03" + integrity sha512-8cP0CzcxUiFuA9xGJkfeVpqmWTk9nx6CWwamRGCj95ph1SmlRRk9KlCZ6avhCbZd4L68LvYT6l1kpdEnQXrF8w== dependencies: "@types/node" "*" - "@types/source-list-map" "*" - source-map "^0.6.1" + tapable "^2.2.0" + webpack "^5" -"@types/webpack@^4.41.24": - version "4.41.24" - resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.41.24.tgz#75b664abe3d5bcfe54e64313ca3b43e498550422" - integrity sha512-1A0MXPwZiMOD3DPMuOKUKcpkdPo8Lq33UGggZ7xio6wJ/jV1dAu5cXDrOfGDnldUroPIRLsr/DT43/GqOA4RFQ== - dependencies: - "@types/anymatch" "*" - "@types/node" "*" - "@types/tapable" "*" - "@types/uglify-js" "*" - "@types/webpack-sources" "*" - source-map "^0.6.0" - -"@types/ws@^7.2.9": - version "7.2.9" - resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.2.9.tgz#cadfac473acfab192678a487c3ecbb13a503547f" - integrity sha512-gmXYAXr7G4BrRMnkGQGkGonc3ArVro9VZd//C1uns/qqsJyl2dxaJdlPMhZbcq5MTxFFC+ttFWtHSfVW5+hlRA== +"@types/ws@^7.4.2": + version "7.4.2" + resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.2.tgz#bfe739b5f8b3a39742605fbe415ae7e88ee614c8" + integrity sha512-PbeN0Eydl7LQl4OIav29YmkO2LxbVuz3nZD/kb19lOS+wLgIkRbWMNmU/QQR7ABpOJ7D7xDOU8co7iohObewrw== dependencies: "@types/node" "*" @@ -435,112 +432,74 @@ dependencies: "@types/node" "*" -"@typescript-eslint/eslint-plugin@^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.0.0.tgz#99349a501447fed91de18346705c0c65cf603bee" - integrity sha512-5e6q1TR7gS2P+8W2xndCu7gBh3BzmYEo70OyIdsmCmknHha/yNbz2vdevl+tP1uoaMOcrzg4gyrAijuV3DDBHA== +"@typescript-eslint/eslint-plugin@^4.23.0": + version "4.23.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.23.0.tgz#29d3c9c81f6200b1fd6d8454cfb007ba176cde80" + integrity sha512-tGK1y3KIvdsQEEgq6xNn1DjiFJtl+wn8JJQiETtCbdQxw1vzjXyAaIkEmO2l6Nq24iy3uZBMFQjZ6ECf1QdgGw== dependencies: - "@typescript-eslint/experimental-utils" "4.0.0" - "@typescript-eslint/scope-manager" "4.0.0" + "@typescript-eslint/experimental-utils" "4.23.0" + "@typescript-eslint/scope-manager" "4.23.0" debug "^4.1.1" functional-red-black-tree "^1.0.1" + lodash "^4.17.15" regexpp "^3.0.0" semver "^7.3.2" tsutils "^3.17.1" -"@typescript-eslint/experimental-utils@3.10.1": - version "3.10.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-3.10.1.tgz#e179ffc81a80ebcae2ea04e0332f8b251345a686" - integrity sha512-DewqIgscDzmAfd5nOGe4zm6Bl7PKtMG2Ad0KG8CUZAHlXfAKTF9Ol5PXhiMh39yRL2ChRH1cuuUGOcVyyrhQIw== +"@typescript-eslint/experimental-utils@4.23.0": + version "4.23.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.23.0.tgz#f2059434cd6e5672bfeab2fb03b7c0a20622266f" + integrity sha512-WAFNiTDnQfrF3Z2fQ05nmCgPsO5o790vOhmWKXbbYQTO9erE1/YsFot5/LnOUizLzU2eeuz6+U/81KV5/hFTGA== dependencies: "@types/json-schema" "^7.0.3" - "@typescript-eslint/types" "3.10.1" - "@typescript-eslint/typescript-estree" "3.10.1" + "@typescript-eslint/scope-manager" "4.23.0" + "@typescript-eslint/types" "4.23.0" + "@typescript-eslint/typescript-estree" "4.23.0" eslint-scope "^5.0.0" eslint-utils "^2.0.0" -"@typescript-eslint/experimental-utils@4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.0.0.tgz#fbec21a3b5ab59127edb6ce2e139ed378cc50eb5" - integrity sha512-hbX6zR+a/vcpFVNJYN/Nbd7gmaMosDTxHEKcvmhWeWcq/0UDifrqmCfkkodbAKL46Fn4ekSBMTyq2zlNDzcQxw== +"@typescript-eslint/parser@^4.23.0": + version "4.23.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.23.0.tgz#239315d38e42e852bef43a4b0b01bef78f78911c" + integrity sha512-wsvjksHBMOqySy/Pi2Q6UuIuHYbgAMwLczRl4YanEPKW5KVxI9ZzDYh3B5DtcZPQTGRWFJrfcbJ6L01Leybwug== dependencies: - "@types/json-schema" "^7.0.3" - "@typescript-eslint/scope-manager" "4.0.0" - "@typescript-eslint/types" "4.0.0" - "@typescript-eslint/typescript-estree" "4.0.0" - eslint-scope "^5.0.0" - eslint-utils "^2.0.0" - -"@typescript-eslint/parser@^3.10.1": - version "3.10.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-3.10.1.tgz#1883858e83e8b442627e1ac6f408925211155467" - integrity sha512-Ug1RcWcrJP02hmtaXVS3axPPTTPnZjupqhgj+NnZ6BCkwSImWk/283347+x9wN+lqOdK9Eo3vsyiyDHgsmiEJw== - dependencies: - "@types/eslint-visitor-keys" "^1.0.0" - "@typescript-eslint/experimental-utils" "3.10.1" - "@typescript-eslint/types" "3.10.1" - "@typescript-eslint/typescript-estree" "3.10.1" - eslint-visitor-keys "^1.1.0" - -"@typescript-eslint/scope-manager@4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.0.0.tgz#8c9e3b3b8cdf5a1fbe671d9fad73ff67bc027ea8" - integrity sha512-9gcWUPoWo7gk/+ZQPg7L1ySRmR5HLIy3Vu6/LfhQbuzIkGm6v2CGIjpVRISoDLFRovNRDImd4aP/sa8O4yIEBg== - dependencies: - "@typescript-eslint/types" "4.0.0" - "@typescript-eslint/visitor-keys" "4.0.0" - -"@typescript-eslint/types@3.10.1": - version "3.10.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-3.10.1.tgz#1d7463fa7c32d8a23ab508a803ca2fe26e758727" - integrity sha512-+3+FCUJIahE9q0lDi1WleYzjCwJs5hIsbugIgnbB+dSCYUxl8L6PwmsyOPFZde2hc1DlTo/xnkOgiTLSyAbHiQ== - -"@typescript-eslint/types@4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.0.0.tgz#ec1f9fc06b8558a1d5afa6e337182d08beece7f5" - integrity sha512-bK+c2VLzznX2fUWLK6pFDv3cXGTp7nHIuBMq1B9klA+QCsqLHOOqe5TQReAQDl7DN2RfH+neweo0oC5hYlG7Rg== - -"@typescript-eslint/typescript-estree@3.10.1": - version "3.10.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-3.10.1.tgz#fd0061cc38add4fad45136d654408569f365b853" - integrity sha512-QbcXOuq6WYvnB3XPsZpIwztBoquEYLXh2MtwVU+kO8jgYCiv4G5xrSP/1wg4tkvrEE+esZVquIPX/dxPlePk1w== - dependencies: - "@typescript-eslint/types" "3.10.1" - "@typescript-eslint/visitor-keys" "3.10.1" + "@typescript-eslint/scope-manager" "4.23.0" + "@typescript-eslint/types" "4.23.0" + "@typescript-eslint/typescript-estree" "4.23.0" debug "^4.1.1" - glob "^7.1.6" - is-glob "^4.0.1" - lodash "^4.17.15" - semver "^7.3.2" - tsutils "^3.17.1" -"@typescript-eslint/typescript-estree@4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.0.0.tgz#2244c63de2f2190bc5718eb0fb3fd2c437d42097" - integrity sha512-ewFMPi2pMLDNIXGMPdf8r7El2oPSZw9PEYB0j+WcpKd7AX2ARmajGa7RUHTukllWX2bj4vWX6JLE1Oih2BMokA== +"@typescript-eslint/scope-manager@4.23.0": + version "4.23.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.23.0.tgz#8792ef7eacac122e2ec8fa2d30a59b8d9a1f1ce4" + integrity sha512-ZZ21PCFxPhI3n0wuqEJK9omkw51wi2bmeKJvlRZPH5YFkcawKOuRMQMnI8mH6Vo0/DoHSeZJnHiIx84LmVQY+w== dependencies: - "@typescript-eslint/types" "4.0.0" - "@typescript-eslint/visitor-keys" "4.0.0" + "@typescript-eslint/types" "4.23.0" + "@typescript-eslint/visitor-keys" "4.23.0" + +"@typescript-eslint/types@4.23.0": + version "4.23.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.23.0.tgz#da1654c8a5332f4d1645b2d9a1c64193cae3aa3b" + integrity sha512-oqkNWyG2SLS7uTWLZf6Sr7Dm02gA5yxiz1RP87tvsmDsguVATdpVguHr4HoGOcFOpCvx9vtCSCyQUGfzq28YCw== + +"@typescript-eslint/typescript-estree@4.23.0": + version "4.23.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.23.0.tgz#0753b292097523852428a6f5a1aa8ccc1aae6cd9" + integrity sha512-5Sty6zPEVZF5fbvrZczfmLCOcby3sfrSPu30qKoY1U3mca5/jvU5cwsPb/CO6Q3ByRjixTMIVsDkqwIxCf/dMw== + dependencies: + "@typescript-eslint/types" "4.23.0" + "@typescript-eslint/visitor-keys" "4.23.0" debug "^4.1.1" globby "^11.0.1" is-glob "^4.0.1" - lodash "^4.17.15" semver "^7.3.2" tsutils "^3.17.1" -"@typescript-eslint/visitor-keys@3.10.1": - version "3.10.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-3.10.1.tgz#cd4274773e3eb63b2e870ac602274487ecd1e931" - integrity sha512-9JgC82AaQeglebjZMgYR5wgmfUdUc+EitGUUMW8u2nDckaeimzW+VsoLV6FoimPv2id3VQzfjwBxEMVz08ameQ== +"@typescript-eslint/visitor-keys@4.23.0": + version "4.23.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.23.0.tgz#7215cc977bd3b4ef22467b9023594e32f9e4e455" + integrity sha512-5PNe5cmX9pSifit0H+nPoQBXdbNzi5tOEec+3riK+ku4e3er37pKxMKDH5Ct5Y4fhWxcD4spnlYjxi9vXbSpwg== dependencies: - eslint-visitor-keys "^1.1.0" - -"@typescript-eslint/visitor-keys@4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.0.0.tgz#e2bbb69d98076d6a3f06abcb2048225a74362c33" - integrity sha512-sTouJbv6rjVJeTE4lpSBVYXq/u5K3gbB6LKt7ccFEZPTZB/VeQ0ssUz9q5Hx++sCqBbdF8PzrrgvEnicXAR6NQ== - dependencies: - "@typescript-eslint/types" "4.0.0" + "@typescript-eslint/types" "4.23.0" eslint-visitor-keys "^2.0.0" "@ungap/promise-all-settled@1.1.2": @@ -548,162 +507,143 @@ resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44" integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q== -"@webassemblyjs/ast@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.9.0.tgz#bd850604b4042459a5a41cd7d338cbed695ed964" - integrity sha512-C6wW5L+b7ogSDVqymbkkvuW9kruN//YisMED04xzeBBqjHa2FYnmvOlS6Xj68xWQRgWvI9cIglsjFowH/RJyEA== +"@webassemblyjs/ast@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.0.tgz#a5aa679efdc9e51707a4207139da57920555961f" + integrity sha512-kX2W49LWsbthrmIRMbQZuQDhGtjyqXfEmmHyEi4XWnSZtPmxY0+3anPIzsnRb45VH/J55zlOfWvZuY47aJZTJg== dependencies: - "@webassemblyjs/helper-module-context" "1.9.0" - "@webassemblyjs/helper-wasm-bytecode" "1.9.0" - "@webassemblyjs/wast-parser" "1.9.0" + "@webassemblyjs/helper-numbers" "1.11.0" + "@webassemblyjs/helper-wasm-bytecode" "1.11.0" -"@webassemblyjs/floating-point-hex-parser@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.9.0.tgz#3c3d3b271bddfc84deb00f71344438311d52ffb4" - integrity sha512-TG5qcFsS8QB4g4MhrxK5TqfdNe7Ey/7YL/xN+36rRjl/BlGE/NcBvJcqsRgCP6Z92mRE+7N50pRIi8SmKUbcQA== +"@webassemblyjs/floating-point-hex-parser@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.0.tgz#34d62052f453cd43101d72eab4966a022587947c" + integrity sha512-Q/aVYs/VnPDVYvsCBL/gSgwmfjeCb4LW8+TMrO3cSzJImgv8lxxEPM2JA5jMrivE7LSz3V+PFqtMbls3m1exDA== -"@webassemblyjs/helper-api-error@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.9.0.tgz#203f676e333b96c9da2eeab3ccef33c45928b6a2" - integrity sha512-NcMLjoFMXpsASZFxJ5h2HZRcEhDkvnNFOAKneP5RbKRzaWJN36NC4jqQHKwStIhGXu5mUWlUUk7ygdtrO8lbmw== +"@webassemblyjs/helper-api-error@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.0.tgz#aaea8fb3b923f4aaa9b512ff541b013ffb68d2d4" + integrity sha512-baT/va95eXiXb2QflSx95QGT5ClzWpGaa8L7JnJbgzoYeaA27FCvuBXU758l+KXWRndEmUXjP0Q5fibhavIn8w== -"@webassemblyjs/helper-buffer@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.9.0.tgz#a1442d269c5feb23fcbc9ef759dac3547f29de00" - integrity sha512-qZol43oqhq6yBPx7YM3m9Bv7WMV9Eevj6kMi6InKOuZxhw+q9hOkvq5e/PpKSiLfyetpaBnogSbNCfBwyB00CA== +"@webassemblyjs/helper-buffer@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.0.tgz#d026c25d175e388a7dbda9694e91e743cbe9b642" + integrity sha512-u9HPBEl4DS+vA8qLQdEQ6N/eJQ7gT7aNvMIo8AAWvAl/xMrcOSiI2M0MAnMCy3jIFke7bEee/JwdX1nUpCtdyA== -"@webassemblyjs/helper-code-frame@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.9.0.tgz#647f8892cd2043a82ac0c8c5e75c36f1d9159f27" - integrity sha512-ERCYdJBkD9Vu4vtjUYe8LZruWuNIToYq/ME22igL+2vj2dQ2OOujIZr3MEFvfEaqKoVqpsFKAGsRdBSBjrIvZA== +"@webassemblyjs/helper-numbers@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.0.tgz#7ab04172d54e312cc6ea4286d7d9fa27c88cd4f9" + integrity sha512-DhRQKelIj01s5IgdsOJMKLppI+4zpmcMQ3XboFPLwCpSNH6Hqo1ritgHgD0nqHeSYqofA6aBN/NmXuGjM1jEfQ== dependencies: - "@webassemblyjs/wast-printer" "1.9.0" + "@webassemblyjs/floating-point-hex-parser" "1.11.0" + "@webassemblyjs/helper-api-error" "1.11.0" + "@xtuc/long" "4.2.2" -"@webassemblyjs/helper-fsm@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-fsm/-/helper-fsm-1.9.0.tgz#c05256b71244214671f4b08ec108ad63b70eddb8" - integrity sha512-OPRowhGbshCb5PxJ8LocpdX9Kl0uB4XsAjl6jH/dWKlk/mzsANvhwbiULsaiqT5GZGT9qinTICdj6PLuM5gslw== +"@webassemblyjs/helper-wasm-bytecode@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.0.tgz#85fdcda4129902fe86f81abf7e7236953ec5a4e1" + integrity sha512-MbmhvxXExm542tWREgSFnOVo07fDpsBJg3sIl6fSp9xuu75eGz5lz31q7wTLffwL3Za7XNRCMZy210+tnsUSEA== -"@webassemblyjs/helper-module-context@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-module-context/-/helper-module-context-1.9.0.tgz#25d8884b76839871a08a6c6f806c3979ef712f07" - integrity sha512-MJCW8iGC08tMk2enck1aPW+BE5Cw8/7ph/VGZxwyvGbJwjktKkDK7vy7gAmMDx88D7mhDTCNKAW5tED+gZ0W8g== +"@webassemblyjs/helper-wasm-section@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.0.tgz#9ce2cc89300262509c801b4af113d1ca25c1a75b" + integrity sha512-3Eb88hcbfY/FCukrg6i3EH8H2UsD7x8Vy47iVJrP967A9JGqgBVL9aH71SETPx1JrGsOUVLo0c7vMCN22ytJew== dependencies: - "@webassemblyjs/ast" "1.9.0" + "@webassemblyjs/ast" "1.11.0" + "@webassemblyjs/helper-buffer" "1.11.0" + "@webassemblyjs/helper-wasm-bytecode" "1.11.0" + "@webassemblyjs/wasm-gen" "1.11.0" -"@webassemblyjs/helper-wasm-bytecode@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.9.0.tgz#4fed8beac9b8c14f8c58b70d124d549dd1fe5790" - integrity sha512-R7FStIzyNcd7xKxCZH5lE0Bqy+hGTwS3LJjuv1ZVxd9O7eHCedSdrId/hMOd20I+v8wDXEn+bjfKDLzTepoaUw== - -"@webassemblyjs/helper-wasm-section@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.9.0.tgz#5a4138d5a6292ba18b04c5ae49717e4167965346" - integrity sha512-XnMB8l3ek4tvrKUUku+IVaXNHz2YsJyOOmz+MMkZvh8h1uSJpSen6vYnw3IoQ7WwEuAhL8Efjms1ZWjqh2agvw== - dependencies: - "@webassemblyjs/ast" "1.9.0" - "@webassemblyjs/helper-buffer" "1.9.0" - "@webassemblyjs/helper-wasm-bytecode" "1.9.0" - "@webassemblyjs/wasm-gen" "1.9.0" - -"@webassemblyjs/ieee754@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.9.0.tgz#15c7a0fbaae83fb26143bbacf6d6df1702ad39e4" - integrity sha512-dcX8JuYU/gvymzIHc9DgxTzUUTLexWwt8uCTWP3otys596io0L5aW02Gb1RjYpx2+0Jus1h4ZFqjla7umFniTg== +"@webassemblyjs/ieee754@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.11.0.tgz#46975d583f9828f5d094ac210e219441c4e6f5cf" + integrity sha512-KXzOqpcYQwAfeQ6WbF6HXo+0udBNmw0iXDmEK5sFlmQdmND+tr773Ti8/5T/M6Tl/413ArSJErATd8In3B+WBA== dependencies: "@xtuc/ieee754" "^1.2.0" -"@webassemblyjs/leb128@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.9.0.tgz#f19ca0b76a6dc55623a09cffa769e838fa1e1c95" - integrity sha512-ENVzM5VwV1ojs9jam6vPys97B/S65YQtv/aanqnU7D8aSoHFX8GyhGg0CMfyKNIHBuAVjy3tlzd5QMMINa7wpw== +"@webassemblyjs/leb128@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.11.0.tgz#f7353de1df38aa201cba9fb88b43f41f75ff403b" + integrity sha512-aqbsHa1mSQAbeeNcl38un6qVY++hh8OpCOzxhixSYgbRfNWcxJNJQwe2rezK9XEcssJbbWIkblaJRwGMS9zp+g== dependencies: "@xtuc/long" "4.2.2" -"@webassemblyjs/utf8@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.9.0.tgz#04d33b636f78e6a6813227e82402f7637b6229ab" - integrity sha512-GZbQlWtopBTP0u7cHrEx+73yZKrQoBMpwkGEIqlacljhXCkVM1kMQge/Mf+csMJAjEdSwhOyLAS0AoR3AG5P8w== +"@webassemblyjs/utf8@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.11.0.tgz#86e48f959cf49e0e5091f069a709b862f5a2cadf" + integrity sha512-A/lclGxH6SpSLSyFowMzO/+aDEPU4hvEiooCMXQPcQFPPJaYcPQNKGOCLUySJsYJ4trbpr+Fs08n4jelkVTGVw== -"@webassemblyjs/wasm-edit@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.9.0.tgz#3fe6d79d3f0f922183aa86002c42dd256cfee9cf" - integrity sha512-FgHzBm80uwz5M8WKnMTn6j/sVbqilPdQXTWraSjBwFXSYGirpkSWE2R9Qvz9tNiTKQvoKILpCuTjBKzOIm0nxw== +"@webassemblyjs/wasm-edit@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.0.tgz#ee4a5c9f677046a210542ae63897094c2027cb78" + integrity sha512-JHQ0damXy0G6J9ucyKVXO2j08JVJ2ntkdJlq1UTiUrIgfGMmA7Ik5VdC/L8hBK46kVJgujkBIoMtT8yVr+yVOQ== dependencies: - "@webassemblyjs/ast" "1.9.0" - "@webassemblyjs/helper-buffer" "1.9.0" - "@webassemblyjs/helper-wasm-bytecode" "1.9.0" - "@webassemblyjs/helper-wasm-section" "1.9.0" - "@webassemblyjs/wasm-gen" "1.9.0" - "@webassemblyjs/wasm-opt" "1.9.0" - "@webassemblyjs/wasm-parser" "1.9.0" - "@webassemblyjs/wast-printer" "1.9.0" + "@webassemblyjs/ast" "1.11.0" + "@webassemblyjs/helper-buffer" "1.11.0" + "@webassemblyjs/helper-wasm-bytecode" "1.11.0" + "@webassemblyjs/helper-wasm-section" "1.11.0" + "@webassemblyjs/wasm-gen" "1.11.0" + "@webassemblyjs/wasm-opt" "1.11.0" + "@webassemblyjs/wasm-parser" "1.11.0" + "@webassemblyjs/wast-printer" "1.11.0" -"@webassemblyjs/wasm-gen@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.9.0.tgz#50bc70ec68ded8e2763b01a1418bf43491a7a49c" - integrity sha512-cPE3o44YzOOHvlsb4+E9qSqjc9Qf9Na1OO/BHFy4OI91XDE14MjFN4lTMezzaIWdPqHnsTodGGNP+iRSYfGkjA== +"@webassemblyjs/wasm-gen@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.0.tgz#3cdb35e70082d42a35166988dda64f24ceb97abe" + integrity sha512-BEUv1aj0WptCZ9kIS30th5ILASUnAPEvE3tVMTrItnZRT9tXCLW2LEXT8ezLw59rqPP9klh9LPmpU+WmRQmCPQ== dependencies: - "@webassemblyjs/ast" "1.9.0" - "@webassemblyjs/helper-wasm-bytecode" "1.9.0" - "@webassemblyjs/ieee754" "1.9.0" - "@webassemblyjs/leb128" "1.9.0" - "@webassemblyjs/utf8" "1.9.0" + "@webassemblyjs/ast" "1.11.0" + "@webassemblyjs/helper-wasm-bytecode" "1.11.0" + "@webassemblyjs/ieee754" "1.11.0" + "@webassemblyjs/leb128" "1.11.0" + "@webassemblyjs/utf8" "1.11.0" -"@webassemblyjs/wasm-opt@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.9.0.tgz#2211181e5b31326443cc8112eb9f0b9028721a61" - integrity sha512-Qkjgm6Anhm+OMbIL0iokO7meajkzQD71ioelnfPEj6r4eOFuqm4YC3VBPqXjFyyNwowzbMD+hizmprP/Fwkl2A== +"@webassemblyjs/wasm-opt@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.0.tgz#1638ae188137f4bb031f568a413cd24d32f92978" + integrity sha512-tHUSP5F4ywyh3hZ0+fDQuWxKx3mJiPeFufg+9gwTpYp324mPCQgnuVKwzLTZVqj0duRDovnPaZqDwoyhIO8kYg== dependencies: - "@webassemblyjs/ast" "1.9.0" - "@webassemblyjs/helper-buffer" "1.9.0" - "@webassemblyjs/wasm-gen" "1.9.0" - "@webassemblyjs/wasm-parser" "1.9.0" + "@webassemblyjs/ast" "1.11.0" + "@webassemblyjs/helper-buffer" "1.11.0" + "@webassemblyjs/wasm-gen" "1.11.0" + "@webassemblyjs/wasm-parser" "1.11.0" -"@webassemblyjs/wasm-parser@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.9.0.tgz#9d48e44826df4a6598294aa6c87469d642fff65e" - integrity sha512-9+wkMowR2AmdSWQzsPEjFU7njh8HTO5MqO8vjwEHuM+AMHioNqSBONRdr0NQQ3dVQrzp0s8lTcYqzUdb7YgELA== +"@webassemblyjs/wasm-parser@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.0.tgz#3e680b8830d5b13d1ec86cc42f38f3d4a7700754" + integrity sha512-6L285Sgu9gphrcpDXINvm0M9BskznnzJTE7gYkjDbxET28shDqp27wpruyx3C2S/dvEwiigBwLA1cz7lNUi0kw== dependencies: - "@webassemblyjs/ast" "1.9.0" - "@webassemblyjs/helper-api-error" "1.9.0" - "@webassemblyjs/helper-wasm-bytecode" "1.9.0" - "@webassemblyjs/ieee754" "1.9.0" - "@webassemblyjs/leb128" "1.9.0" - "@webassemblyjs/utf8" "1.9.0" + "@webassemblyjs/ast" "1.11.0" + "@webassemblyjs/helper-api-error" "1.11.0" + "@webassemblyjs/helper-wasm-bytecode" "1.11.0" + "@webassemblyjs/ieee754" "1.11.0" + "@webassemblyjs/leb128" "1.11.0" + "@webassemblyjs/utf8" "1.11.0" -"@webassemblyjs/wast-parser@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-parser/-/wast-parser-1.9.0.tgz#3031115d79ac5bd261556cecc3fa90a3ef451914" - integrity sha512-qsqSAP3QQ3LyZjNC/0jBJ/ToSxfYJ8kYyuiGvtn/8MK89VrNEfwj7BPQzJVHi0jGTRK2dGdJ5PRqhtjzoww+bw== +"@webassemblyjs/wast-printer@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.11.0.tgz#680d1f6a5365d6d401974a8e949e05474e1fab7e" + integrity sha512-Fg5OX46pRdTgB7rKIUojkh9vXaVN6sGYCnEiJN1GYkb0RPwShZXp6KTDqmoMdQPKhcroOXh3fEzmkWmCYaKYhQ== dependencies: - "@webassemblyjs/ast" "1.9.0" - "@webassemblyjs/floating-point-hex-parser" "1.9.0" - "@webassemblyjs/helper-api-error" "1.9.0" - "@webassemblyjs/helper-code-frame" "1.9.0" - "@webassemblyjs/helper-fsm" "1.9.0" + "@webassemblyjs/ast" "1.11.0" "@xtuc/long" "4.2.2" -"@webassemblyjs/wast-printer@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.9.0.tgz#4935d54c85fef637b00ce9f52377451d00d47899" - integrity sha512-2J0nE95rHXHyQ24cWjMKJ1tqB/ds8z/cyeOZxJhcb+rW+SQASVjuznUSmdz5GpVJTzU8JkhYut0D3siFDD6wsA== - dependencies: - "@webassemblyjs/ast" "1.9.0" - "@webassemblyjs/wast-parser" "1.9.0" - "@xtuc/long" "4.2.2" +"@webpack-cli/configtest@^1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@webpack-cli/configtest/-/configtest-1.0.3.tgz#204bcff87cda3ea4810881f7ea96e5f5321b87b9" + integrity sha512-WQs0ep98FXX2XBAfQpRbY0Ma6ADw8JR6xoIkaIiJIzClGOMqVRvPCWqndTxf28DgFopWan0EKtHtg/5W1h0Zkw== -"@webpack-cli/info@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@webpack-cli/info/-/info-1.1.0.tgz#c596d5bc48418b39df00c5ed7341bf0f102dbff1" - integrity sha512-uNWSdaYHc+f3LdIZNwhdhkjjLDDl3jP2+XBqAq9H8DjrJUvlOKdP8TNruy1yEaDfgpAIgbSAN7pye4FEHg9tYQ== +"@webpack-cli/info@^1.2.4": + version "1.2.4" + resolved "https://registry.yarnpkg.com/@webpack-cli/info/-/info-1.2.4.tgz#7381fd41c9577b2d8f6c2594fad397ef49ad5573" + integrity sha512-ogE2T4+pLhTTPS/8MM3IjHn0IYplKM4HbVNMCWA9N4NrdPzunwenpCsqKEXyejMfRu6K8mhauIPYf8ZxWG5O6g== dependencies: envinfo "^7.7.3" -"@webpack-cli/serve@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-1.1.0.tgz#13ad38f89b6e53d1133bac0006a128217a6ebf92" - integrity sha512-7RfnMXCpJ/NThrhq4gYQYILB18xWyoQcBey81oIyVbmgbc6m5ZHHyFK+DyH7pLHJf0p14MxL4mTsoPAgBSTpIg== +"@webpack-cli/serve@^1.4.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-1.4.0.tgz#f84fd07bcacefe56ce762925798871092f0f228e" + integrity sha512-xgT/HqJ+uLWGX+Mzufusl3cgjAcnqYYskaB7o0vRcwOEfuu6hMzSILQpnIzFMGsTaeaX4Nnekl+6fadLbl1/Vg== "@xtuc/ieee754@^1.2.0": version "1.2.0" @@ -736,40 +676,38 @@ acorn-globals@^6.0.0: acorn "^7.1.1" acorn-walk "^7.1.1" -acorn-jsx@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.2.0.tgz#4c66069173d6fdd68ed85239fc256226182b2ebe" - integrity sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ== +acorn-jsx@^5.3.1: + version "5.3.1" + resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.1.tgz#fc8661e11b7ac1539c47dbfea2e72b3af34d267b" + integrity sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng== acorn-walk@^7.1.1: - version "7.1.1" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-7.1.1.tgz#345f0dffad5c735e7373d2fec9a1023e6a44b83e" - integrity sha512-wdlPY2tm/9XBr7QkKlq0WQVgiuGTX6YWPyRyBviSoScBuLfTVQhvwg6wJ369GJ/1nPfTLMfnrFIfjqVg6d+jQQ== + version "7.2.0" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-7.2.0.tgz#0de889a601203909b0fbe07b8938dc21d2e967bc" + integrity sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA== acorn@^7.1.1, acorn@^7.4.0: - version "7.4.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.0.tgz#e1ad486e6c54501634c6c397c5c121daa383607c" - integrity sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w== + version "7.4.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" + integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== -acorn@^8.0.4: - version "8.0.4" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.0.4.tgz#7a3ae4191466a6984eee0fe3407a4f3aa9db8354" - integrity sha512-XNP0PqF1XD19ZlLKvB7cMmnZswW4C/03pRHgirB30uSJTaS3A3V1/P4sS3HPvFmjoriPCJQs+JDSbm4bL1TxGQ== +acorn@^8.1.0, acorn@^8.2.1: + version "8.2.4" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.2.4.tgz#caba24b08185c3b56e3168e97d15ed17f4d31fd0" + integrity sha512-Ibt84YwBDDA890eDiDCEqcbwvHlBvzzDkU2cGBBDDI1QWT12jTiXIOn2CIw5KK4i6N5Z2HUxwYjzriDyqaqqZg== + +agent-base@5: + version "5.1.1" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-5.1.1.tgz#e8fb3f242959db44d63be665db7a8e739537a32c" + integrity sha512-TMeqbNl2fMW0nMjTEPOwe3J/PRFP4vqeoNuQMG0HlMrtm5QxKqdvAkZ1pRBQ/ulIyDD5Yq0nJ7YbdD8ey0TO3g== agent-base@6: - version "6.0.1" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.1.tgz#808007e4e5867decb0ab6ab2f928fbdb5a596db4" - integrity sha512-01q25QQDwLSsyfhrKbn8yuur+JNw0H+0Y4JiGIKd3z9aYk/w/2kxD/Upc+t2ZBBSUNff50VjPsSW2YxM8QYKVg== + version "6.0.2" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77" + integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ== dependencies: debug "4" -agent-base@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee" - integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg== - dependencies: - es6-promisify "^5.0.0" - aggregate-error@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-3.0.1.tgz#db2fe7246e536f40d9b5442a39e117d7dd6a24e0" @@ -783,7 +721,17 @@ ajv-keywords@^3.5.2: resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== -ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.4, ajv@^6.12.5, ajv@^6.5.5: +ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4: + version "6.12.6" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" + integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + +ajv@^6.12.5: version "6.12.5" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.5.tgz#19b0e8bae8f476e5ba666300387775fb1a00a4da" integrity sha512-lRF8RORchjpKG50/WFf8xmg7sgCLFiYNNnqdKflk63whMQcWR5ngGjiSXkL9bjxy6B2npOK2HSMN49jEBMSkag== @@ -793,10 +741,15 @@ ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.4, ajv@^6.12.5, ajv@^6.5.5: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ansi-colors@3.2.3: - version "3.2.3" - resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.3.tgz#57d35b8686e851e2cc04c403f1c00203976a1813" - integrity sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw== +ajv@^8.0.1: + version "8.3.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.3.0.tgz#25ee7348e32cdc4a1dbb38256bf6bdc451dd577c" + integrity sha512-RYE7B5An83d7eWnDR8kbdaIFqmKCNsP16ay1hDbJEU+sa0e3H9SebskCt0Uufem6cfAVu7Col6ubcn/W+Sm8/Q== + dependencies: + fast-deep-equal "^3.1.1" + json-schema-traverse "^1.0.0" + require-from-string "^2.0.2" + uri-js "^4.2.2" ansi-colors@4.1.1, ansi-colors@^4.1.1: version "4.1.1" @@ -813,17 +766,12 @@ ansi-regex@^3.0.0: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= -ansi-regex@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" - integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== - ansi-regex@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75" integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg== -ansi-styles@^3.2.0, ansi-styles@^3.2.1: +ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== @@ -846,10 +794,10 @@ anymatch@~3.1.1: normalize-path "^3.0.0" picomatch "^2.0.4" -app-root-path@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/app-root-path/-/app-root-path-2.2.1.tgz#d0df4a682ee408273583d43f6f79e9892624bc9a" - integrity sha512-91IFKeKk7FjfmezPKkwtaRvSpnUc4gDwPAjA1YZ9Gn0q0PPeW+vbeUsZuyDwjI7+QTHhcLen2v25fi/AmhvbJA== +app-root-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/app-root-path/-/app-root-path-3.0.0.tgz#210b6f43873227e18a4b810a032283311555d5ad" + integrity sha512-qMcx+Gy2UZynHjOHOIXPNvpf+9cjvk3cWrBBK7zg4gH9+clobJRb9NGzcT7mQTcV/6Gm/1WelUtqxVXnNlrwcw== append-transform@^2.0.0: version "2.0.0" @@ -870,10 +818,10 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" -array-back@^4.0.0, array-back@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/array-back/-/array-back-4.0.1.tgz#9b80312935a52062e1a233a9c7abeb5481b30e90" - integrity sha512-Z/JnaVEXv+A9xabHzN43FiiiWEE7gPCRXMrVmRm00tWbjZRul1iHm7ECzlyNq1p4a4ATXz+G9FJ3GqGOkOV3fg== +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== array-filter@^1.0.0: version "1.0.0" @@ -907,29 +855,32 @@ assertion-error@^1.1.0: resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== -astral-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9" - integrity sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg== +astral-regex@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" + integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ== async-limiter@~1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd" integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ== -async@^2.6.1: - version "2.6.3" - resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff" - integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg== - dependencies: - lodash "^4.17.14" +async@^3.1.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/async/-/async-3.2.0.tgz#b3a2685c5ebb641d3de02d161002c60fc9f85720" + integrity sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw== asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= -available-typed-arrays@^1.0.0, available-typed-arrays@^1.0.2: +at-least-node@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2" + integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg== + +available-typed-arrays@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.2.tgz#6b098ca9d8039079ee3f77f7b783c4480ba513f5" integrity sha512-XWX3OX8Onv97LMk/ftVyBibpGwY5a8SmuxZPzeOxqmuEqUCOM9ZE+uIaD1VNJ5QnvU2UQusvmKbuM1FR8QWGfQ== @@ -942,15 +893,20 @@ aws-sign2@~0.7.0: integrity sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg= aws4@^1.8.0: - version "1.9.1" - resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.9.1.tgz#7e33d8f7d449b3f673cd72deb9abdc552dbe528e" - integrity sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug== + version "1.11.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.11.0.tgz#d61f46d83b2519250e2784daf5b09479a8b41c59" + integrity sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA== balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= +base64-js@^1.3.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" + integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== + bcrypt-pbkdf@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" @@ -968,6 +924,15 @@ binary-extensions@^2.0.0: resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.0.0.tgz#23c0df14f6a88077f5f986c0d167ec03c3d5537c" integrity sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow== +bl@^4.0.3: + version "4.1.0" + resolved "https://registry.yarnpkg.com/bl/-/bl-4.1.0.tgz#451535264182bec2fbbc83a62ab98cf11d9f7b3a" + integrity sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w== + dependencies: + buffer "^5.5.0" + inherits "^2.0.4" + readable-stream "^3.4.0" + body-parser@1.19.0: version "1.19.0" resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a" @@ -1010,14 +975,15 @@ browser-stdout@1.3.1: integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== browserslist@^4.14.5: - version "4.14.5" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.14.5.tgz#1c751461a102ddc60e40993639b709be7f2c4015" - integrity sha512-Z+vsCZIvCBvqLoYkBFTwEYH3v5MCQbsAjp50ERycpOjnPmolg1Gjy4+KaWWpm8QOJt9GHkhdqAl14NpCX73CWA== + version "4.16.6" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.16.6.tgz#d7901277a5a88e554ed305b183ec9b0c08f66fa2" + integrity sha512-Wspk/PqO+4W9qp5iUTJsa1B/QrYn1keNCcEP5OvP7WBwT4KaDly0uONYmC6Xa3Z5IqnUgS0KcgLYu1l74x0ZXQ== dependencies: - caniuse-lite "^1.0.30001135" - electron-to-chromium "^1.3.571" - escalade "^3.1.0" - node-releases "^1.1.61" + caniuse-lite "^1.0.30001219" + colorette "^1.2.2" + electron-to-chromium "^1.3.723" + escalade "^3.1.1" + node-releases "^1.1.71" buffer-crc32@~0.2.3: version "0.2.13" @@ -1029,6 +995,14 @@ buffer-from@^1.0.0: resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== +buffer@^5.2.1, buffer@^5.5.0: + version "5.7.1" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" + integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.1.13" + builtin-modules@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" @@ -1049,6 +1023,14 @@ caching-transform@^4.0.0: package-hash "^4.0.0" write-file-atomic "^3.0.0" +call-bind@^1.0.0, call-bind@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" + integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== + dependencies: + function-bind "^1.1.1" + get-intrinsic "^1.0.2" + callsites@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" @@ -1064,29 +1046,29 @@ camelcase@^6.0.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.1.0.tgz#27dc176173725fb0adf8a48b647f4d7871944d78" integrity sha512-WCMml9ivU60+8rEJgELlFp1gxFcEGxwYleE3bziHEDeqsqAWGHdimB7beBFGjLzVNgPGyDsfgXLQEYMpmIFnVQ== -caniuse-lite@^1.0.30001135: - version "1.0.30001154" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001154.tgz#f3bbc245ce55e4c1cd20fa731b097880181a7f17" - integrity sha512-y9DvdSti8NnYB9Be92ddMZQrcOe04kcQtcxtBx4NkB04+qZ+JUWotnXBJTmxlKudhxNTQ3RRknMwNU2YQl/Org== +caniuse-lite@^1.0.30001219: + version "1.0.30001228" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001228.tgz#bfdc5942cd3326fa51ee0b42fbef4da9d492a7fa" + integrity sha512-QQmLOGJ3DEgokHbMSA8cj2a+geXqmnpyOFT0lhQV6P3/YOJvGDEwoedcwxEQ30gJIwIIunHIicunJ2rzK5gB2A== caseless@~0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= -chai@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/chai/-/chai-4.2.0.tgz#760aa72cf20e3795e84b12877ce0e83737aa29e5" - integrity sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw== +chai@^4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.4.tgz#b55e655b31e1eac7099be4c08c21964fce2e6c49" + integrity sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA== dependencies: assertion-error "^1.1.0" check-error "^1.0.2" deep-eql "^3.0.1" get-func-name "^2.0.0" - pathval "^1.1.0" + pathval "^1.1.1" type-detect "^4.0.5" -chalk@^2.0.0, chalk@^2.0.1, chalk@^2.3.0, chalk@^2.4.2: +chalk@^2.0.0, chalk@^2.3.0: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -1103,15 +1085,23 @@ chalk@^4.0.0: ansi-styles "^4.1.0" supports-color "^7.1.0" +chalk@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.1.tgz#c80b3fab28bf6371e6863325eee67e618b77e6ad" + integrity sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + check-error@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" integrity sha1-V00xLt2Iu13YkS6Sht1sCu1KrII= -chokidar@3.4.3: - version "3.4.3" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.4.3.tgz#c1df38231448e45ca4ac588e6c79573ba6a57d5b" - integrity sha512-DtM3g7juCXQxFVSNPNByEC2+NImtBuxQQvWlHunpJIS5Ocr0lG306cC7FCi7cEA0fzmybPUIl4txBIobk1gGOQ== +chokidar@3.5.1: + version "3.5.1" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.1.tgz#ee9ce7bbebd2b79f49f304799d5468e31e14e68a" + integrity sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw== dependencies: anymatch "~3.1.1" braces "~3.0.2" @@ -1121,55 +1111,50 @@ chokidar@3.4.3: normalize-path "~3.0.0" readdirp "~3.5.0" optionalDependencies: - fsevents "~2.1.2" + fsevents "~2.3.1" + +chownr@^1.1.1: + version "1.1.4" + resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b" + integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg== chrome-devtools-frontend@1.0.445684: version "1.0.445684" resolved "https://registry.yarnpkg.com/chrome-devtools-frontend/-/chrome-devtools-frontend-1.0.445684.tgz#8540131836024df2b70fe90d0322af368931d762" integrity sha1-hUATGDYCTfK3D+kNAyKvNokx12I= -chrome-timeline@0.0.12: - version "0.0.12" - resolved "https://registry.yarnpkg.com/chrome-timeline/-/chrome-timeline-0.0.12.tgz#1516223b4bf289750b4b244c3f88d0095b10f914" - integrity sha512-lDVZGV2VYVS7kTmoLxwOmoTvKLxBHRiBQqGNvD87Bky+uIsnK6ThwESqIj+rsjx218Vq9tU5H6Bv2u6IsafS/g== +chrome-timeline@0.0.15: + version "0.0.15" + resolved "https://registry.yarnpkg.com/chrome-timeline/-/chrome-timeline-0.0.15.tgz#4fbc719d6abf08e0a0b1f0d5fea80ac461c4410b" + integrity sha512-6vc+MiyFsiOIAje+Z9MFurk9sDnKE5/WknPDpvPfApzApUxdhrml2ybTBRe2U3m2v0vYGis4VMLn9nuuoiofDA== dependencies: "@types/app-root-path" "^1.2.4" - "@types/fs-extra" "^7.0.0" - "@types/puppeteer" "^1.12.4" - app-root-path "^2.2.1" + "@types/fs-extra" "9.0.1" + "@types/puppeteer" "^5.4.3" + app-root-path "^3.0.0" devtools-timeline-model "^1.4.0" - puppeteer "^1.17.0" - simple-git "^1.113.0" - winston "^3.2.1" + fs-extra "9.0.1" + puppeteer "^5.5.0" + simple-git "^2.37.0" + winston "^3.3.3" chrome-trace-event@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.2.tgz#234090ee97c7d4ad1a2c4beae27505deffc608a4" - integrity sha512-9e/zx1jw7B4CO+c/RXoCsfg/x1AfUBioy4owYH0bJprEYAx5hRFLRhWBqHAG57D0ZM4H7vxbP7bPe0VwhQRYDQ== - dependencies: - tslib "^1.9.0" + version "1.0.3" + resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac" + integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== clean-stack@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b" integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A== -cli-table@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/cli-table/-/cli-table-0.3.1.tgz#f53b05266a8b1a0b934b3d0821e6e2dc5914ae23" - integrity sha1-9TsFJmqLGguTSz0IIebi3FkUriM= +cli-table@^0.3.6: + version "0.3.6" + resolved "https://registry.yarnpkg.com/cli-table/-/cli-table-0.3.6.tgz#e9d6aa859c7fe636981fd3787378c2a20bce92fc" + integrity sha512-ZkNZbnZjKERTY5NwC2SeMeLeifSPq/pubeRoTpdr3WchLlnZg6hEgvHkK5zL7KNFdd9PmHN8lxrENUwI3cE8vQ== dependencies: colors "1.0.3" -cliui@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-5.0.0.tgz#deefcfdb2e800784aa34f46fa08e06851c7bbbc5" - integrity sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA== - dependencies: - string-width "^3.1.0" - strip-ansi "^5.2.0" - wrap-ansi "^5.1.0" - cliui@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/cliui/-/cliui-6.0.0.tgz#511d702c0c4e41ca156d7d0e96021f23e13225b1" @@ -1179,6 +1164,24 @@ cliui@^6.0.0: strip-ansi "^6.0.0" wrap-ansi "^6.2.0" +cliui@^7.0.2: + version "7.0.4" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" + integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.0" + wrap-ansi "^7.0.0" + +clone-deep@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387" + integrity sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ== + dependencies: + is-plain-object "^2.0.4" + kind-of "^6.0.2" + shallow-clone "^3.0.0" + clone@^1.0.2: version "1.0.4" resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" @@ -1209,9 +1212,9 @@ color-name@^1.0.0, color-name@~1.1.4: integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== color-string@^1.5.2: - version "1.5.3" - resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.5.3.tgz#c9bbc5f01b58b5492f3d6857459cb6590ce204cc" - integrity sha512-dC2C5qeWoYkxki5UAXapdjqO672AM4vZuPGRQfO8b5HKuKGBbKWpITyDYN7TOFKvRW7kOgAn3746clDBMDJyQw== + version "1.5.5" + resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.5.5.tgz#65474a8f0e7439625f3d27a6a19d89fc45223014" + integrity sha512-jgIoum0OfQfq9Whcfc2z/VhCNcmQjWbey6qBX0vqt7YICflUmBCh9E9CiQD5GSJ+Uehixm3NUwHVhqUAWRivZg== dependencies: color-name "^1.0.0" simple-swizzle "^0.2.2" @@ -1224,15 +1227,10 @@ color@3.0.x: color-convert "^1.9.1" color-string "^1.5.2" -colorette@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.1.tgz#4d0b921325c14faf92633086a536db6e89564b1b" - integrity sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw== - -colornames@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/colornames/-/colornames-1.1.1.tgz#f8889030685c7c4ff9e2a559f5077eb76a816f96" - integrity sha1-+IiQMGhcfE/54qVZ9Qd+t2qBb5Y= +colorette@^1.2.1, colorette@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94" + integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w== colors@1.0.3: version "1.0.3" @@ -1267,51 +1265,36 @@ combined-stream@^1.0.6, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" -command-line-usage@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/command-line-usage/-/command-line-usage-6.1.0.tgz#f28376a3da3361ff3d36cfd31c3c22c9a64c7cb6" - integrity sha512-Ew1clU4pkUeo6AFVDFxCbnN7GIZfXl48HIOQeFQnkO3oOqvpI7wdqtLRwv9iOCZ/7A+z4csVZeiDdEcj8g6Wiw== - dependencies: - array-back "^4.0.0" - chalk "^2.4.2" - table-layout "^1.0.0" - typical "^5.2.0" - commander@^2.12.1, commander@^2.20.0: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== -commander@^6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.0.tgz#b990bfb8ac030aedc6d11bc04d1488ffef56db75" - integrity sha512-zP4jEKbe8SHzKJYQmq8Y9gYjtO/POJLgIdKgV7B9qNmABVFVc+ctqSX6iXh4mCpJfRBOabiZ2YKPg8ciDw6C+Q== +commander@^6.1.0, commander@^6.2.1: + version "6.2.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c" + integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA== + +commander@^7.0.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7" + integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw== commondir@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs= -complex.js@2.0.11: - version "2.0.11" - resolved "https://registry.yarnpkg.com/complex.js/-/complex.js-2.0.11.tgz#09a873fbf15ffd8c18c9c2201ccef425c32b8bf1" - integrity sha512-6IArJLApNtdg1P1dFtn3dnyzoZBEF0MwMnrfF1exSBRpZYoy4yieMkpZhQDC0uwctw48vii0CFVyHfpgZ/DfGw== +complex.js@^2.0.11: + version "2.0.12" + resolved "https://registry.yarnpkg.com/complex.js/-/complex.js-2.0.12.tgz#fa4df97d8928e5f7b6a86b35bdeecc3a3eda8a22" + integrity sha512-oQX99fwL6LrTVg82gDY1dIWXy6qZRnRL35N+YhIX0N7tSwsa0KFy6IEMHTNuCW4mP7FS7MEqZ/2I/afzYwPldw== concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= -concat-stream@^1.6.2: - version "1.6.2" - resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" - integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== - dependencies: - buffer-from "^1.0.0" - inherits "^2.0.3" - readable-stream "^2.2.2" - typedarray "^0.0.6" - content-disposition@0.5.3: version "0.5.3" resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.3.tgz#e130caf7e7279087c5616c2007d0485698984fbd" @@ -1346,7 +1329,7 @@ core-util-is@1.0.2, core-util-is@~1.0.0: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= -cross-spawn@^7.0.0, cross-spawn@^7.0.2: +cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== @@ -1365,10 +1348,10 @@ cssom@~0.3.6: resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.8.tgz#9f1276f5b2b463f2114d3f2c75250af8c1a36f4a" integrity sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg== -cssstyle@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/cssstyle/-/cssstyle-2.2.0.tgz#e4c44debccd6b7911ed617a4395e5754bba59992" - integrity sha512-sEb3XFPx3jNnCAMtqrXPDeSgQr+jojtCeNf8cvMNMh1cG970+lljssvQDzPq6lmmJu2Vhqood/gtEomBiHOGnA== +cssstyle@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/cssstyle/-/cssstyle-2.3.0.tgz#ff665a0ddbdc31864b09647f34163443d90b0852" + integrity sha512-AZL67abkUzIuvcHqk7c09cezpGNcxUxU4Ioi/05xHk4DQeTkWmGYftIE6ctU6AEt+Gn4n1lDStOtj7FKycP71A== dependencies: cssom "~0.3.6" @@ -1388,27 +1371,27 @@ data-urls@^2.0.0: whatwg-mimetype "^2.3.0" whatwg-url "^8.0.0" -debug@2.6.9, debug@^2.6.9: +debug@2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== dependencies: ms "2.0.0" -debug@3.2.6, debug@^3.1.0: - version "3.2.6" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" - integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== - dependencies: - ms "^2.1.1" - -debug@4, debug@4.2.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: +debug@4, debug@^4.1.0, debug@^4.1.1: version "4.2.0" resolved "https://registry.yarnpkg.com/debug/-/debug-4.2.0.tgz#7f150f93920e94c58f5574c2fd01a3110effe7f1" integrity sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg== dependencies: ms "2.1.2" +debug@4.3.1, debug@^4.0.1, debug@^4.3.1: + version "4.3.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.1.tgz#f0d229c505e0c6d8c49ac553d1b13dc183f6b2ee" + integrity sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ== + dependencies: + ms "2.1.2" + decamelize@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -1419,10 +1402,10 @@ decamelize@^4.0.0: resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== -decimal.js@10.2.0, decimal.js@^10.0.0, decimal.js@^10.2.0: - version "10.2.0" - resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.2.0.tgz#39466113a9e036111d02f82489b5fd6b0b5ed231" - integrity sha512-vDPw+rDgn3bZe1+F/pyEwb1oMG2XTlRVgAa6B4KccTEpYgF8w6eQllVbQcfIJnZyvzFtFpxnpGtx8dd7DJp/Rw== +decimal.js@^10.0.0, decimal.js@^10.2.1: + version "10.2.1" + resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.2.1.tgz#238ae7b0f0c793d3e3cea410108b35a2c01426a3" + integrity sha512-KaL7+6Fw6i5A2XSnsbhm/6B+NuEA7TZ4vqxnd5tXz9sbKtrN9Srj8ab4vKVdK8YAqZO9P1kg45Y6YLoduPf+kw== deep-eql@^3.0.1: version "3.0.1" @@ -1431,31 +1414,27 @@ deep-eql@^3.0.1: dependencies: type-detect "^4.0.0" -deep-equal@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-2.0.4.tgz#6b0b407a074666033169df3acaf128e1c6f3eab6" - integrity sha512-BUfaXrVoCfgkOQY/b09QdO9L3XNoF2XH0A3aY9IQwQL/ZjLOe8FQgCNVl1wiolhsFo8kFdO9zdPViCPbmaJA5w== +deep-equal@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-2.0.5.tgz#55cd2fe326d83f9cbf7261ef0e060b3f724c5cb9" + integrity sha512-nPiRgmbAtm1a3JsnLCf6/SLfXcjyN5v8L1TXzdCmHrXJ4hx+gW/w1YCcn7z8gJtSiDArZCgYtbao3QqLm/N1Sw== dependencies: - es-abstract "^1.18.0-next.1" - es-get-iterator "^1.1.0" + call-bind "^1.0.0" + es-get-iterator "^1.1.1" + get-intrinsic "^1.0.1" is-arguments "^1.0.4" is-date-object "^1.0.2" is-regex "^1.1.1" isarray "^2.0.5" - object-is "^1.1.3" + object-is "^1.1.4" object-keys "^1.1.1" - object.assign "^4.1.1" + object.assign "^4.1.2" regexp.prototype.flags "^1.3.0" side-channel "^1.0.3" which-boxed-primitive "^1.0.1" which-collection "^1.0.1" which-typed-array "^1.1.2" -deep-extend@~0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" - integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== - deep-is@^0.1.3, deep-is@~0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" @@ -1475,7 +1454,7 @@ defaults@^1.0.3: dependencies: clone "^1.0.2" -define-properties@^1.1.2, define-properties@^1.1.3: +define-properties@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== @@ -1497,6 +1476,11 @@ destroy@~1.0.4: resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" integrity sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA= +devtools-protocol@0.0.818844: + version "0.0.818844" + resolved "https://registry.yarnpkg.com/devtools-protocol/-/devtools-protocol-0.0.818844.tgz#d1947278ec85b53e4c8ca598f607a28fa785ba9e" + integrity sha512-AD1hi7iVJ8OD0aMLQU5VK0XH9LDlA1+BcPIgrAxPfaibx2DbWucuyOhc4oyQCbnvDDO68nN6/LcKfqTP343Jjg== + devtools-timeline-model@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/devtools-timeline-model/-/devtools-timeline-model-1.4.0.tgz#91f9624fb0313fa3ebeda7bf99865357bc66c726" @@ -1505,21 +1489,12 @@ devtools-timeline-model@^1.4.0: chrome-devtools-frontend "1.0.445684" resolve "1.1.7" -diagnostics@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/diagnostics/-/diagnostics-1.1.1.tgz#cab6ac33df70c9d9a727490ae43ac995a769b22a" - integrity sha512-8wn1PmdunLJ9Tqbx+Fx/ZEuHfJf4NKSN2ZBj7SJC/OWRWha843+WsTjqMe1B5E3p28jqBlp+mJ2fPVxPyNgYKQ== - dependencies: - colorspace "1.1.x" - enabled "1.0.x" - kuler "1.0.x" +diff@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" + integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== -diff@3.5.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" - integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== - -diff@4.0.2, diff@^4.0.1: +diff@^4.0.1: version "4.0.2" resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== @@ -1558,15 +1533,10 @@ ee-first@1.1.1: resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= -electron-to-chromium@^1.3.571: - version "1.3.585" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.585.tgz#71cdb722c73488b9475ad1c572cf43a763ef9081" - integrity sha512-xoeqjMQhgHDZM7FiglJAb2aeOxHZWFruUc3MbAGTgE7GB8rr5fTn1Sdh5THGuQtndU3GuXlu91ZKqRivxoCZ/A== - -emoji-regex@^7.0.1: - version "7.0.3" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" - integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== +electron-to-chromium@^1.3.723: + version "1.3.727" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.727.tgz#857e310ca00f0b75da4e1db6ff0e073cc4a91ddf" + integrity sha512-Mfz4FIB4FSvEwBpDfdipRIrwd6uo8gUDoRDF4QEYb4h4tSuI3ov594OrjU6on042UlFHouIJpClDODGkPcBSbg== emoji-regex@^8.0.0: version "8.0.0" @@ -1578,19 +1548,17 @@ emojis-list@^3.0.0: resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78" integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q== -enabled@1.0.x: - version "1.0.2" - resolved "https://registry.yarnpkg.com/enabled/-/enabled-1.0.2.tgz#965f6513d2c2d1c5f4652b64a2e3396467fc2f93" - integrity sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M= - dependencies: - env-variable "0.0.x" +enabled@2.0.x: + version "2.0.0" + resolved "https://registry.yarnpkg.com/enabled/-/enabled-2.0.0.tgz#f9dd92ec2d6f4bbc0d5d1e64e21d61cd4665e7c2" + integrity sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ== encodeurl@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k= -end-of-stream@^1.1.0: +end-of-stream@^1.1.0, end-of-stream@^1.4.1: version "1.4.4" resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== @@ -1598,94 +1566,82 @@ end-of-stream@^1.1.0: once "^1.4.0" enhanced-resolve@^4.0.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-4.3.0.tgz#3b806f3bfafc1ec7de69551ef93cca46c1704126" - integrity sha512-3e87LvavsdxyoCfGusJnrZ5G8SLPOFeHSNpZI/ATL9a5leXo2k0w6MKnbqhdBad9qTobSfB20Ld7UmgoNbAZkQ== + version "4.5.0" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-4.5.0.tgz#2f3cfd84dbe3b487f18f2db2ef1e064a571ca5ec" + integrity sha512-Nv9m36S/vxpsI+Hc4/ZGRs0n9mXqSWGGq49zxb/cJfPAQMbUtttJAlNPS4AQzaBdw/pKskw5bMbekT/Y7W/Wlg== dependencies: graceful-fs "^4.1.2" memory-fs "^0.5.0" tapable "^1.0.0" -enhanced-resolve@^5.3.1: - version "5.3.1" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.3.1.tgz#3f988d0d7775bdc2d96ede321dc81f8249492f57" - integrity sha512-G1XD3MRGrGfNcf6Hg0LVZG7GIKcYkbfHa5QMxt1HDUTdYoXH0JR1xXyg+MaKLF73E9A27uWNVxvFivNRYeUB6w== +enhanced-resolve@^5.8.0: + version "5.8.2" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.8.2.tgz#15ddc779345cbb73e97c611cd00c01c1e7bf4d8b" + integrity sha512-F27oB3WuHDzvR2DOGNTaYy0D5o0cnrv8TeI482VM4kYgQd/FT9lUQwuNsJ0oOHtBUq7eiW5ytqzp7nBFknL+GA== dependencies: graceful-fs "^4.2.4" - tapable "^2.0.0" + tapable "^2.2.0" -enquirer@^2.3.5, enquirer@^2.3.6: +enquirer@^2.3.5: version "2.3.6" resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" integrity sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg== dependencies: ansi-colors "^4.1.1" -env-variable@0.0.x: - version "0.0.6" - resolved "https://registry.yarnpkg.com/env-variable/-/env-variable-0.0.6.tgz#74ab20b3786c545b62b4a4813ab8cf22726c9808" - integrity sha512-bHz59NlBbtS0NhftmR8+ExBEekE7br0e01jw+kk0NDro7TtZzBYZ5ScGPs3OmwnpyfHTHOtr1Y6uedCdrIldtg== - envinfo@^7.7.3: - version "7.7.3" - resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.7.3.tgz#4b2d8622e3e7366afb8091b23ed95569ea0208cc" - integrity sha512-46+j5QxbPWza0PB1i15nZx0xQ4I/EfQxg9J8Had3b408SV63nEtor2e+oiY63amTo9KTuh2a3XLObNwduxYwwA== + version "7.8.1" + resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475" + integrity sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw== errno@^0.1.3: - version "0.1.7" - resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.7.tgz#4684d71779ad39af177e3f007996f7c67c852618" - integrity sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg== + version "0.1.8" + resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.8.tgz#8bb3e9c7d463be4976ff888f76b4809ebc2e811f" + integrity sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A== dependencies: prr "~1.0.1" -es-abstract@^1.17.0-next.1, es-abstract@^1.17.4, es-abstract@^1.17.5: - version "1.17.5" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.5.tgz#d8c9d1d66c8981fb9200e2251d799eee92774ae9" - integrity sha512-BR9auzDbySxOcfog0tLECW8l28eRGpDpU3Dm3Hp4q/N+VtLTmyj4EUN088XZWQDW/hzj6sYRDXeOFsaAODKvpg== +es-abstract@^1.18.0-next.1, es-abstract@^1.18.0-next.2: + version "1.18.0" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.0.tgz#ab80b359eecb7ede4c298000390bc5ac3ec7b5a4" + integrity sha512-LJzK7MrQa8TS0ja2w3YNLzUgJCGPdPOV1yVvezjNnS89D+VR08+Szt2mz3YB2Dck/+w5tfIq/RoUAFqJJGM2yw== dependencies: + call-bind "^1.0.2" es-to-primitive "^1.2.1" function-bind "^1.1.1" + get-intrinsic "^1.1.1" has "^1.0.3" - has-symbols "^1.0.1" - is-callable "^1.1.5" - is-regex "^1.0.5" - object-inspect "^1.7.0" + has-symbols "^1.0.2" + is-callable "^1.2.3" + is-negative-zero "^2.0.1" + is-regex "^1.1.2" + is-string "^1.0.5" + object-inspect "^1.9.0" object-keys "^1.1.1" - object.assign "^4.1.0" - string.prototype.trimleft "^2.1.1" - string.prototype.trimright "^2.1.1" + object.assign "^4.1.2" + string.prototype.trimend "^1.0.4" + string.prototype.trimstart "^1.0.4" + unbox-primitive "^1.0.0" -es-abstract@^1.18.0-next.0, es-abstract@^1.18.0-next.1: - version "1.18.0-next.1" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.0-next.1.tgz#6e3a0a4bda717e5023ab3b8e90bec36108d22c68" - integrity sha512-I4UGspA0wpZXWENrdA0uHbnhte683t3qT/1VFH9aX2dA5PPSf6QW5HHXf5HImaqPmjXaVeVk4RGWnaylmV7uAA== +es-get-iterator@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/es-get-iterator/-/es-get-iterator-1.1.2.tgz#9234c54aba713486d7ebde0220864af5e2b283f7" + integrity sha512-+DTO8GYwbMCwbywjimwZMHp8AuYXOS2JZFWoi2AlPOS3ebnII9w/NLpNZtA7A0YLaVDw+O7KFCeoIV7OPvM7hQ== dependencies: - es-to-primitive "^1.2.1" - function-bind "^1.1.1" - has "^1.0.3" + call-bind "^1.0.2" + get-intrinsic "^1.1.0" has-symbols "^1.0.1" - is-callable "^1.2.2" - is-negative-zero "^2.0.0" - is-regex "^1.1.1" - object-inspect "^1.8.0" - object-keys "^1.1.1" - object.assign "^4.1.1" - string.prototype.trimend "^1.0.1" - string.prototype.trimstart "^1.0.1" - -es-get-iterator@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/es-get-iterator/-/es-get-iterator-1.1.0.tgz#bb98ad9d6d63b31aacdc8f89d5d0ee57bcb5b4c8" - integrity sha512-UfrmHuWQlNMTs35e1ypnvikg6jCz3SK8v8ImvmDsh36fCVUR1MqoFDiyn0/k52C8NqO3YsO8Oe0azeesNuqSsQ== - dependencies: - es-abstract "^1.17.4" - has-symbols "^1.0.1" - is-arguments "^1.0.4" - is-map "^2.0.1" - is-set "^2.0.1" + is-arguments "^1.1.0" + is-map "^2.0.2" + is-set "^2.0.2" is-string "^1.0.5" isarray "^2.0.5" +es-module-lexer@^0.4.0: + version "0.4.1" + resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.4.1.tgz#dda8c6a14d8f340a24e34331e0fab0cb50438e0e" + integrity sha512-ooYciCUtfw6/d2w56UVeqHPcoCFAiJdz5XOkYpv/Txl1HMUozpXjz/2RIQgqwKdXNDPSF1W7mJCFse3G+HDyAA== + es-to-primitive@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" @@ -1700,19 +1656,7 @@ es6-error@^4.0.1: resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d" integrity sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg== -es6-promise@^4.0.3: - version "4.2.8" - resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" - integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== - -es6-promisify@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" - integrity sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM= - dependencies: - es6-promise "^4.0.3" - -escalade@^3.1.0: +escalade@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== @@ -1722,28 +1666,33 @@ escape-html@~1.0.3: resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg= -escape-latex@1.2.0: +escape-latex@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/escape-latex/-/escape-latex-1.2.0.tgz#07c03818cf7dac250cce517f4fda1b001ef2bca1" integrity sha512-nV5aVWW1K0wEiUIEdZ4erkGGH8mDxGyxSeqPzRNtWP7ataw+/olFObw7hujFWlVjNsaDFw5VZ5NzVSIqRgfTiw== -escape-string-regexp@1.0.5, escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - escape-string-regexp@4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== -escodegen@^1.14.1: - version "1.14.1" - resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.14.1.tgz#ba01d0c8278b5e95a9a45350142026659027a457" - integrity sha512-Bmt7NcRySdIfNPfU2ZoXDrrXsG9ZjvDxcAlMfDUgRBjLOWTuIACXPBFJH7Z+cLb40JeQco5toikyc9t9P8E9SQ== +escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= + +escape-string-regexp@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344" + integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== + +escodegen@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-2.0.0.tgz#5e32b12833e8aa8fa35e1bf0befa89380484c7dd" + integrity sha512-mmHKys/C8BFUGI+MAWNcSYoORYLMdPzjrknd2Vc+bUsjN5bXcr8EhrNB+UTqfL1y3I9c4fw2ihgtMPQLBRiQxw== dependencies: esprima "^4.0.1" - estraverse "^4.2.0" + estraverse "^5.2.0" esutils "^2.0.2" optionator "^0.8.1" optionalDependencies: @@ -1770,17 +1719,17 @@ eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.3.0: integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ== eslint-visitor-keys@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz#21fdc8fbcd9c795cc0321f0563702095751511a8" - integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== + version "2.1.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303" + integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw== -eslint@^7.12.1: - version "7.12.1" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.12.1.tgz#bd9a81fa67a6cfd51656cdb88812ce49ccec5801" - integrity sha512-HlMTEdr/LicJfN08LB3nM1rRYliDXOmfoO4vj39xN6BLpFzF00hbwBoqHk8UcJ2M/3nlARZWy/mslvGEuZFvsg== +eslint@^7.26.0: + version "7.26.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.26.0.tgz#d416fdcdcb3236cd8f282065312813f8c13982f6" + integrity sha512-4R1ieRf52/izcZE7AlLy56uIHHDLT74Yzz2Iv2l6kDaYvEu9x+wMB5dZArVL8SYGXSYV2YAg70FcW5Y5nGGNIg== dependencies: - "@babel/code-frame" "^7.0.0" - "@eslint/eslintrc" "^0.2.1" + "@babel/code-frame" "7.12.11" + "@eslint/eslintrc" "^0.4.1" ajv "^6.10.0" chalk "^4.0.0" cross-spawn "^7.0.2" @@ -1790,13 +1739,13 @@ eslint@^7.12.1: eslint-scope "^5.1.1" eslint-utils "^2.1.0" eslint-visitor-keys "^2.0.0" - espree "^7.3.0" - esquery "^1.2.0" + espree "^7.3.1" + esquery "^1.4.0" esutils "^2.0.2" - file-entry-cache "^5.0.1" + file-entry-cache "^6.0.1" functional-red-black-tree "^1.0.1" glob-parent "^5.0.0" - globals "^12.1.0" + globals "^13.6.0" ignore "^4.0.6" import-fresh "^3.0.0" imurmurhash "^0.1.4" @@ -1804,7 +1753,7 @@ eslint@^7.12.1: js-yaml "^3.13.1" json-stable-stringify-without-jsonify "^1.0.1" levn "^0.4.1" - lodash "^4.17.19" + lodash "^4.17.21" minimatch "^3.0.4" natural-compare "^1.4.0" optionator "^0.9.1" @@ -1813,17 +1762,17 @@ eslint@^7.12.1: semver "^7.2.1" strip-ansi "^6.0.0" strip-json-comments "^3.1.0" - table "^5.2.3" + table "^6.0.4" text-table "^0.2.0" v8-compile-cache "^2.0.3" -espree@^7.3.0: - version "7.3.0" - resolved "https://registry.yarnpkg.com/espree/-/espree-7.3.0.tgz#dc30437cf67947cf576121ebd780f15eeac72348" - integrity sha512-dksIWsvKCixn1yrEXO8UosNSxaDoSYpq9reEjZSbHLpT5hpaCAKTLBwq0RHtLrIr+c0ByiYzWT8KTMRzoRCNlw== +espree@^7.3.0, espree@^7.3.1: + version "7.3.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-7.3.1.tgz#f2df330b752c6f55019f8bd89b7660039c1bbbb6" + integrity sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g== dependencies: acorn "^7.4.0" - acorn-jsx "^5.2.0" + acorn-jsx "^5.3.1" eslint-visitor-keys "^1.3.0" esprima@^4.0.0, esprima@^4.0.1: @@ -1831,10 +1780,10 @@ esprima@^4.0.0, esprima@^4.0.1: resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== -esquery@^1.2.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.3.1.tgz#b78b5828aa8e214e29fb74c4d5b752e1c033da57" - integrity sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ== +esquery@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.4.0.tgz#2148ffc38b82e8c7057dfed48425b3e61f0f24a5" + integrity sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w== dependencies: estraverse "^5.1.0" @@ -1845,7 +1794,7 @@ esrecurse@^4.3.0: dependencies: estraverse "^5.2.0" -estraverse@^4.1.1, estraverse@^4.2.0: +estraverse@^4.1.1: version "4.3.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== @@ -1866,23 +1815,23 @@ etag@~1.8.1: integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc= events@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/events/-/events-3.2.0.tgz#93b87c18f8efcd4202a461aec4dfc0556b639379" - integrity sha512-/46HWwbfCX2xTawVfkKLGxMifJYQBWMwY1mjywRtb4c9x8l5NP3KoJtnIOiL1hfdRkIuYhETxQlo62IF8tcnlg== + version "3.3.0" + resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" + integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== -execa@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-4.1.0.tgz#4e5491ad1572f2f17a77d388c6c857135b22847a" - integrity sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA== +execa@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-5.0.0.tgz#4029b0007998a841fbd1032e5f4de86a3c1e3376" + integrity sha512-ov6w/2LCiuyO4RLYGdpFGjkcs0wMTgGE8PrkTHikeUy5iJekXyPIKUjifk5CsE0pt7sMCrMZ3YNqoCj6idQOnQ== dependencies: - cross-spawn "^7.0.0" - get-stream "^5.0.0" - human-signals "^1.1.1" + cross-spawn "^7.0.3" + get-stream "^6.0.0" + human-signals "^2.1.0" is-stream "^2.0.0" merge-stream "^2.0.0" - npm-run-path "^4.0.0" - onetime "^5.1.0" - signal-exit "^3.0.2" + npm-run-path "^4.0.1" + onetime "^5.1.2" + signal-exit "^3.0.3" strip-final-newline "^2.0.0" express-ws@^4.0.0: @@ -1933,17 +1882,7 @@ extend@~3.0.2: resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== -extract-zip@^1.6.6: - version "1.7.0" - resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.7.0.tgz#556cc3ae9df7f452c493a0cfb51cc30277940927" - integrity sha512-xoh5G1W/PB0/27lXgMQyIhP5DSY/LhoCsOyZgb+6iMmRtCwVBo55uKaMoEYrDCKQhWvqEip5ZPKAc6eFNyf/MA== - dependencies: - concat-stream "^1.6.2" - debug "^2.6.9" - mkdirp "^0.5.4" - yauzl "^2.10.0" - -extract-zip@^2.0.1: +extract-zip@^2.0.0, extract-zip@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-2.0.1.tgz#663dca56fe46df890d5f131ef4a06d22bb8ba13a" integrity sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg== @@ -1970,9 +1909,9 @@ fast-deep-equal@^3.1.1: integrity sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA== fast-glob@^3.1.1: - version "3.2.4" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.4.tgz#d20aefbf99579383e7f3cc66529158c9b98554d3" - integrity sha512-kr/Oo6PX51265qeuCYsyGypiO5uJFgBS0jksyG7FUeCyQzNwYnzrNIMR1NXfkZXsMYXYLRAHgISHBz8gQcxKHQ== + version "3.2.5" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.5.tgz#7939af2a656de79a4f1901903ee8adcaa7cb9661" + integrity sha512-2DtFcgT68wiTTiwZ2hNdJfcHNke9XOfnwmBRWXhmeKM8rF0TGwmC/Qto3S7RoZKp5cilZbxzO5iTNTQsJ+EeDg== dependencies: "@nodelib/fs.stat" "^2.0.2" "@nodelib/fs.walk" "^1.2.3" @@ -1996,10 +1935,15 @@ fast-safe-stringify@^2.0.4: resolved "https://registry.yarnpkg.com/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz#124aa885899261f68aedb42a7c080de9da608743" integrity sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA== +fastest-levenshtein@^1.0.12: + version "1.0.12" + resolved "https://registry.yarnpkg.com/fastest-levenshtein/-/fastest-levenshtein-1.0.12.tgz#9990f7d3a88cc5a9ffd1f1745745251700d497e2" + integrity sha512-On2N+BpYJ15xIC974QNVuYGMOlEVt4s0EOI3wwMqOmK1fdDY+FN/zltPV8vosq4ad4c/gJ1KHScUn/6AWIgiow== + fastq@^1.6.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.8.0.tgz#550e1f9f59bbc65fe185cb6a9b4d95357107f481" - integrity sha512-SMIZoZdLh/fgofivvIkmknUXyPnvxRE3DhtZ5Me3Mrsk5gyPL42F0xr51TdRXskBxHfMp+07bcYzfsYEsSQA9Q== + version "1.11.0" + resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.11.0.tgz#bb9fb955a07130a918eb63c1f5161cc32a5d0858" + integrity sha512-7Eczs8gIPDrVzT+EksYBcupqMyxSHXXrHOLRRxU2/DicV8789MRBRR8+Hc2uWzUupOs4YS4JzBmBxjjCVBxD/g== dependencies: reusify "^1.0.4" @@ -2010,17 +1954,17 @@ fd-slicer@~1.1.0: dependencies: pend "~1.2.0" -fecha@^2.3.3: - version "2.3.3" - resolved "https://registry.yarnpkg.com/fecha/-/fecha-2.3.3.tgz#948e74157df1a32fd1b12c3a3c3cdcb6ec9d96cd" - integrity sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg== +fecha@^4.2.0: + version "4.2.1" + resolved "https://registry.yarnpkg.com/fecha/-/fecha-4.2.1.tgz#0a83ad8f86ef62a091e22bb5a039cd03d23eecce" + integrity sha512-MMMQ0ludy/nBs1/o0zVOiKTpG7qMbonKUzjJgQFEuvq6INZ1OraKPRAWkBq5vlKLOUMpmNYG1JoN3oDPUQ9m3Q== -file-entry-cache@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-5.0.1.tgz#ca0f6efa6dd3d561333fb14515065c2fafdf439c" - integrity sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g== +file-entry-cache@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz#211b2dd9659cb0394b073e7323ac3c933d522027" + integrity sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg== dependencies: - flat-cache "^2.0.1" + flat-cache "^3.0.4" fill-range@^7.0.1: version "7.0.1" @@ -2051,13 +1995,6 @@ find-cache-dir@^3.2.0: make-dir "^3.0.2" pkg-dir "^4.1.0" -find-up@3.0.0, find-up@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" - integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== - dependencies: - locate-path "^3.0.0" - find-up@5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" @@ -2074,31 +2011,28 @@ find-up@^4.0.0, find-up@^4.1.0: locate-path "^5.0.0" path-exists "^4.0.0" -flat-cache@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0" - integrity sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA== +flat-cache@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11" + integrity sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg== dependencies: - flatted "^2.0.0" - rimraf "2.6.3" - write "1.0.3" - -flat@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/flat/-/flat-4.1.0.tgz#090bec8b05e39cba309747f1d588f04dbaf98db2" - integrity sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw== - dependencies: - is-buffer "~2.0.3" + flatted "^3.1.0" + rimraf "^3.0.2" flat@^5.0.2: version "5.0.2" resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== -flatted@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" - integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== +flatted@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.1.1.tgz#c4b489e80096d9df1dfc97c79871aea7c617c469" + integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA== + +fn.name@1.x.x: + version "1.1.0" + resolved "https://registry.yarnpkg.com/fn.name/-/fn.name-1.1.0.tgz#26cad8017967aea8731bc42961d04a3d5988accc" + integrity sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw== foreach@^2.0.5: version "2.0.5" @@ -2132,10 +2066,10 @@ forwarded@~0.1.2: resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84" integrity sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ= -fraction.js@4.0.12: - version "4.0.12" - resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.0.12.tgz#0526d47c65a5fb4854df78bc77f7bec708d7b8c3" - integrity sha512-8Z1K0VTG4hzYY7kA/1sj4/r1/RWLBD3xwReT/RCrUCbzPszjNQCCsy3ktkU/eaEqX3MYa4pY37a52eiBlPMlhA== +fraction.js@^4.0.13: + version "4.0.13" + resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.0.13.tgz#3c1c315fa16b35c85fffa95725a36fa729c69dfe" + integrity sha512-E1fz2Xs9ltlUp+qbiyx9wmt2n9dRzPsS11Jtdb8D2o+cC7wr9xkkKsVKJuBX0ST+LVS+LhLO+SbLJNtfWcJvXA== fresh@0.5.2: version "0.5.2" @@ -2147,15 +2081,30 @@ fromentries@^1.2.0: resolved "https://registry.yarnpkg.com/fromentries/-/fromentries-1.2.0.tgz#e6aa06f240d6267f913cea422075ef88b63e7897" integrity sha512-33X7H/wdfO99GdRLLgkjUrD4geAFdq/Uv0kl3HD4da6HDixd2GUg8Mw7dahLCV9r/EARkmtYBB6Tch4EEokFTQ== +fs-constants@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad" + integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow== + +fs-extra@9.0.1: + version "9.0.1" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.0.1.tgz#910da0062437ba4c39fedd863f1675ccfefcb9fc" + integrity sha512-h2iAoN838FqAFJY2/qVpzFXy+EBxfVE220PalAqQLDVsFOHLJrZvut5puAbCdNv6WJk+B8ihI+k0c7JK5erwqQ== + dependencies: + at-least-node "^1.0.0" + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^1.0.0" + fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= -fsevents@~2.1.2: - version "2.1.3" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e" - integrity sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ== +fsevents@~2.3.1: + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== function-bind@^1.1.1: version "1.1.1" @@ -2172,7 +2121,7 @@ gensync@^1.0.0-beta.1: resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.1.tgz#58f4361ff987e5ff6e1e7a210827aa371eaac269" integrity sha512-r8EC6NO1sngH/zdD9fiRDLdcgnbayXah+mLgManTaIZJqEC1MZstmnox8KpnI2/fxQwrp5OpCOYWLp4rBl4Jcg== -get-caller-file@^2.0.1: +get-caller-file@^2.0.1, get-caller-file@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== @@ -2182,18 +2131,32 @@ get-func-name@^2.0.0: resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" integrity sha1-6td0q+5y4gQJQzoGY2YCPdaIekE= +get-intrinsic@^1.0.1, get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6" + integrity sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q== + dependencies: + function-bind "^1.1.1" + has "^1.0.3" + has-symbols "^1.0.1" + get-package-type@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a" integrity sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q== -get-stream@^5.0.0, get-stream@^5.1.0: +get-stream@^5.1.0: version "5.2.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== dependencies: pump "^3.0.0" +get-stream@^6.0.0: + version "6.0.1" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" + integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== + getpass@^0.1.1: version "0.1.7" resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" @@ -2201,7 +2164,14 @@ getpass@^0.1.1: dependencies: assert-plus "^1.0.0" -glob-parent@^5.0.0, glob-parent@^5.1.0, glob-parent@~5.1.0: +glob-parent@^5.0.0, glob-parent@^5.1.0: + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" + +glob-parent@~5.1.0: version "5.1.1" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229" integrity sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ== @@ -2213,10 +2183,10 @@ glob-to-regexp@^0.4.1: resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== -glob@7.1.3: - version "7.1.3" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1" - integrity sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ== +glob@7.1.6, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6: + version "7.1.6" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" + integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" @@ -2225,10 +2195,10 @@ glob@7.1.3: once "^1.3.0" path-is-absolute "^1.0.0" -glob@7.1.6, glob@^7.0.5, glob@^7.1.1, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6: - version "7.1.6" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" - integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== +glob@^7.1.1, glob@^7.1.7: + version "7.1.7" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90" + integrity sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ== dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" @@ -2249,10 +2219,17 @@ globals@^12.1.0: dependencies: type-fest "^0.8.1" +globals@^13.6.0: + version "13.8.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-13.8.0.tgz#3e20f504810ce87a8d72e55aecf8435b50f4c1b3" + integrity sha512-rHtdA6+PDBIjeEvA91rpqzEvk/k3/i7EeNQiryiWuJH0Hw9cpyJMAt2jtbAwUaRdhD+573X4vWw6IcjKPasi9Q== + dependencies: + type-fest "^0.20.2" + globby@^11.0.1: - version "11.0.1" - resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.1.tgz#9a2bf107a068f3ffeabc49ad702c79ede8cfd357" - integrity sha512-iH9RmgwCmUJHi2z5o2l3eTtGBtXek1OYlHrbcxOYugyHLmAsZrPj43OtHThd62Buh/Vv6VyCBD2bdyWcGNQqoQ== + version "11.0.3" + resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.3.tgz#9b1f0cb523e171dd1ad8c7b2a9fb4b644b9593cb" + integrity sha512-ffdmosjA807y7+lA1NM0jELARVmYul/715xiILEjo3hBLPTcirgQNnXECn5g3mtR8TOLCVbkfua1Hpen25/Xcg== dependencies: array-union "^2.1.0" dir-glob "^3.0.1" @@ -2261,11 +2238,16 @@ globby@^11.0.1: merge2 "^1.3.0" slash "^3.0.0" -graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.2.4: +graceful-fs@^4.1.15, graceful-fs@^4.1.2: version "4.2.4" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== +graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4: + version "4.2.6" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.6.tgz#ff040b2b0853b23c3d31027523706f1885d76bee" + integrity sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ== + growl@1.10.5: version "1.10.5" resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" @@ -2277,13 +2259,18 @@ har-schema@^2.0.0: integrity sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI= har-validator@~5.1.3: - version "5.1.3" - resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.3.tgz#1ef89ebd3e4996557675eed9893110dc350fa080" - integrity sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g== + version "5.1.5" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.5.tgz#1f0803b9f8cb20c0fa13822df1ecddb36bde1efd" + integrity sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w== dependencies: - ajv "^6.5.5" + ajv "^6.12.3" har-schema "^2.0.0" +has-bigints@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.1.tgz#64fe6acb020673e3b78db035a5af69aa9d07b113" + integrity sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA== + has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" @@ -2294,10 +2281,10 @@ has-flag@^4.0.0: resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== -has-symbols@^1.0.0, has-symbols@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.1.tgz#9f5214758a44196c406d9bd76cebf81ec2dd31e8" - integrity sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg== +has-symbols@^1.0.1, has-symbols@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.2.tgz#165d3070c00309752a1236a479331e3ac56f1423" + integrity sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw== has@^1.0.3: version "1.0.3" @@ -2362,13 +2349,13 @@ http-signature@~1.2.0: jsprim "^1.2.2" sshpk "^1.7.0" -https-proxy-agent@^2.2.1: - version "2.2.4" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz#4ee7a737abd92678a293d9b34a1af4d0d08c787b" - integrity sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg== +https-proxy-agent@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-4.0.0.tgz#702b71fb5520a132a66de1f67541d9e62154d82b" + integrity sha512-zoDhWrkR3of1l9QAL8/scJZyLu8j/gBkcwcaQOZh7Gyh/+uJQzGVETdgT30akuwkpL8HTRfssqI3BZuV18teDg== dependencies: - agent-base "^4.3.0" - debug "^3.1.0" + agent-base "5" + debug "4" https-proxy-agent@^5.0.0: version "5.0.0" @@ -2378,10 +2365,10 @@ https-proxy-agent@^5.0.0: agent-base "6" debug "4" -human-signals@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" - integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== +human-signals@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" + integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== iconv-lite@0.4.24: version "0.4.24" @@ -2397,6 +2384,11 @@ iconv-lite@^0.6.2: dependencies: safer-buffer ">= 2.1.2 < 3.0.0" +ieee754@^1.1.13: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" + integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== + ignore@^4.0.6: version "4.0.6" resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" @@ -2408,9 +2400,9 @@ ignore@^5.1.4: integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw== import-fresh@^3.0.0, import-fresh@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.2.1.tgz#633ff618506e793af5ac91bf48b72677e15cbe66" - integrity sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ== + version "3.3.0" + resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" + integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== dependencies: parent-module "^1.0.0" resolve-from "^4.0.0" @@ -2441,7 +2433,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@2.0.4, inherits@^2.0.3, inherits@~2.0.3: +inherits@2, inherits@2.0.4, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -2456,30 +2448,27 @@ interpret@^2.2.0: resolved "https://registry.yarnpkg.com/interpret/-/interpret-2.2.0.tgz#1a78a0b5965c40a5416d007ad6f50ad27c417df9" integrity sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw== -ip-regex@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-2.1.0.tgz#fa78bf5d2e6913c911ce9f819ee5146bb6d844e9" - integrity sha1-+ni/XS5pE8kRzp+BnuUUa7bYROk= - ipaddr.js@1.9.1: version "1.9.1" resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== -is-arguments@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.0.4.tgz#3faf966c7cba0ff437fb31f6250082fcf0448cf3" - integrity sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA== +is-arguments@^1.0.4, is-arguments@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.1.0.tgz#62353031dfbee07ceb34656a6bde59efecae8dd9" + integrity sha512-1Ij4lOMPl/xB5kBDn7I+b2ttPMKa8szhEIrXDuXQD/oe3HJLTLhqhgGspwgyGd6MOywBUqVvYicF72lkgDnIHg== + dependencies: + call-bind "^1.0.0" is-arrayish@^0.3.1: version "0.3.2" resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.3.2.tgz#4574a2ae56f7ab206896fb431eaeed066fdf8f03" integrity sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ== -is-bigint@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-bigint/-/is-bigint-1.0.0.tgz#73da8c33208d00f130e9b5e15d23eac9215601c4" - integrity sha512-t5mGUXC/xRheCK431ylNiSkGGpBp8bHENBcENTkDT6ppwPzEVxNGZRvgvmOEfbWkFhA7D2GEuE2mmQTr78sl2g== +is-bigint@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-bigint/-/is-bigint-1.0.2.tgz#ffb381442503235ad245ea89e45b3dbff040ee5a" + integrity sha512-0JV5+SOCQkIdzjBK9buARcV804Ddu7A0Qet6sHi3FimE9ne6m4BGQZfRn+NZiXbBk4F4XmHfDZIipLj9pX8dSA== is-binary-path@~2.1.0: version "2.1.0" @@ -2488,30 +2477,29 @@ is-binary-path@~2.1.0: dependencies: binary-extensions "^2.0.0" -is-boolean-object@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-boolean-object/-/is-boolean-object-1.0.1.tgz#10edc0900dd127697a92f6f9807c7617d68ac48e" - integrity sha512-TqZuVwa/sppcrhUCAYkGBk7w0yxfQQnxq28fjkO53tnK9FQXmdwz2JS5+GjsWQ6RByES1K40nI+yDic5c9/aAQ== +is-boolean-object@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/is-boolean-object/-/is-boolean-object-1.1.1.tgz#3c0878f035cb821228d350d2e1e36719716a3de8" + integrity sha512-bXdQWkECBUIAcCkeH1unwJLIpZYaa5VvuygSyS/c2lf719mTKZDU5UdDRlpd01UjADgmW8RfqaP+mRaVPdr/Ng== + dependencies: + call-bind "^1.0.2" -is-buffer@~2.0.3: - version "2.0.4" - resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.4.tgz#3e572f23c8411a5cfd9557c849e3665e0b290623" - integrity sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A== +is-callable@^1.1.4, is-callable@^1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.3.tgz#8b1e0500b73a1d76c70487636f368e519de8db8e" + integrity sha512-J1DcMe8UYTBSrKezuIUTUwjXsho29693unXM2YhJUTR2txK/eG47bvNa/wipPFmZFgr/N6f1GA66dv0mEyTIyQ== -is-callable@^1.1.4, is-callable@^1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.5.tgz#f7e46b596890456db74e7f6e976cb3273d06faab" - integrity sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q== - -is-callable@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.2.tgz#c7c6715cd22d4ddb48d3e19970223aceabb080d9" - integrity sha512-dnMqspv5nU3LoewK2N/y7KLtxtakvTuaCsU9FU50/QDmdbHNy/4/JuRtMHqRU22o3q+W89YQndQEeCVwK+3qrA== +is-core-module@^2.2.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.4.0.tgz#8e9fc8e15027b011418026e98f0e6f4d86305cc1" + integrity sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A== + dependencies: + has "^1.0.3" is-date-object@^1.0.1, is-date-object@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.2.tgz#bda736f2cd8fd06d32844e7743bfa7494c3bfd7e" - integrity sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g== + version "1.0.4" + resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.4.tgz#550cfcc03afada05eea3dd30981c7b09551f73e5" + integrity sha512-/b4ZVsG7Z5XVtIxs/h9W8nvfLgSAyKYdtGWQLbqy6jA1icmgjf8WCoTKgeS4wy5tYaPePouzFMANbnj94c2Z+A== is-extglob@^2.1.1: version "2.1.1" @@ -2535,20 +2523,20 @@ is-glob@^4.0.0, is-glob@^4.0.1, is-glob@~4.0.1: dependencies: is-extglob "^2.1.1" -is-map@^2.0.1: +is-map@^2.0.1, is-map@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/is-map/-/is-map-2.0.2.tgz#00922db8c9bf73e81b7a335827bc2a43f2b91127" + integrity sha512-cOZFQQozTha1f4MxLFzlgKYPTyj26picdZTx82hbc/Xf4K/tZOOXSCkMvU4pKioRXGDLJRn0GM7Upe7kR721yg== + +is-negative-zero@^2.0.1: version "2.0.1" - resolved "https://registry.yarnpkg.com/is-map/-/is-map-2.0.1.tgz#520dafc4307bb8ebc33b813de5ce7c9400d644a1" - integrity sha512-T/S49scO8plUiAOA2DBTBG3JHpn1yiw0kRp6dgiZ0v2/6twi5eiB0rHtHFH9ZIrvlWc6+4O+m4zg5+Z833aXgw== + resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.1.tgz#3de746c18dda2319241a53675908d8f766f11c24" + integrity sha512-2z6JzQvZRa9A2Y7xC6dQQm4FSTSTNWjKIYYTt4246eMTJmIo0Q+ZyOsU66X8lxK1AbB92dFeglPLrhwpeRKO6w== -is-negative-zero@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.0.tgz#9553b121b0fac28869da9ed459e20c7543788461" - integrity sha1-lVOxIbD6wohp2p7UWeIMdUN4hGE= - -is-number-object@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.4.tgz#36ac95e741cf18b283fc1ddf5e83da798e3ec197" - integrity sha512-zohwelOAur+5uXtk8O3GPQ1eAcu4ZX3UwxQhUlfFFMNpUd83gXgjbhJh6HmB6LUNV/ieOLQuDwJO3dWJosUeMw== +is-number-object@^1.0.4: + version "1.0.5" + resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.5.tgz#6edfaeed7950cff19afedce9fbfca9ee6dd289eb" + integrity sha512-RU0lI/n95pMoUKu9v1BZP5MBcZuNSVJkMkAG2dJqC4z2GlkGUNeH68SuHuBKBD/XFe+LHZ+f9BKkLET60Niedw== is-number@^7.0.0: version "7.0.0" @@ -2560,52 +2548,56 @@ is-plain-obj@^2.1.0: resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== -is-potential-custom-element-name@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.0.tgz#0c52e54bcca391bb2c494b21e8626d7336c6e397" - integrity sha1-DFLlS8yjkbssSUsh6GJtczbG45c= - -is-regex@^1.0.5, is-regex@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.1.tgz#c6f98aacc546f6cec5468a07b7b153ab564a57b9" - integrity sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg== +is-plain-object@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" + integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== dependencies: - has-symbols "^1.0.1" + isobject "^3.0.1" -is-set@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-set/-/is-set-2.0.1.tgz#d1604afdab1724986d30091575f54945da7e5f43" - integrity sha512-eJEzOtVyenDs1TMzSQ3kU3K+E0GUS9sno+F0OBT97xsgcJsF9nXMBtkT9/kut5JEpM7oL7X/0qxR17K3mcwIAA== +is-potential-custom-element-name@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz#171ed6f19e3ac554394edf78caa05784a45bebb5" + integrity sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ== -is-stream@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" - integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= +is-regex@^1.1.1, is-regex@^1.1.2: + version "1.1.3" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.3.tgz#d029f9aff6448b93ebbe3f33dac71511fdcbef9f" + integrity sha512-qSVXFz28HM7y+IWX6vLCsexdlvzT1PJNFSBuaQLQ5o0IEw8UDYW6/2+eCMVyIsbM8CNLX2a/QWmSpyxYEHY7CQ== + dependencies: + call-bind "^1.0.2" + has-symbols "^1.0.2" + +is-set@^2.0.1, is-set@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/is-set/-/is-set-2.0.2.tgz#90755fa4c2562dc1c5d4024760d6119b94ca18ec" + integrity sha512-+2cnTEZeY5z/iXGbLhPrOAaK/Mau5k5eXq9j14CpRTftq0pAJu2MwVRSZhyZWBzx3o6X795Lz6Bpb6R0GKf37g== is-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.0.tgz#bde9c32680d6fae04129d6ac9d921ce7815f78e3" integrity sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw== -is-string@^1.0.4, is-string@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.5.tgz#40493ed198ef3ff477b8c7f92f644ec82a5cd3a6" - integrity sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ== +is-string@^1.0.5: + version "1.0.6" + resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.6.tgz#3fe5d5992fb0d93404f32584d4b0179a71b54a5f" + integrity sha512-2gdzbKUuqtQ3lYNrUTQYoClPhm7oQu4UdpSZMp1/DGgkHBT8E2Z1l0yMdb6D4zNAxwDiMv8MdulKROJGNl0Q0w== -is-symbol@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.3.tgz#38e1014b9e6329be0de9d24a414fd7441ec61937" - integrity sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ== +is-symbol@^1.0.2, is-symbol@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.4.tgz#a6dac93b635b063ca6872236de88910a57af139c" + integrity sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg== dependencies: - has-symbols "^1.0.1" + has-symbols "^1.0.2" is-typed-array@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.3.tgz#a4ff5a5e672e1a55f99c7f54e59597af5c1df04d" - integrity sha512-BSYUBOK/HJibQ30wWkWold5txYwMUXQct9YHAQJr8fSwvZoiglcqB0pd7vEN23+Tsi9IUEjztdOSzl4qLVYGTQ== + version "1.1.5" + resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.5.tgz#f32e6e096455e329eb7b423862456aa213f0eb4e" + integrity sha512-S+GRDgJlR3PyEbsX/Fobd9cqpZBuvUS+8asRqYDMLCb2qMzt1oz5m5oxQCxOgUDxiWsOVNi4yaF+/uvdlHlYug== dependencies: - available-typed-arrays "^1.0.0" - es-abstract "^1.17.4" + available-typed-arrays "^1.0.2" + call-bind "^1.0.2" + es-abstract "^1.18.0-next.2" foreach "^2.0.5" has-symbols "^1.0.1" @@ -2644,6 +2636,11 @@ isexe@^2.0.0: resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= +isobject@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" + integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= + isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" @@ -2713,39 +2710,38 @@ istanbul-reports@^3.0.2: html-escaper "^2.0.0" istanbul-lib-report "^3.0.0" -javascript-natural-sort@0.7.1: +javascript-natural-sort@^0.7.1: version "0.7.1" resolved "https://registry.yarnpkg.com/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz#f9e2303d4507f6d74355a73664d1440fb5a0ef59" integrity sha1-+eIwPUUH9tdDVac2ZNFED7Wg71k= -jest-worker@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.1.tgz#c2ae8cde6802cc14056043f997469ec170d9c32a" - integrity sha512-R5IE3qSGz+QynJx8y+ICEkdI2OJ3RJjRQVEyCcFAd3yVhQSEtquziPO29Mlzgn07LOVE8u8jhJ1FqcwegiXWOw== +jest-worker@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.2.tgz#7f72cbc4d643c365e27b9fd775f9d0eaa9c7a8ed" + integrity sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ== dependencies: "@types/node" "*" merge-stream "^2.0.0" supports-color "^7.0.0" jpeg-js@^0.4.2: - version "0.4.2" - resolved "https://registry.yarnpkg.com/jpeg-js/-/jpeg-js-0.4.2.tgz#8b345b1ae4abde64c2da2fe67ea216a114ac279d" - integrity sha512-+az2gi/hvex7eLTMTlbRLOhH6P6WFdk2ITI8HJsaH2VqYO0I594zXSYEP+tf4FW+8Cy68ScDXoAsQdyQanv3sw== + version "0.4.3" + resolved "https://registry.yarnpkg.com/jpeg-js/-/jpeg-js-0.4.3.tgz#6158e09f1983ad773813704be80680550eff977b" + integrity sha512-ru1HWKek8octvUHFHvE5ZzQ1yAsJmIvRdGWvSoKV52XKyuyYA437QWDttXT8eZXDSbuMpHlLzPDZUPd6idIz+Q== js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== -js-yaml@3.13.1: - version "3.13.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" - integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== +js-yaml@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.0.0.tgz#f426bc0ff4b4051926cd588c71113183409a121f" + integrity sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q== dependencies: - argparse "^1.0.7" - esprima "^4.0.0" + argparse "^2.0.1" -js-yaml@3.14.0, js-yaml@^3.13.1: +js-yaml@^3.13.1: version "3.14.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.0.tgz#a7a34170f26a21bb162424d8adacb4113a69e482" integrity sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A== @@ -2758,36 +2754,36 @@ jsbn@~0.1.0: resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= -jsdom@^16.4.0: - version "16.4.0" - resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-16.4.0.tgz#36005bde2d136f73eee1a830c6d45e55408edddb" - integrity sha512-lYMm3wYdgPhrl7pDcRmvzPhhrGVBeVhPIqeHjzeiHN3DFmD1RBpbExbi8vU7BJdH8VAZYovR8DMt0PNNDM7k8w== +jsdom@^16.5.3: + version "16.5.3" + resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-16.5.3.tgz#13a755b3950eb938b4482c407238ddf16f0d2136" + integrity sha512-Qj1H+PEvUsOtdPJ056ewXM4UJPCi4hhLA8wpiz9F2YvsRBhuFsXxtrIFAgGBDynQA9isAMGE91PfUYbdMPXuTA== dependencies: - abab "^2.0.3" - acorn "^7.1.1" + abab "^2.0.5" + acorn "^8.1.0" acorn-globals "^6.0.0" cssom "^0.4.4" - cssstyle "^2.2.0" + cssstyle "^2.3.0" data-urls "^2.0.0" - decimal.js "^10.2.0" + decimal.js "^10.2.1" domexception "^2.0.1" - escodegen "^1.14.1" + escodegen "^2.0.0" html-encoding-sniffer "^2.0.1" is-potential-custom-element-name "^1.0.0" nwsapi "^2.2.0" - parse5 "5.1.1" + parse5 "6.0.1" request "^2.88.2" - request-promise-native "^1.0.8" - saxes "^5.0.0" + request-promise-native "^1.0.9" + saxes "^5.0.1" symbol-tree "^3.2.4" - tough-cookie "^3.0.1" + tough-cookie "^4.0.0" w3c-hr-time "^1.0.2" w3c-xmlserializer "^2.0.0" webidl-conversions "^6.1.0" whatwg-encoding "^1.0.5" whatwg-mimetype "^2.3.0" - whatwg-url "^8.0.0" - ws "^7.2.3" + whatwg-url "^8.5.0" + ws "^7.4.4" xml-name-validator "^3.0.0" jsesc@^2.5.1: @@ -2805,6 +2801,11 @@ json-schema-traverse@^0.4.1: resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== +json-schema-traverse@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" + integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== + json-schema@0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" @@ -2820,13 +2821,6 @@ json-stringify-safe@~5.0.1: resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= -json5@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe" - integrity sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow== - dependencies: - minimist "^1.2.0" - json5@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.2.tgz#43ef1f0af9835dd624751a6b7fa48874fb2d608e" @@ -2834,6 +2828,15 @@ json5@^2.1.2: dependencies: minimist "^1.2.5" +jsonfile@^6.0.1: + version "6.1.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae" + integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ== + dependencies: + universalify "^2.0.0" + optionalDependencies: + graceful-fs "^4.1.6" + jsprim@^1.2.2: version "1.4.1" resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" @@ -2844,17 +2847,15 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" -kuler@1.0.x: - version "1.0.1" - resolved "https://registry.yarnpkg.com/kuler/-/kuler-1.0.1.tgz#ef7c784f36c9fb6e16dd3150d152677b2b0228a6" - integrity sha512-J9nVUucG1p/skKul6DU3PUZrhs0LPulNaeUOox0IyXDi8S4CztTHs1gQphhuZmzXG7VOQSf6NJfKuzteQLv9gQ== - dependencies: - colornames "^1.1.1" +kind-of@^6.0.2: + version "6.0.3" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" + integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== -leven@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2" - integrity sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A== +kuler@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/kuler/-/kuler-2.0.0.tgz#e2c570a3800388fb44407e851531c1d670b061b3" + integrity sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A== levn@^0.4.1: version "0.4.1" @@ -2872,19 +2873,10 @@ levn@~0.3.0: prelude-ls "~1.1.2" type-check "~0.3.2" -loader-runner@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.1.0.tgz#f70bc0c29edbabdf2043e7ee73ccc3fe1c96b42d" - integrity sha512-oR4lB4WvwFoC70ocraKhn5nkKSs23t57h9udUgw8o0iH8hMXeEoRuUgfcvgUwAJ1ZpRqBvcou4N2SMvM1DwMrA== - -loader-utils@^1.0.2: - version "1.4.0" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.4.0.tgz#c579b5e34cb34b1a74edc6c1fb36bfa371d5a613" - integrity sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA== - dependencies: - big.js "^5.2.2" - emojis-list "^3.0.0" - json5 "^1.0.1" +loader-runner@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.2.0.tgz#d7022380d66d14c5fb1d496b89864ebcfd478384" + integrity sha512-92+huvxMvYlMzMt0iIOukcwYBFpkYJdpl2xsZ7LrlayO7E8SOv+JJUEK17B/dJIHAOLMfh2dZZ/Y18WgmGtYNw== loader-utils@^2.0.0: version "2.0.0" @@ -2895,14 +2887,6 @@ loader-utils@^2.0.0: emojis-list "^3.0.0" json5 "^2.1.2" -locate-path@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" - integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== - dependencies: - p-locate "^3.0.0" - path-exists "^3.0.0" - locate-path@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" @@ -2917,28 +2901,26 @@ locate-path@^6.0.0: dependencies: p-locate "^5.0.0" +lodash.clonedeep@^4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" + integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8= + lodash.flattendeep@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2" integrity sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI= -lodash.sortby@^4.7.0: - version "4.7.0" - resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" - integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg= +lodash.truncate@^4.4.2: + version "4.4.2" + resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193" + integrity sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM= -lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19: +lodash@^4.17.13, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.21, lodash@^4.7.0: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== -log-symbols@2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a" - integrity sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg== - dependencies: - chalk "^2.0.1" - log-symbols@4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.0.0.tgz#69b3cc46d20f448eccdb75ea1fa733d9e821c920" @@ -2946,17 +2928,24 @@ log-symbols@4.0.0: dependencies: chalk "^4.0.0" -logform@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/logform/-/logform-2.1.2.tgz#957155ebeb67a13164069825ce67ddb5bb2dd360" - integrity sha512-+lZh4OpERDBLqjiwDLpAWNQu6KMjnlXH2ByZwCuSqVPJletw0kTWJf5CgSNAUKn1KUkv3m2cUz/LK8zyEy7wzQ== +logform@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/logform/-/logform-2.2.0.tgz#40f036d19161fc76b68ab50fdc7fe495544492f2" + integrity sha512-N0qPlqfypFx7UHNn4B3lzS/b0uLqt2hmuoa+PpuXNYgozdJYAyauF5Ky0BWVjrxDlMWiT3qN4zPq3vVAfZy7Yg== dependencies: colors "^1.2.1" fast-safe-stringify "^2.0.4" - fecha "^2.3.3" + fecha "^4.2.0" ms "^2.1.1" triple-beam "^1.3.0" +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== + dependencies: + yallist "^4.0.0" + make-dir@^3.0.0, make-dir@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.0.2.tgz#04a1acbf22221e1d6ef43559f43e05a90dbb4392" @@ -2964,19 +2953,19 @@ make-dir@^3.0.0, make-dir@^3.0.2: dependencies: semver "^6.0.0" -mathjs@^5.10.3: - version "5.10.3" - resolved "https://registry.yarnpkg.com/mathjs/-/mathjs-5.10.3.tgz#e998885f932ea8886db8b40f7f5b199f89b427f1" - integrity sha512-ySjg30BC3dYjQm73ILZtwcWzFJde0VU6otkXW/57IjjuYRa3Qaf0Kb8pydEuBZYtqW2OxreAtsricrAmOj3jIw== +mathjs@^9.3.0: + version "9.3.2" + resolved "https://registry.yarnpkg.com/mathjs/-/mathjs-9.3.2.tgz#6523dd5c963d200ff1cea0ff7963b10521b82185" + integrity sha512-0YKSKAeN9OkbIQrxfxnBT4kk/KlH71piWOsvVvAasyRIj/Xd/zlpc5VP/aFxwr+llOq2F3f6booPEu2fWv3yjQ== dependencies: - complex.js "2.0.11" - decimal.js "10.2.0" - escape-latex "1.2.0" - fraction.js "4.0.12" - javascript-natural-sort "0.7.1" - seed-random "2.2.0" - tiny-emitter "2.1.0" - typed-function "1.1.0" + complex.js "^2.0.11" + decimal.js "^10.2.1" + escape-latex "^1.2.0" + fraction.js "^4.0.13" + javascript-natural-sort "^0.7.1" + seedrandom "^3.0.5" + tiny-emitter "^2.1.0" + typed-function "^2.0.0" media-typer@0.3.0: version "0.3.0" @@ -3012,19 +3001,31 @@ methods@~1.1.2: integrity sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4= micromatch@^4.0.0, micromatch@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259" - integrity sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q== + version "4.0.4" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.4.tgz#896d519dfe9db25fce94ceb7a500919bf881ebf9" + integrity sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg== dependencies: braces "^3.0.1" - picomatch "^2.0.5" + picomatch "^2.2.3" mime-db@1.44.0: version "1.44.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.44.0.tgz#fa11c5eb0aca1334b4233cb4d52f10c5a6272f92" integrity sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg== -mime-types@^2.1.12, mime-types@^2.1.27, mime-types@~2.1.19, mime-types@~2.1.24: +mime-db@1.47.0: + version "1.47.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.47.0.tgz#8cb313e59965d3c05cfbf898915a267af46a335c" + integrity sha512-QBmA/G2y+IfeS4oktet3qRZ+P5kPhCKRXxXnQEudYqUaEioAU1/Lq2us3D/t1Jfo4hE9REQPrbB7K5sOczJVIw== + +mime-types@^2.1.12, mime-types@^2.1.27, mime-types@~2.1.19: + version "2.1.30" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.30.tgz#6e7be8b4c479825f85ed6326695db73f9305d62d" + integrity sha512-crmjA4bLtR8m9qLpHvgxSChT+XoSlZi8J4n/aIdn3z92e/U47Z0V/yl+Wh9W046GgFVAmoNR/fmdbZYcSSIUeg== + dependencies: + mime-db "1.47.0" + +mime-types@~2.1.24: version "2.1.27" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.27.tgz#47949f98e279ea53119f5722e0f34e529bec009f" integrity sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w== @@ -3036,10 +3037,10 @@ mime@1.6.0: resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== -mime@^2.0.3, mime@^2.4.6: - version "2.4.6" - resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.6.tgz#e5b407c90db442f2beb5b162373d07b69affa4d1" - integrity sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA== +mime@^2.4.6: + version "2.5.2" + resolved "https://registry.yarnpkg.com/mime/-/mime-2.5.2.tgz#6e3dc6cc2b9510643830e5f19d5cb753da5eeabe" + integrity sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg== mimic-fn@^2.1.0: version "2.1.0" @@ -3053,83 +3054,52 @@ minimatch@3.0.4, minimatch@^3.0.4: dependencies: brace-expansion "^1.1.7" -minimist@^1.2.0, minimist@^1.2.5: +minimist@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== -mkdirp@0.5.4: - version "0.5.4" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.4.tgz#fd01504a6797ec5c9be81ff43d204961ed64a512" - integrity sha512-iG9AK/dJLtJ0XNgTuDbSyNS3zECqDlAhnQW4CsNxBG3LQJBbHmRX1egw39DmtOdCAqY+dKXV+sgPgilNWUKMVw== - dependencies: - minimist "^1.2.5" +mkdirp-classic@^0.5.2: + version "0.5.3" + resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz#fa10c9115cc6d8865be221ba47ee9bed78601113" + integrity sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A== -mkdirp@^0.5.1, mkdirp@^0.5.4: +mkdirp@^0.5.3: version "0.5.5" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== dependencies: minimist "^1.2.5" -mocha@^6.1.4: - version "6.2.3" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-6.2.3.tgz#e648432181d8b99393410212664450a4c1e31912" - integrity sha512-0R/3FvjIGH3eEuG17ccFPk117XL2rWxatr81a57D+r/x2uTYZRbdZ4oVidEUMh2W2TJDa7MdAb12Lm2/qrKajg== - dependencies: - ansi-colors "3.2.3" - browser-stdout "1.3.1" - debug "3.2.6" - diff "3.5.0" - escape-string-regexp "1.0.5" - find-up "3.0.0" - glob "7.1.3" - growl "1.10.5" - he "1.2.0" - js-yaml "3.13.1" - log-symbols "2.2.0" - minimatch "3.0.4" - mkdirp "0.5.4" - ms "2.1.1" - node-environment-flags "1.0.5" - object.assign "4.1.0" - strip-json-comments "2.0.1" - supports-color "6.0.0" - which "1.3.1" - wide-align "1.1.3" - yargs "13.3.2" - yargs-parser "13.1.2" - yargs-unparser "1.6.0" - -mocha@^8.2.1: - version "8.2.1" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-8.2.1.tgz#f2fa68817ed0e53343d989df65ccd358bc3a4b39" - integrity sha512-cuLBVfyFfFqbNR0uUKbDGXKGk+UDFe6aR4os78XIrMQpZl/nv7JYHcvP5MFIAb374b2zFXsdgEGwmzMtP0Xg8w== +mocha@^8.3.2, mocha@^8.4.0: + version "8.4.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-8.4.0.tgz#677be88bf15980a3cae03a73e10a0fc3997f0cff" + integrity sha512-hJaO0mwDXmZS4ghXsvPVriOhsxQ7ofcpQdm8dE+jISUOKopitvnXFQmpRR7jd2K6VBG6E26gU3IAbXXGIbu4sQ== dependencies: "@ungap/promise-all-settled" "1.1.2" ansi-colors "4.1.1" browser-stdout "1.3.1" - chokidar "3.4.3" - debug "4.2.0" - diff "4.0.2" + chokidar "3.5.1" + debug "4.3.1" + diff "5.0.0" escape-string-regexp "4.0.0" find-up "5.0.0" glob "7.1.6" growl "1.10.5" he "1.2.0" - js-yaml "3.14.0" + js-yaml "4.0.0" log-symbols "4.0.0" minimatch "3.0.4" - ms "2.1.2" - nanoid "3.1.12" + ms "2.1.3" + nanoid "3.1.20" serialize-javascript "5.0.1" strip-json-comments "3.1.1" - supports-color "7.2.0" + supports-color "8.1.1" which "2.0.2" wide-align "1.1.3" - workerpool "6.0.2" - yargs "13.3.2" - yargs-parser "13.1.2" + workerpool "6.1.0" + yargs "16.2.0" + yargs-parser "20.2.4" yargs-unparser "2.0.0" ms@2.0.0: @@ -3142,25 +3112,30 @@ ms@2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== -ms@2.1.2, ms@^2.1.1: +ms@2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -mustache@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/mustache/-/mustache-4.0.1.tgz#d99beb031701ad433338e7ea65e0489416c854a2" - integrity sha512-yL5VE97+OXn4+Er3THSmTdCFCtx5hHWzrolvH+JObZnUYwuaG7XV+Ch4fR2cIrcYI0tFHxS7iyFYl14bW8y2sA== +ms@2.1.3, ms@^2.1.1: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +mustache@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/mustache/-/mustache-4.2.0.tgz#e5892324d60a12ec9c2a73359edca52972bf6f64" + integrity sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ== nan@^2.14.0: - version "2.14.0" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c" - integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg== + version "2.14.2" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.2.tgz#f5376400695168f4cc694ac9393d0c9585eeea19" + integrity sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ== -nanoid@3.1.12: - version "3.1.12" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.12.tgz#6f7736c62e8d39421601e4a0c77623a97ea69654" - integrity sha512-1qstj9z5+x491jfiC4Nelk+f8XBad7LN20PmyWINJEMRSf3wcAjAWysw1qaA8z6NSKe2sjq1hRSDpBH5paCb6A== +nanoid@3.1.20: + version "3.1.20" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.20.tgz#badc263c6b1dcf14b71efaa85f6ab4c1d6cfc788" + integrity sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw== natural-compare@^1.4.0: version "1.4.0" @@ -3177,13 +3152,10 @@ neo-async@^2.6.2: resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== -node-environment-flags@1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/node-environment-flags/-/node-environment-flags-1.0.5.tgz#fa930275f5bf5dae188d6192b24b4c8bbac3d76a" - integrity sha512-VNYPRfGfmZLx0Ye20jWzHUjyTW/c+6Wq+iLhDzUI4XmhrDd9l/FozXV3F2xOaXjvp0co0+v1YSR3CMP6g+VvLQ== - dependencies: - object.getownpropertydescriptors "^2.0.3" - semver "^5.7.0" +node-fetch@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" + integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== node-preload@^0.2.1: version "0.2.1" @@ -3192,24 +3164,24 @@ node-preload@^0.2.1: dependencies: process-on-spawn "^1.0.0" -node-pty@^0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/node-pty/-/node-pty-0.9.0.tgz#8f9bcc0d1c5b970a3184ffd533d862c7eb6590a6" - integrity sha512-MBnCQl83FTYOu7B4xWw10AW77AAh7ThCE1VXEv+JeWj8mSpGo+0bwgsV+b23ljBFwEM9OmsOv3kM27iUPPm84g== +node-pty@^0.10.1: + version "0.10.1" + resolved "https://registry.yarnpkg.com/node-pty/-/node-pty-0.10.1.tgz#cd05d03a2710315ec40221232ec04186f6ac2c6d" + integrity sha512-JTdtUS0Im/yRsWJSx7yiW9rtpfmxqxolrtnyKwPLI+6XqTAPW/O2MjS8FYL4I5TsMbH2lVgDb2VMjp+9LoQGNg== dependencies: nan "^2.14.0" -node-releases@^1.1.61: - version "1.1.65" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.65.tgz#52d9579176bd60f23eba05c4438583f341944b81" - integrity sha512-YpzJOe2WFIW0V4ZkJQd/DGR/zdVwc/pI4Nl1CZrBO19FdRcSTmsuhdttw9rsTzzJLrNcSloLiBbEYx1C4f6gpA== +node-releases@^1.1.71: + version "1.1.71" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.71.tgz#cb1334b179896b1c89ecfdd4b725fb7bbdfc7dbb" + integrity sha512-zR6HoT6LrLCRBwukmrVbHv0EpEQjksO6GmFcZQQuCAy139BEsoVKPYnf3jongYW83fAa1torLGYwxxky/p28sg== normalize-path@^3.0.0, normalize-path@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== -npm-run-path@^4.0.0: +npm-run-path@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== @@ -3259,57 +3231,34 @@ oauth-sign@~0.9.0: resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== -object-inspect@^1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.7.0.tgz#f4f6bd181ad77f006b5ece60bd0b6f398ff74a67" - integrity sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw== +object-inspect@^1.9.0: + version "1.10.3" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.10.3.tgz#c2aa7d2d09f50c99375704f7a0adf24c5782d369" + integrity sha512-e5mCJlSH7poANfC8z8S9s9S2IN5/4Zb3aZ33f5s8YqoazCFzNLloLU8r5VCG+G7WoqLvAAZoVMcy3tp/3X0Plw== -object-inspect@^1.8.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.8.0.tgz#df807e5ecf53a609cc6bfe93eac3cc7be5b3a9d0" - integrity sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA== - -object-is@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.3.tgz#2e3b9e65560137455ee3bd62aec4d90a2ea1cc81" - integrity sha512-teyqLvFWzLkq5B9ki8FVWA902UER2qkxmdA4nLf+wjOLAWgxzCWZNCxpDq9MvE8MmhWNr+I8w3BN49Vx36Y6Xg== +object-is@^1.1.4: + version "1.1.5" + resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.5.tgz#b9deeaa5fc7f1846a0faecdceec138e5778f53ac" + integrity sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw== dependencies: + call-bind "^1.0.2" define-properties "^1.1.3" - es-abstract "^1.18.0-next.1" -object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1: +object-keys@^1.0.12, object-keys@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== -object.assign@4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" - integrity sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w== - dependencies: - define-properties "^1.1.2" - function-bind "^1.1.1" - has-symbols "^1.0.0" - object-keys "^1.0.11" - -object.assign@^4.1.0, object.assign@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.1.tgz#303867a666cdd41936ecdedfb1f8f3e32a478cdd" - integrity sha512-VT/cxmx5yaoHSOTSyrCygIDFco+RsibY2NM0a4RdEeY/4KgqezwFtK1yr3U67xYhqJSlASm2pKhLVzPj2lr4bA== +object.assign@^4.1.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.2.tgz#0ed54a342eceb37b38ff76eb831a0e788cb63940" + integrity sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ== dependencies: + call-bind "^1.0.0" define-properties "^1.1.3" - es-abstract "^1.18.0-next.0" has-symbols "^1.0.1" object-keys "^1.1.1" -object.getownpropertydescriptors@^2.0.3: - version "2.1.0" - resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.0.tgz#369bf1f9592d8ab89d712dced5cb81c7c5352649" - integrity sha512-Z53Oah9A3TdLoblT7VKJaTDdXdT+lQO+cNpKVnya5JDe9uLvzu1YyY1yFDFrcxrlRgWrEFH0jJtD/IbuwjcEVg== - dependencies: - define-properties "^1.1.3" - es-abstract "^1.17.0-next.1" - on-finished@~2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" @@ -3324,12 +3273,14 @@ once@^1.3.0, once@^1.3.1, once@^1.4.0: dependencies: wrappy "1" -one-time@0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/one-time/-/one-time-0.0.4.tgz#f8cdf77884826fe4dff93e3a9cc37b1e4480742e" - integrity sha1-+M33eISCb+Tf+T46nMN7HkSAdC4= +one-time@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/one-time/-/one-time-1.0.0.tgz#e06bc174aed214ed58edede573b433bbf827cb45" + integrity sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g== + dependencies: + fn.name "1.x.x" -onetime@^5.1.0: +onetime@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== @@ -3360,7 +3311,7 @@ optionator@^0.9.1: type-check "^0.4.0" word-wrap "^1.2.3" -p-limit@^2.0.0, p-limit@^2.2.0: +p-limit@^2.2.0: version "2.2.2" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.2.2.tgz#61279b67721f5287aa1c13a9a7fbbc48c9291b1e" integrity sha512-WGR+xHecKTr7EbUEhyLSh5Dube9JtdiG78ufaeLxTgpudf/20KqyMioIUZJAezlTIi6evxuoUs9YXc11cU+yzQ== @@ -3374,12 +3325,12 @@ p-limit@^3.0.2: dependencies: p-try "^2.0.0" -p-locate@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" - integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== +p-limit@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== dependencies: - p-limit "^2.0.0" + yocto-queue "^0.1.0" p-locate@^4.1.0: version "4.1.0" @@ -3424,21 +3375,16 @@ parent-module@^1.0.0: dependencies: callsites "^3.0.0" -parse5@5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/parse5/-/parse5-5.1.1.tgz#f68e4e5ba1852ac2cadc00f4555fff6c2abb6178" - integrity sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug== +parse5@6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/parse5/-/parse5-6.0.1.tgz#e1a1c085c569b3dc08321184f19a39cc27f7c30b" + integrity sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw== parseurl@~1.3.3: version "1.3.3" resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== -path-exists@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" - integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= - path-exists@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" @@ -3469,10 +3415,10 @@ path-type@^4.0.0: resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== -pathval@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0" - integrity sha1-uULm1L3mUwBe9rcTYd74cn0GReA= +pathval@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d" + integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ== pend@~1.2.0: version "1.2.0" @@ -3484,11 +3430,16 @@ performance-now@^2.1.0: resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= -picomatch@^2.0.4, picomatch@^2.0.5, picomatch@^2.2.1: +picomatch@^2.0.4, picomatch@^2.2.1: version "2.2.2" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== +picomatch@^2.2.3: + version "2.2.3" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.3.tgz#465547f359ccc206d3c48e46a1bcb89bf7ee619d" + integrity sha512-KpELjfwcCDUb9PeigTs2mBJzXUPzAuP2oPcA989He8Rte0+YUAjw1JVedDhuTKPkHjSYzMN3npC9luThGYEKdg== + pkg-dir@^4.1.0, pkg-dir@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" @@ -3496,11 +3447,12 @@ pkg-dir@^4.1.0, pkg-dir@^4.2.0: dependencies: find-up "^4.0.0" -playwright@^1.5.2: - version "1.5.2" - resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.5.2.tgz#e127142cba86c918fad9f68315db5e79524af64c" - integrity sha512-on7IEui47bDZta0txL86QKMDSgjbxERkLc5N0+lU2zajIfN/Ld6vMl+xiROEUPlT/QtqVekq9pTDGdcc0yScMQ== +playwright@^1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.10.0.tgz#a14d295f1ad886caf4cc5e674afe03ac832066bc" + integrity sha512-b7SGBcCPq4W3pb4ImEDmNXtO0ZkJbZMuWiShsaNJd+rGfY/6fqwgllsAojmxGSgFmijYw7WxCoPiAIEDIH16Kw== dependencies: + commander "^6.1.0" debug "^4.1.1" extract-zip "^2.0.1" https-proxy-agent "^5.0.0" @@ -3511,6 +3463,7 @@ playwright@^1.5.2: proper-lockfile "^4.1.1" proxy-from-env "^1.1.0" rimraf "^3.0.2" + stack-utils "^2.0.3" ws "^7.3.1" pngjs@^5.0.0: @@ -3546,11 +3499,11 @@ progress@^2.0.0, progress@^2.0.1, progress@^2.0.3: integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== proper-lockfile@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/proper-lockfile/-/proper-lockfile-4.1.1.tgz#284cf9db9e30a90e647afad69deb7cb06881262c" - integrity sha512-1w6rxXodisVpn7QYvLk706mzprPTAPCYAqxMvctmPN3ekuRk/kuGkGc82pangZiAt4R3lwSuUzheTTn0/Yb7Zg== + version "4.1.2" + resolved "https://registry.yarnpkg.com/proper-lockfile/-/proper-lockfile-4.1.2.tgz#c8b9de2af6b2f1601067f98e01ac66baa223141f" + integrity sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA== dependencies: - graceful-fs "^4.1.11" + graceful-fs "^4.2.4" retry "^0.12.0" signal-exit "^3.0.2" @@ -3572,7 +3525,7 @@ prr@~1.0.1: resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476" integrity sha1-0/wRS6BplaRexok/SEzrHXj19HY= -psl@^1.1.28: +psl@^1.1.28, psl@^1.1.33: version "1.8.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.8.0.tgz#9326f8bcfb013adcc005fdff056acce020e51c24" integrity sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ== @@ -3590,19 +3543,23 @@ punycode@^2.1.0, punycode@^2.1.1: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== -puppeteer@^1.17.0: - version "1.20.0" - resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-1.20.0.tgz#e3d267786f74e1d87cf2d15acc59177f471bbe38" - integrity sha512-bt48RDBy2eIwZPrkgbcwHtb51mj2nKvHOPMaSH2IsWiv7lOG9k9zhaRzpDZafrk05ajMc3cu+lSQYYOfH2DkVQ== +puppeteer@^5.5.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-5.5.0.tgz#331a7edd212ca06b4a556156435f58cbae08af00" + integrity sha512-OM8ZvTXAhfgFA7wBIIGlPQzvyEETzDjeRa4mZRCRHxYL+GNH5WAuYUQdja3rpWZvkX/JKqmuVgbsxDNsDFjMEg== dependencies: debug "^4.1.0" - extract-zip "^1.6.6" - https-proxy-agent "^2.2.1" - mime "^2.0.3" + devtools-protocol "0.0.818844" + extract-zip "^2.0.0" + https-proxy-agent "^4.0.0" + node-fetch "^2.6.1" + pkg-dir "^4.2.0" progress "^2.0.1" proxy-from-env "^1.0.0" - rimraf "^2.6.1" - ws "^6.1.0" + rimraf "^3.0.2" + tar-fs "^2.0.0" + unbzip2-stream "^1.3.3" + ws "^7.2.3" qs@6.7.0: version "6.7.0" @@ -3614,6 +3571,11 @@ qs@~6.5.2: resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA== +queue-microtask@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" + integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== + randombytes@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" @@ -3636,7 +3598,7 @@ raw-body@2.4.0: iconv-lite "0.4.24" unpipe "1.0.0" -readable-stream@^2.0.1, readable-stream@^2.2.2, readable-stream@^2.3.6: +readable-stream@^2.0.1, readable-stream@^2.3.7: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== @@ -3649,7 +3611,7 @@ readable-stream@^2.0.1, readable-stream@^2.2.2, readable-stream@^2.3.6: string_decoder "~1.1.1" util-deprecate "~1.0.1" -readable-stream@^3.1.1: +readable-stream@^3.1.1, readable-stream@^3.4.0: version "3.6.0" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== @@ -3672,18 +3634,13 @@ rechoir@^0.7.0: dependencies: resolve "^1.9.0" -reduce-flatten@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/reduce-flatten/-/reduce-flatten-2.0.0.tgz#734fd84e65f375d7ca4465c69798c25c9d10ae27" - integrity sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w== - regexp.prototype.flags@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.3.0.tgz#7aba89b3c13a64509dabcf3ca8d9fbb9bdf5cb75" - integrity sha512-2+Q0C5g951OlYlJz6yu5/M33IcsESLlLfsyIaLJaG4FA2r4yP8MvVMJUUP/fVBkSpbbbZlS5gynbEWLipiiXiQ== + version "1.3.1" + resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.3.1.tgz#7ef352ae8d159e758c0eadca6f8fcb4eef07be26" + integrity sha512-JiBdRBq91WlY7uRJ0ds7R+dU02i6LKi8r3BuQhNXn+kmeLN+EfHhfjqMRis1zJxnlu88hq/4dx0P2OP3APRTOA== dependencies: + call-bind "^1.0.2" define-properties "^1.1.3" - es-abstract "^1.17.0-next.1" regexpp@^3.0.0, regexpp@^3.1.0: version "3.1.0" @@ -3697,19 +3654,19 @@ release-zalgo@^1.0.0: dependencies: es6-error "^4.0.1" -request-promise-core@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/request-promise-core/-/request-promise-core-1.1.3.tgz#e9a3c081b51380dfea677336061fea879a829ee9" - integrity sha512-QIs2+ArIGQVp5ZYbWD5ZLCY29D5CfWizP8eWnm8FoGD1TX61veauETVQbrV60662V0oFBkrDOuaBI8XgtuyYAQ== +request-promise-core@1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/request-promise-core/-/request-promise-core-1.1.4.tgz#3eedd4223208d419867b78ce815167d10593a22f" + integrity sha512-TTbAfBBRdWD7aNNOoVOBH4pN/KigV6LyapYNNlAPA8JwbovRti1E88m3sYAwsLi5ryhPKsE9APwnjFTgdUjTpw== dependencies: - lodash "^4.17.15" + lodash "^4.17.19" -request-promise-native@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/request-promise-native/-/request-promise-native-1.0.8.tgz#a455b960b826e44e2bf8999af64dff2bfe58cb36" - integrity sha512-dapwLGqkHtwL5AEbfenuzjTYg35Jd6KPytsC2/TLkVMz8rm+tNt72MGUWT1RP/aYawMpN6HqbNGBQaRcBtjQMQ== +request-promise-native@^1.0.9: + version "1.0.9" + resolved "https://registry.yarnpkg.com/request-promise-native/-/request-promise-native-1.0.9.tgz#e407120526a5efdc9a39b28a5679bf47b9d9dc28" + integrity sha512-wcW+sIUiWnKgNY0dqCpOZkUbF/I+YPi+f09JZIDa39Ec+q82CpSYniDp+ISgTTbKmnpJWASeJBPZmoxH84wt3g== dependencies: - request-promise-core "1.1.3" + request-promise-core "1.1.4" stealthy-require "^1.1.1" tough-cookie "^2.3.3" @@ -3744,6 +3701,11 @@ require-directory@^2.1.1: resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= +require-from-string@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" + integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== + require-main-filename@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" @@ -3779,10 +3741,11 @@ resolve@^1.3.2: path-parse "^1.0.6" resolve@^1.9.0: - version "1.17.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" - integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== + version "1.20.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" + integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A== dependencies: + is-core-module "^2.2.0" path-parse "^1.0.6" retry@^0.12.0: @@ -3795,20 +3758,6 @@ reusify@^1.0.4: resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== -rimraf@2.6.3: - version "2.6.3" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" - integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== - dependencies: - glob "^7.1.3" - -rimraf@^2.6.1: - version "2.7.1" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" - integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== - dependencies: - glob "^7.1.3" - rimraf@^3.0.0, rimraf@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" @@ -3817,16 +3766,23 @@ rimraf@^3.0.0, rimraf@^3.0.2: glob "^7.1.3" run-parallel@^1.1.9: - version "1.1.9" - resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.1.9.tgz#c9dd3a7cf9f4b2c4b6244e173a6ed866e61dd679" - integrity sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q== + version "1.2.0" + resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" + integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== + dependencies: + queue-microtask "^1.2.2" safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.2" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.2, safe-buffer@~5.2.0: +safe-buffer@^5.0.1, safe-buffer@^5.1.2, safe-buffer@~5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + +safe-buffer@^5.1.0: version "5.2.0" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.0.tgz#b74daec49b1148f88c64b68d49b1e815c1f2f519" integrity sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg== @@ -3836,10 +3792,10 @@ safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.2, safe-buffer@~5.2.0: resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== -saxes@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/saxes/-/saxes-5.0.0.tgz#b7d30284d7583a5ca6ad0248b56d8889da53788b" - integrity sha512-LXTZygxhf8lfwKaTP/8N9CsVdjTlea3teze4lL6u37ivbgGbV0GGMuNtS/I9rnD/HC2/txUM7Df4S2LVl1qhiA== +saxes@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/saxes/-/saxes-5.0.1.tgz#eebab953fa3b7608dbe94e5dadb15c888fa6696d" + integrity sha512-5LBh1Tls8c9xgGjw3QrMwETmTMVk0oFgvrFSvWx62llR2hcEInrKNZ2GZCCuuy2lvWrdl5jhbpeqc5hRYKFOcw== dependencies: xmlchars "^2.2.0" @@ -3852,12 +3808,12 @@ schema-utils@^3.0.0: ajv "^6.12.5" ajv-keywords "^3.5.2" -seed-random@2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/seed-random/-/seed-random-2.2.0.tgz#2a9b19e250a817099231a5b99a4daf80b7fbed54" - integrity sha1-KpsZ4lCoFwmSMaW5mk2vgLf77VQ= +seedrandom@^3.0.5: + version "3.0.5" + resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.5.tgz#54edc85c95222525b0c7a6f6b3543d8e0b3aa0a7" + integrity sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg== -semver@^5.3.0, semver@^5.4.1, semver@^5.7.0: +semver@^5.3.0, semver@^5.4.1: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -3867,10 +3823,12 @@ semver@^6.0.0, semver@^6.3.0: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== -semver@^7.2.1, semver@^7.3.2: - version "7.3.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938" - integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ== +semver@^7.2.1, semver@^7.3.2, semver@^7.3.4: + version "7.3.5" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" + integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ== + dependencies: + lru-cache "^6.0.0" send@0.17.1: version "0.17.1" @@ -3918,6 +3876,13 @@ setprototypeof@1.1.1: resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.1.tgz#7e95acb24aa92f5885e0abef5ba131330d4ae683" integrity sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw== +shallow-clone@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3" + integrity sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA== + dependencies: + kind-of "^6.0.2" + shebang-command@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" @@ -3931,24 +3896,27 @@ shebang-regex@^3.0.0: integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== side-channel@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.3.tgz#cdc46b057550bbab63706210838df5d4c19519c3" - integrity sha512-A6+ByhlLkksFoUepsGxfj5x1gTSrs+OydsRptUxeNCabQpCFUvcwIczgOigI8vhY/OJCnPnyE9rGiwgvr9cS1g== + version "1.0.4" + resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf" + integrity sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw== dependencies: - es-abstract "^1.18.0-next.0" - object-inspect "^1.8.0" + call-bind "^1.0.0" + get-intrinsic "^1.0.2" + object-inspect "^1.9.0" -signal-exit@^3.0.2: +signal-exit@^3.0.2, signal-exit@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== -simple-git@^1.113.0: - version "1.132.0" - resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-1.132.0.tgz#53ac4c5ec9e74e37c2fd461e23309f22fcdf09b1" - integrity sha512-xauHm1YqCTom1sC9eOjfq3/9RKiUA9iPnxBbrY2DdL8l4ADMu0jjM5l5lphQP5YWNqAL2aXC/OeuQ76vHtW5fg== +simple-git@^2.37.0: + version "2.38.1" + resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-2.38.1.tgz#6c3ce211777a65482598f4bd93c66443465228c0" + integrity sha512-SeMgUEA6Cmk7Ta57ZzMbkBcAfh8A+DZ6ACZ2onfCp/9UklC9yMJgvcH+GGI3QDTv0lTDIbWtl5LSbBk1UtEfeg== dependencies: - debug "^4.0.1" + "@kwsites/file-exists" "^1.1.1" + "@kwsites/promise-deferred" "^1.1.1" + debug "^4.3.1" simple-swizzle@^0.2.2: version "0.2.2" @@ -3962,31 +3930,33 @@ slash@^3.0.0: resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== -slice-ansi@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636" - integrity sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ== +slice-ansi@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-4.0.0.tgz#500e8dd0fd55b05815086255b3195adf2a45fe6b" + integrity sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ== dependencies: - ansi-styles "^3.2.0" - astral-regex "^1.0.0" - is-fullwidth-code-point "^2.0.0" + ansi-styles "^4.0.0" + astral-regex "^2.0.0" + is-fullwidth-code-point "^3.0.0" source-list-map@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34" integrity sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw== -source-map-loader@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/source-map-loader/-/source-map-loader-1.1.2.tgz#5b782bf08496d3a7f355e1780df0e25190a80991" - integrity sha512-bjf6eSENOYBX4JZDfl9vVLNsGAQ6Uz90fLmOazcmMcyDYOBFsGxPNn83jXezWLY9bJsVAo1ObztxPcV8HAbjVA== +source-map-js@^0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-0.6.2.tgz#0bb5de631b41cfbda6cfba8bd05a80efdfd2385e" + integrity sha512-/3GptzWzu0+0MBQFrDKzw/DvvMTUORvgY6k6jd/VS6iCR4RDTKWH6v6WPwQoUO8667uQEf9Oe38DxAYWY5F/Ug== + +source-map-loader@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/source-map-loader/-/source-map-loader-2.0.1.tgz#b4fd0ae7fa7e7d3954300f383f2d6fcc230a4261" + integrity sha512-UzOTTQhoNPeTNzOxwFw220RSRzdGSyH4lpNyWjR7Qm34P4/N0W669YSUFdH07+YNeN75h765XLHmNsF/bm97RQ== dependencies: abab "^2.0.5" iconv-lite "^0.6.2" - loader-utils "^2.0.0" - schema-utils "^3.0.0" - source-map "^0.6.1" - whatwg-mimetype "^2.3.0" + source-map-js "^0.6.2" source-map-support@~0.5.19: version "0.5.19" @@ -4048,6 +4018,13 @@ stack-trace@0.0.x: resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0" integrity sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA= +stack-utils@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.3.tgz#cd5f030126ff116b78ccb3c027fe302713b61277" + integrity sha512-gL//fkxfWUsIlFL2Tl42Cl6+HFALEaB1FU76I/Fy+oZjRreP7OPMXFlGbxM7NQsI0ZpUfw76sHnv0WNYuTb7Iw== + dependencies: + escape-string-regexp "^2.0.0" + "statuses@>= 1.5.0 < 2", statuses@~1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" @@ -4066,15 +4043,6 @@ stealthy-require@^1.1.1: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" -string-width@^3.0.0, string-width@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" - integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== - dependencies: - emoji-regex "^7.0.1" - is-fullwidth-code-point "^2.0.0" - strip-ansi "^5.1.0" - string-width@^4.1.0, string-width@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5" @@ -4084,37 +4052,21 @@ string-width@^4.1.0, string-width@^4.2.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.0" -string.prototype.trimend@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz#85812a6b847ac002270f5808146064c995fb6913" - integrity sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g== +string.prototype.trimend@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz#e75ae90c2942c63504686c18b287b4a0b1a45f80" + integrity sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A== dependencies: + call-bind "^1.0.2" define-properties "^1.1.3" - es-abstract "^1.17.5" -string.prototype.trimleft@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz#9bdb8ac6abd6d602b17a4ed321870d2f8dcefc74" - integrity sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag== +string.prototype.trimstart@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz#b36399af4ab2999b4c9c648bd7a3fb2bb26feeed" + integrity sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgKSmcWwziwYuZw== dependencies: + call-bind "^1.0.2" define-properties "^1.1.3" - function-bind "^1.1.1" - -string.prototype.trimright@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz#440314b15996c866ce8a0341894d45186200c5d9" - integrity sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g== - dependencies: - define-properties "^1.1.3" - function-bind "^1.1.1" - -string.prototype.trimstart@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz#14af6d9f34b053f7cfc89b72f8f2ee14b9039a54" - integrity sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw== - dependencies: - define-properties "^1.1.3" - es-abstract "^1.17.5" string_decoder@^1.1.1: version "1.3.0" @@ -4144,13 +4096,6 @@ strip-ansi@^4.0.0: dependencies: ansi-regex "^3.0.0" -strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" - integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== - dependencies: - ansi-regex "^4.1.0" - strip-ansi@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" @@ -4168,27 +4113,15 @@ strip-final-newline@^2.0.0: resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad" integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== -strip-json-comments@2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" - integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= - strip-json-comments@3.1.1, strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== -supports-color@6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.0.0.tgz#76cfe742cf1f41bb9b1c29ad03068c05b4c0e40a" - integrity sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg== - dependencies: - has-flag "^3.0.0" - -supports-color@7.2.0, supports-color@^7.0.0, supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== +supports-color@8.1.1: + version "8.1.1" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" + integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== dependencies: has-flag "^4.0.0" @@ -4199,57 +4132,77 @@ supports-color@^5.3.0: dependencies: has-flag "^3.0.0" +supports-color@^7.0.0, supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + symbol-tree@^3.2.4: version "3.2.4" resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== -table-layout@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/table-layout/-/table-layout-1.0.1.tgz#8411181ee951278ad0638aea2f779a9ce42894f9" - integrity sha512-dEquqYNJiGwY7iPfZ3wbXDI944iqanTSchrACLL2nOB+1r+h1Nzu2eH+DuPPvWvm5Ry7iAPeFlgEtP5bIp5U7Q== +table@^6.0.4: + version "6.7.0" + resolved "https://registry.yarnpkg.com/table/-/table-6.7.0.tgz#26274751f0ee099c547f6cb91d3eff0d61d155b2" + integrity sha512-SAM+5p6V99gYiiy2gT5ArdzgM1dLDed0nkrWmG6Fry/bUS/m9x83BwpJUOf1Qj/x2qJd+thL6IkIx7qPGRxqBw== dependencies: - array-back "^4.0.1" - deep-extend "~0.6.0" - typical "^5.2.0" - wordwrapjs "^4.0.0" - -table@^5.2.3: - version "5.4.6" - resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e" - integrity sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug== - dependencies: - ajv "^6.10.2" - lodash "^4.17.14" - slice-ansi "^2.1.0" - string-width "^3.0.0" + ajv "^8.0.1" + lodash.clonedeep "^4.5.0" + lodash.truncate "^4.4.2" + slice-ansi "^4.0.0" + string-width "^4.2.0" + strip-ansi "^6.0.0" tapable@^1.0.0: version "1.1.3" resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.1.3.tgz#a1fccc06b58db61fd7a45da2da44f5f3a3e67ba2" integrity sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA== -tapable@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.0.0.tgz#a49c3d6a8a2bb606e7db372b82904c970d537a08" - integrity sha512-bjzn0C0RWoffnNdTzNi7rNDhs1Zlwk2tRXgk8EiHKAOX1Mag3d6T0Y5zNa7l9CJ+EoUne/0UHdwS8tMbkh9zDg== +tapable@^2.1.1, tapable@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.0.tgz#5c373d281d9c672848213d0e037d1c4165ab426b" + integrity sha512-FBk4IesMV1rBxX2tfiK8RAmogtWn53puLOQlvO8XuwlgxcYbP4mVPS9Ph4aeamSyyVjOl24aYWAuc8U5kCVwMw== -terser-webpack-plugin@^5.0.3: - version "5.0.3" - resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.0.3.tgz#ec60542db2421f45735c719d2e17dabfbb2e3e42" - integrity sha512-zFdGk8Lh9ZJGPxxPE6jwysOlATWB8GMW8HcfGULWA/nPal+3VdATflQvSBSLQJRCmYZnfFJl6vkRTiwJGNgPiQ== +tar-fs@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-2.1.1.tgz#489a15ab85f1f0befabb370b7de4f9eb5cbe8784" + integrity sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng== dependencies: - jest-worker "^26.6.1" - p-limit "^3.0.2" + chownr "^1.1.1" + mkdirp-classic "^0.5.2" + pump "^3.0.0" + tar-stream "^2.1.4" + +tar-stream@^2.1.4: + version "2.2.0" + resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-2.2.0.tgz#acad84c284136b060dc3faa64474aa9aebd77287" + integrity sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ== + dependencies: + bl "^4.0.3" + end-of-stream "^1.4.1" + fs-constants "^1.0.0" + inherits "^2.0.3" + readable-stream "^3.1.1" + +terser-webpack-plugin@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.1.1.tgz#7effadee06f7ecfa093dbbd3e9ab23f5f3ed8673" + integrity sha512-5XNNXZiR8YO6X6KhSGXfY0QrGrCRlSwAEjIIrlRQR4W8nP69TaJUlh3bkuac6zzgspiGPfKEHcY295MMVExl5Q== + dependencies: + jest-worker "^26.6.2" + p-limit "^3.1.0" schema-utils "^3.0.0" serialize-javascript "^5.0.1" source-map "^0.6.1" - terser "^5.3.8" + terser "^5.5.1" -terser@^5.3.8: - version "5.3.8" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.3.8.tgz#991ae8ba21a3d990579b54aa9af11586197a75dd" - integrity sha512-zVotuHoIfnYjtlurOouTazciEfL7V38QMAOhGqpXDEg6yT13cF4+fEP9b0rrCEQTn+tT46uxgFsTZzhygk+CzQ== +terser@^5.5.1: + version "5.7.0" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.7.0.tgz#a761eeec206bc87b605ab13029876ead938ae693" + integrity sha512-HP5/9hp2UaZt5fYkuhNBR8YyRcT8juw8+uFbAme53iN9hblvKnLUTKkmwJG6ocWpIKf8UK4DoeWG4ty0J6S6/g== dependencies: commander "^2.20.0" source-map "~0.7.2" @@ -4274,7 +4227,12 @@ text-table@^0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= -tiny-emitter@2.1.0: +through@^2.3.8: + version "2.3.8" + resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" + integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= + +tiny-emitter@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/tiny-emitter/-/tiny-emitter-2.1.0.tgz#1d1a56edfc51c43e863cbb5382a72330e3555423" integrity sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q== @@ -4304,16 +4262,16 @@ tough-cookie@^2.3.3, tough-cookie@~2.5.0: psl "^1.1.28" punycode "^2.1.1" -tough-cookie@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-3.0.1.tgz#9df4f57e739c26930a018184887f4adb7dca73b2" - integrity sha512-yQyJ0u4pZsv9D4clxO69OEjLWYw+jbgspjTue4lTQZLfV0c5l1VmK2y1JK8E9ahdpltPOaAThPcp5nKPUgSnsg== +tough-cookie@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.0.0.tgz#d822234eeca882f991f0f908824ad2622ddbece4" + integrity sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg== dependencies: - ip-regex "^2.1.0" - psl "^1.1.28" + psl "^1.1.33" punycode "^2.1.1" + universalify "^0.1.2" -tr46@^2.0.0: +tr46@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/tr46/-/tr46-2.0.2.tgz#03273586def1595ae08fedb38d7733cee91d2479" integrity sha512-3n1qG+/5kg+jrbTzwAykB5yRYtQCTqOGKq5U5PE3b0a1/mzo6snDhjGS0zJVJunO0NrT3Dg1MLy5TjWP/UJppg== @@ -4325,31 +4283,31 @@ triple-beam@^1.2.0, triple-beam@^1.3.0: resolved "https://registry.yarnpkg.com/triple-beam/-/triple-beam-1.3.0.tgz#a595214c7298db8339eeeee083e4d10bd8cb8dd9" integrity sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw== -ts-loader@^8.0.8: - version "8.0.8" - resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-8.0.8.tgz#5c514c895d3b2462bf0148f63da0c22b227f7867" - integrity sha512-wihija1i2Ub9FxKFoEgx/phToJiDZKLIbTFURgf4Efxla2QuVucDO6ZpHf2jNJsRtDQfBId0g+1HF0biIjoT6Q== +ts-loader@8.2.0: + version "8.2.0" + resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-8.2.0.tgz#6a3aeaa378aecda543e2ed2c332d3123841d52e0" + integrity sha512-ebXBFrNyMSmbWgjnb3WBloUBK+VSx1xckaXsMXxlZRDqce/OPdYBVN5efB0W3V0defq0Gcy4YuzvPGqRgjj85A== dependencies: - chalk "^2.3.0" + chalk "^4.1.0" enhanced-resolve "^4.0.0" - loader-utils "^1.0.2" + loader-utils "^2.0.0" micromatch "^4.0.0" - semver "^6.0.0" + semver "^7.3.4" -tslib@^1.8.0, tslib@^1.8.1: +tslib@^1.13.0: + version "1.14.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" + integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== + +tslib@^1.8.1: version "1.11.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35" integrity sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA== -tslib@^1.9.0: - version "1.13.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043" - integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q== - -tslint@^5.17.0: - version "5.20.1" - resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.20.1.tgz#e401e8aeda0152bc44dd07e614034f3f80c67b7d" - integrity sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg== +tslint@^6.1.3: + version "6.1.3" + resolved "https://registry.yarnpkg.com/tslint/-/tslint-6.1.3.tgz#5c23b2eccc32487d5523bd3a470e9aa31789d904" + integrity sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg== dependencies: "@babel/code-frame" "^7.0.0" builtin-modules "^1.1.1" @@ -4359,10 +4317,10 @@ tslint@^5.17.0: glob "^7.1.1" js-yaml "^3.13.1" minimatch "^3.0.4" - mkdirp "^0.5.1" + mkdirp "^0.5.3" resolve "^1.3.2" semver "^5.3.0" - tslib "^1.8.0" + tslib "^1.13.0" tsutils "^2.29.0" tsutils@^2.29.0: @@ -4373,9 +4331,9 @@ tsutils@^2.29.0: tslib "^1.8.1" tsutils@^3.17.1: - version "3.17.1" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759" - integrity sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g== + version "3.21.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" + integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA== dependencies: tslib "^1.8.1" @@ -4410,6 +4368,11 @@ type-detect@^4.0.0, type-detect@^4.0.5: resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== +type-fest@^0.20.2: + version "0.20.2" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" + integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== + type-fest@^0.8.0, type-fest@^0.8.1: version "0.8.1" resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d" @@ -4423,10 +4386,10 @@ type-is@~1.6.17, type-is@~1.6.18: media-typer "0.3.0" mime-types "~2.1.24" -typed-function@1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/typed-function/-/typed-function-1.1.0.tgz#ea149706e0fb42aca1791c053a6d94ccd6c4fdcb" - integrity sha512-TuQzwiT4DDg19beHam3E66oRXhyqlyfgjHB/5fcvsRXbfmWPJfto9B4a0TBdTrQAPGlGmXh/k7iUI+WsObgORA== +typed-function@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/typed-function/-/typed-function-2.0.0.tgz#15ab3825845138a8b1113bd89e60cd6a435739e8" + integrity sha512-Hhy1Iwo/e4AtLZNK10ewVVcP2UEs408DS35ubP825w/YgSBK1KVLwALvvIG4yX75QJrxjCpcWkzkVRB0BwwYlA== typedarray-to-buffer@^3.1.5: version "3.1.5" @@ -4435,25 +4398,43 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typedarray@^0.0.6: - version "0.0.6" - resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" - integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= +typescript@^4.2.3, typescript@^4.2.4: + version "4.2.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961" + integrity sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg== -typescript@4.0: - version "4.0.5" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.5.tgz#ae9dddfd1069f1cb5beb3ef3b2170dd7c1332389" - integrity sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ== +unbox-primitive@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.1.tgz#085e215625ec3162574dc8859abee78a59b14471" + integrity sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw== + dependencies: + function-bind "^1.1.1" + has-bigints "^1.0.1" + has-symbols "^1.0.2" + which-boxed-primitive "^1.0.2" -typescript@^3.5.1: - version "3.9.7" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa" - integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw== +unbzip2-stream@^1.3.3: + version "1.4.3" + resolved "https://registry.yarnpkg.com/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz#b0da04c4371311df771cdc215e87f2130991ace7" + integrity sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg== + dependencies: + buffer "^5.2.1" + through "^2.3.8" -typical@^5.0.0, typical@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/typical/-/typical-5.2.0.tgz#4daaac4f2b5315460804f0acf6cb69c52bb93066" - integrity sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg== +universalify@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" + integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== + +universalify@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-1.0.0.tgz#b61a1da173e8435b2fe3c67d29b9adf8594bd16d" + integrity sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug== + +universalify@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" + integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0" @@ -4488,9 +4469,9 @@ uuid@^3.3.2, uuid@^3.3.3: integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== v8-compile-cache@^2.0.3, v8-compile-cache@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.2.0.tgz#9471efa3ef9128d2f7c6a7ca39c4dd6b5055b132" - integrity sha512-gTpR5XQNKFwOd4clxfnhaqvfqMpqEwr4tOtCyz4MtYZX2JYhfr1JvBFKdS+7K/9rfpZR3VLX+YWBbKoxCgS43Q== + version "2.3.0" + resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" + integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== vary@~1.1.2: version "1.1.2" @@ -4521,9 +4502,9 @@ w3c-xmlserializer@^2.0.0: xml-name-validator "^3.0.0" watchpack@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.0.1.tgz#2f2192c542c82a3bcde76acd3411470c120426a8" - integrity sha512-vO8AKGX22ZRo6PiOFM9dC0re8IcKh8Kd/aH2zeqUc6w4/jBGlTy2P7fTC6ekT0NjVeGjgU2dGC5rNstKkeLEQg== + version "2.1.1" + resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.1.1.tgz#e99630550fca07df9f90a06056987baa40a689c7" + integrity sha512-Oo7LXCmc1eE1AjyuSBmtC3+Wy4HcV8PxWh2kP6fOl8yTlNS7r0K9l1ao2lrrUza7V39Y3D/BbJgY8VeSlc5JKw== dependencies: glob-to-regexp "^0.4.1" graceful-fs "^4.1.2" @@ -4545,31 +4526,32 @@ webidl-conversions@^6.1.0: resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-6.1.0.tgz#9111b4d7ea80acd40f5270d666621afa78b69514" integrity sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w== -webpack-cli@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-4.2.0.tgz#10a09030ad2bd4d8b0f78322fba6ea43ec56aaaa" - integrity sha512-EIl3k88vaF4fSxWSgtAQR+VwicfLMTZ9amQtqS4o+TDPW9HGaEpbFBbAZ4A3ZOT5SOnMxNOzROsSTPiE8tBJPA== +webpack-cli@^4.7.0: + version "4.7.0" + resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-4.7.0.tgz#3195a777f1f802ecda732f6c95d24c0004bc5a35" + integrity sha512-7bKr9182/sGfjFm+xdZSwgQuFjgEcy0iCTIBxRUeteJ2Kr8/Wz0qNJX+jw60LU36jApt4nmMkep6+W5AKhok6g== dependencies: - "@webpack-cli/info" "^1.1.0" - "@webpack-cli/serve" "^1.1.0" + "@discoveryjs/json-ext" "^0.5.0" + "@webpack-cli/configtest" "^1.0.3" + "@webpack-cli/info" "^1.2.4" + "@webpack-cli/serve" "^1.4.0" colorette "^1.2.1" - command-line-usage "^6.1.0" - commander "^6.2.0" - enquirer "^2.3.6" - execa "^4.1.0" + commander "^7.0.0" + execa "^5.0.0" + fastest-levenshtein "^1.0.12" import-local "^3.0.2" interpret "^2.2.0" - leven "^3.1.0" rechoir "^0.7.0" v8-compile-cache "^2.2.0" - webpack-merge "^4.2.2" + webpack-merge "^5.7.3" -webpack-merge@^4.2.2: - version "4.2.2" - resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-4.2.2.tgz#a27c52ea783d1398afd2087f547d7b9d2f43634d" - integrity sha512-TUE1UGoTX2Cd42j3krGYqObZbOD+xF7u28WB7tfUordytSjbWTIjK/8V0amkBfTYN4/pB/GIDlJZZ657BGG19g== +webpack-merge@^5.7.3: + version "5.7.3" + resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-5.7.3.tgz#2a0754e1877a25a8bbab3d2475ca70a052708213" + integrity sha512-6/JUQv0ELQ1igjGDzHkXbVDRxkfA57Zw7PfiupdLFJYrgFqY5ZP8xxbpp2lU3EPwYx89ht5Z/aDkD40hFCm5AA== dependencies: - lodash "^4.17.15" + clone-deep "^4.0.1" + wildcard "^2.0.0" webpack-sources@^2.1.1: version "2.2.0" @@ -4579,33 +4561,32 @@ webpack-sources@^2.1.1: source-list-map "^2.0.1" source-map "^0.6.1" -webpack@^5.4.0: - version "5.4.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.4.0.tgz#4fdc6ec8a0ff9160701fb8f2eb8d06b33ecbae0f" - integrity sha512-udpYTyqz8toTTdaOsL2QKPLeZLt2IEm9qY7yTXuFEQhKu5bk0yQD9BtAdVQksmz4jFbbWOiWmm3NHarO0zr/ng== +webpack@^5, webpack@^5.37.0: + version "5.37.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.37.0.tgz#2ab00f613faf494504eb2beef278dab7493cc39d" + integrity sha512-yvdhgcI6QkQkDe1hINBAJ1UNevqNGTVaCkD2SSJcB8rcrNNl922RI8i2DXUAuNfANoxwsiXXEA4ZPZI9q2oGLA== dependencies: "@types/eslint-scope" "^3.7.0" - "@types/estree" "^0.0.45" - "@webassemblyjs/ast" "1.9.0" - "@webassemblyjs/helper-module-context" "1.9.0" - "@webassemblyjs/wasm-edit" "1.9.0" - "@webassemblyjs/wasm-parser" "1.9.0" - acorn "^8.0.4" + "@types/estree" "^0.0.47" + "@webassemblyjs/ast" "1.11.0" + "@webassemblyjs/wasm-edit" "1.11.0" + "@webassemblyjs/wasm-parser" "1.11.0" + acorn "^8.2.1" browserslist "^4.14.5" chrome-trace-event "^1.0.2" - enhanced-resolve "^5.3.1" + enhanced-resolve "^5.8.0" + es-module-lexer "^0.4.0" eslint-scope "^5.1.1" events "^3.2.0" glob-to-regexp "^0.4.1" graceful-fs "^4.2.4" json-parse-better-errors "^1.0.2" - loader-runner "^4.1.0" + loader-runner "^4.2.0" mime-types "^2.1.27" neo-async "^2.6.2" - pkg-dir "^4.2.0" schema-utils "^3.0.0" - tapable "^2.0.0" - terser-webpack-plugin "^5.0.3" + tapable "^2.1.1" + terser-webpack-plugin "^5.1.1" watchpack "^2.0.0" webpack-sources "^2.1.1" @@ -4621,25 +4602,25 @@ whatwg-mimetype@^2.3.0: resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz#3d4b1e0312d2079879f826aff18dbeeca5960fbf" integrity sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g== -whatwg-url@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-8.0.0.tgz#37f256cb746398e19b107bd6ef820b4ae2d15871" - integrity sha512-41ou2Dugpij8/LPO5Pq64K5q++MnRCBpEHvQr26/mArEKTkCV5aoXIqyhuYtE0pkqScXwhf2JP57rkRTYM29lQ== +whatwg-url@^8.0.0, whatwg-url@^8.5.0: + version "8.5.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-8.5.0.tgz#7752b8464fc0903fec89aa9846fc9efe07351fd3" + integrity sha512-fy+R77xWv0AiqfLl4nuGUlQ3/6b5uNfQ4WAbGQVMYshCTCCPK9psC1nWh3XHuxGVCtlcDDQPQW1csmmIQo+fwg== dependencies: - lodash.sortby "^4.7.0" - tr46 "^2.0.0" - webidl-conversions "^5.0.0" + lodash "^4.7.0" + tr46 "^2.0.2" + webidl-conversions "^6.1.0" -which-boxed-primitive@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.1.tgz#cbe8f838ebe91ba2471bb69e9edbda67ab5a5ec1" - integrity sha512-7BT4TwISdDGBgaemWU0N0OU7FeAEJ9Oo2P1PHRm/FCWoEi2VLWC9b6xvxAA3C/NMpxg3HXVgi0sMmGbNUbNepQ== +which-boxed-primitive@^1.0.1, which-boxed-primitive@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6" + integrity sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg== dependencies: - is-bigint "^1.0.0" - is-boolean-object "^1.0.0" - is-number-object "^1.0.3" - is-string "^1.0.4" - is-symbol "^1.0.2" + is-bigint "^1.0.1" + is-boolean-object "^1.1.0" + is-number-object "^1.0.4" + is-string "^1.0.5" + is-symbol "^1.0.3" which-collection@^1.0.1: version "1.0.1" @@ -4657,24 +4638,18 @@ which-module@^2.0.0: integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= which-typed-array@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.2.tgz#e5f98e56bda93e3dac196b01d47c1156679c00b2" - integrity sha512-KT6okrd1tE6JdZAy3o2VhMoYPh3+J6EMZLyrxBQsZflI1QCZIxMrIYLkosd8Twf+YfknVIHmYQPgJt238p8dnQ== + version "1.1.4" + resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.4.tgz#8fcb7d3ee5adf2d771066fba7cf37e32fe8711ff" + integrity sha512-49E0SpUe90cjpoc7BOJwyPHRqSAd12c10Qm2amdEZrJPCY2NDxaW01zHITrem+rnETY3dwrbH3UUrUwagfCYDA== dependencies: available-typed-arrays "^1.0.2" - es-abstract "^1.17.5" + call-bind "^1.0.0" + es-abstract "^1.18.0-next.1" foreach "^2.0.5" function-bind "^1.1.1" has-symbols "^1.0.1" is-typed-array "^1.1.3" -which@1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" - integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== - dependencies: - isexe "^2.0.0" - which@2.0.2, which@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" @@ -4689,55 +4664,43 @@ wide-align@1.1.3: dependencies: string-width "^1.0.2 || 2" -winston-transport@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/winston-transport/-/winston-transport-4.3.0.tgz#df68c0c202482c448d9b47313c07304c2d7c2c66" - integrity sha512-B2wPuwUi3vhzn/51Uukcao4dIduEiPOcOt9HJ3QeaXgkJ5Z7UwpBzxS4ZGNHtrxrUvTwemsQiSys0ihOf8Mp1A== +wildcard@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.0.tgz#a77d20e5200c6faaac979e4b3aadc7b3dd7f8fec" + integrity sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw== + +winston-transport@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/winston-transport/-/winston-transport-4.4.0.tgz#17af518daa690d5b2ecccaa7acf7b20ca7925e59" + integrity sha512-Lc7/p3GtqtqPBYYtS6KCN3c77/2QCev51DvcJKbkFPQNoj1sinkGwLGFDxkXY9J6p9+EPnYs+D90uwbnaiURTw== dependencies: - readable-stream "^2.3.6" + readable-stream "^2.3.7" triple-beam "^1.2.0" -winston@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/winston/-/winston-3.2.1.tgz#63061377976c73584028be2490a1846055f77f07" - integrity sha512-zU6vgnS9dAWCEKg/QYigd6cgMVVNwyTzKs81XZtTFuRwJOcDdBg7AU0mXVyNbs7O5RH2zdv+BdNZUlx7mXPuOw== +winston@^3.3.3: + version "3.3.3" + resolved "https://registry.yarnpkg.com/winston/-/winston-3.3.3.tgz#ae6172042cafb29786afa3d09c8ff833ab7c9170" + integrity sha512-oEXTISQnC8VlSAKf1KYSSd7J6IWuRPQqDdo8eoRNaYKLvwSb5+79Z3Yi1lrl6KDpU6/VWaxpakDAtb1oQ4n9aw== dependencies: - async "^2.6.1" - diagnostics "^1.1.1" - is-stream "^1.1.0" - logform "^2.1.1" - one-time "0.0.4" - readable-stream "^3.1.1" + "@dabh/diagnostics" "^2.0.2" + async "^3.1.0" + is-stream "^2.0.0" + logform "^2.2.0" + one-time "^1.0.0" + readable-stream "^3.4.0" stack-trace "0.0.x" triple-beam "^1.3.0" - winston-transport "^4.3.0" + winston-transport "^4.4.0" word-wrap@^1.2.3, word-wrap@~1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== -wordwrapjs@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/wordwrapjs/-/wordwrapjs-4.0.0.tgz#9aa9394155993476e831ba8e59fb5795ebde6800" - integrity sha512-Svqw723a3R34KvsMgpjFBYCgNOSdcW3mQFK4wIfhGQhtaFVOJmdYoXgi63ne3dTlWgatVcUc7t4HtQ/+bUVIzQ== - dependencies: - reduce-flatten "^2.0.0" - typical "^5.0.0" - -workerpool@6.0.2: - version "6.0.2" - resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.0.2.tgz#e241b43d8d033f1beb52c7851069456039d1d438" - integrity sha512-DSNyvOpFKrNusaaUwk+ej6cBj1bmhLcBfj80elGk+ZIo5JSkq+unB1dLKEOcNfJDZgjGICfhQ0Q5TbP0PvF4+Q== - -wrap-ansi@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-5.1.0.tgz#1fd1f67235d5b6d0fee781056001bfb694c03b09" - integrity sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q== - dependencies: - ansi-styles "^3.2.0" - string-width "^3.0.0" - strip-ansi "^5.0.0" +workerpool@6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.1.0.tgz#a8e038b4c94569596852de7a8ea4228eefdeb37b" + integrity sha512-toV7q9rWNYha963Pl/qyeZ6wG+3nnsyvolaNUS8+R5Wtw6qJPTxIlOP1ZSvcGhEJw+l3HMMmtiNo9Gl61G4GVg== wrap-ansi@^6.2.0: version "6.2.0" @@ -4748,6 +4711,15 @@ wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" @@ -4763,13 +4735,6 @@ write-file-atomic@^3.0.0: signal-exit "^3.0.2" typedarray-to-buffer "^3.1.5" -write@1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/write/-/write-1.0.3.tgz#0800e14523b923a387e415123c865616aae0f5c3" - integrity sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig== - dependencies: - mkdirp "^0.5.1" - ws@^5.2.0: version "5.2.2" resolved "https://registry.yarnpkg.com/ws/-/ws-5.2.2.tgz#dffef14866b8e8dc9133582514d1befaf96e980f" @@ -4777,18 +4742,16 @@ ws@^5.2.0: dependencies: async-limiter "~1.0.0" -ws@^6.1.0: - version "6.2.1" - resolved "https://registry.yarnpkg.com/ws/-/ws-6.2.1.tgz#442fdf0a47ed64f59b6a5d8ff130f4748ed524fb" - integrity sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA== - dependencies: - async-limiter "~1.0.0" - -ws@^7.2.3, ws@^7.3.1: +ws@^7.2.3: version "7.3.1" resolved "https://registry.yarnpkg.com/ws/-/ws-7.3.1.tgz#d0547bf67f7ce4f12a72dfe31262c68d7dc551c8" integrity sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA== +ws@^7.3.1, ws@^7.4.4, ws@^7.4.5: + version "7.4.5" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.5.tgz#a484dd851e9beb6fdb420027e3885e8ce48986c1" + integrity sha512-xzyu3hFvomRfXKH8vOFMU3OguG6oOvhXMo3xsGy3xWExqaM2dxBbVxuD99O7m3ZUFMvvscsZDqxfgMaRr/Nr1g== + xml-name-validator@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" @@ -4799,38 +4762,46 @@ xmlchars@^2.2.0: resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb" integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw== -xterm-benchmark@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/xterm-benchmark/-/xterm-benchmark-0.1.3.tgz#c637d078f7b73f77a4342299e706b4d0e52ab46a" - integrity sha512-HBSeUOFlr9JVMFNkL5w8EkuWccczkfZAX6adK5fSot1sRRAFJS9NZcXH/yRLZp9S24qOUBJznMZGa9CjWB3h3g== +xterm-benchmark@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/xterm-benchmark/-/xterm-benchmark-0.2.1.tgz#f7741127aa8eceaffbb0cbbca93d374075e44d64" + integrity sha512-QtfTIlCrjPlzmdjaxRXC0JeE1Dwk25WjNzHR1bTKRqSSQToVw+rcp53o5V5I9AaVWef8vCdJ7lVxXuuX4sphew== dependencies: "@types/app-root-path" "^1.2.4" "@types/cli-table" "^0.3.0" - "@types/mathjs" "^5.0.1" - "@types/mocha" "^5.2.7" - "@types/node" "^12.0.4" - app-root-path "^2.2.1" - chrome-timeline "0.0.12" - cli-table "^0.3.1" + "@types/mathjs" "^6.0.11" + "@types/mocha" "^8.2.1" + "@types/node" "^12.12.37" + "@types/puppeteer" "^5.4.3" + app-root-path "^3.0.0" + chrome-timeline "0.0.15" + cli-table "^0.3.6" columnify "^1.5.4" - commander "^2.20.0" - mathjs "^5.10.3" - mocha "^6.1.4" - tslint "^5.17.0" - typescript "^3.5.1" + commander "^6.2.1" + mathjs "^9.3.0" + mocha "^8.3.2" + tslint "^6.1.3" + typescript "^4.2.3" y18n@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.1.tgz#8db2b83c31c5d75099bb890b23f3094891e247d4" integrity sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ== -yargs-parser@13.1.2, yargs-parser@^13.1.2: - version "13.1.2" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38" - integrity sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg== - dependencies: - camelcase "^5.0.0" - decamelize "^1.2.0" +y18n@^5.0.5: + version "5.0.8" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" + integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== + +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== + +yargs-parser@20.2.4: + version "20.2.4" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" + integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== yargs-parser@^18.1.1: version "18.1.2" @@ -4840,14 +4811,10 @@ yargs-parser@^18.1.1: camelcase "^5.0.0" decamelize "^1.2.0" -yargs-unparser@1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-1.6.0.tgz#ef25c2c769ff6bd09e4b0f9d7c605fb27846ea9f" - integrity sha512-W9tKgmSn0DpSatfri0nx52Joq5hVXgeLiqR/5G0sZNDoLZFOr/xjBUDcShCOGNsBnEMNo1KAMBkTej1Hm62HTw== - dependencies: - flat "^4.1.0" - lodash "^4.17.15" - yargs "^13.3.0" +yargs-parser@^20.2.2: + version "20.2.7" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.7.tgz#61df85c113edfb5a7a4e36eb8aa60ef423cbc90a" + integrity sha512-FiNkvbeHzB/syOjIUxFDCnhSfzAL8R5vs40MgLFBorXACCOAEaWu0gRZl14vG8MR9AOJIZbmkjhusqBYZ3HTHw== yargs-unparser@2.0.0: version "2.0.0" @@ -4859,21 +4826,18 @@ yargs-unparser@2.0.0: flat "^5.0.2" is-plain-obj "^2.1.0" -yargs@13.3.2, yargs@^13.3.0: - version "13.3.2" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.3.2.tgz#ad7ffefec1aa59565ac915f82dccb38a9c31a2dd" - integrity sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw== +yargs@16.2.0: + version "16.2.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" + integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== dependencies: - cliui "^5.0.0" - find-up "^3.0.0" - get-caller-file "^2.0.1" + cliui "^7.0.2" + escalade "^3.1.1" + get-caller-file "^2.0.5" require-directory "^2.1.1" - require-main-filename "^2.0.0" - set-blocking "^2.0.0" - string-width "^3.0.0" - which-module "^2.0.0" - y18n "^4.0.0" - yargs-parser "^13.1.2" + string-width "^4.2.0" + y18n "^5.0.5" + yargs-parser "^20.2.2" yargs@^15.0.2: version "15.3.1" @@ -4899,3 +4863,8 @@ yauzl@^2.10.0: dependencies: buffer-crc32 "~0.2.3" fd-slicer "~1.1.0" + +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== From 8c65fcacb37e729da5f4c0307065bbe3b89252f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Mon, 10 May 2021 22:56:30 +0200 Subject: [PATCH 197/377] flip eslint rule to reflect code base --- .eslintrc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index 114a0f1d..390e2c54 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -43,7 +43,7 @@ "@typescript-eslint/array-type": [ "warn", { - "default": "array-simple", + "default": "array", "readonly": "generic" } ], From e91d90dbbc17a106b5d424218d17d0c4b7c8762a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Mon, 10 May 2021 23:04:06 +0200 Subject: [PATCH 198/377] switch to 12.x for CI --- azure-pipelines.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 33da22b2..b0bdda66 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -10,7 +10,7 @@ jobs: steps: - task: NodeTool@0 inputs: - versionSpec: '10.x' + versionSpec: '12.x' displayName: 'Install Node.js' - task: YarnInstaller@3 inputs: @@ -43,7 +43,7 @@ jobs: steps: - task: NodeTool@0 inputs: - versionSpec: '10.x' + versionSpec: '12.x' displayName: 'Install Node.js' - task: CacheBeta@1 inputs: @@ -63,7 +63,7 @@ jobs: steps: - task: NodeTool@0 inputs: - versionSpec: '10.x' + versionSpec: '12.x' displayName: 'Install Node.js' - task: CacheBeta@1 inputs: @@ -92,7 +92,7 @@ jobs: displayName: Install required packages - task: NodeTool@0 inputs: - versionSpec: '10.x' + versionSpec: '12.x' displayName: 'Install Node.js' - task: YarnInstaller@3 inputs: @@ -111,7 +111,7 @@ jobs: steps: - task: NodeTool@0 inputs: - versionSpec: '10.x' + versionSpec: '12.x' displayName: 'Install Node.js' - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' @@ -128,7 +128,7 @@ jobs: steps: - task: NodeTool@0 inputs: - versionSpec: '10.x' + versionSpec: '12.x' displayName: 'Install Node.js' - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' @@ -151,7 +151,7 @@ jobs: steps: - task: NodeTool@0 inputs: - versionSpec: '10.x' + versionSpec: '12.x' displayName: 'Install Node.js' - task: YarnInstaller@3 inputs: From 973eb7b350315f4cd004644b496305a685986711 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 11 May 2021 05:10:04 -0700 Subject: [PATCH 199/377] Make sure all rows are refreshed on input Fixes #3323 --- src/browser/Viewport.ts | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index 02f74ce8..7b377a47 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -30,7 +30,6 @@ export class Viewport extends Disposable implements IViewport { private _wheelPartialScroll: number = 0; private _refreshAnimationFrame: number | null = null; - private _ignoreNextScrollEvent: boolean = false; constructor( private readonly _scrollLines: (amount: number) => void, @@ -88,14 +87,12 @@ export class Viewport extends Disposable implements IViewport { // Sync scrollTop const scrollTop = this._bufferService.buffer.ydisp * this._currentRowHeight; if (this._viewportElement.scrollTop !== scrollTop) { - // Ignore the next scroll event which will be triggered by setting the scrollTop as we do not - // want this event to scroll the terminal - this._ignoreNextScrollEvent = true; this._viewportElement.scrollTop = scrollTop; } this._refreshAnimationFrame = null; } + /** * Updates dimensions and synchronizes the scroll area if necessary. */ @@ -148,12 +145,6 @@ export class Viewport extends Disposable implements IViewport { return; } - // Ignore the event if it was flagged to ignore (when the source of the event is from Viewport) - if (this._ignoreNextScrollEvent) { - this._ignoreNextScrollEvent = false; - return; - } - const newRow = Math.round(this._lastScrollTop / this._currentRowHeight); const diff = newRow - this._bufferService.buffer.ydisp; this._scrollLines(diff); From da39129bd2cba926e7c7ef4d20d6154c685b6889 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 11 May 2021 05:10:04 -0700 Subject: [PATCH 200/377] Revert "Make sure all rows are refreshed on input" This reverts commit 973eb7b350315f4cd004644b496305a685986711. --- src/browser/Viewport.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index 7b377a47..02f74ce8 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -30,6 +30,7 @@ export class Viewport extends Disposable implements IViewport { private _wheelPartialScroll: number = 0; private _refreshAnimationFrame: number | null = null; + private _ignoreNextScrollEvent: boolean = false; constructor( private readonly _scrollLines: (amount: number) => void, @@ -87,12 +88,14 @@ export class Viewport extends Disposable implements IViewport { // Sync scrollTop const scrollTop = this._bufferService.buffer.ydisp * this._currentRowHeight; if (this._viewportElement.scrollTop !== scrollTop) { + // Ignore the next scroll event which will be triggered by setting the scrollTop as we do not + // want this event to scroll the terminal + this._ignoreNextScrollEvent = true; this._viewportElement.scrollTop = scrollTop; } this._refreshAnimationFrame = null; } - /** * Updates dimensions and synchronizes the scroll area if necessary. */ @@ -145,6 +148,12 @@ export class Viewport extends Disposable implements IViewport { return; } + // Ignore the event if it was flagged to ignore (when the source of the event is from Viewport) + if (this._ignoreNextScrollEvent) { + this._ignoreNextScrollEvent = false; + return; + } + const newRow = Math.round(this._lastScrollTop / this._currentRowHeight); const diff = newRow - this._bufferService.buffer.ydisp; this._scrollLines(diff); From bcbcc71bfc4e275d77703d724eb85a6152636acd Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 11 May 2021 06:52:04 -0700 Subject: [PATCH 201/377] Trigger scroll when ignoring event This is a less aggressive fix that doesn't regress tests --- src/browser/Viewport.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index 02f74ce8..162ed174 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -151,6 +151,8 @@ export class Viewport extends Disposable implements IViewport { // Ignore the event if it was flagged to ignore (when the source of the event is from Viewport) if (this._ignoreNextScrollEvent) { this._ignoreNextScrollEvent = false; + // Still trigger the scroll so lines get refreshed + this._scrollLines(0); return; } From 0c47cd4d4ded64ade797d9d2b1af2c9aa9f9cb31 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 11 May 2021 07:09:41 -0700 Subject: [PATCH 202/377] v4.12.0 --- addons/xterm-addon-ligatures/package.json | 2 +- addons/xterm-addon-webgl/package.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/xterm-addon-ligatures/package.json b/addons/xterm-addon-ligatures/package.json index f96ce167..64d8eed7 100644 --- a/addons/xterm-addon-ligatures/package.json +++ b/addons/xterm-addon-ligatures/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-ligatures", - "version": "0.4.0", + "version": "0.5.0", "description": "Add support for programming ligatures to xterm.js", "author": { "name": "The xterm.js authors", diff --git a/addons/xterm-addon-webgl/package.json b/addons/xterm-addon-webgl/package.json index 28c6f5bc..5990fbe1 100644 --- a/addons/xterm-addon-webgl/package.json +++ b/addons/xterm-addon-webgl/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-webgl", - "version": "0.10.0", + "version": "0.11.0", "author": { "name": "The xterm.js authors", "url": "https://xtermjs.org/" diff --git a/package.json b/package.json index 9134a378..1eb8cda5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "xterm", "description": "Full xterm terminal, in your browser", - "version": "4.11.0", + "version": "4.12.0", "main": "lib/xterm.js", "style": "css/xterm.css", "types": "typings/xterm.d.ts", From 7a0b462e7eedbf8824652409bce325afd19f16c2 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Tue, 11 May 2021 20:33:58 -0500 Subject: [PATCH 203/377] chore(types): use IEvent from xterm --- addons/xterm-addon-webgl/typings/xterm-addon-webgl.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/xterm-addon-webgl/typings/xterm-addon-webgl.d.ts b/addons/xterm-addon-webgl/typings/xterm-addon-webgl.d.ts index d95d8961..ee390d8a 100644 --- a/addons/xterm-addon-webgl/typings/xterm-addon-webgl.d.ts +++ b/addons/xterm-addon-webgl/typings/xterm-addon-webgl.d.ts @@ -3,8 +3,7 @@ * @license MIT */ -import { IEvent } from 'node-pty'; -import { Terminal, ITerminalAddon } from 'xterm'; +import { Terminal, ITerminalAddon, IEvent } from 'xterm'; declare module 'xterm-addon-webgl' { /** From 8cc6df1f70ab5185946c1218ee075cf13513b7cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Wed, 12 May 2021 10:58:04 +0200 Subject: [PATCH 204/377] upgrade to node v14.x --- azure-pipelines.yml | 14 +++---- package.json | 8 ++-- yarn.lock | 97 +++++++++++++-------------------------------- 3 files changed, 39 insertions(+), 80 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b0bdda66..f4220176 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -10,7 +10,7 @@ jobs: steps: - task: NodeTool@0 inputs: - versionSpec: '12.x' + versionSpec: '14.x' displayName: 'Install Node.js' - task: YarnInstaller@3 inputs: @@ -43,7 +43,7 @@ jobs: steps: - task: NodeTool@0 inputs: - versionSpec: '12.x' + versionSpec: '14.x' displayName: 'Install Node.js' - task: CacheBeta@1 inputs: @@ -63,7 +63,7 @@ jobs: steps: - task: NodeTool@0 inputs: - versionSpec: '12.x' + versionSpec: '14.x' displayName: 'Install Node.js' - task: CacheBeta@1 inputs: @@ -92,7 +92,7 @@ jobs: displayName: Install required packages - task: NodeTool@0 inputs: - versionSpec: '12.x' + versionSpec: '14.x' displayName: 'Install Node.js' - task: YarnInstaller@3 inputs: @@ -111,7 +111,7 @@ jobs: steps: - task: NodeTool@0 inputs: - versionSpec: '12.x' + versionSpec: '14.x' displayName: 'Install Node.js' - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' @@ -128,7 +128,7 @@ jobs: steps: - task: NodeTool@0 inputs: - versionSpec: '12.x' + versionSpec: '14.x' displayName: 'Install Node.js' - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' @@ -151,7 +151,7 @@ jobs: steps: - task: NodeTool@0 inputs: - versionSpec: '12.x' + versionSpec: '14.x' displayName: 'Install Node.js' - task: YarnInstaller@3 inputs: diff --git a/package.json b/package.json index a7de4815..6d9a351d 100644 --- a/package.json +++ b/package.json @@ -40,10 +40,10 @@ "@types/glob": "^7.1.3", "@types/jsdom": "^16.2.10", "@types/mocha": "^8.2.2", - "@types/node": "^12.12.37", + "@types/node": "^14.14.44", "@types/utf8": "^2.1.6", "@types/webpack": "^5.28.0", - "@types/ws": "^7.4.2", + "@types/ws": "^7.4.4", "@typescript-eslint/eslint-plugin": "^4.23.0", "@typescript-eslint/parser": "^4.23.0", "chai": "^4.3.4", @@ -57,9 +57,9 @@ "mustache": "^4.2.0", "node-pty": "^0.10.1", "nyc": "^15.1.0", - "playwright": "^1.10.0", + "playwright": "^1.11.0", "source-map-loader": "^2.0.1", - "ts-loader": "8.2.0", + "ts-loader": "^9.1.2", "typescript": "^4.2.4", "utf8": "^3.0.0", "webpack": "^5.37.0", diff --git a/yarn.lock b/yarn.lock index 460b36f5..5edf8871 100644 --- a/yarn.lock +++ b/yarn.lock @@ -387,6 +387,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.12.tgz#fd9c1c2cfab536a2383ed1ef70f94adea743a226" integrity sha512-KQZ1al2hKOONAs2MFv+yTQP1LkDWMrRJ9YCVRalXltOfXsBmH5IownLxQaiq0lnAHwAViLnh2aTYqrPcRGEbgg== +"@types/node@^14.14.44": + version "14.14.44" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.44.tgz#df7503e6002847b834371c004b372529f3f85215" + integrity sha512-+gaugz6Oce6ZInfI/tK4Pq5wIIkJMEJUu92RB3Eu93mtj4wjjjz9EB5mLp5s1pSsLXdC/CPut/xF20ZzAQJbTA== + "@types/parse5@*": version "6.0.0" resolved "https://registry.yarnpkg.com/@types/parse5/-/parse5-6.0.0.tgz#38590dc2c3cf5717154064e3ee9b6947ee21b299" @@ -418,10 +423,10 @@ tapable "^2.2.0" webpack "^5" -"@types/ws@^7.4.2": - version "7.4.2" - resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.2.tgz#bfe739b5f8b3a39742605fbe415ae7e88ee614c8" - integrity sha512-PbeN0Eydl7LQl4OIav29YmkO2LxbVuz3nZD/kb19lOS+wLgIkRbWMNmU/QQR7ABpOJ7D7xDOU8co7iohObewrw== +"@types/ws@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.4.tgz#93e1e00824c1de2608c30e6de4303ab3b4c0c9bc" + integrity sha512-d/7W23JAXPodQNbOZNXvl2K+bqAQrCMwlh/nuQsPSQk6Fq0opHoPrUw43aHsvSbIiQPr8Of2hkFbnz1XBFVyZQ== dependencies: "@types/node" "*" @@ -914,11 +919,6 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" -big.js@^5.2.2: - version "5.2.2" - resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" - integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ== - binary-extensions@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.0.0.tgz#23c0df14f6a88077f5f986c0d167ec03c3d5537c" @@ -1543,11 +1543,6 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== -emojis-list@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78" - integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q== - enabled@2.0.x: version "2.0.0" resolved "https://registry.yarnpkg.com/enabled/-/enabled-2.0.0.tgz#f9dd92ec2d6f4bbc0d5d1e64e21d61cd4665e7c2" @@ -1565,16 +1560,7 @@ end-of-stream@^1.1.0, end-of-stream@^1.4.1: dependencies: once "^1.4.0" -enhanced-resolve@^4.0.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-4.5.0.tgz#2f3cfd84dbe3b487f18f2db2ef1e064a571ca5ec" - integrity sha512-Nv9m36S/vxpsI+Hc4/ZGRs0n9mXqSWGGq49zxb/cJfPAQMbUtttJAlNPS4AQzaBdw/pKskw5bMbekT/Y7W/Wlg== - dependencies: - graceful-fs "^4.1.2" - memory-fs "^0.5.0" - tapable "^1.0.0" - -enhanced-resolve@^5.8.0: +enhanced-resolve@^5.0.0, enhanced-resolve@^5.8.0: version "5.8.2" resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.8.2.tgz#15ddc779345cbb73e97c611cd00c01c1e7bf4d8b" integrity sha512-F27oB3WuHDzvR2DOGNTaYy0D5o0cnrv8TeI482VM4kYgQd/FT9lUQwuNsJ0oOHtBUq7eiW5ytqzp7nBFknL+GA== @@ -1594,13 +1580,6 @@ envinfo@^7.7.3: resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475" integrity sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw== -errno@^0.1.3: - version "0.1.8" - resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.8.tgz#8bb3e9c7d463be4976ff888f76b4809ebc2e811f" - integrity sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A== - dependencies: - prr "~1.0.1" - es-abstract@^1.18.0-next.1, es-abstract@^1.18.0-next.2: version "1.18.0" resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.0.tgz#ab80b359eecb7ede4c298000390bc5ac3ec7b5a4" @@ -2878,15 +2857,6 @@ loader-runner@^4.2.0: resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.2.0.tgz#d7022380d66d14c5fb1d496b89864ebcfd478384" integrity sha512-92+huvxMvYlMzMt0iIOukcwYBFpkYJdpl2xsZ7LrlayO7E8SOv+JJUEK17B/dJIHAOLMfh2dZZ/Y18WgmGtYNw== -loader-utils@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.0.tgz#e4cace5b816d425a166b5f097e10cd12b36064b0" - integrity sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ== - dependencies: - big.js "^5.2.2" - emojis-list "^3.0.0" - json5 "^2.1.2" - locate-path@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" @@ -2972,14 +2942,6 @@ media-typer@0.3.0: resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= -memory-fs@^0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.5.0.tgz#324c01288b88652966d161db77838720845a8e3c" - integrity sha512-jA0rdU5KoQMC0e6ppoNRtpp6vjFq6+NY7r8hywnC7V+1Xj/MtHwGIbB1QaK/dunyjWteJzmkpd7ooeWg10T7GA== - dependencies: - errno "^0.1.3" - readable-stream "^2.0.1" - merge-descriptors@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" @@ -3447,10 +3409,10 @@ pkg-dir@^4.1.0, pkg-dir@^4.2.0: dependencies: find-up "^4.0.0" -playwright@^1.10.0: - version "1.10.0" - resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.10.0.tgz#a14d295f1ad886caf4cc5e674afe03ac832066bc" - integrity sha512-b7SGBcCPq4W3pb4ImEDmNXtO0ZkJbZMuWiShsaNJd+rGfY/6fqwgllsAojmxGSgFmijYw7WxCoPiAIEDIH16Kw== +playwright@^1.11.0: + version "1.11.0" + resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.11.0.tgz#0796cf08f4756e8187e01c705315d8e1fb48e25f" + integrity sha512-s3FQBRpu/pW/vZ/lFYhG/Q3WBUbT2rvMgrgy1PHDA7QtPN910C2rj9Ovd6A/m8yxuLnltd/OKqvlAGevWISHKw== dependencies: commander "^6.1.0" debug "^4.1.1" @@ -3465,6 +3427,7 @@ playwright@^1.10.0: rimraf "^3.0.2" stack-utils "^2.0.3" ws "^7.3.1" + yazl "^2.5.1" pngjs@^5.0.0: version "5.0.0" @@ -3520,11 +3483,6 @@ proxy-from-env@^1.0.0, proxy-from-env@^1.1.0: resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== -prr@~1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476" - integrity sha1-0/wRS6BplaRexok/SEzrHXj19HY= - psl@^1.1.28, psl@^1.1.33: version "1.8.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.8.0.tgz#9326f8bcfb013adcc005fdff056acce020e51c24" @@ -3598,7 +3556,7 @@ raw-body@2.4.0: iconv-lite "0.4.24" unpipe "1.0.0" -readable-stream@^2.0.1, readable-stream@^2.3.7: +readable-stream@^2.3.7: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== @@ -4156,11 +4114,6 @@ table@^6.0.4: string-width "^4.2.0" strip-ansi "^6.0.0" -tapable@^1.0.0: - version "1.1.3" - resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.1.3.tgz#a1fccc06b58db61fd7a45da2da44f5f3a3e67ba2" - integrity sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA== - tapable@^2.1.1, tapable@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.0.tgz#5c373d281d9c672848213d0e037d1c4165ab426b" @@ -4283,14 +4236,13 @@ triple-beam@^1.2.0, triple-beam@^1.3.0: resolved "https://registry.yarnpkg.com/triple-beam/-/triple-beam-1.3.0.tgz#a595214c7298db8339eeeee083e4d10bd8cb8dd9" integrity sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw== -ts-loader@8.2.0: - version "8.2.0" - resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-8.2.0.tgz#6a3aeaa378aecda543e2ed2c332d3123841d52e0" - integrity sha512-ebXBFrNyMSmbWgjnb3WBloUBK+VSx1xckaXsMXxlZRDqce/OPdYBVN5efB0W3V0defq0Gcy4YuzvPGqRgjj85A== +ts-loader@^9.1.2: + version "9.1.2" + resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-9.1.2.tgz#ba9b9abb05a514e8ff825791a3f6fcf793272728" + integrity sha512-ryMgATvLLl+z8zQvdlm6Pep0slmwxFWIEnq/5VdiLVjqQXnFJgO+qNLGIIP+d2N2jsFZ9MibZCVDb2bSp7OmEA== dependencies: chalk "^4.1.0" - enhanced-resolve "^4.0.0" - loader-utils "^2.0.0" + enhanced-resolve "^5.0.0" micromatch "^4.0.0" semver "^7.3.4" @@ -4864,6 +4816,13 @@ yauzl@^2.10.0: buffer-crc32 "~0.2.3" fd-slicer "~1.1.0" +yazl@^2.5.1: + version "2.5.1" + resolved "https://registry.yarnpkg.com/yazl/-/yazl-2.5.1.tgz#a3d65d3dd659a5b0937850e8609f22fffa2b5c35" + integrity sha512-phENi2PLiHnHb6QBVot+dJnaAZ0xosj7p3fWl+znIjBDlnMI2PsZCJZ306BPTFOaHf5qdDEI8x5qFrSOBN5vrw== + dependencies: + buffer-crc32 "~0.2.3" + yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" From 01f68c50edd25b6e70156f33cfc7f865df032ea7 Mon Sep 17 00:00:00 2001 From: Labhansh Agrawal Date: Thu, 13 May 2021 12:46:39 +0530 Subject: [PATCH 205/377] Update local fonts query --- addons/xterm-addon-ligatures/src/font.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/xterm-addon-ligatures/src/font.ts b/addons/xterm-addon-ligatures/src/font.ts index fca110a4..b3ba436a 100644 --- a/addons/xterm-addon-ligatures/src/font.ts +++ b/addons/xterm-addon-ligatures/src/font.ts @@ -44,8 +44,8 @@ export default async function load(fontFamily: string, cacheSize: number): Promi } const fonts: Record = {}; try { - const fontsIterator: AsyncIterableIterator = (navigator as any).fonts.query(); - for await (const metadata of fontsIterator) { + const fontsIterator: IFontMetadata[] = await (navigator as any).fonts.query(); + for (const metadata of fontsIterator) { if (!fonts.hasOwnProperty(metadata.family)) { fonts[metadata.family] = []; } From de712d9b430e8b41b3e94edd0868aab3c81e3e9c Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 13 May 2021 05:09:39 -0700 Subject: [PATCH 206/377] v0.11.1 webgl - types fix --- addons/xterm-addon-webgl/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/xterm-addon-webgl/package.json b/addons/xterm-addon-webgl/package.json index 5990fbe1..421f6092 100644 --- a/addons/xterm-addon-webgl/package.json +++ b/addons/xterm-addon-webgl/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-webgl", - "version": "0.11.0", + "version": "0.11.1", "author": { "name": "The xterm.js authors", "url": "https://xtermjs.org/" From 74edc6fdd4c1b9c4202172c319b2ca88a6d89463 Mon Sep 17 00:00:00 2001 From: Labhansh Agrawal Date: Thu, 13 May 2021 18:12:07 +0530 Subject: [PATCH 207/377] Add navigator typing for fonts access --- addons/xterm-addon-ligatures/src/font.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/addons/xterm-addon-ligatures/src/font.ts b/addons/xterm-addon-ligatures/src/font.ts index b3ba436a..72872a0b 100644 --- a/addons/xterm-addon-ligatures/src/font.ts +++ b/addons/xterm-addon-ligatures/src/font.ts @@ -15,6 +15,15 @@ interface IFontMetadata { blob: () => Promise; } +interface IFontAccessNavigator { + fonts: { + query: () => Promise; + }; + permissions: { + request?: (permission: { name: string }) => Promise<{state: string}>; + }; +} + let fontsPromise: Promise> | undefined = undefined; /** @@ -28,7 +37,7 @@ export default async function load(fontFamily: string, cacheSize: number): Promi // Web environment that supports font access API if (typeof navigator !== 'undefined' && 'fonts' in navigator) { try { - const status = await (navigator as any).permissions.request?.({ + const status = await (navigator as IFontAccessNavigator).permissions.request?.({ name: 'local-fonts' }); if (status && status.state !== 'granted') { @@ -44,7 +53,7 @@ export default async function load(fontFamily: string, cacheSize: number): Promi } const fonts: Record = {}; try { - const fontsIterator: IFontMetadata[] = await (navigator as any).fonts.query(); + const fontsIterator = await (navigator as IFontAccessNavigator).fonts.query(); for (const metadata of fontsIterator) { if (!fonts.hasOwnProperty(metadata.family)) { fonts[metadata.family] = []; From d046e2a77f92de89403115e810eeb323a13b17b7 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Sat, 15 May 2021 01:17:17 +0300 Subject: [PATCH 208/377] chore: lint using putout --- addons/xterm-addon-attach/src/AttachAddon.ts | 2 +- addons/xterm-addon-search/src/SearchAddon.ts | 2 +- .../test/SerializeAddon.api.ts | 4 +-- addons/xterm-addon-webgl/src/GlyphRenderer.ts | 2 +- addons/xterm-addon-webgl/src/WebglAddon.ts | 6 ++-- addons/xterm-addon-webgl/src/WebglRenderer.ts | 2 +- src/browser/AccessibilityManager.ts | 2 +- src/browser/ColorManager.test.ts | 4 +-- src/browser/Linkifier.test.ts | 4 +-- src/browser/Linkifier.ts | 2 +- src/browser/Terminal.test.ts | 30 +++++++++---------- src/browser/Terminal.ts | 4 +-- src/browser/Terminal2.test.ts | 2 +- src/browser/TestUtils.test.ts | 2 +- src/common/Clone.ts | 2 +- src/common/InputHandler.test.ts | 10 +++---- src/common/TestUtils.test.ts | 2 +- 17 files changed, 41 insertions(+), 41 deletions(-) diff --git a/addons/xterm-addon-attach/src/AttachAddon.ts b/addons/xterm-addon-attach/src/AttachAddon.ts index 035807ae..9fbd796b 100644 --- a/addons/xterm-addon-attach/src/AttachAddon.ts +++ b/addons/xterm-addon-attach/src/AttachAddon.ts @@ -20,7 +20,7 @@ export class AttachAddon implements ITerminalAddon { this._socket = socket; // always set binary type to arraybuffer, we do not handle blobs this._socket.binaryType = 'arraybuffer'; - this._bidirectional = (options && options.bidirectional === false) ? false : true; + this._bidirectional = !(options && options.bidirectional === false); } public activate(terminal: Terminal): void { diff --git a/addons/xterm-addon-search/src/SearchAddon.ts b/addons/xterm-addon-search/src/SearchAddon.ts index 64e89bb3..4a73d998 100644 --- a/addons/xterm-addon-search/src/SearchAddon.ts +++ b/addons/xterm-addon-search/src/SearchAddon.ts @@ -394,7 +394,7 @@ export class SearchAddon implements ITerminalAddon { // If it is not in the viewport then we scroll else it just gets selected if (result.row >= (terminal.buffer.active.viewportY + terminal.rows) || result.row < terminal.buffer.active.viewportY) { let scroll = result.row - terminal.buffer.active.viewportY; - scroll = scroll - Math.floor(terminal.rows / 2); + scroll -= Math.floor(terminal.rows / 2); terminal.scrollLines(scroll); } return true; diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index a7b3b816..c46b3815 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -487,9 +487,9 @@ function newArray(initial: T | ((index: number) => T), count: number): T[] { const array: T[] = new Array(count); for (let i = 0; i < array.length; i++) { if (typeof initial === 'function') { - array[i] = (<(index: number) => T>initial)(i); + array[i] = (initial as (index: number) => T)(i); } else { - array[i] = initial; + array[i] = initial as T; } } return array; diff --git a/addons/xterm-addon-webgl/src/GlyphRenderer.ts b/addons/xterm-addon-webgl/src/GlyphRenderer.ts index 8be4c011..b09fe540 100644 --- a/addons/xterm-addon-webgl/src/GlyphRenderer.ts +++ b/addons/xterm-addon-webgl/src/GlyphRenderer.ts @@ -263,7 +263,7 @@ export class GlyphRenderer { // Get attributes from fg (excluding inverse) and resolve inverse by pullibng rgb colors // from bg. This is needed since the inverse fg color should be based on the original bg // color, not on the selection color - fg = (fg & ~(Attributes.CM_MASK | Attributes.RGB_MASK | FgFlags.INVERSE)); + fg &= ~(Attributes.CM_MASK | Attributes.RGB_MASK | FgFlags.INVERSE); switch (workCell.getBgColorMode()) { case Attributes.CM_P16: case Attributes.CM_P256: diff --git a/addons/xterm-addon-webgl/src/WebglAddon.ts b/addons/xterm-addon-webgl/src/WebglAddon.ts index 91fa7968..ad2393d8 100644 --- a/addons/xterm-addon-webgl/src/WebglAddon.ts +++ b/addons/xterm-addon-webgl/src/WebglAddon.ts @@ -24,9 +24,9 @@ export class WebglAddon implements ITerminalAddon { throw new Error('Cannot activate WebglAddon before Terminal.open'); } this._terminal = terminal; - const renderService: IRenderService = (terminal)._core._renderService; - const characterJoinerService: ICharacterJoinerService = (terminal)._core._characterJoinerService; - const colors: IColorSet = (terminal)._core._colorManager.colors; + const renderService: IRenderService = (terminal as any)._core._renderService; + const characterJoinerService: ICharacterJoinerService = (terminal as any)._core._characterJoinerService; + const colors: IColorSet = (terminal as any)._core._colorManager.colors; this._renderer = new WebglRenderer(terminal, colors, characterJoinerService, this._preserveDrawingBuffer); this._renderer.onContextLoss(() => this._onContextLoss.fire()); renderService.setRenderer(this._renderer); diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index 3d25e5b0..9b75d1de 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -342,7 +342,7 @@ export class WebglRenderer extends Disposable implements IRenderer { // Flag combined chars with a bit mask so they're easily identifiable if (chars.length > 1) { - code = code | COMBINED_CHAR_BIT_MASK; + code |= COMBINED_CHAR_BIT_MASK; } // Cache the results in the model diff --git a/src/browser/AccessibilityManager.ts b/src/browser/AccessibilityManager.ts index e5cbb372..c1ffc39a 100644 --- a/src/browser/AccessibilityManager.ts +++ b/src/browser/AccessibilityManager.ts @@ -112,7 +112,7 @@ export class AccessibilityManager extends Disposable { } private _onBoundaryFocus(e: FocusEvent, position: BoundaryPosition): void { - const boundaryElement = e.target; + const boundaryElement = e.target as HTMLElement; const beforeBoundaryElement = this._rowElements[position === BoundaryPosition.TOP ? 1 : this._rowElements.length - 2]; // Don't scroll if the buffer top has reached the end in that direction diff --git a/src/browser/ColorManager.test.ts b/src/browser/ColorManager.test.ts index 766f4c12..926a7df3 100644 --- a/src/browser/ColorManager.test.ts +++ b/src/browser/ColorManager.test.ts @@ -17,7 +17,7 @@ describe('ColorManager', () => { dom = new jsdom.JSDOM(''); window = dom.window; document = window.document; - (window).HTMLCanvasElement.prototype.getContext = () => ({ + (window as any).HTMLCanvasElement.prototype.getContext = () => ({ createLinearGradient(): any { return null; }, @@ -36,7 +36,7 @@ describe('ColorManager', () => { for (const key of Object.keys(cm.colors)) { if (key !== 'ansi' && key !== 'contrastCache') { // A #rrggbb or rgba(...) - assert.ok((cm.colors)[key].css.length >= 7); + assert.ok((cm.colors as any)[key].css.length >= 7); } } assert.equal(cm.colors.ansi.length, 256); diff --git a/src/browser/Linkifier.test.ts b/src/browser/Linkifier.test.ts index 2567a669..a0755745 100644 --- a/src/browser/Linkifier.test.ts +++ b/src/browser/Linkifier.test.ts @@ -174,7 +174,7 @@ describe('Linkifier', () => { assert.equal(mouseZoneManager.zones[0].y1, 1); assert.equal(mouseZoneManager.zones[0].y2, 1); // Fires done() - mouseZoneManager.zones[0].clickCallback({}); + mouseZoneManager.zones[0].clickCallback({} as any); } }); linkifier.linkifyRows(); @@ -210,7 +210,7 @@ describe('Linkifier', () => { let count = 0; linkifier.registerLinkMatcher(/test/, () => assert.fail(), { validationCallback: (url, cb) => { - count += 1; + ++count; if (count === 2) { done(); } diff --git a/src/browser/Linkifier.ts b/src/browser/Linkifier.ts index 6d25e730..bad9d322 100644 --- a/src/browser/Linkifier.ts +++ b/src/browser/Linkifier.ts @@ -89,7 +89,7 @@ export class Linkifier implements ILinkifier { if (this._rowsTimeoutId) { clearTimeout(this._rowsTimeoutId); } - this._rowsTimeoutId = setTimeout(() => this._linkifyRows(), Linkifier._timeBeforeLatency); + this._rowsTimeoutId = setTimeout(() => this._linkifyRows(), Linkifier._timeBeforeLatency) as any as number; } /** diff --git a/src/browser/Terminal.test.ts b/src/browser/Terminal.test.ts index 140ec6e5..4947b92a 100644 --- a/src/browser/Terminal.test.ts +++ b/src/browser/Terminal.test.ts @@ -29,10 +29,10 @@ describe('Terminal', () => { beforeEach(() => { term = new TestTerminal(termOptions); term.refresh = () => { }; - (term).renderer = new MockRenderer(); + (term as any).renderer = new MockRenderer(); term.viewport = new MockViewport(); - (term)._compositionHelper = new MockCompositionHelper(); - (term).element = { + (term as any)._compositionHelper = new MockCompositionHelper(); + (term as any).element = { classList: { toggle: () => { }, remove: () => { } @@ -86,12 +86,12 @@ describe('Terminal', () => { assert.equal(e.domEvent instanceof Object, true); done(); }); - const evKeyPress = { + const evKeyPress = { preventDefault: () => { }, stopPropagation: () => { }, type: 'keypress', keyCode: 13 - }; + } as KeyboardEvent; term.keyPress(evKeyPress); }); it('should fire a key event after a keydown DOM event', (done) => { @@ -100,13 +100,13 @@ describe('Terminal', () => { assert.equal(e.domEvent instanceof Object, true); done(); }); - (term).textarea = { value: '' }; - const evKeyDown = { + (term as any).textarea = { value: '' }; + const evKeyDown = { preventDefault: () => { }, stopPropagation: () => { }, type: 'keydown', keyCode: 13 - }; + } as KeyboardEvent; term.keyDown(evKeyDown); }); it('should fire the onResize event', (done) => { @@ -140,18 +140,18 @@ describe('Terminal', () => { }); describe('attachCustomKeyEventHandler', () => { - const evKeyDown = { + const evKeyDown = { preventDefault: () => { }, stopPropagation: () => { }, type: 'keydown', keyCode: 77 - }; - const evKeyPress = { + } as KeyboardEvent; + const evKeyPress = { preventDefault: () => { }, stopPropagation: () => { }, type: 'keypress', keyCode: 77 - }; + } as KeyboardEvent; beforeEach(() => { term.clearSelection = () => { }; @@ -374,13 +374,13 @@ describe('Terminal', () => { describe('keyPress', () => { it('should scroll down, when a key is pressed and terminal is scrolled up', () => { - const event = { + const event = { type: 'keydown', key: 'a', keyCode: 65, preventDefault: () => { }, stopPropagation: () => { } - }; + } as KeyboardEvent; term.buffer.ydisp = 0; term.buffer.ybase = 40; @@ -403,7 +403,7 @@ describe('Terminal', () => { assert.equal(term.buffer.ydisp, startYDisp); term.scrollLines(-1); assert.equal(term.buffer.ydisp, startYDisp - 1); - term.keyPress({ keyCode: 0 }); + term.keyPress({ keyCode: 0 } as KeyboardEvent); assert.equal(term.buffer.ydisp, startYDisp - 1); }); }); diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 9d3838a6..5aed701a 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -72,7 +72,7 @@ export class Terminal extends CoreTerminal implements ITerminal { // private _visualBellTimer: number; - public browser: IBrowser = Browser; + public browser: IBrowser = Browser as any; // TODO: We should remove options once components adopt optionsService public get options(): IInitializedTerminalOptions { return this.optionsService.options; } @@ -601,7 +601,7 @@ export class Terminal extends CoreTerminal implements ITerminal { let but: CoreMouseButton; let action: CoreMouseAction | undefined; - switch ((ev).overrideType || ev.type) { + switch ((ev as any).overrideType || ev.type) { case 'mousemove': action = CoreMouseAction.MOVE; if (ev.buttons === undefined) { diff --git a/src/browser/Terminal2.test.ts b/src/browser/Terminal2.test.ts index 1ad0e905..9f073c33 100644 --- a/src/browser/Terminal2.test.ts +++ b/src/browser/Terminal2.test.ts @@ -105,7 +105,7 @@ function formatError(input: string, output: string, expected: string): string { function addLineNumber(start: number, color: string): (s: string) => string { let counter = start || 0; return (s: string): string => { - counter += 1; + ++counter; return '\x1b[33m' + (' ' + counter).slice(-2) + color + s; }; } diff --git a/src/browser/TestUtils.test.ts b/src/browser/TestUtils.test.ts index f9ad2a7d..9d5373c8 100644 --- a/src/browser/TestUtils.test.ts +++ b/src/browser/TestUtils.test.ts @@ -153,7 +153,7 @@ export class MockTerminal implements ITerminal { public textarea!: HTMLTextAreaElement; public rows!: number; public cols!: number; - public browser: IBrowser = Browser; + public browser: IBrowser = Browser as any; public writeBuffer!: string[]; public children!: HTMLElement[]; public cursorHidden!: boolean; diff --git a/src/common/Clone.ts b/src/common/Clone.ts index 51c5abaa..37821fe0 100644 --- a/src/common/Clone.ts +++ b/src/common/Clone.ts @@ -16,7 +16,7 @@ export function clone(val: T, depth: number = 5): T { for (const key in val) { // Recursively clone eack item unless we're at the maximum depth - clonedObject[key] = depth <= 1 ? val[key] : (val[key] ? clone(val[key], depth - 1) : val[key]); + clonedObject[key] = depth <= 1 ? val[key] : (val[key] && clone(val[key], depth - 1)); } return clonedObject as T; diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index cb60aec3..676b1e45 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -77,7 +77,7 @@ describe('InputHandler', () => { optionsService.options.scrollback = 1; bufferService.reset(); }); - it('SL (scrollLeft)', async () => { + it('SL (scrollLeft)', () => { inputHandler.parseP('12345'.repeat(6)); inputHandler.parseP('\x1b[ @'); assert.deepEqual(getLines(bufferService, 6), ['12345', '2345', '2345', '2345', '2345', '2345']); @@ -86,7 +86,7 @@ describe('InputHandler', () => { inputHandler.parseP('\x1b[2 @'); assert.deepEqual(getLines(bufferService, 6), ['12345', '5', '5', '5', '5', '5']); }); - it('SR (scrollRight)', async () => { + it('SR (scrollRight)', () => { inputHandler.parseP('12345'.repeat(6)); inputHandler.parseP('\x1b[ A'); assert.deepEqual(getLines(bufferService, 6), ['12345', ' 1234', ' 1234', ' 1234', ' 1234', ' 1234']); @@ -95,7 +95,7 @@ describe('InputHandler', () => { inputHandler.parseP('\x1b[2 A'); assert.deepEqual(getLines(bufferService, 6), ['12345', ' 1', ' 1', ' 1', ' 1', ' 1']); }); - it('insertColumns (DECIC)', async () => { + it('insertColumns (DECIC)', () => { inputHandler.parseP('12345'.repeat(6)); inputHandler.parseP('\x1b[3;3H'); inputHandler.parseP('\x1b[\'}'); @@ -111,7 +111,7 @@ describe('InputHandler', () => { inputHandler.parseP('\x1b[2\'}'); assert.deepEqual(getLines(bufferService, 6), ['12345', '12 3', '12 3', '12 3', '12 3', '12 3']); }); - it('deleteColumns (DECDC)', async () => { + it('deleteColumns (DECDC)', () => { inputHandler.parseP('12345'.repeat(6)); inputHandler.parseP('\x1b[3;3H'); inputHandler.parseP('\x1b[\'~'); @@ -137,7 +137,7 @@ describe('InputHandler', () => { bufferService.reset(); }); describe('reverseWraparound set', () => { - it('should not reverse outside of scroll margins', async () => { + it('should not reverse outside of scroll margins', () => { // prepare buffer content inputHandler.parseP('#####abcdefghijklmnopqrstuvwxy'); assert.deepEqual(getLines(bufferService, 6), ['#####', 'abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy']); diff --git a/src/common/TestUtils.test.ts b/src/common/TestUtils.test.ts index dce0f570..52fe00d0 100644 --- a/src/common/TestUtils.test.ts +++ b/src/common/TestUtils.test.ts @@ -125,7 +125,7 @@ export class MockOptionsService implements IOptionsService { constructor(testOptions?: IPartialTerminalOptions) { if (testOptions) { for (const key of Object.keys(testOptions)) { - this.options[key] = (testOptions)[key]; + this.options[key] = (testOptions as any)[key]; } } } From c9eab73bd431ca2a4582a5eb5be451c1f9805ae1 Mon Sep 17 00:00:00 2001 From: Simon Lamon Date: Sat, 15 May 2021 16:06:30 +0200 Subject: [PATCH 209/377] devcontainer: upgrade to node v14.x --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index e5736562..141f7711 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM node:10 +FROM node:14 # Configure apt ENV DEBIAN_FRONTEND=noninteractive From d19a740825449ef13560109e739e1f7de89ecdad Mon Sep 17 00:00:00 2001 From: Simon Lamon Date: Sat, 15 May 2021 17:35:23 +0200 Subject: [PATCH 210/377] Support strikethrough text style --- css/xterm.css | 4 ++++ src/browser/renderer/BaseRenderLayer.ts | 15 +++++++++++++++ src/browser/renderer/TextRenderLayer.ts | 9 +++++++-- .../renderer/dom/DomRendererRowFactory.test.ts | 10 ++++++++++ src/browser/renderer/dom/DomRendererRowFactory.ts | 5 +++++ src/common/InputHandler.test.ts | 6 ++++++ src/common/InputHandler.ts | 6 ++++++ src/common/Types.d.ts | 1 + src/common/buffer/AttributeData.ts | 15 ++++++++------- src/common/buffer/Constants.ts | 5 +++-- 10 files changed, 65 insertions(+), 11 deletions(-) diff --git a/css/xterm.css b/css/xterm.css index 831a89c6..3fab18bd 100644 --- a/css/xterm.css +++ b/css/xterm.css @@ -168,3 +168,7 @@ .xterm-underline { text-decoration: underline; } + +.xterm-strikethrough { + text-decoration: line-through; +} diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index ef869ef3..7986e510 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -152,6 +152,21 @@ export abstract class BaseRenderLayer implements IRenderLayer { height * this._scaledCellHeight); } + /** + * Fills a 1px line (2px on HDPI) at the middle of the cell. This uses the + * existing fillStyle on the context. + * @param x The column to fill. + * @param y The row to fill. + */ + protected _fillMiddleLineAtCells(x: number, y: number, width: number = 1): void { + const cellOffset = Math.ceil(this._scaledCellHeight * 0.5); + this._ctx.fillRect( + x * this._scaledCellWidth, + (y + 1) * this._scaledCellHeight - cellOffset - window.devicePixelRatio, + width * this._scaledCellWidth, + window.devicePixelRatio); + } + /** * Fills a 1px line (2px on HDPI) at the bottom of the cell. This uses the * existing fillStyle on the context. diff --git a/src/browser/renderer/TextRenderLayer.ts b/src/browser/renderer/TextRenderLayer.ts index ded6c9c6..59fbb7b1 100644 --- a/src/browser/renderer/TextRenderLayer.ts +++ b/src/browser/renderer/TextRenderLayer.ts @@ -215,7 +215,7 @@ export class TextRenderLayer extends BaseRenderLayer { return; } this._drawChars(cell, x, y); - if (cell.isUnderline()) { + if (cell.isUnderline() || cell.isStrikethrough()) { this._ctx.save(); if (cell.isInverse()) { @@ -244,7 +244,12 @@ export class TextRenderLayer extends BaseRenderLayer { } } - this._fillBottomLineAtCells(x, y, cell.getWidth()); + if (cell.isStrikethrough()) { + this._fillMiddleLineAtCells(x, y, cell.getWidth()); + } + if (cell.isUnderline()) { + this._fillBottomLineAtCells(x, y, cell.getWidth()); + } this._ctx.restore(); } }); diff --git a/src/browser/renderer/dom/DomRendererRowFactory.test.ts b/src/browser/renderer/dom/DomRendererRowFactory.test.ts index 9eacb97a..2f8d264a 100644 --- a/src/browser/renderer/dom/DomRendererRowFactory.test.ts +++ b/src/browser/renderer/dom/DomRendererRowFactory.test.ts @@ -132,6 +132,16 @@ describe('DomRendererRowFactory', () => { ); }); + it('should add class for strikethrough', () => { + const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]); + cell.fg = DEFAULT_ATTR_DATA.fg | FgFlags.STRIKETHROUGH; + lineData.setCell(0, cell); + const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20); + assert.equal(getFragmentHtml(fragment), + 'a' + ); + }); + it('should add classes for 256 foreground colors', () => { const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]); cell.fg |= Attributes.CM_P256; diff --git a/src/browser/renderer/dom/DomRendererRowFactory.ts b/src/browser/renderer/dom/DomRendererRowFactory.ts index eb2dd1fc..a61ebd73 100644 --- a/src/browser/renderer/dom/DomRendererRowFactory.ts +++ b/src/browser/renderer/dom/DomRendererRowFactory.ts @@ -17,6 +17,7 @@ export const BOLD_CLASS = 'xterm-bold'; export const DIM_CLASS = 'xterm-dim'; export const ITALIC_CLASS = 'xterm-italic'; export const UNDERLINE_CLASS = 'xterm-underline'; +export const STRIKETHROUGH_CLASS = 'xterm-strikethrough'; export const CURSOR_CLASS = 'xterm-cursor'; export const CURSOR_BLINK_CLASS = 'xterm-cursor-blink'; export const CURSOR_STYLE_BLOCK_CLASS = 'xterm-cursor-block'; @@ -151,6 +152,10 @@ export class DomRendererRowFactory { charElement.textContent = cell.getChars() || WHITESPACE_CELL_CHAR; } + if (cell.isStrikethrough()) { + charElement.classList.add(STRIKETHROUGH_CLASS); + } + let fg = cell.getFgColor(); let fgColorMode = cell.getFgColorMode(); let bg = cell.getBgColor(); diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index cb60aec3..25b602ea 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -636,6 +636,12 @@ describe('InputHandler', () => { await inputHandler.parseP('\x1b[28m'); assert.equal(!!inputHandler.curAttrData.isInvisible(), false); }); + it('strikethrough', async () => { + await inputHandler.parseP('\x1b[9m'); + assert.equal(!!inputHandler.curAttrData.isStrikethrough(), true); + await inputHandler.parseP('\x1b[29m'); + assert.equal(!!inputHandler.curAttrData.isStrikethrough(), false); + }); it('colormode palette 16', async () => { assert.equal(inputHandler.curAttrData.getFgColorMode(), 0); // DEFAULT assert.equal(inputHandler.curAttrData.getBgColorMode(), 0); // DEFAULT diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index a2b5a782..06f4ac9f 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -2478,6 +2478,9 @@ export class InputHandler extends Disposable implements IInputHandler { } else if (p === 8) { // invisible attr.fg |= FgFlags.INVISIBLE; + } else if (p === 9) { + // strikethrough + attr.fg |= FgFlags.STRIKETHROUGH; } else if (p === 2) { // dimmed text attr.bg |= BgFlags.DIM; @@ -2503,6 +2506,9 @@ export class InputHandler extends Disposable implements IInputHandler { } else if (p === 28) { // not invisible attr.fg &= ~FgFlags.INVISIBLE; + } else if (p === 29) { + // not strikethrough + attr.fg &= ~FgFlags.STRIKETHROUGH; } else if (p === 39) { // reset fg attr.fg &= ~(Attributes.CM_MASK | Attributes.RGB_MASK); diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index df299195..51f7e172 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -117,6 +117,7 @@ export interface IAttributeData { isInvisible(): number; isItalic(): number; isDim(): number; + isStrikethrough(): number; // color modes getFgColorMode(): number; diff --git a/src/common/buffer/AttributeData.ts b/src/common/buffer/AttributeData.ts index c7217a2a..43d378ea 100644 --- a/src/common/buffer/AttributeData.ts +++ b/src/common/buffer/AttributeData.ts @@ -33,13 +33,14 @@ export class AttributeData implements IAttributeData { public extended = new ExtendedAttrs(); // flags - public isInverse(): number { return this.fg & FgFlags.INVERSE; } - public isBold(): number { return this.fg & FgFlags.BOLD; } - public isUnderline(): number { return this.fg & FgFlags.UNDERLINE; } - public isBlink(): number { return this.fg & FgFlags.BLINK; } - public isInvisible(): number { return this.fg & FgFlags.INVISIBLE; } - public isItalic(): number { return this.bg & BgFlags.ITALIC; } - public isDim(): number { return this.bg & BgFlags.DIM; } + public isInverse(): number { return this.fg & FgFlags.INVERSE; } + public isBold(): number { return this.fg & FgFlags.BOLD; } + public isUnderline(): number { return this.fg & FgFlags.UNDERLINE; } + public isBlink(): number { return this.fg & FgFlags.BLINK; } + public isInvisible(): number { return this.fg & FgFlags.INVISIBLE; } + public isItalic(): number { return this.bg & BgFlags.ITALIC; } + public isDim(): number { return this.bg & BgFlags.DIM; } + public isStrikethrough(): number { return this.fg & FgFlags.STRIKETHROUGH; } // color modes public getFgColorMode(): number { return this.fg & Attributes.CM_MASK; } diff --git a/src/common/buffer/Constants.ts b/src/common/buffer/Constants.ts index ee86a804..a2c1b884 100644 --- a/src/common/buffer/Constants.ts +++ b/src/common/buffer/Constants.ts @@ -110,13 +110,14 @@ export const enum Attributes { export const enum FgFlags { /** - * bit 27..31 (32th bit unused) + * bit 27..32 */ INVERSE = 0x4000000, BOLD = 0x8000000, UNDERLINE = 0x10000000, BLINK = 0x20000000, - INVISIBLE = 0x40000000 + INVISIBLE = 0x40000000, + STRIKETHROUGH = 0x80000000, } export const enum BgFlags { From 0131fc9ebf7ae84bc9bd0aecaae0f768238526f0 Mon Sep 17 00:00:00 2001 From: Adarsh TS Date: Sun, 16 May 2021 09:39:18 +0530 Subject: [PATCH 211/377] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 33f6b6d4..f16cb640 100644 --- a/README.md +++ b/README.md @@ -175,6 +175,7 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**gifcast**](https://dstein64.github.io/gifcast/): Converts an asciinema cast to an animated GIF. - [**WizardWebssh**](https://gitlab.com/mikeramsey/wizardwebssh): A terminal with Pyqt5 Widget for embedding, which can be used as an ssh client to connect to your ssh servers. It is written in Python, based on tornado, paramiko, and xterm.js. - [**Wizard Assistant**](https://wizardassistant.com/): Wizard Assistant comes with advanced automation tools, preloaded common and special time-saving commands, and a built-in SSH terminal. Now you can remotely administer, troubleshoot, and analyze any system with ease. +- [**ucli**](https://github.com/tsadarsh/ucli): Command Line for everyone :family_man_woman_girl_boy: at [www.ucli.tech](https://www.ucli.tech). [And much more...](https://github.com/xtermjs/xterm.js/network/dependents) Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it on our list. Note: Please add any new contributions to the end of the list only. From ea7f89842a7523c7cd1ac38e112a2b71db5711ae Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 17 May 2021 17:45:35 +0300 Subject: [PATCH 212/377] chore: browser: Linkifier: increment --- src/browser/Linkifier.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/Linkifier.test.ts b/src/browser/Linkifier.test.ts index a0755745..a07f69ed 100644 --- a/src/browser/Linkifier.test.ts +++ b/src/browser/Linkifier.test.ts @@ -210,7 +210,7 @@ describe('Linkifier', () => { let count = 0; linkifier.registerLinkMatcher(/test/, () => assert.fail(), { validationCallback: (url, cb) => { - ++count; + count++; if (count === 2) { done(); } From f8d8288e0e75571a7c9216c7e00633e836753f3f Mon Sep 17 00:00:00 2001 From: Squitch <63391793+SquitchYT@users.noreply.github.com> Date: Mon, 24 May 2021 20:27:07 +0200 Subject: [PATCH 213/377] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f16cb640..84b89b1b 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,7 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**WizardWebssh**](https://gitlab.com/mikeramsey/wizardwebssh): A terminal with Pyqt5 Widget for embedding, which can be used as an ssh client to connect to your ssh servers. It is written in Python, based on tornado, paramiko, and xterm.js. - [**Wizard Assistant**](https://wizardassistant.com/): Wizard Assistant comes with advanced automation tools, preloaded common and special time-saving commands, and a built-in SSH terminal. Now you can remotely administer, troubleshoot, and analyze any system with ease. - [**ucli**](https://github.com/tsadarsh/ucli): Command Line for everyone :family_man_woman_girl_boy: at [www.ucli.tech](https://www.ucli.tech). +- [**Tess**](https://github.com/SquitchYT/Tess/): Simple Terminal Fully Customizable for Everyone [And much more...](https://github.com/xtermjs/xterm.js/network/dependents) Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it on our list. Note: Please add any new contributions to the end of the list only. From 579e43c4ccb4f169df9089f891a2c73180180b05 Mon Sep 17 00:00:00 2001 From: Squitch <63391793+SquitchYT@users.noreply.github.com> Date: Mon, 24 May 2021 20:30:33 +0200 Subject: [PATCH 214/377] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 84b89b1b..32876ed2 100644 --- a/README.md +++ b/README.md @@ -176,8 +176,7 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**WizardWebssh**](https://gitlab.com/mikeramsey/wizardwebssh): A terminal with Pyqt5 Widget for embedding, which can be used as an ssh client to connect to your ssh servers. It is written in Python, based on tornado, paramiko, and xterm.js. - [**Wizard Assistant**](https://wizardassistant.com/): Wizard Assistant comes with advanced automation tools, preloaded common and special time-saving commands, and a built-in SSH terminal. Now you can remotely administer, troubleshoot, and analyze any system with ease. - [**ucli**](https://github.com/tsadarsh/ucli): Command Line for everyone :family_man_woman_girl_boy: at [www.ucli.tech](https://www.ucli.tech). -- [**Tess**](https://github.com/SquitchYT/Tess/): Simple Terminal Fully Customizable for Everyone -[And much more...](https://github.com/xtermjs/xterm.js/network/dependents) +- [**Tess**](https://github.com/SquitchYT/Tess/): Simple Terminal Fully Customizable for Everyone. [And much more...](https://github.com/xtermjs/xterm.js/network/dependents) Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it on our list. Note: Please add any new contributions to the end of the list only. From dc1b1b4537b381fa25b808a9a8df3f9837c8387f Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 24 May 2021 11:55:53 -0700 Subject: [PATCH 215/377] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 32876ed2..b1f25995 100644 --- a/README.md +++ b/README.md @@ -176,7 +176,8 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**WizardWebssh**](https://gitlab.com/mikeramsey/wizardwebssh): A terminal with Pyqt5 Widget for embedding, which can be used as an ssh client to connect to your ssh servers. It is written in Python, based on tornado, paramiko, and xterm.js. - [**Wizard Assistant**](https://wizardassistant.com/): Wizard Assistant comes with advanced automation tools, preloaded common and special time-saving commands, and a built-in SSH terminal. Now you can remotely administer, troubleshoot, and analyze any system with ease. - [**ucli**](https://github.com/tsadarsh/ucli): Command Line for everyone :family_man_woman_girl_boy: at [www.ucli.tech](https://www.ucli.tech). -- [**Tess**](https://github.com/SquitchYT/Tess/): Simple Terminal Fully Customizable for Everyone. [And much more...](https://github.com/xtermjs/xterm.js/network/dependents) +- [**Tess**](https://github.com/SquitchYT/Tess/): Simple Terminal Fully Customizable for Everyone. +- [And much more...](https://github.com/xtermjs/xterm.js/network/dependents) Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it on our list. Note: Please add any new contributions to the end of the list only. From 64b37ef518fe330cd1bb104b26624d3a2833900d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 29 May 2021 03:56:37 +0000 Subject: [PATCH 216/377] Bump ws from 7.4.5 to 7.4.6 Bumps [ws](https://github.com/websockets/ws) from 7.4.5 to 7.4.6. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/7.4.5...7.4.6) Signed-off-by: dependabot[bot] --- yarn.lock | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/yarn.lock b/yarn.lock index 5edf8871..712bdc47 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4694,15 +4694,10 @@ ws@^5.2.0: dependencies: async-limiter "~1.0.0" -ws@^7.2.3: - version "7.3.1" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.3.1.tgz#d0547bf67f7ce4f12a72dfe31262c68d7dc551c8" - integrity sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA== - -ws@^7.3.1, ws@^7.4.4, ws@^7.4.5: - version "7.4.5" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.5.tgz#a484dd851e9beb6fdb420027e3885e8ce48986c1" - integrity sha512-xzyu3hFvomRfXKH8vOFMU3OguG6oOvhXMo3xsGy3xWExqaM2dxBbVxuD99O7m3ZUFMvvscsZDqxfgMaRr/Nr1g== +ws@^7.2.3, ws@^7.3.1, ws@^7.4.4, ws@^7.4.5: + version "7.4.6" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.6.tgz#5654ca8ecdeee47c33a9a4bf6d28e2be2980377c" + integrity sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A== xml-name-validator@^3.0.0: version "3.0.0" From f52d631fa4b703dafa8e17b1356f4ee159484409 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 4 Jun 2021 06:23:12 -0700 Subject: [PATCH 217/377] Add eslint type assertions rule Fixes #3359 --- .eslintrc.json | 1 + .../test/SerializeAddon.api.ts | 4 +- addons/xterm-addon-webgl/src/WebglAddon.ts | 6 +-- src/browser/AccessibilityManager.ts | 2 +- src/browser/ColorManager.test.ts | 4 +- src/browser/Linkifier.test.ts | 2 +- src/browser/Linkifier.ts | 2 +- src/browser/Terminal.test.ts | 30 ++++++------ src/browser/Terminal.ts | 4 +- src/browser/TestUtils.test.ts | 2 +- src/browser/input/CompositionHelper.test.ts | 48 +++++++++---------- src/browser/input/CompositionHelper.ts | 2 +- src/browser/public/AddonManager.ts | 2 +- src/browser/public/Terminal.ts | 2 +- src/browser/renderer/atlas/CharAtlasUtils.ts | 2 +- src/browser/renderer/dom/DomRenderer.ts | 2 +- .../services/CharacterJoinerService.test.ts | 2 +- src/browser/services/SelectionService.ts | 4 +- src/browser/services/SoundService.ts | 2 +- src/common/TestUtils.test.ts | 2 +- 20 files changed, 63 insertions(+), 62 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 390e2c54..6031c195 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -47,6 +47,7 @@ "readonly": "generic" } ], + "@typescript-eslint/consistent-type-assertions": "warn", "@typescript-eslint/consistent-type-definitions": "warn", "@typescript-eslint/explicit-function-return-type": [ "warn", diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index a7b3b816..c46b3815 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -487,9 +487,9 @@ function newArray(initial: T | ((index: number) => T), count: number): T[] { const array: T[] = new Array(count); for (let i = 0; i < array.length; i++) { if (typeof initial === 'function') { - array[i] = (<(index: number) => T>initial)(i); + array[i] = (initial as (index: number) => T)(i); } else { - array[i] = initial; + array[i] = initial as T; } } return array; diff --git a/addons/xterm-addon-webgl/src/WebglAddon.ts b/addons/xterm-addon-webgl/src/WebglAddon.ts index 91fa7968..ad2393d8 100644 --- a/addons/xterm-addon-webgl/src/WebglAddon.ts +++ b/addons/xterm-addon-webgl/src/WebglAddon.ts @@ -24,9 +24,9 @@ export class WebglAddon implements ITerminalAddon { throw new Error('Cannot activate WebglAddon before Terminal.open'); } this._terminal = terminal; - const renderService: IRenderService = (terminal)._core._renderService; - const characterJoinerService: ICharacterJoinerService = (terminal)._core._characterJoinerService; - const colors: IColorSet = (terminal)._core._colorManager.colors; + const renderService: IRenderService = (terminal as any)._core._renderService; + const characterJoinerService: ICharacterJoinerService = (terminal as any)._core._characterJoinerService; + const colors: IColorSet = (terminal as any)._core._colorManager.colors; this._renderer = new WebglRenderer(terminal, colors, characterJoinerService, this._preserveDrawingBuffer); this._renderer.onContextLoss(() => this._onContextLoss.fire()); renderService.setRenderer(this._renderer); diff --git a/src/browser/AccessibilityManager.ts b/src/browser/AccessibilityManager.ts index e5cbb372..c1ffc39a 100644 --- a/src/browser/AccessibilityManager.ts +++ b/src/browser/AccessibilityManager.ts @@ -112,7 +112,7 @@ export class AccessibilityManager extends Disposable { } private _onBoundaryFocus(e: FocusEvent, position: BoundaryPosition): void { - const boundaryElement = e.target; + const boundaryElement = e.target as HTMLElement; const beforeBoundaryElement = this._rowElements[position === BoundaryPosition.TOP ? 1 : this._rowElements.length - 2]; // Don't scroll if the buffer top has reached the end in that direction diff --git a/src/browser/ColorManager.test.ts b/src/browser/ColorManager.test.ts index 766f4c12..926a7df3 100644 --- a/src/browser/ColorManager.test.ts +++ b/src/browser/ColorManager.test.ts @@ -17,7 +17,7 @@ describe('ColorManager', () => { dom = new jsdom.JSDOM(''); window = dom.window; document = window.document; - (window).HTMLCanvasElement.prototype.getContext = () => ({ + (window as any).HTMLCanvasElement.prototype.getContext = () => ({ createLinearGradient(): any { return null; }, @@ -36,7 +36,7 @@ describe('ColorManager', () => { for (const key of Object.keys(cm.colors)) { if (key !== 'ansi' && key !== 'contrastCache') { // A #rrggbb or rgba(...) - assert.ok((cm.colors)[key].css.length >= 7); + assert.ok((cm.colors as any)[key].css.length >= 7); } } assert.equal(cm.colors.ansi.length, 256); diff --git a/src/browser/Linkifier.test.ts b/src/browser/Linkifier.test.ts index 2567a669..29be9b70 100644 --- a/src/browser/Linkifier.test.ts +++ b/src/browser/Linkifier.test.ts @@ -174,7 +174,7 @@ describe('Linkifier', () => { assert.equal(mouseZoneManager.zones[0].y1, 1); assert.equal(mouseZoneManager.zones[0].y2, 1); // Fires done() - mouseZoneManager.zones[0].clickCallback({}); + mouseZoneManager.zones[0].clickCallback({} as any); } }); linkifier.linkifyRows(); diff --git a/src/browser/Linkifier.ts b/src/browser/Linkifier.ts index 6d25e730..3d70770d 100644 --- a/src/browser/Linkifier.ts +++ b/src/browser/Linkifier.ts @@ -89,7 +89,7 @@ export class Linkifier implements ILinkifier { if (this._rowsTimeoutId) { clearTimeout(this._rowsTimeoutId); } - this._rowsTimeoutId = setTimeout(() => this._linkifyRows(), Linkifier._timeBeforeLatency); + this._rowsTimeoutId = window.setTimeout(() => this._linkifyRows(), Linkifier._timeBeforeLatency); } /** diff --git a/src/browser/Terminal.test.ts b/src/browser/Terminal.test.ts index 140ec6e5..84e6a87e 100644 --- a/src/browser/Terminal.test.ts +++ b/src/browser/Terminal.test.ts @@ -29,10 +29,10 @@ describe('Terminal', () => { beforeEach(() => { term = new TestTerminal(termOptions); term.refresh = () => { }; - (term).renderer = new MockRenderer(); + (term as any).renderer = new MockRenderer(); term.viewport = new MockViewport(); - (term)._compositionHelper = new MockCompositionHelper(); - (term).element = { + (term as any)._compositionHelper = new MockCompositionHelper(); + (term as any).element = { classList: { toggle: () => { }, remove: () => { } @@ -86,12 +86,12 @@ describe('Terminal', () => { assert.equal(e.domEvent instanceof Object, true); done(); }); - const evKeyPress = { + const evKeyPress = { preventDefault: () => { }, stopPropagation: () => { }, type: 'keypress', keyCode: 13 - }; + } as KeyboardEvent; term.keyPress(evKeyPress); }); it('should fire a key event after a keydown DOM event', (done) => { @@ -100,13 +100,13 @@ describe('Terminal', () => { assert.equal(e.domEvent instanceof Object, true); done(); }); - (term).textarea = { value: '' }; - const evKeyDown = { + (term as any).textarea = { value: '' }; + const evKeyDown = { preventDefault: () => { }, stopPropagation: () => { }, type: 'keydown', keyCode: 13 - }; + } as KeyboardEvent; term.keyDown(evKeyDown); }); it('should fire the onResize event', (done) => { @@ -140,18 +140,18 @@ describe('Terminal', () => { }); describe('attachCustomKeyEventHandler', () => { - const evKeyDown = { + const evKeyDown = { preventDefault: () => { }, stopPropagation: () => { }, type: 'keydown', keyCode: 77 - }; - const evKeyPress = { + } as KeyboardEvent; + const evKeyPress = { preventDefault: () => { }, stopPropagation: () => { }, type: 'keypress', keyCode: 77 - }; + } as KeyboardEvent; beforeEach(() => { term.clearSelection = () => { }; @@ -374,13 +374,13 @@ describe('Terminal', () => { describe('keyPress', () => { it('should scroll down, when a key is pressed and terminal is scrolled up', () => { - const event = { + const event = { type: 'keydown', key: 'a', keyCode: 65, preventDefault: () => { }, stopPropagation: () => { } - }; + } as KeyboardEvent; term.buffer.ydisp = 0; term.buffer.ybase = 40; @@ -403,7 +403,7 @@ describe('Terminal', () => { assert.equal(term.buffer.ydisp, startYDisp); term.scrollLines(-1); assert.equal(term.buffer.ydisp, startYDisp - 1); - term.keyPress({ keyCode: 0 }); + term.keyPress({ keyCode: 0 }); assert.equal(term.buffer.ydisp, startYDisp - 1); }); }); diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 9d3838a6..5aed701a 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -72,7 +72,7 @@ export class Terminal extends CoreTerminal implements ITerminal { // private _visualBellTimer: number; - public browser: IBrowser = Browser; + public browser: IBrowser = Browser as any; // TODO: We should remove options once components adopt optionsService public get options(): IInitializedTerminalOptions { return this.optionsService.options; } @@ -601,7 +601,7 @@ export class Terminal extends CoreTerminal implements ITerminal { let but: CoreMouseButton; let action: CoreMouseAction | undefined; - switch ((ev).overrideType || ev.type) { + switch ((ev as any).overrideType || ev.type) { case 'mousemove': action = CoreMouseAction.MOVE; if (ev.buttons === undefined) { diff --git a/src/browser/TestUtils.test.ts b/src/browser/TestUtils.test.ts index f9ad2a7d..9d5373c8 100644 --- a/src/browser/TestUtils.test.ts +++ b/src/browser/TestUtils.test.ts @@ -153,7 +153,7 @@ export class MockTerminal implements ITerminal { public textarea!: HTMLTextAreaElement; public rows!: number; public cols!: number; - public browser: IBrowser = Browser; + public browser: IBrowser = Browser as any; public writeBuffer!: string[]; public children!: HTMLElement[]; public cursorHidden!: boolean; diff --git a/src/browser/input/CompositionHelper.test.ts b/src/browser/input/CompositionHelper.test.ts index c722570b..e29111e1 100644 --- a/src/browser/input/CompositionHelper.test.ts +++ b/src/browser/input/CompositionHelper.test.ts @@ -49,7 +49,7 @@ describe('CompositionHelper', () => { it('Should insert simple characters', (done) => { // First character 'ㅇ' compositionHelper.compositionstart(); - compositionHelper.compositionupdate({ data: 'ㅇ' }); + compositionHelper.compositionupdate({ data: 'ㅇ' }); textarea.value = 'ㅇ'; setTimeout(() => { // wait for any textarea updates compositionHelper.compositionend(); @@ -57,7 +57,7 @@ describe('CompositionHelper', () => { assert.equal(handledText, 'ㅇ'); // Second character 'ㅇ' compositionHelper.compositionstart(); - compositionHelper.compositionupdate({ data: 'ㅇ' }); + compositionHelper.compositionupdate({ data: 'ㅇ' }); textarea.value = 'ㅇㅇ'; setTimeout(() => { // wait for any textarea updates compositionHelper.compositionend(); @@ -73,13 +73,13 @@ describe('CompositionHelper', () => { it('Should insert complex characters', (done) => { // First character '앙' compositionHelper.compositionstart(); - compositionHelper.compositionupdate({ data: 'ㅇ' }); + compositionHelper.compositionupdate({ data: 'ㅇ' }); textarea.value = 'ㅇ'; setTimeout(() => { // wait for any textarea updates - compositionHelper.compositionupdate({ data: '아' }); + compositionHelper.compositionupdate({ data: '아' }); textarea.value = '아'; setTimeout(() => { // wait for any textarea updates - compositionHelper.compositionupdate({ data: '앙' }); + compositionHelper.compositionupdate({ data: '앙' }); textarea.value = '앙'; setTimeout(() => { // wait for any textarea updates compositionHelper.compositionend(); @@ -87,13 +87,13 @@ describe('CompositionHelper', () => { assert.equal(handledText, '앙'); // Second character '앙' compositionHelper.compositionstart(); - compositionHelper.compositionupdate({ data: 'ㅇ' }); + compositionHelper.compositionupdate({ data: 'ㅇ' }); textarea.value = '앙ㅇ'; setTimeout(() => { // wait for any textarea updates - compositionHelper.compositionupdate({ data: '아' }); + compositionHelper.compositionupdate({ data: '아' }); textarea.value = '앙아'; setTimeout(() => { // wait for any textarea updates - compositionHelper.compositionupdate({ data: '앙' }); + compositionHelper.compositionupdate({ data: '앙' }); textarea.value = '앙앙'; setTimeout(() => { // wait for any textarea updates compositionHelper.compositionend(); @@ -113,19 +113,19 @@ describe('CompositionHelper', () => { it('Should insert complex characters that change with following character', (done) => { // First character '아' compositionHelper.compositionstart(); - compositionHelper.compositionupdate({ data: 'ㅇ' }); + compositionHelper.compositionupdate({ data: 'ㅇ' }); textarea.value = 'ㅇ'; setTimeout(() => { // wait for any textarea updates - compositionHelper.compositionupdate({ data: '아' }); + compositionHelper.compositionupdate({ data: '아' }); textarea.value = '아'; setTimeout(() => { // wait for any textarea updates // Start second character '아' in first character - compositionHelper.compositionupdate({ data: '앙' }); + compositionHelper.compositionupdate({ data: '앙' }); textarea.value = '앙'; setTimeout(() => { // wait for any textarea updates compositionHelper.compositionend(); compositionHelper.compositionstart(); - compositionHelper.compositionupdate({ data: '아' }); + compositionHelper.compositionupdate({ data: '아' }); textarea.value = '아아'; setTimeout(() => { // wait for any textarea updates compositionHelper.compositionend(); @@ -142,14 +142,14 @@ describe('CompositionHelper', () => { it('Should insert multi-characters compositions', (done) => { // First character 'だ' compositionHelper.compositionstart(); - compositionHelper.compositionupdate({ data: 'd' }); + compositionHelper.compositionupdate({ data: 'd' }); textarea.value = 'd'; setTimeout(() => { // wait for any textarea updates - compositionHelper.compositionupdate({ data: 'だ' }); + compositionHelper.compositionupdate({ data: 'だ' }); textarea.value = 'だ'; setTimeout(() => { // wait for any textarea updates // Second character 'あ' - compositionHelper.compositionupdate({ data: 'だあ' }); + compositionHelper.compositionupdate({ data: 'だあ' }); textarea.value = 'だあ'; setTimeout(() => { // wait for any textarea updates compositionHelper.compositionend(); @@ -165,18 +165,18 @@ describe('CompositionHelper', () => { it('Should insert multi-character compositions that are converted to other characters with the same length', (done) => { // First character 'だ' compositionHelper.compositionstart(); - compositionHelper.compositionupdate({ data: 'd' }); + compositionHelper.compositionupdate({ data: 'd' }); textarea.value = 'd'; setTimeout(() => { // wait for any textarea updates - compositionHelper.compositionupdate({ data: 'だ' }); + compositionHelper.compositionupdate({ data: 'だ' }); textarea.value = 'だ'; setTimeout(() => { // wait for any textarea updates // Second character 'ー' - compositionHelper.compositionupdate({ data: 'だー' }); + compositionHelper.compositionupdate({ data: 'だー' }); textarea.value = 'だー'; setTimeout(() => { // wait for any textarea updates // Convert to katakana 'ダー' - compositionHelper.compositionupdate({ data: 'ダー' }); + compositionHelper.compositionupdate({ data: 'ダー' }); textarea.value = 'ダー'; setTimeout(() => { // wait for any textarea updates compositionHelper.compositionend(); @@ -193,18 +193,18 @@ describe('CompositionHelper', () => { it('Should insert multi-character compositions that are converted to other characters with different lengths', (done) => { // First character 'い' compositionHelper.compositionstart(); - compositionHelper.compositionupdate({ data: 'い' }); + compositionHelper.compositionupdate({ data: 'い' }); textarea.value = 'い'; setTimeout(() => { // wait for any textarea updates // Second character 'ま' - compositionHelper.compositionupdate({ data: 'いm' }); + compositionHelper.compositionupdate({ data: 'いm' }); textarea.value = 'いm'; setTimeout(() => { // wait for any textarea updates - compositionHelper.compositionupdate({ data: 'いま' }); + compositionHelper.compositionupdate({ data: 'いま' }); textarea.value = 'いま'; setTimeout(() => { // wait for any textarea updates // Convert to kanji '今' - compositionHelper.compositionupdate({ data: '今' }); + compositionHelper.compositionupdate({ data: '今' }); textarea.value = '今'; setTimeout(() => { // wait for any textarea updates compositionHelper.compositionend(); @@ -221,7 +221,7 @@ describe('CompositionHelper', () => { it('Should insert non-composition characters input immediately after composition characters', (done) => { // First character 'ㅇ' compositionHelper.compositionstart(); - compositionHelper.compositionupdate({ data: 'ㅇ' }); + compositionHelper.compositionupdate({ data: 'ㅇ' }); textarea.value = 'ㅇ'; setTimeout(() => { // wait for any textarea updates compositionHelper.compositionend(); diff --git a/src/browser/input/CompositionHelper.ts b/src/browser/input/CompositionHelper.ts index 8a204831..4e176725 100644 --- a/src/browser/input/CompositionHelper.ts +++ b/src/browser/input/CompositionHelper.ts @@ -69,7 +69,7 @@ export class CompositionHelper { * Handles the compositionupdate event, updating the composition view. * @param ev The event. */ - public compositionupdate(ev: CompositionEvent): void { + public compositionupdate(ev: Pick): void { this._compositionView.textContent = ev.data; this.updateCompositionElements(); setTimeout(() => { diff --git a/src/browser/public/AddonManager.ts b/src/browser/public/AddonManager.ts index 0261fd68..06c78121 100644 --- a/src/browser/public/AddonManager.ts +++ b/src/browser/public/AddonManager.ts @@ -31,7 +31,7 @@ export class AddonManager implements IDisposable { }; this._addons.push(loadedAddon); instance.dispose = () => this._wrappedAddonDispose(loadedAddon); - instance.activate(terminal); + instance.activate(terminal as any); } private _wrappedAddonDispose(loadedAddon: ILoadedAddon): void { diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index 14606454..90153a6e 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -280,7 +280,7 @@ class BufferLineApiView implements IBufferLineApi { } if (cell) { - this._line.loadCell(x, cell); + this._line.loadCell(x, cell as ICellData); return cell; } return this._line.loadCell(x, new CellData()); diff --git a/src/browser/renderer/atlas/CharAtlasUtils.ts b/src/browser/renderer/atlas/CharAtlasUtils.ts index 20695d3c..b196b373 100644 --- a/src/browser/renderer/atlas/CharAtlasUtils.ts +++ b/src/browser/renderer/atlas/CharAtlasUtils.ts @@ -10,7 +10,7 @@ import { ITerminalOptions } from 'common/services/Services'; export function generateConfig(scaledCharWidth: number, scaledCharHeight: number, options: ITerminalOptions, colors: IColorSet): ICharAtlasConfig { // null out some fields that don't matter - const clonedColors = { + const clonedColors: IPartialColorSet = { foreground: colors.foreground, background: colors.background, cursor: undefined, diff --git a/src/browser/renderer/dom/DomRenderer.ts b/src/browser/renderer/dom/DomRenderer.ts index dccdb877..d08cf987 100644 --- a/src/browser/renderer/dom/DomRenderer.ts +++ b/src/browser/renderer/dom/DomRenderer.ts @@ -387,7 +387,7 @@ export class DomRenderer extends Disposable implements IRenderer { if (!row) { return; } - const span = row.children[x]; + const span = row.children[x] as HTMLElement; if (span) { span.style.textDecoration = enabled ? 'underline' : 'none'; } diff --git a/src/browser/services/CharacterJoinerService.test.ts b/src/browser/services/CharacterJoinerService.test.ts index 94abc4d5..6b5326d9 100644 --- a/src/browser/services/CharacterJoinerService.test.ts +++ b/src/browser/services/CharacterJoinerService.test.ts @@ -270,7 +270,7 @@ function lineData(data: IPartialLineData[]): IBufferLine { const tline = new BufferLine(0); for (let i = 0; i < data.length; ++i) { const line = data[i][0]; - const attr = (data[i][1] || 0); + const attr = (data[i][1] || 0) as number; const offset = tline.length; tline.resize(tline.length + line.split('').length, CellData.fromCharData([0, '', 0, 0])); line.split('').map((char, idx) => tline.setCell(idx + offset, CellData.fromCharData([attr, char, 1, char.charCodeAt(0)]))); diff --git a/src/browser/services/SelectionService.ts b/src/browser/services/SelectionService.ts index 8e3b8809..c0547755 100644 --- a/src/browser/services/SelectionService.ts +++ b/src/browser/services/SelectionService.ts @@ -133,8 +133,8 @@ export class SelectionService extends Disposable implements ISelectionService { super(); // Init listeners - this._mouseMoveListener = event => this._onMouseMove(event); - this._mouseUpListener = event => this._onMouseUp(event); + this._mouseMoveListener = event => this._onMouseMove(event as MouseEvent); + this._mouseUpListener = event => this._onMouseUp(event as MouseEvent); this._coreService.onUserInput(() => { if (this.hasSelection) { this.clearSelection(); diff --git a/src/browser/services/SoundService.ts b/src/browser/services/SoundService.ts index 8d940c13..3880b42d 100644 --- a/src/browser/services/SoundService.ts +++ b/src/browser/services/SoundService.ts @@ -13,7 +13,7 @@ export class SoundService implements ISoundService { public static get audioContext(): AudioContext | null { if (!SoundService._audioContext) { - const audioContextCtor: typeof AudioContext = (window).AudioContext || (window).webkitAudioContext; + const audioContextCtor: typeof AudioContext = (window as any).AudioContext || (window as any).webkitAudioContext; if (!audioContextCtor) { console.warn('Web Audio API is not supported by this browser. Consider upgrading to the latest version'); return null; diff --git a/src/common/TestUtils.test.ts b/src/common/TestUtils.test.ts index dce0f570..52fe00d0 100644 --- a/src/common/TestUtils.test.ts +++ b/src/common/TestUtils.test.ts @@ -125,7 +125,7 @@ export class MockOptionsService implements IOptionsService { constructor(testOptions?: IPartialTerminalOptions) { if (testOptions) { for (const key of Object.keys(testOptions)) { - this.options[key] = (testOptions)[key]; + this.options[key] = (testOptions as any)[key]; } } } From 6801793547a43d243cf51bbbb3bd87a484bbe5b8 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 4 Jun 2021 19:36:41 +0300 Subject: [PATCH 218/377] chore: inc -> prefix -> postfix --- src/browser/Terminal2.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/Terminal2.test.ts b/src/browser/Terminal2.test.ts index 92a0a44c..44540c6e 100644 --- a/src/browser/Terminal2.test.ts +++ b/src/browser/Terminal2.test.ts @@ -105,7 +105,7 @@ function formatError(input: string, output: string, expected: string): string { function addLineNumber(start: number, color: string): (s: string) => string { let counter = start || 0; return (s: string): string => { - ++counter; + counter++; return '\x1b[33m' + (' ' + counter).slice(-2) + color + s; }; } From f593d1482350ebe62be874d6468790561c584b5d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 4 Jun 2021 12:21:15 -0700 Subject: [PATCH 219/377] Fix tests, add explanatory comment --- src/browser/Linkifier.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/browser/Linkifier.ts b/src/browser/Linkifier.ts index 3d70770d..b17d66a8 100644 --- a/src/browser/Linkifier.ts +++ b/src/browser/Linkifier.ts @@ -89,7 +89,9 @@ export class Linkifier implements ILinkifier { if (this._rowsTimeoutId) { clearTimeout(this._rowsTimeoutId); } - this._rowsTimeoutId = window.setTimeout(() => this._linkifyRows(), Linkifier._timeBeforeLatency); + + // Cannot use window.setTimeout since tests need to run in node + this._rowsTimeoutId = setTimeout(() => this._linkifyRows(), Linkifier._timeBeforeLatency) as any as number; } /** From c335682559768e5b7ba884bc994be8b1cf62c6f3 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 8 Jun 2021 07:00:20 +0000 Subject: [PATCH 220/377] [Security] Bump glob-parent from 5.1.1 to 5.1.2 Bumps [glob-parent](https://github.com/gulpjs/glob-parent) from 5.1.1 to 5.1.2. **This update includes a security fix.** - [Release notes](https://github.com/gulpjs/glob-parent/releases) - [Changelog](https://github.com/gulpjs/glob-parent/blob/main/CHANGELOG.md) - [Commits](https://github.com/gulpjs/glob-parent/compare/v5.1.1...v5.1.2) Signed-off-by: dependabot-preview[bot] --- yarn.lock | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/yarn.lock b/yarn.lock index 712bdc47..ee0f0558 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2143,20 +2143,13 @@ getpass@^0.1.1: dependencies: assert-plus "^1.0.0" -glob-parent@^5.0.0, glob-parent@^5.1.0: +glob-parent@^5.0.0, glob-parent@^5.1.0, glob-parent@~5.1.0: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== dependencies: is-glob "^4.0.1" -glob-parent@~5.1.0: - version "5.1.1" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229" - integrity sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ== - dependencies: - is-glob "^4.0.1" - glob-to-regexp@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" From 09acb2b5f93c87f6651d76f8e66ad5bf7a6f4a95 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Tue, 8 Jun 2021 14:52:05 -0700 Subject: [PATCH 221/377] +1 to rangeLength when on a wrapped line to match standard behavior --- src/common/buffer/BufferRange.test.ts | 4 ++-- src/common/buffer/BufferRange.ts | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/common/buffer/BufferRange.test.ts b/src/common/buffer/BufferRange.test.ts index d0f287dc..69aacd99 100644 --- a/src/common/buffer/BufferRange.test.ts +++ b/src/common/buffer/BufferRange.test.ts @@ -16,10 +16,10 @@ describe('BufferRange', () => { assert.throws(() => getRangeLength(createRange(1, 3, 1, 1), 0)); }); it('should get range multiple lines', () => { - assert.equal(getRangeLength(createRange(1, 1, 4, 5), 5), 23); + assert.equal(getRangeLength(createRange(1, 1, 4, 5), 5), 24); }); it('should get range for end line right after start line', () => { - assert.equal(getRangeLength(createRange(1, 1, 7, 2), 5), 11); + assert.equal(getRangeLength(createRange(1, 1, 7, 2), 5), 12); }); }); }); diff --git a/src/common/buffer/BufferRange.ts b/src/common/buffer/BufferRange.ts index 9091c68d..a49cf481 100644 --- a/src/common/buffer/BufferRange.ts +++ b/src/common/buffer/BufferRange.ts @@ -5,12 +5,9 @@ import { IBufferRange } from 'xterm'; -export function getRangeLength(range: IBufferRange, cols: number): number { - if (range.start.y === range.end.y) { - return range.end.x - range.start.x + 1; - } +export function getRangeLength(range: IBufferRange, bufferCols: number): number { if (range.start.y > range.end.y) { throw new Error(`Buffer range end (${range.end.x}, ${range.end.y}) cannot be before start (${range.start.x}, ${range.start.y})`); } - return cols * (range.end.y - range.start.y - 1) + cols - range.start.x + range.end.x; + return bufferCols * (range.end.y - range.start.y) + (range.end.x - range.start.x + 1); } From 2f0a4fc5c02d52351d7ab80b5de0f1453a70057c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Thu, 10 Jun 2021 10:35:58 +0200 Subject: [PATCH 222/377] allow cursor to stick at cols in ED/EL --- src/browser/Terminal2.test.ts | 1 + src/common/InputHandler.test.ts | 86 +++++++++++++++++++++++++++++++++ src/common/InputHandler.ts | 4 +- 3 files changed, 89 insertions(+), 2 deletions(-) diff --git a/src/browser/Terminal2.test.ts b/src/browser/Terminal2.test.ts index 44540c6e..4965e8f3 100644 --- a/src/browser/Terminal2.test.ts +++ b/src/browser/Terminal2.test.ts @@ -17,6 +17,7 @@ const ROWS = 25; const TESTFILES = glob.sync('**/escape_sequence_files/*.in', { cwd: path.join(__dirname, '../..')}); const SKIP_FILES = [ + 't0055-EL.in', // EL/ED handle cursor at cols differently (see #3362) 't0084-CBT.in', 't0101-NLM.in', 't0103-reverse_wrap.in', // not comparable, we deviate from xterm reverse wrap on purpose diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index 676b1e45..58b1c5b8 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -1913,6 +1913,92 @@ describe('InputHandler', () => { }); }); }); + + // issue #3362 and #2979 + describe.only('EL/ED cursor at buffer.cols', () => { + beforeEach(() => { + bufferService.resize(10, 5); + }); + describe('cursor should stay at cols / does not overflow', () => { + it('EL0', async () => { + await inputHandler.parseP('##########\x1b[0K'); + assert.equal(bufferService.buffer.x, 10); + assert.deepEqual(getLines(bufferService), ['#'.repeat(10), '', '', '', '']); + }); + it('EL1', async () => { + await inputHandler.parseP('##########\x1b[1K'); + assert.equal(bufferService.buffer.x, 10); + assert.deepEqual(getLines(bufferService), ['', '', '', '', '']); + }); + it('EL2', async () => { + await inputHandler.parseP('##########\x1b[2K'); + assert.equal(bufferService.buffer.x, 10); + assert.deepEqual(getLines(bufferService), ['', '', '', '', '']); + }); + it('ED0', async () => { + await inputHandler.parseP('##########\x1b[0J'); + assert.equal(bufferService.buffer.x, 10); + assert.deepEqual(getLines(bufferService), ['#'.repeat(10), '', '', '', '']); + }); + it('ED1', async () => { + await inputHandler.parseP('##########\x1b[1J'); + assert.equal(bufferService.buffer.x, 10); + assert.deepEqual(getLines(bufferService), ['', '', '', '', '']); + }); + it('ED2', async () => { + await inputHandler.parseP('##########\x1b[2J'); + assert.equal(bufferService.buffer.x, 10); + assert.deepEqual(getLines(bufferService), ['', '', '', '', '']); + }); + it('ED3', async () => { + await inputHandler.parseP('##########\x1b[3J'); + assert.equal(bufferService.buffer.x, 10); + assert.deepEqual(getLines(bufferService), ['#'.repeat(10), '', '', '', '']); + }); + }); + describe('following sequence keeps working', () => { + // sequences to test (cursor related ones) + const SEQ = [ + /* ICH */ '\x1b[10@', + /* SL */ '\x1b[10 @', + /* CUU */ '\x1b[10A', + /* SR */ '\x1b[10 A', + /* CUD */ '\x1b[10B', + /* CUF */ '\x1b[10C', + /* CUB */ '\x1b[10D', + /* CNL */ '\x1b[10E', + /* CPL */ '\x1b[10F', + /* CHA */ '\x1b[10G', + /* CUP */ '\x1b[10;10H', + /* CHT */ '\x1b[10I', + /* IL */ '\x1b[10L', + /* DL */ '\x1b[10M', + /* DCH */ '\x1b[10P', + /* SU */ '\x1b[10S', + /* SD */ '\x1b[10T', + /* ECH */ '\x1b[10X', + /* CBT */ '\x1b[10Z', + /* HPA */ '\x1b[10`', + /* HPR */ '\x1b[10a', + /* REP */ '\x1b[10b', + /* VPA */ '\x1b[10d', + /* VPR */ '\x1b[10e', + /* HVP */ '\x1b[10;10f', + /* TBC */ '\x1b[0g', + /* SCOSC */ '\x1b[s', + /* DECIC */ '\x1b[10\'}', + /* DECDC */ '\x1b[10\'~' + ]; + it('cursor never advances beyond cols', async () => { + for (const seq of SEQ) { + await inputHandler.parseP('##########\x1b[2J' + seq); + assert.equal(bufferService.buffer.x <= bufferService.cols, true); + inputHandler.reset(); + bufferService.reset(); + } + }); + }); + }); }); diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index a2b5a782..d3b29a70 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -1247,7 +1247,7 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #P[Protection attributes are not supported.] CSI DECSED "Selective Erase In Display" "CSI ? Ps J" "Currently the same as ED." */ public eraseInDisplay(params: IParams): boolean { - this._restrictCursor(); + this._restrictCursor(this._bufferService.cols); let j; switch (params.params[0]) { case 0: @@ -1319,7 +1319,7 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #P[Protection attributes are not supported.] CSI DECSEL "Selective Erase In Line" "CSI ? Ps K" "Currently the same as EL." */ public eraseInLine(params: IParams): boolean { - this._restrictCursor(); + this._restrictCursor(this._bufferService.cols); switch (params.params[0]) { case 0: this._eraseInBufferLine(this._bufferService.buffer.y, this._bufferService.buffer.x, this._bufferService.cols); From 55cd97ec68fd138c6ba11c200278d4e4bb65329e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Thu, 10 Jun 2021 10:42:27 +0200 Subject: [PATCH 223/377] remove left over only test clause --- src/common/InputHandler.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index 58b1c5b8..902640f9 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -1915,7 +1915,7 @@ describe('InputHandler', () => { }); // issue #3362 and #2979 - describe.only('EL/ED cursor at buffer.cols', () => { + describe('EL/ED cursor at buffer.cols', () => { beforeEach(() => { bufferService.resize(10, 5); }); From ff3781a4311ced394788a75ea0562b019bb17c2b Mon Sep 17 00:00:00 2001 From: Austin Anderson Date: Thu, 10 Jun 2021 12:01:03 -0700 Subject: [PATCH 224/377] Remove Shellvault Shellvault was shut down a while ago and the link is dead. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index b1f25995..0ac211ed 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,6 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**cPanel & WHM**](https://cpanel.com): The hosting platform of choice. - [**Nutanix**](https://github.com/nutanix): Nutanix Enterprise Cloud uses xterm in the webssh functionality within Nutanix Calm, and is also looking to move our old noserial (termjs) functionality to xterm.js. - [**SSH Web Client**](https://github.com/roke22/PHP-SSH2-Web-Client): SSH Web Client with PHP. -- [**Shellvault**](https://www.shellvault.io): The cloud-based SSH terminal you can access from anywhere. - [**Juno**](http://junolab.org/): A flexible Julia IDE, based on Atom. - [**webssh**](https://github.com/huashengdun/webssh): Web based ssh client. - [**info-beamer hosted**](https://info-beamer.com): Uses xterm.js to manage digital signage devices from the web dashboard. From 19bd04045352e1985002a28d894ee47fb0281b19 Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Fri, 11 Jun 2021 14:18:04 -0700 Subject: [PATCH 225/377] Update xterm version to 4.13.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1b290c6e..bab93bf4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "xterm", "description": "Full xterm terminal, in your browser", - "version": "4.12.0", + "version": "4.13.0", "main": "lib/xterm.js", "style": "css/xterm.css", "types": "typings/xterm.d.ts", From 094bcbd81d1f080d204331088aa99f4d7173d56c Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 15 Jun 2021 04:02:35 -0700 Subject: [PATCH 226/377] v0.5.1 --- addons/xterm-addon-ligatures/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/xterm-addon-ligatures/package.json b/addons/xterm-addon-ligatures/package.json index 64d8eed7..ecbcc006 100644 --- a/addons/xterm-addon-ligatures/package.json +++ b/addons/xterm-addon-ligatures/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-ligatures", - "version": "0.5.0", + "version": "0.5.1", "description": "Add support for programming ligatures to xterm.js", "author": { "name": "The xterm.js authors", From c7ced8009287f6539a97b92300a9382b68abe040 Mon Sep 17 00:00:00 2001 From: Labhansh Agrawal Date: Fri, 18 Jun 2021 08:27:43 +0530 Subject: [PATCH 227/377] Fix navigator types issue --- addons/xterm-addon-ligatures/src/font.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/xterm-addon-ligatures/src/font.ts b/addons/xterm-addon-ligatures/src/font.ts index 72872a0b..abdbbc04 100644 --- a/addons/xterm-addon-ligatures/src/font.ts +++ b/addons/xterm-addon-ligatures/src/font.ts @@ -37,7 +37,7 @@ export default async function load(fontFamily: string, cacheSize: number): Promi // Web environment that supports font access API if (typeof navigator !== 'undefined' && 'fonts' in navigator) { try { - const status = await (navigator as IFontAccessNavigator).permissions.request?.({ + const status = await (navigator as unknown as IFontAccessNavigator).permissions.request?.({ name: 'local-fonts' }); if (status && status.state !== 'granted') { @@ -53,7 +53,7 @@ export default async function load(fontFamily: string, cacheSize: number): Promi } const fonts: Record = {}; try { - const fontsIterator = await (navigator as IFontAccessNavigator).fonts.query(); + const fontsIterator = await (navigator as unknown as IFontAccessNavigator).fonts.query(); for (const metadata of fontsIterator) { if (!fonts.hasOwnProperty(metadata.family)) { fonts[metadata.family] = []; From b7e96f9e54f799a9c043cdfe51bae541b8fcac07 Mon Sep 17 00:00:00 2001 From: Puneethnaik Date: Sun, 20 Jun 2021 03:31:12 +0000 Subject: [PATCH 228/377] attach a listener to inputHandler._onScroll in CoreTerminal --- src/common/CoreTerminal.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 815326d6..e61a8e16 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -125,6 +125,10 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this._onScroll.fire({ position: this._bufferService.buffer.ydisp, source: ScrollSource.TERMINAL }); this._dirtyRowService.markRangeDirty(this._bufferService.buffer.scrollTop, this._bufferService.buffer.scrollBottom); })); + this.register(this._inputHandler.onScroll(event => { + this._onScroll.fire({ position: this._bufferService.buffer.ydisp, source: ScrollSource.TERMINAL }); + this._dirtyRowService.markRangeDirty(this._bufferService.buffer.scrollTop, this._bufferService.buffer.scrollBottom); + })); // Setup WriteBuffer this._writeBuffer = new WriteBuffer((data, promiseResult) => this._inputHandler.parse(data, promiseResult)); From a1f65a2f77d95fd2f604e2c488e0b7165813d18d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 9 Jul 2021 06:52:28 -0700 Subject: [PATCH 229/377] Update crossed out characters support to partial --- src/common/InputHandler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 06f4ac9f..e7d4f130 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -2365,7 +2365,7 @@ export class InputHandler extends Disposable implements IInputHandler { * | 6 | Rapidly blinking. | #N | * | 7 | Inverse. Flips foreground and background color. | #Y | * | 8 | Invisible (hidden). | #Y | - * | 9 | Crossed-out characters. | #N | + * | 9 | Crossed-out characters. | #P[Support in DOM and Canvas renderers, not WebGL] | * | 21 | Doubly underlined. | #P[Currently outputs a single underline.] | * | 22 | Normal (neither bold nor faint). | #Y | * | 23 | No italic. | #Y | @@ -2373,7 +2373,7 @@ export class InputHandler extends Disposable implements IInputHandler { * | 25 | Steady (not blinking). | #Y | * | 27 | Positive (not inverse). | #Y | * | 28 | Visible (not hidden). | #Y | - * | 29 | Not Crossed-out. | #N | + * | 29 | Not Crossed-out. | #Y | * | 30 | Foreground color: Black. | #Y | * | 31 | Foreground color: Red. | #Y | * | 32 | Foreground color: Green. | #Y | From fa8a4853f72d88907586e6241a2429b40ee97e73 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 9 Jul 2021 06:52:54 -0700 Subject: [PATCH 230/377] Clarify crossed out = strikethrough --- src/common/InputHandler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index e7d4f130..30c8fbe9 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -2365,7 +2365,7 @@ export class InputHandler extends Disposable implements IInputHandler { * | 6 | Rapidly blinking. | #N | * | 7 | Inverse. Flips foreground and background color. | #Y | * | 8 | Invisible (hidden). | #Y | - * | 9 | Crossed-out characters. | #P[Support in DOM and Canvas renderers, not WebGL] | + * | 9 | Crossed-out characters (strikethrough). | #P[Support in DOM and Canvas renderers, not WebGL] | * | 21 | Doubly underlined. | #P[Currently outputs a single underline.] | * | 22 | Normal (neither bold nor faint). | #Y | * | 23 | No italic. | #Y | @@ -2373,7 +2373,7 @@ export class InputHandler extends Disposable implements IInputHandler { * | 25 | Steady (not blinking). | #Y | * | 27 | Positive (not inverse). | #Y | * | 28 | Visible (not hidden). | #Y | - * | 29 | Not Crossed-out. | #Y | + * | 29 | Not Crossed-out (strikethrough). | #Y | * | 30 | Foreground color: Black. | #Y | * | 31 | Foreground color: Red. | #Y | * | 32 | Foreground color: Green. | #Y | From d8c790cb7ae0697ca8fc3c9028399d5c4c6582a2 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 9 Jul 2021 07:05:28 -0700 Subject: [PATCH 231/377] Set underlined style support to partial Feature tracked in #2251 --- src/common/InputHandler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 0b284d8e..d4f2159f 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -2360,7 +2360,7 @@ export class InputHandler extends Disposable implements IInputHandler { * | 1 | Bold. (also see `options.drawBoldTextInBrightColors`) | #Y | * | 2 | Faint, decreased intensity. | #Y | * | 3 | Italic. | #Y | - * | 4 | Underlined (see below for style support). | #Y | + * | 4 | Underlined (see below for style support). | #P[Support in DOM and Canvas renderers, not WebGL] | * | 5 | Slowly blinking. | #N | * | 6 | Rapidly blinking. | #N | * | 7 | Inverse. Flips foreground and background color. | #Y | From 96dd021ca4c361a547b12901d8805a9c9c07926f Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 9 Jul 2021 07:32:25 -0700 Subject: [PATCH 232/377] Support underline in webgl renderer Fixes #2251 --- addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 5e1ad195..fb20c1c8 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -338,6 +338,7 @@ export class WebglCharAtlas implements IDisposable { const inverse = !!this._workAttributeData.isInverse(); const dim = !!this._workAttributeData.isDim(); const italic = !!this._workAttributeData.isItalic(); + const underline = !!this._workAttributeData.isUnderline(); let fgColor = this._workAttributeData.getFgColor(); let fgColorMode = this._workAttributeData.getFgColorMode(); let bgColor = this._workAttributeData.getBgColor(); @@ -390,6 +391,12 @@ export class WebglCharAtlas implements IDisposable { // Draw the character this._tmpCtx.fillText(chars, padding, padding + this._config.scaledCharHeight); + if (underline) { + this._tmpCtx.strokeStyle = this._tmpCtx.fillStyle; + this._tmpCtx.moveTo(0, this._config.scaledCharHeight - 1); + this._tmpCtx.lineTo(this._config.scaledCharWidth, this._config.scaledCharHeight - 1); + this._tmpCtx.stroke(); + } this._tmpCtx.restore(); // clear the background from the character to avoid issues with drawing over the previous From bc702d28ff32ad3086b18a4db75e732ae544a55d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 9 Jul 2021 07:39:19 -0700 Subject: [PATCH 233/377] Support webgl strikethrough, fix underline position Fixes #580 --- .../xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index fb20c1c8..db0da6d7 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -339,6 +339,7 @@ export class WebglCharAtlas implements IDisposable { const dim = !!this._workAttributeData.isDim(); const italic = !!this._workAttributeData.isItalic(); const underline = !!this._workAttributeData.isUnderline(); + const strikethrough = !!this._workAttributeData.isStrikethrough(); let fgColor = this._workAttributeData.getFgColor(); let fgColorMode = this._workAttributeData.getFgColorMode(); let bgColor = this._workAttributeData.getBgColor(); @@ -393,9 +394,19 @@ export class WebglCharAtlas implements IDisposable { this._tmpCtx.fillText(chars, padding, padding + this._config.scaledCharHeight); if (underline) { this._tmpCtx.strokeStyle = this._tmpCtx.fillStyle; - this._tmpCtx.moveTo(0, this._config.scaledCharHeight - 1); - this._tmpCtx.lineTo(this._config.scaledCharWidth, this._config.scaledCharHeight - 1); + this._tmpCtx.beginPath(); + this._tmpCtx.moveTo(padding, padding + this._config.scaledCharHeight - 0.5); + this._tmpCtx.lineTo(padding + this._config.scaledCharWidth, padding + this._config.scaledCharHeight - 0.5); this._tmpCtx.stroke(); + this._tmpCtx.closePath(); + } + if (strikethrough) { + this._tmpCtx.strokeStyle = this._tmpCtx.fillStyle; + this._tmpCtx.beginPath(); + this._tmpCtx.moveTo(padding, padding + Math.floor(this._config.scaledCharHeight / 2) + 0.5); + this._tmpCtx.lineTo(padding + this._config.scaledCharWidth, padding + Math.floor(this._config.scaledCharHeight / 2) + 0.5); + this._tmpCtx.stroke(); + this._tmpCtx.closePath(); } this._tmpCtx.restore(); From aad6f8147e2696c9f1bb9e6cdfae10799294052c Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 9 Jul 2021 07:44:10 -0700 Subject: [PATCH 234/377] Increase underline/strikethrough width with font size --- .../src/atlas/WebglCharAtlas.ts | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index db0da6d7..5f729e28 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -392,22 +392,26 @@ export class WebglCharAtlas implements IDisposable { // Draw the character this._tmpCtx.fillText(chars, padding, padding + this._config.scaledCharHeight); - if (underline) { + + // Draw underline and strikethrough + if (underline || strikethrough) { + const lineWidth = Math.max(1, Math.floor(this._config.fontSize / 10)); + const yOffset = this._tmpCtx.lineWidth % 2 === 1 ? 0.5 : 0; // When the width is odd, draw at 0.5 position + this._tmpCtx.lineWidth = lineWidth; this._tmpCtx.strokeStyle = this._tmpCtx.fillStyle; this._tmpCtx.beginPath(); - this._tmpCtx.moveTo(padding, padding + this._config.scaledCharHeight - 0.5); - this._tmpCtx.lineTo(padding + this._config.scaledCharWidth, padding + this._config.scaledCharHeight - 0.5); - this._tmpCtx.stroke(); - this._tmpCtx.closePath(); - } - if (strikethrough) { - this._tmpCtx.strokeStyle = this._tmpCtx.fillStyle; - this._tmpCtx.beginPath(); - this._tmpCtx.moveTo(padding, padding + Math.floor(this._config.scaledCharHeight / 2) + 0.5); - this._tmpCtx.lineTo(padding + this._config.scaledCharWidth, padding + Math.floor(this._config.scaledCharHeight / 2) + 0.5); + if (underline) { + this._tmpCtx.moveTo(padding, padding + this._config.scaledCharHeight - yOffset); + this._tmpCtx.lineTo(padding + this._config.scaledCharWidth, padding + this._config.scaledCharHeight - yOffset); + } + if (strikethrough) { + this._tmpCtx.moveTo(padding, padding + Math.floor(this._config.scaledCharHeight / 2) - yOffset); + this._tmpCtx.lineTo(padding + this._config.scaledCharWidth, padding + Math.floor(this._config.scaledCharHeight / 2) - yOffset); + } this._tmpCtx.stroke(); this._tmpCtx.closePath(); } + this._tmpCtx.restore(); // clear the background from the character to avoid issues with drawing over the previous From 1f019093fc59bb637ac9677ad5642ecd87c1241e Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 9 Jul 2021 07:48:26 -0700 Subject: [PATCH 235/377] Update SGR support table --- src/common/InputHandler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index d4f2159f..d4354e90 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -2360,12 +2360,12 @@ export class InputHandler extends Disposable implements IInputHandler { * | 1 | Bold. (also see `options.drawBoldTextInBrightColors`) | #Y | * | 2 | Faint, decreased intensity. | #Y | * | 3 | Italic. | #Y | - * | 4 | Underlined (see below for style support). | #P[Support in DOM and Canvas renderers, not WebGL] | + * | 4 | Underlined (see below for style support). | #Y | * | 5 | Slowly blinking. | #N | * | 6 | Rapidly blinking. | #N | * | 7 | Inverse. Flips foreground and background color. | #Y | * | 8 | Invisible (hidden). | #Y | - * | 9 | Crossed-out characters (strikethrough). | #P[Support in DOM and Canvas renderers, not WebGL] | + * | 9 | Crossed-out characters (strikethrough). | #Y | * | 21 | Doubly underlined. | #P[Currently outputs a single underline.] | * | 22 | Normal (neither bold nor faint). | #Y | * | 23 | No italic. | #Y | From 8ec33686366ad43304d818180a7bc3dcbff4f6bf Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 9 Jul 2021 08:17:52 -0700 Subject: [PATCH 236/377] Fix underline/strikethrough on space chars --- addons/xterm-addon-webgl/src/GlyphRenderer.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/xterm-addon-webgl/src/GlyphRenderer.ts b/addons/xterm-addon-webgl/src/GlyphRenderer.ts index b09fe540..71b3659e 100644 --- a/addons/xterm-addon-webgl/src/GlyphRenderer.ts +++ b/addons/xterm-addon-webgl/src/GlyphRenderer.ts @@ -176,8 +176,9 @@ export class GlyphRenderer { const i = (y * terminal.cols + x) * INDICES_PER_CELL; - // Exit early if this is a null/space character - if (code === NULL_CELL_CODE || code === WHITESPACE_CELL_CODE || code === undefined/* This is used for the right side of wide chars */) { + // Exit early if this is a null character, allow space character to continue as it may have + // underline/strikethrough styles + if (code === NULL_CELL_CODE || code === undefined/* This is used for the right side of wide chars */) { fill(array, 0, i, i + INDICES_PER_CELL - 1 - CELL_POSITION_INDICES); return; } From 361998bd346a0114b182899e1b35ca53aaa18d73 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 16 Jul 2021 10:08:36 -0700 Subject: [PATCH 237/377] Fix cursor ghosting in canvas/webgl renderers Fixes #3391 --- .../xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts | 7 ++++++- src/browser/renderer/CursorRenderLayer.ts | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts b/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts index b2e834d3..6aa33828 100644 --- a/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts +++ b/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts @@ -193,7 +193,12 @@ export class CursorRenderLayer extends BaseRenderLayer { private _clearCursor(): void { if (this._state) { - this._clearCells(this._state.x, this._state.y, this._state.width, 1); + // Avoid potential rounding errors when device pixel ratio is an odd number + if (window.devicePixelRatio % 1 !== 0) { + this._clearAll(); + } else { + this._clearCells(this._state.x, this._state.y, this._state.width, 1); + } this._state = { x: 0, y: 0, diff --git a/src/browser/renderer/CursorRenderLayer.ts b/src/browser/renderer/CursorRenderLayer.ts index a78b2048..8fda0b35 100644 --- a/src/browser/renderer/CursorRenderLayer.ts +++ b/src/browser/renderer/CursorRenderLayer.ts @@ -197,7 +197,12 @@ export class CursorRenderLayer extends BaseRenderLayer { private _clearCursor(): void { if (this._state) { - this._clearCells(this._state.x, this._state.y, this._state.width, 1); + // Avoid potential rounding errors when device pixel ratio is less than 1 + if (window.devicePixelRatio < 1) { + this._clearAll(); + } else { + this._clearCells(this._state.x, this._state.y, this._state.width, 1); + } this._state = { x: 0, y: 0, From 0ceeb087e9a24da2073630dbe882dc3427d3a4a8 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 16 Jul 2021 13:25:52 -0700 Subject: [PATCH 238/377] Use less than instead of non-integer check Part of #3391 --- addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts b/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts index 6aa33828..880896e0 100644 --- a/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts +++ b/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts @@ -193,8 +193,8 @@ export class CursorRenderLayer extends BaseRenderLayer { private _clearCursor(): void { if (this._state) { - // Avoid potential rounding errors when device pixel ratio is an odd number - if (window.devicePixelRatio % 1 !== 0) { + // Avoid potential rounding errors when device pixel ratio is less than 1 + if (window.devicePixelRatio < 1) { this._clearAll(); } else { this._clearCells(this._state.x, this._state.y, this._state.width, 1); From a5c6252ff577acb6d65ffcc0a66e2fb2c177e56d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 14:36:14 -0700 Subject: [PATCH 239/377] Remove browser references from common/public --- src/common/public/BufferNamespaceApi.ts | 4 ++-- src/common/public/ParserApi.ts | 4 ++-- src/common/public/UnicodeApi.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/public/BufferNamespaceApi.ts b/src/common/public/BufferNamespaceApi.ts index 8d787700..7c0f2287 100644 --- a/src/common/public/BufferNamespaceApi.ts +++ b/src/common/public/BufferNamespaceApi.ts @@ -1,7 +1,7 @@ import { IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi } from 'xterm'; import { BufferApiView } from 'common/public/BufferApiView'; import { IEvent, EventEmitter } from 'common/EventEmitter'; -import { ITerminal } from 'browser/Types'; +import { CoreTerminal } from 'common/CoreTerminal'; export class BufferNamespaceApi implements IBufferNamespaceApi { private _normal: BufferApiView; @@ -9,7 +9,7 @@ export class BufferNamespaceApi implements IBufferNamespaceApi { private _onBufferChange = new EventEmitter(); public get onBufferChange(): IEvent { return this._onBufferChange.event; } - constructor(private _core: ITerminal) { + constructor(private _core: CoreTerminal) { this._normal = new BufferApiView(this._core.buffers.normal, 'normal'); this._alternate = new BufferApiView(this._core.buffers.alt, 'alternate'); this._core.buffers.onBufferActivate(() => this._onBufferChange.fire(this.active)); diff --git a/src/common/public/ParserApi.ts b/src/common/public/ParserApi.ts index f8e61de4..ffc5a0fd 100644 --- a/src/common/public/ParserApi.ts +++ b/src/common/public/ParserApi.ts @@ -1,9 +1,9 @@ import { IParams } from 'common/parser/Types'; -import { ITerminal } from 'browser/Types'; +import { CoreTerminal } from 'common/CoreTerminal'; import { IDisposable, IFunctionIdentifier, IParser } from 'xterm'; export class ParserApi implements IParser { - constructor(private _core: ITerminal) { } + constructor(private _core: CoreTerminal) { } public registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean | Promise): IDisposable { return this._core.registerCsiHandler(id, (params: IParams) => callback(params.toArray())); diff --git a/src/common/public/UnicodeApi.ts b/src/common/public/UnicodeApi.ts index 1bfd7a92..141863dc 100644 --- a/src/common/public/UnicodeApi.ts +++ b/src/common/public/UnicodeApi.ts @@ -1,8 +1,8 @@ -import { ITerminal } from 'browser/Types'; +import { CoreTerminal } from 'common/CoreTerminal'; import { IUnicodeHandling, IUnicodeVersionProvider } from 'xterm'; export class UnicodeApi implements IUnicodeHandling { - constructor(private _core: ITerminal) { } + constructor(private _core: CoreTerminal) { } public register(provider: IUnicodeVersionProvider): void { this._core.unicodeService.register(provider); From 41e4de35e9fdb363d9a22a6b0062b53b941ae370 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 14:42:11 -0700 Subject: [PATCH 240/377] common/public use ICoreTerminal instead of concrete --- src/browser/Types.d.ts | 2 -- src/common/Types.d.ts | 6 ++++++ src/common/public/BufferApiView.ts | 5 +++++ src/common/public/BufferLineApiView.ts | 5 +++++ src/common/public/BufferNamespaceApi.ts | 8 +++++++- src/common/public/ParserApi.ts | 9 +++++++-- src/common/public/UnicodeApi.ts | 9 +++++++-- 7 files changed, 37 insertions(+), 7 deletions(-) diff --git a/src/browser/Types.d.ts b/src/browser/Types.d.ts index b2ff29d7..fcae7e47 100644 --- a/src/browser/Types.d.ts +++ b/src/browser/Types.d.ts @@ -14,8 +14,6 @@ export interface ITerminal extends IPublicTerminal, ICoreTerminal { element: HTMLElement | undefined; screenElement: HTMLElement | undefined; browser: IBrowser; - buffer: IBuffer; - buffers: IBufferSet; viewport: IViewport | undefined; // TODO: We should remove options once components adopt optionsService options: ITerminalOptions; diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index 51f7e172..950e5e57 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -8,10 +8,16 @@ import { IEvent, IEventEmitter } from 'common/EventEmitter'; import { IDeleteEvent, IInsertEvent } from 'common/CircularList'; import { IParams } from 'common/parser/Types'; import { IOptionsService, IUnicodeService } from 'common/services/Services'; +import { IBuffer, IBufferSet } from 'common/buffer/Types'; export interface ICoreTerminal { optionsService: IOptionsService; unicodeService: IUnicodeService; + buffers: IBufferSet; + registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise): IDisposable; + registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise): IDisposable; + registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise): IDisposable; + registerOscHandler(ident: number, callback: (data: string) => boolean | Promise): IDisposable; } export interface IDisposable { diff --git a/src/common/public/BufferApiView.ts b/src/common/public/BufferApiView.ts index f6f12744..56ed0155 100644 --- a/src/common/public/BufferApiView.ts +++ b/src/common/public/BufferApiView.ts @@ -1,3 +1,8 @@ +/** + * Copyright (c) 2021 The xterm.js authors. All rights reserved. + * @license MIT + */ + import { IBuffer as IBufferApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi } from 'xterm'; import { IBuffer } from 'common/buffer/Types'; import { BufferLineApiView } from 'common/public/BufferLineApiView'; diff --git a/src/common/public/BufferLineApiView.ts b/src/common/public/BufferLineApiView.ts index 2482adb7..60375015 100644 --- a/src/common/public/BufferLineApiView.ts +++ b/src/common/public/BufferLineApiView.ts @@ -1,3 +1,8 @@ +/** + * Copyright (c) 2021 The xterm.js authors. All rights reserved. + * @license MIT + */ + import { CellData } from 'common/buffer/CellData'; import { IBufferLine, ICellData } from 'common/Types'; import { IBufferCell as IBufferCellApi, IBufferLine as IBufferLineApi } from 'xterm'; diff --git a/src/common/public/BufferNamespaceApi.ts b/src/common/public/BufferNamespaceApi.ts index 7c0f2287..c7bee600 100644 --- a/src/common/public/BufferNamespaceApi.ts +++ b/src/common/public/BufferNamespaceApi.ts @@ -1,7 +1,13 @@ +/** + * Copyright (c) 2021 The xterm.js authors. All rights reserved. + * @license MIT + */ + import { IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi } from 'xterm'; import { BufferApiView } from 'common/public/BufferApiView'; import { IEvent, EventEmitter } from 'common/EventEmitter'; import { CoreTerminal } from 'common/CoreTerminal'; +import { ICoreTerminal } from 'common/Types'; export class BufferNamespaceApi implements IBufferNamespaceApi { private _normal: BufferApiView; @@ -9,7 +15,7 @@ export class BufferNamespaceApi implements IBufferNamespaceApi { private _onBufferChange = new EventEmitter(); public get onBufferChange(): IEvent { return this._onBufferChange.event; } - constructor(private _core: CoreTerminal) { + constructor(private _core: ICoreTerminal) { this._normal = new BufferApiView(this._core.buffers.normal, 'normal'); this._alternate = new BufferApiView(this._core.buffers.alt, 'alternate'); this._core.buffers.onBufferActivate(() => this._onBufferChange.fire(this.active)); diff --git a/src/common/public/ParserApi.ts b/src/common/public/ParserApi.ts index ffc5a0fd..67df4be5 100644 --- a/src/common/public/ParserApi.ts +++ b/src/common/public/ParserApi.ts @@ -1,9 +1,14 @@ +/** + * Copyright (c) 2021 The xterm.js authors. All rights reserved. + * @license MIT + */ + import { IParams } from 'common/parser/Types'; -import { CoreTerminal } from 'common/CoreTerminal'; import { IDisposable, IFunctionIdentifier, IParser } from 'xterm'; +import { ICoreTerminal } from 'common/Types'; export class ParserApi implements IParser { - constructor(private _core: CoreTerminal) { } + constructor(private _core: ICoreTerminal) { } public registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean | Promise): IDisposable { return this._core.registerCsiHandler(id, (params: IParams) => callback(params.toArray())); diff --git a/src/common/public/UnicodeApi.ts b/src/common/public/UnicodeApi.ts index 141863dc..8a669a05 100644 --- a/src/common/public/UnicodeApi.ts +++ b/src/common/public/UnicodeApi.ts @@ -1,8 +1,13 @@ -import { CoreTerminal } from 'common/CoreTerminal'; +/** + * Copyright (c) 2021 The xterm.js authors. All rights reserved. + * @license MIT + */ + +import { ICoreTerminal } from 'common/Types'; import { IUnicodeHandling, IUnicodeVersionProvider } from 'xterm'; export class UnicodeApi implements IUnicodeHandling { - constructor(private _core: CoreTerminal) { } + constructor(private _core: ICoreTerminal) { } public register(provider: IUnicodeVersionProvider): void { this._core.unicodeService.register(provider); From cb284447c8dd58e9103d4dc4b2d99f68dbd2a76b Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 14:44:49 -0700 Subject: [PATCH 241/377] Clean up imports --- src/common/Types.d.ts | 2 +- src/common/public/BufferApiView.ts | 2 +- src/common/public/BufferNamespaceApi.ts | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index 950e5e57..36f75dd0 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -8,7 +8,7 @@ import { IEvent, IEventEmitter } from 'common/EventEmitter'; import { IDeleteEvent, IInsertEvent } from 'common/CircularList'; import { IParams } from 'common/parser/Types'; import { IOptionsService, IUnicodeService } from 'common/services/Services'; -import { IBuffer, IBufferSet } from 'common/buffer/Types'; +import { IBufferSet } from 'common/buffer/Types'; export interface ICoreTerminal { optionsService: IOptionsService; diff --git a/src/common/public/BufferApiView.ts b/src/common/public/BufferApiView.ts index 56ed0155..ca9ef2d8 100644 --- a/src/common/public/BufferApiView.ts +++ b/src/common/public/BufferApiView.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { IBuffer as IBufferApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi } from 'xterm'; +import { IBuffer as IBufferApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi } from 'xterm'; import { IBuffer } from 'common/buffer/Types'; import { BufferLineApiView } from 'common/public/BufferLineApiView'; import { CellData } from 'common/buffer/CellData'; diff --git a/src/common/public/BufferNamespaceApi.ts b/src/common/public/BufferNamespaceApi.ts index c7bee600..d86f6bf5 100644 --- a/src/common/public/BufferNamespaceApi.ts +++ b/src/common/public/BufferNamespaceApi.ts @@ -6,7 +6,6 @@ import { IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi } from 'xterm'; import { BufferApiView } from 'common/public/BufferApiView'; import { IEvent, EventEmitter } from 'common/EventEmitter'; -import { CoreTerminal } from 'common/CoreTerminal'; import { ICoreTerminal } from 'common/Types'; export class BufferNamespaceApi implements IBufferNamespaceApi { From a14bb3ead3e4fae853c813d0cf0ed778094672f1 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 14:45:39 -0700 Subject: [PATCH 242/377] Add buffer back to ITerminal --- src/browser/Types.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/browser/Types.d.ts b/src/browser/Types.d.ts index fcae7e47..c268c7bf 100644 --- a/src/browser/Types.d.ts +++ b/src/browser/Types.d.ts @@ -14,6 +14,7 @@ export interface ITerminal extends IPublicTerminal, ICoreTerminal { element: HTMLElement | undefined; screenElement: HTMLElement | undefined; browser: IBrowser; + buffer: IBuffer; viewport: IViewport | undefined; // TODO: We should remove options once components adopt optionsService options: ITerminalOptions; From 91c7032aac38c6a3fa7d1d4a960efe5f8d7897f1 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 15:17:28 -0700 Subject: [PATCH 243/377] Use core terminal in common, remove duplicate classes --- src/common/public/Terminal.ts | 134 ++-------------------------------- 1 file changed, 6 insertions(+), 128 deletions(-) diff --git a/src/common/public/Terminal.ts b/src/common/public/Terminal.ts index 39ad5cd4..6b63ee1e 100644 --- a/src/common/public/Terminal.ts +++ b/src/common/public/Terminal.ts @@ -3,17 +3,15 @@ * @license MIT */ -import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi, IParser, IFunctionIdentifier, IUnicodeHandling, IUnicodeVersionProvider } from 'xterm-core'; -import { IBufferLine, ICellData } from 'common/Types'; -import { IBuffer } from 'common/buffer/Types'; -import { CellData } from 'common/buffer/CellData'; +import { IEvent } from 'common/EventEmitter'; +import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi'; +import { ParserApi } from 'common/public/ParserApi'; +import { UnicodeApi } from 'common/public/UnicodeApi'; +import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core'; import { Terminal as TerminalCore } from './TerminalCore'; -import { IEvent, EventEmitter } from 'common/EventEmitter'; -import { IParams } from 'common/parser/Types'; -import { ITerminal } from 'common/public/types'; export class Terminal implements ITerminalApi { - private _core: ITerminal; + private _core: TerminalCore; private _parser: IParser | undefined; private _buffer: BufferNamespaceApi | undefined; @@ -117,123 +115,3 @@ export class Terminal implements ITerminalApi { } } } - -class BufferApiView implements IBufferApi { - constructor( - private _buffer: IBuffer, - public readonly type: 'normal' | 'alternate' - ) { } - - public init(buffer: IBuffer): BufferApiView { - this._buffer = buffer; - return this; - } - - public get cursorY(): number { return this._buffer.y; } - public get cursorX(): number { return this._buffer.x; } - public get viewportY(): number { return this._buffer.ydisp; } - public get baseY(): number { return this._buffer.ybase; } - public get length(): number { return this._buffer.lines.length; } - public getLine(y: number): IBufferLineApi | undefined { - const line = this._buffer.lines.get(y); - if (!line) { - return undefined; - } - return new BufferLineApiView(line); - } - public getNullCell(): IBufferCellApi { return new CellData(); } -} - -class BufferNamespaceApi implements IBufferNamespaceApi { - private _normal: BufferApiView; - private _alternate: BufferApiView; - private _onBufferChange = new EventEmitter(); - public get onBufferChange(): IEvent { return this._onBufferChange.event; } - - constructor(private _core: ITerminal) { - this._normal = new BufferApiView(this._core.buffers.normal, 'normal'); - this._alternate = new BufferApiView(this._core.buffers.alt, 'alternate'); - this._core.buffers.onBufferActivate(() => this._onBufferChange.fire(this.active)); - } - public get active(): IBufferApi { - if (this._core.buffers.active === this._core.buffers.normal) { return this.normal; } - if (this._core.buffers.active === this._core.buffers.alt) { return this.alternate; } - throw new Error('Active buffer is neither normal nor alternate'); - } - public get normal(): IBufferApi { - return this._normal.init(this._core.buffers.normal); - } - public get alternate(): IBufferApi { - return this._alternate.init(this._core.buffers.alt); - } -} - -class BufferLineApiView implements IBufferLineApi { - constructor(private _line: IBufferLine) { } - - public get isWrapped(): boolean { return this._line.isWrapped; } - public get length(): number { return this._line.length; } - public getCell(x: number, cell?: IBufferCellApi): IBufferCellApi | undefined { - if (x < 0 || x >= this._line.length) { - return undefined; - } - - if (cell) { - this._line.loadCell(x, cell); - return cell; - } - return this._line.loadCell(x, new CellData()); - } - public translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string { - return this._line.translateToString(trimRight, startColumn, endColumn); - } -} - -class ParserApi implements IParser { - constructor(private _core: ITerminal) { } - - public registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable { - return this._core.addCsiHandler(id, (params: IParams) => callback(params.toArray())); - } - public addCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable { - return this.registerCsiHandler(id, callback); - } - public registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable { - return this._core.addDcsHandler(id, (data: string, params: IParams) => callback(data, params.toArray())); - } - public addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable { - return this.registerDcsHandler(id, callback); - } - public registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable { - return this._core.addEscHandler(id, handler); - } - public addEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable { - return this.registerEscHandler(id, handler); - } - public registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { - return this._core.addOscHandler(ident, callback); - } - public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { - return this.registerOscHandler(ident, callback); - } -} - -class UnicodeApi implements IUnicodeHandling { - constructor(private _core: ITerminal) { } - - public register(provider: IUnicodeVersionProvider): void { - this._core.unicodeService.register(provider); - } - - public get versions(): string[] { - return this._core.unicodeService.versions; - } - - public get activeVersion(): string { - return this._core.unicodeService.activeVersion; - } - - public set activeVersion(version: string) { - this._core.unicodeService.activeVersion = version; - } -} From 625e17ee1c0da9636bcd73f10da8851b90f376ae Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 15:30:55 -0700 Subject: [PATCH 244/377] Fix some errors, move TerminalCore to common/ --- .../{public/TerminalCore.ts => Terminal.ts} | 17 +++++++++++------ src/common/public/Terminal.ts | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) rename src/common/{public/TerminalCore.ts => Terminal.ts} (90%) diff --git a/src/common/public/TerminalCore.ts b/src/common/Terminal.ts similarity index 90% rename from src/common/public/TerminalCore.ts rename to src/common/Terminal.ts index 2aae1ee2..4011adb9 100644 --- a/src/common/public/TerminalCore.ts +++ b/src/common/Terminal.ts @@ -21,19 +21,20 @@ * http://linux.die.net/man/7/urxvt */ -import { ICoreTerminal, IDisposable, IMarker, ITerminalOptions } from 'common/Types'; -import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter'; import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; -import { IBuffer, IBufferSet } from 'common/buffer/Types'; +import { IBuffer } from 'common/buffer/Types'; import { CoreTerminal } from 'common/CoreTerminal'; +import { EventEmitter, forwardEvent, IEvent } from 'common/EventEmitter'; import { ITerminalOptions as IInitializedTerminalOptions } from 'common/services/Services'; -import { IFunctionIdentifier, IParams } from 'common/parser/Types'; +import { IMarker, ITerminalOptions, ScrollSource } from 'common/Types'; export class Terminal extends CoreTerminal { // TODO: We should remove options once components adopt optionsService public get options(): IInitializedTerminalOptions { return this.optionsService.options; } + private _onBell = new EventEmitter(); + public get onBell (): IEvent { return this._onBell.event; } private _onCursorMove = new EventEmitter(); public get onCursorMove(): IEvent { return this._onCursorMove.event; } private _onTitleChange = new EventEmitter(); @@ -64,8 +65,8 @@ export class Terminal extends CoreTerminal { this._setup(); // Setup InputHandler listeners + this.register(this._inputHandler.onRequestBell(() => this.bell())); this.register(this._inputHandler.onRequestReset(() => this.reset())); - this.register(this._inputHandler.onRequestScroll((eraseAttr, isWrapped) => this.scroll(eraseAttr, isWrapped || undefined))); this.register(forwardEvent(this._inputHandler.onCursorMove, this._onCursorMove)); this.register(forwardEvent(this._inputHandler.onTitleChange, this._onTitleChange)); this.register(forwardEvent(this._inputHandler.onA11yChar, this._onA11yCharEmitter)); @@ -100,6 +101,10 @@ export class Terminal extends CoreTerminal { return this.buffer.addMarker(this.buffer.ybase + this.buffer.y + cursorYOffset); } + public bell(): void { + this._onBell.fire(); + } + /** * Resizes the terminal. * @@ -130,7 +135,7 @@ export class Terminal extends CoreTerminal { for (let i = 1; i < this.rows; i++) { this.buffer.lines.push(this.buffer.getBlankLine(DEFAULT_ATTR_DATA)); } - this._onScroll.fire(this.buffer.ydisp); + this._onScroll.fire({ position: this.buffer.ydisp, source: ScrollSource.TERMINAL }); } /** diff --git a/src/common/public/Terminal.ts b/src/common/public/Terminal.ts index 6b63ee1e..3d195b75 100644 --- a/src/common/public/Terminal.ts +++ b/src/common/public/Terminal.ts @@ -8,7 +8,7 @@ import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi'; import { ParserApi } from 'common/public/ParserApi'; import { UnicodeApi } from 'common/public/UnicodeApi'; import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core'; -import { Terminal as TerminalCore } from './TerminalCore'; +import { Terminal as TerminalCore } from '../Terminal'; export class Terminal implements ITerminalApi { private _core: TerminalCore; From df17288c1e35983751345f8f6e05b399ba372a3a Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 15:40:13 -0700 Subject: [PATCH 245/377] Create headless project, fix compile --- .eslintrc.json | 1 + headless/headless/Terminal.d.ts | 28 + headless/headless/Terminal.d.ts.map | 1 + headless/headless/Terminal.js | 130 ++ headless/headless/Terminal.js.map | 1 + headless/headless/public/Terminal.d.ts | 48 + headless/headless/public/Terminal.d.ts.map | 1 + headless/headless/public/Terminal.js | 147 +++ headless/headless/public/Terminal.js.map | 1 + headless/headless/tsconfig.tsbuildinfo | 1120 +++++++++++++++++ headless/headless/types.d.ts | 32 + headless/headless/types.d.ts.map | 1 + headless/headless/types.js | 3 + headless/headless/types.js.map | 1 + src/common/public/tsconfig.json | 21 - src/{common => headless}/Terminal.ts | 0 .../public/types.ts => headless/Types.d.ts} | 2 +- src/{common => headless}/public/Terminal.ts | 2 +- src/headless/tsconfig.json | 27 + tsconfig.all.json | 1 + 20 files changed, 1545 insertions(+), 23 deletions(-) create mode 100644 headless/headless/Terminal.d.ts create mode 100644 headless/headless/Terminal.d.ts.map create mode 100644 headless/headless/Terminal.js create mode 100644 headless/headless/Terminal.js.map create mode 100644 headless/headless/public/Terminal.d.ts create mode 100644 headless/headless/public/Terminal.d.ts.map create mode 100644 headless/headless/public/Terminal.js create mode 100644 headless/headless/public/Terminal.js.map create mode 100644 headless/headless/tsconfig.tsbuildinfo create mode 100644 headless/headless/types.d.ts create mode 100644 headless/headless/types.d.ts.map create mode 100644 headless/headless/types.js create mode 100644 headless/headless/types.js.map delete mode 100644 src/common/public/tsconfig.json rename src/{common => headless}/Terminal.ts (100%) rename src/{common/public/types.ts => headless/Types.d.ts} (99%) rename src/{common => headless}/public/Terminal.ts (98%) create mode 100644 src/headless/tsconfig.json diff --git a/.eslintrc.json b/.eslintrc.json index 6031c195..427c7a16 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -9,6 +9,7 @@ "project": [ "src/browser/tsconfig.json", "src/common/tsconfig.json", + "src/headless/tsconfig.json", "test/api/tsconfig.json", "test/benchmark/tsconfig.json", "addons/xterm-addon-attach/src/tsconfig.json", diff --git a/headless/headless/Terminal.d.ts b/headless/headless/Terminal.d.ts new file mode 100644 index 00000000..7ab11fc7 --- /dev/null +++ b/headless/headless/Terminal.d.ts @@ -0,0 +1,28 @@ +import { IBuffer } from 'common/buffer/Types'; +import { CoreTerminal } from 'common/CoreTerminal'; +import { IEvent } from 'common/EventEmitter'; +import { ITerminalOptions as IInitializedTerminalOptions } from 'common/services/Services'; +import { IMarker, ITerminalOptions } from 'common/Types'; +export declare class Terminal extends CoreTerminal { + get options(): IInitializedTerminalOptions; + private _onBell; + get onBell(): IEvent; + private _onCursorMove; + get onCursorMove(): IEvent; + private _onTitleChange; + get onTitleChange(): IEvent; + private _onA11yCharEmitter; + get onA11yChar(): IEvent; + private _onA11yTabEmitter; + get onA11yTab(): IEvent; + constructor(options?: ITerminalOptions); + dispose(): void; + get buffer(): IBuffer; + get markers(): IMarker[]; + addMarker(cursorYOffset: number): IMarker | undefined; + bell(): void; + resize(x: number, y: number): void; + clear(): void; + reset(): void; +} +//# sourceMappingURL=Terminal.d.ts.map \ No newline at end of file diff --git a/headless/headless/Terminal.d.ts.map b/headless/headless/Terminal.d.ts.map new file mode 100644 index 00000000..f5020f83 --- /dev/null +++ b/headless/headless/Terminal.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Terminal.d.ts","sourceRoot":"","sources":["../../src/headless/Terminal.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAA8B,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,gBAAgB,IAAI,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAgB,MAAM,cAAc,CAAC;AAEvE,qBAAa,QAAS,SAAQ,YAAY;IAExC,IAAW,OAAO,IAAI,2BAA2B,CAAwC;IAGzF,OAAO,CAAC,OAAO,CAA6B;IAC5C,IAAW,MAAM,IAAK,MAAM,CAAC,IAAI,CAAC,CAA+B;IACjE,OAAO,CAAC,aAAa,CAA4B;IACjD,IAAW,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,CAAqC;IAC5E,OAAO,CAAC,cAAc,CAA8B;IACpD,IAAW,aAAa,IAAI,MAAM,CAAC,MAAM,CAAC,CAAsC;IAEhF,OAAO,CAAC,kBAAkB,CAA8B;IACxD,IAAW,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,CAA0C;IACjF,OAAO,CAAC,iBAAiB,CAA8B;IACvD,IAAW,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,CAAyC;gBAe7E,OAAO,GAAE,gBAAqB;IAezB,OAAO,IAAI,IAAI;IAWtB,IAAW,MAAM,IAAI,OAAO,CAE3B;IAED,IAAW,OAAO,IAAI,OAAO,EAAE,CAE9B;IAEM,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IASrD,IAAI,IAAI,IAAI;IAUZ,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAWlC,KAAK,IAAI,IAAI;IAwBb,KAAK,IAAI,IAAI;CAWrB"} \ No newline at end of file diff --git a/headless/headless/Terminal.js b/headless/headless/Terminal.js new file mode 100644 index 00000000..66f4d364 --- /dev/null +++ b/headless/headless/Terminal.js @@ -0,0 +1,130 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Terminal = void 0; +var BufferLine_1 = require("common/buffer/BufferLine"); +var CoreTerminal_1 = require("common/CoreTerminal"); +var EventEmitter_1 = require("common/EventEmitter"); +var Terminal = (function (_super) { + __extends(Terminal, _super); + function Terminal(options) { + if (options === void 0) { options = {}; } + var _this = _super.call(this, options) || this; + _this._onBell = new EventEmitter_1.EventEmitter(); + _this._onCursorMove = new EventEmitter_1.EventEmitter(); + _this._onTitleChange = new EventEmitter_1.EventEmitter(); + _this._onA11yCharEmitter = new EventEmitter_1.EventEmitter(); + _this._onA11yTabEmitter = new EventEmitter_1.EventEmitter(); + _this._setup(); + _this.register(_this._inputHandler.onRequestBell(function () { return _this.bell(); })); + _this.register(_this._inputHandler.onRequestReset(function () { return _this.reset(); })); + _this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onCursorMove, _this._onCursorMove)); + _this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onTitleChange, _this._onTitleChange)); + _this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onA11yChar, _this._onA11yCharEmitter)); + _this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onA11yTab, _this._onA11yTabEmitter)); + return _this; + } + Object.defineProperty(Terminal.prototype, "options", { + get: function () { return this.optionsService.options; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onBell", { + get: function () { return this._onBell.event; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onCursorMove", { + get: function () { return this._onCursorMove.event; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onTitleChange", { + get: function () { return this._onTitleChange.event; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onA11yChar", { + get: function () { return this._onA11yCharEmitter.event; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onA11yTab", { + get: function () { return this._onA11yTabEmitter.event; }, + enumerable: false, + configurable: true + }); + Terminal.prototype.dispose = function () { + if (this._isDisposed) { + return; + } + _super.prototype.dispose.call(this); + this.write = function () { }; + }; + Object.defineProperty(Terminal.prototype, "buffer", { + get: function () { + return this.buffers.active; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "markers", { + get: function () { + return this.buffer.markers; + }, + enumerable: false, + configurable: true + }); + Terminal.prototype.addMarker = function (cursorYOffset) { + if (this.buffer !== this.buffers.normal) { + return; + } + return this.buffer.addMarker(this.buffer.ybase + this.buffer.y + cursorYOffset); + }; + Terminal.prototype.bell = function () { + this._onBell.fire(); + }; + Terminal.prototype.resize = function (x, y) { + if (x === this.cols && y === this.rows) { + return; + } + _super.prototype.resize.call(this, x, y); + }; + Terminal.prototype.clear = function () { + if (this.buffer.ybase === 0 && this.buffer.y === 0) { + return; + } + this.buffer.lines.set(0, this.buffer.lines.get(this.buffer.ybase + this.buffer.y)); + this.buffer.lines.length = 1; + this.buffer.ydisp = 0; + this.buffer.ybase = 0; + this.buffer.y = 0; + for (var i = 1; i < this.rows; i++) { + this.buffer.lines.push(this.buffer.getBlankLine(BufferLine_1.DEFAULT_ATTR_DATA)); + } + this._onScroll.fire({ position: this.buffer.ydisp, source: 0 }); + }; + Terminal.prototype.reset = function () { + this.options.rows = this.rows; + this.options.cols = this.cols; + this._setup(); + _super.prototype.reset.call(this); + }; + return Terminal; +}(CoreTerminal_1.CoreTerminal)); +exports.Terminal = Terminal; +//# sourceMappingURL=Terminal.js.map \ No newline at end of file diff --git a/headless/headless/Terminal.js.map b/headless/headless/Terminal.js.map new file mode 100644 index 00000000..ba7e26de --- /dev/null +++ b/headless/headless/Terminal.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Terminal.js","sourceRoot":"","sources":["../../src/headless/Terminal.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAuBA,uDAA6D;AAE7D,oDAAmD;AACnD,oDAAyE;AAIzE;IAA8B,4BAAY;IA6BxC,kBACE,OAA8B;QAA9B,wBAAA,EAAA,YAA8B;QADhC,YAGE,kBAAM,OAAO,CAAC,SAWf;QAtCO,aAAO,GAAI,IAAI,2BAAY,EAAQ,CAAC;QAEpC,mBAAa,GAAG,IAAI,2BAAY,EAAQ,CAAC;QAEzC,oBAAc,GAAG,IAAI,2BAAY,EAAU,CAAC;QAG5C,wBAAkB,GAAG,IAAI,2BAAY,EAAU,CAAC;QAEhD,uBAAiB,GAAG,IAAI,2BAAY,EAAU,CAAC;QAoBrD,KAAI,CAAC,MAAM,EAAE,CAAC;QAGd,KAAI,CAAC,QAAQ,CAAC,KAAI,CAAC,aAAa,CAAC,aAAa,CAAC,cAAM,OAAA,KAAI,CAAC,IAAI,EAAE,EAAX,CAAW,CAAC,CAAC,CAAC;QACnE,KAAI,CAAC,QAAQ,CAAC,KAAI,CAAC,aAAa,CAAC,cAAc,CAAC,cAAM,OAAA,KAAI,CAAC,KAAK,EAAE,EAAZ,CAAY,CAAC,CAAC,CAAC;QACrE,KAAI,CAAC,QAAQ,CAAC,2BAAY,CAAC,KAAI,CAAC,aAAa,CAAC,YAAY,EAAE,KAAI,CAAC,aAAa,CAAC,CAAC,CAAC;QACjF,KAAI,CAAC,QAAQ,CAAC,2BAAY,CAAC,KAAI,CAAC,aAAa,CAAC,aAAa,EAAE,KAAI,CAAC,cAAc,CAAC,CAAC,CAAC;QACnF,KAAI,CAAC,QAAQ,CAAC,2BAAY,CAAC,KAAI,CAAC,aAAa,CAAC,UAAU,EAAE,KAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACpF,KAAI,CAAC,QAAQ,CAAC,2BAAY,CAAC,KAAI,CAAC,aAAa,CAAC,SAAS,EAAE,KAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;;IACpF,CAAC;IAzCD,sBAAW,6BAAO;aAAlB,cAAoD,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;;;OAAA;IAIzF,sBAAW,4BAAM;aAAjB,cAAqC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IAEjE,sBAAW,kCAAY;aAAvB,cAA0C,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IAE5E,sBAAW,mCAAa;aAAxB,cAA6C,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IAGhF,sBAAW,gCAAU;aAArB,cAA0C,OAAO,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IAEjF,sBAAW,+BAAS;aAApB,cAAyC,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IA8BxE,0BAAO,GAAd;QACE,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,OAAO;SACR;QACD,iBAAM,OAAO,WAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,cAAQ,CAAC,CAAC;IACzB,CAAC;IAKD,sBAAW,4BAAM;aAAjB;YACE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QAC7B,CAAC;;;OAAA;IAED,sBAAW,6BAAO;aAAlB;YACE,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;QAC7B,CAAC;;;OAAA;IAEM,4BAAS,GAAhB,UAAiB,aAAqB;QAEpC,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACvC,OAAO;SACR;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC;IAClF,CAAC;IAEM,uBAAI,GAAX;QACE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;IAQM,yBAAM,GAAb,UAAc,CAAS,EAAE,CAAS;QAChC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE;YACtC,OAAO;SACR;QAED,iBAAM,MAAM,YAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrB,CAAC;IAKM,wBAAK,GAAZ;QACE,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE;YAElD,OAAO;SACR;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,CAAC;QACpF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;YAClC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,8BAAiB,CAAC,CAAC,CAAC;SACrE;QACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAuB,EAAE,CAAC,CAAC;IACtF,CAAC;IAUM,wBAAK,GAAZ;QAKE,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAE9B,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,iBAAM,KAAK,WAAE,CAAC;IAChB,CAAC;IACH,eAAC;AAAD,CAAC,AAjID,CAA8B,2BAAY,GAiIzC;AAjIY,4BAAQ"} \ No newline at end of file diff --git a/headless/headless/public/Terminal.d.ts b/headless/headless/public/Terminal.d.ts new file mode 100644 index 00000000..669fff57 --- /dev/null +++ b/headless/headless/public/Terminal.d.ts @@ -0,0 +1,48 @@ +import { IEvent } from 'common/EventEmitter'; +import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core'; +export declare class Terminal implements ITerminalApi { + private _core; + private _parser; + private _buffer; + constructor(options?: ITerminalOptions); + private _checkProposedApi; + get onCursorMove(): IEvent; + get onLineFeed(): IEvent; + get onData(): IEvent; + get onBinary(): IEvent; + get onTitleChange(): IEvent; + get onResize(): IEvent<{ + cols: number; + rows: number; + }>; + get parser(): IParser; + get unicode(): IUnicodeHandling; + get rows(): number; + get cols(): number; + get buffer(): IBufferNamespaceApi; + get markers(): ReadonlyArray; + resize(columns: number, rows: number): void; + registerMarker(cursorYOffset: number): IMarker | undefined; + addMarker(cursorYOffset: number): IMarker | undefined; + dispose(): void; + clear(): void; + write(data: string | Uint8Array, callback?: () => void): void; + writeUtf8(data: Uint8Array, callback?: () => void): void; + writeln(data: string | Uint8Array, callback?: () => void): void; + getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string; + getOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell'): boolean; + getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; + getOption(key: string): any; + setOption(key: 'bellSound' | 'fontFamily' | 'termName' | 'wordSeparator', value: string): void; + setOption(key: 'fontWeight' | 'fontWeightBold', value: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void; + setOption(key: 'logLevel', value: 'debug' | 'info' | 'warn' | 'error' | 'off'): void; + setOption(key: 'bellStyle', value: 'none' | 'visual' | 'sound' | 'both'): void; + setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void; + setOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell', value: boolean): void; + setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; + setOption(key: 'cols' | 'rows', value: number): void; + setOption(key: string, value: any): void; + reset(): void; + private _verifyIntegers; +} +//# sourceMappingURL=Terminal.d.ts.map \ No newline at end of file diff --git a/headless/headless/public/Terminal.d.ts.map b/headless/headless/public/Terminal.d.ts.map new file mode 100644 index 00000000..b8fda933 --- /dev/null +++ b/headless/headless/public/Terminal.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Terminal.d.ts","sourceRoot":"","sources":["../../../src/headless/public/Terminal.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAI7C,OAAO,EAAE,gBAAgB,IAAI,mBAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AAGrJ,qBAAa,QAAS,YAAW,YAAY;IAC3C,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,OAAO,CAAiC;gBAEpC,OAAO,CAAC,EAAE,gBAAgB;IAItC,OAAO,CAAC,iBAAiB;IAMzB,IAAW,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,CAAoC;IAC3E,IAAW,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,CAAkC;IACvE,IAAW,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,CAA8B;IACjE,IAAW,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,CAAgC;IACrE,IAAW,aAAa,IAAI,MAAM,CAAC,MAAM,CAAC,CAAqC;IAC/E,IAAW,QAAQ,IAAI,MAAM,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAgC;IAE7F,IAAW,MAAM,IAAI,OAAO,CAM3B;IACD,IAAW,OAAO,IAAI,gBAAgB,CAGrC;IACD,IAAW,IAAI,IAAI,MAAM,CAA4B;IACrD,IAAW,IAAI,IAAI,MAAM,CAA4B;IACrD,IAAW,MAAM,IAAI,mBAAmB,CAMvC;IACD,IAAW,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAG3C;IACM,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAI3C,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAK1D,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAGrD,OAAO,IAAI,IAAI;IAGf,KAAK,IAAI,IAAI;IAGb,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;IAG7D,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;IAGxD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;IAI/D,SAAS,CAAC,GAAG,EAAE,WAAW,GAAG,WAAW,GAAG,aAAa,GAAG,YAAY,GAAG,UAAU,GAAG,cAAc,GAAG,UAAU,GAAG,eAAe,GAAG,MAAM;IAC7I,SAAS,CAAC,GAAG,EAAE,mBAAmB,GAAG,qBAAqB,GAAG,cAAc,GAAG,YAAY,GAAG,aAAa,GAAG,cAAc,GAAG,iBAAiB,GAAG,uBAAuB,GAAG,WAAW,GAAG,YAAY,GAAG,OAAO;IAChN,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,eAAe,GAAG,YAAY,GAAG,MAAM,GAAG,cAAc,GAAG,YAAY,GAAG,MAAM;IACrH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG;IAI3B,SAAS,CAAC,GAAG,EAAE,WAAW,GAAG,YAAY,GAAG,UAAU,GAAG,eAAe,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAC9F,SAAS,CAAC,GAAG,EAAE,YAAY,GAAG,gBAAgB,EAAE,KAAK,EAAE,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,IAAI;IAChK,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,IAAI;IACpF,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI;IAC9E,SAAS,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,KAAK,GAAG,IAAI;IACzE,SAAS,CAAC,GAAG,EAAE,mBAAmB,GAAG,qBAAqB,GAAG,cAAc,GAAG,YAAY,GAAG,aAAa,GAAG,cAAc,GAAG,iBAAiB,GAAG,uBAAuB,GAAG,WAAW,GAAG,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAC7N,SAAS,CAAC,GAAG,EAAE,UAAU,GAAG,eAAe,GAAG,YAAY,GAAG,cAAc,GAAG,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAChH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IACpD,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAIxC,KAAK,IAAI,IAAI;IAIpB,OAAO,CAAC,eAAe;CAOxB"} \ No newline at end of file diff --git a/headless/headless/public/Terminal.js b/headless/headless/public/Terminal.js new file mode 100644 index 00000000..1718c3b6 --- /dev/null +++ b/headless/headless/public/Terminal.js @@ -0,0 +1,147 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Terminal = void 0; +var BufferNamespaceApi_1 = require("common/public/BufferNamespaceApi"); +var ParserApi_1 = require("common/public/ParserApi"); +var UnicodeApi_1 = require("common/public/UnicodeApi"); +var Terminal_1 = require("headless/Terminal"); +var Terminal = (function () { + function Terminal(options) { + this._core = new Terminal_1.Terminal(options); + } + Terminal.prototype._checkProposedApi = function () { + if (!this._core.optionsService.options.allowProposedApi) { + throw new Error('You must set the allowProposedApi option to true to use proposed API'); + } + }; + Object.defineProperty(Terminal.prototype, "onCursorMove", { + get: function () { return this._core.onCursorMove; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onLineFeed", { + get: function () { return this._core.onLineFeed; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onData", { + get: function () { return this._core.onData; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onBinary", { + get: function () { return this._core.onBinary; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onTitleChange", { + get: function () { return this._core.onTitleChange; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onResize", { + get: function () { return this._core.onResize; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "parser", { + get: function () { + this._checkProposedApi(); + if (!this._parser) { + this._parser = new ParserApi_1.ParserApi(this._core); + } + return this._parser; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "unicode", { + get: function () { + this._checkProposedApi(); + return new UnicodeApi_1.UnicodeApi(this._core); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "rows", { + get: function () { return this._core.rows; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "cols", { + get: function () { return this._core.cols; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "buffer", { + get: function () { + this._checkProposedApi(); + if (!this._buffer) { + this._buffer = new BufferNamespaceApi_1.BufferNamespaceApi(this._core); + } + return this._buffer; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "markers", { + get: function () { + this._checkProposedApi(); + return this._core.markers; + }, + enumerable: false, + configurable: true + }); + Terminal.prototype.resize = function (columns, rows) { + this._verifyIntegers(columns, rows); + this._core.resize(columns, rows); + }; + Terminal.prototype.registerMarker = function (cursorYOffset) { + this._checkProposedApi(); + this._verifyIntegers(cursorYOffset); + return this._core.addMarker(cursorYOffset); + }; + Terminal.prototype.addMarker = function (cursorYOffset) { + return this.registerMarker(cursorYOffset); + }; + Terminal.prototype.dispose = function () { + this._core.dispose(); + }; + Terminal.prototype.clear = function () { + this._core.clear(); + }; + Terminal.prototype.write = function (data, callback) { + this._core.write(data, callback); + }; + Terminal.prototype.writeUtf8 = function (data, callback) { + this._core.write(data, callback); + }; + Terminal.prototype.writeln = function (data, callback) { + this._core.write(data); + this._core.write('\r\n', callback); + }; + Terminal.prototype.getOption = function (key) { + return this._core.optionsService.getOption(key); + }; + Terminal.prototype.setOption = function (key, value) { + this._core.optionsService.setOption(key, value); + }; + Terminal.prototype.reset = function () { + this._core.reset(); + }; + Terminal.prototype._verifyIntegers = function () { + var values = []; + for (var _i = 0; _i < arguments.length; _i++) { + values[_i] = arguments[_i]; + } + for (var _a = 0, values_1 = values; _a < values_1.length; _a++) { + var value = values_1[_a]; + if (value === Infinity || isNaN(value) || value % 1 !== 0) { + throw new Error('This API only accepts integers'); + } + } + }; + return Terminal; +}()); +exports.Terminal = Terminal; +//# sourceMappingURL=Terminal.js.map \ No newline at end of file diff --git a/headless/headless/public/Terminal.js.map b/headless/headless/public/Terminal.js.map new file mode 100644 index 00000000..6e27bbc7 --- /dev/null +++ b/headless/headless/public/Terminal.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Terminal.js","sourceRoot":"","sources":["../../../src/headless/public/Terminal.ts"],"names":[],"mappings":";;;AAMA,uEAAsE;AACtE,qDAAoD;AACpD,uDAAsD;AAEtD,8CAA6D;AAE7D;IAKE,kBAAY,OAA0B;QACpC,IAAI,CAAC,KAAK,GAAG,IAAI,mBAAY,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAEO,oCAAiB,GAAzB;QACE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,gBAAgB,EAAE;YACvD,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;SACzF;IACH,CAAC;IAED,sBAAW,kCAAY;aAAvB,cAA0C,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;;;OAAA;IAC3E,sBAAW,gCAAU;aAArB,cAAwC,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;;;OAAA;IACvE,sBAAW,4BAAM;aAAjB,cAAsC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;;;OAAA;IACjE,sBAAW,8BAAQ;aAAnB,cAAwC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;;;OAAA;IACrE,sBAAW,mCAAa;aAAxB,cAA6C,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;;;OAAA;IAC/E,sBAAW,8BAAQ;aAAnB,cAAgE,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;;;OAAA;IAE7F,sBAAW,4BAAM;aAAjB;YACE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjB,IAAI,CAAC,OAAO,GAAG,IAAI,qBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAC1C;YACD,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;;;OAAA;IACD,sBAAW,6BAAO;aAAlB;YACE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,OAAO,IAAI,uBAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC;;;OAAA;IACD,sBAAW,0BAAI;aAAf,cAA4B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;;;OAAA;IACrD,sBAAW,0BAAI;aAAf,cAA4B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;;;OAAA;IACrD,sBAAW,4BAAM;aAAjB;YACE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjB,IAAI,CAAC,OAAO,GAAG,IAAI,uCAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACnD;YACD,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;;;OAAA;IACD,sBAAW,6BAAO;aAAlB;YACE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;QAC5B,CAAC;;;OAAA;IACM,yBAAM,GAAb,UAAc,OAAe,EAAE,IAAY;QACzC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IACM,iCAAc,GAArB,UAAsB,aAAqB;QACzC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IAC7C,CAAC;IACM,4BAAS,GAAhB,UAAiB,aAAqB;QACpC,OAAO,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;IAC5C,CAAC;IACM,0BAAO,GAAd;QACE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;IACM,wBAAK,GAAZ;QACE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IACM,wBAAK,GAAZ,UAAa,IAAyB,EAAE,QAAqB;QAC3D,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IACM,4BAAS,GAAhB,UAAiB,IAAgB,EAAE,QAAqB;QACtD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IACM,0BAAO,GAAd,UAAe,IAAyB,EAAE,QAAqB;QAC7D,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACrC,CAAC;IAKM,4BAAS,GAAhB,UAAiB,GAAQ;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAClD,CAAC;IAUM,4BAAS,GAAhB,UAAiB,GAAQ,EAAE,KAAU;QACnC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;IACM,wBAAK,GAAZ;QACE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAEO,kCAAe,GAAvB;QAAwB,gBAAmB;aAAnB,UAAmB,EAAnB,qBAAmB,EAAnB,IAAmB;YAAnB,2BAAmB;;QACzC,KAAoB,UAAM,EAAN,iBAAM,EAAN,oBAAM,EAAN,IAAM,EAAE;YAAvB,IAAM,KAAK,eAAA;YACd,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,KAAK,CAAC,EAAE;gBACzD,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;aACnD;SACF;IACH,CAAC;IACH,eAAC;AAAD,CAAC,AAxGD,IAwGC;AAxGY,4BAAQ"} \ No newline at end of file diff --git a/headless/headless/tsconfig.tsbuildinfo b/headless/headless/tsconfig.tsbuildinfo new file mode 100644 index 00000000..7307c747 --- /dev/null +++ b/headless/headless/tsconfig.tsbuildinfo @@ -0,0 +1,1120 @@ +{ + "program": { + "fileInfos": { + "../../node_modules/typescript/lib/lib.es5.d.ts": { + "version": "b3584bc5798ed422ce2516df360ffa9cf2d80b5eae852867db9ba3743145f895", + "signature": "b3584bc5798ed422ce2516df360ffa9cf2d80b5eae852867db9ba3743145f895", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.d.ts": { + "version": "dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6", + "signature": "dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6", + "affectsGlobalScope": false + }, + "../../node_modules/typescript/lib/lib.es2016.d.ts": { + "version": "7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467", + "signature": "7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467", + "affectsGlobalScope": false + }, + "../../node_modules/typescript/lib/lib.es2017.d.ts": { + "version": "8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9", + "signature": "8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9", + "affectsGlobalScope": false + }, + "../../node_modules/typescript/lib/lib.es2018.d.ts": { + "version": "5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06", + "signature": "5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06", + "affectsGlobalScope": false + }, + "../../node_modules/typescript/lib/lib.dom.d.ts": { + "version": "feeeb1dd8a80fb76be42b0426e8f3ffa9bdef3c2f3c12c147e7660b1c5ba8b3b", + "signature": "feeeb1dd8a80fb76be42b0426e8f3ffa9bdef3c2f3c12c147e7660b1c5ba8b3b", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.core.d.ts": { + "version": "46ee15e9fefa913333b61eaf6b18885900b139867d89832a515059b62cf16a17", + "signature": "46ee15e9fefa913333b61eaf6b18885900b139867d89832a515059b62cf16a17", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.collection.d.ts": { + "version": "43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c", + "signature": "43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.generator.d.ts": { + "version": "cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a", + "signature": "cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.iterable.d.ts": { + "version": "8b2a5df1ce95f78f6b74f1a555ccdb6baab0486b42d8345e0871dd82811f9b9a", + "signature": "8b2a5df1ce95f78f6b74f1a555ccdb6baab0486b42d8345e0871dd82811f9b9a", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.promise.d.ts": { + "version": "2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c", + "signature": "2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.proxy.d.ts": { + "version": "810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357", + "signature": "810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.reflect.d.ts": { + "version": "62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6", + "signature": "62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.symbol.d.ts": { + "version": "3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93", + "signature": "3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts": { + "version": "9d122b7e8c1a5c72506eea50c0973cba55b92b5532d5cafa8a6ce2c547d57551", + "signature": "9d122b7e8c1a5c72506eea50c0973cba55b92b5532d5cafa8a6ce2c547d57551", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2016.array.include.d.ts": { + "version": "3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006", + "signature": "3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2017.object.d.ts": { + "version": "17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a", + "signature": "17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts": { + "version": "7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98", + "signature": "7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2017.string.d.ts": { + "version": "6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577", + "signature": "6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2017.intl.d.ts": { + "version": "12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d", + "signature": "12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts": { + "version": "b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e", + "signature": "b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts": { + "version": "0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a", + "signature": "0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts": { + "version": "a40c4d82bf13fcded295ac29f354eb7d40249613c15e07b53f2fc75e45e16359", + "signature": "a40c4d82bf13fcded295ac29f354eb7d40249613c15e07b53f2fc75e45e16359", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2018.intl.d.ts": { + "version": "df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e", + "signature": "df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2018.promise.d.ts": { + "version": "bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c", + "signature": "bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2018.regexp.d.ts": { + "version": "c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8", + "signature": "c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2020.bigint.d.ts": { + "version": "7b5a10e3c897fabece5a51aa85b4111727d7adb53c2734b5d37230ff96802a09", + "signature": "7b5a10e3c897fabece5a51aa85b4111727d7adb53c2734b5d37230ff96802a09", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.esnext.intl.d.ts": { + "version": "506b80b9951c9381dc5f11897b31fca5e2a65731d96ddefa19687fbc26b23c6e", + "signature": "506b80b9951c9381dc5f11897b31fca5e2a65731d96ddefa19687fbc26b23c6e", + "affectsGlobalScope": true + }, + "../../out/common/eventemitter.d.ts": { + "version": "5b03a7f7f7f551e3fe0e92da13d2e17e7ad7ee19c41d0637f4edbc120bc06f66", + "signature": "5b03a7f7f7f551e3fe0e92da13d2e17e7ad7ee19c41d0637f4edbc120bc06f66", + "affectsGlobalScope": false + }, + "../../out/common/circularlist.d.ts": { + "version": "f96222a7fe4af80068de748cd4bd0b247359b303c72cc827e887eaf6ef9fb758", + "signature": "f96222a7fe4af80068de748cd4bd0b247359b303c72cc827e887eaf6ef9fb758", + "affectsGlobalScope": false + }, + "../../out/common/parser/constants.d.ts": { + "version": "ae42446973a3c189ecac84723e74828ee292f9392935db874cb27ee19ca89093", + "signature": "ae42446973a3c189ecac84723e74828ee292f9392935db874cb27ee19ca89093", + "affectsGlobalScope": false + }, + "../../src/common/parser/types.d.ts": { + "version": "55b56377b6fa8b93856027f20ebaccd8e0c77d4327e45e45b5e2041cf94011cc", + "signature": "55b56377b6fa8b93856027f20ebaccd8e0c77d4327e45e45b5e2041cf94011cc", + "affectsGlobalScope": false + }, + "../../src/common/buffer/types.d.ts": { + "version": "5e2f59fc5cb1b39a2e163bafe30139a33dac4033edcb9b1b831d542abb7f7bae", + "signature": "5e2f59fc5cb1b39a2e163bafe30139a33dac4033edcb9b1b831d542abb7f7bae", + "affectsGlobalScope": false + }, + "../../out/common/services/services.d.ts": { + "version": "4672a4d6d71a25b4592922ecd70094e932348a031d39acc4cef027ea9b62cba0", + "signature": "4672a4d6d71a25b4592922ecd70094e932348a031d39acc4cef027ea9b62cba0", + "affectsGlobalScope": false + }, + "../../src/common/types.d.ts": { + "version": "d7d8eb9c47232c80348f2fc6c8eb7d3acb329b6d8fdcf1f1c38d6e5099f8370b", + "signature": "d7d8eb9c47232c80348f2fc6c8eb7d3acb329b6d8fdcf1f1c38d6e5099f8370b", + "affectsGlobalScope": false + }, + "../../out/common/buffer/constants.d.ts": { + "version": "ff74cff1b7fe399447fd661d0c68586e7b991d11d044af133963c04bde38a852", + "signature": "ff74cff1b7fe399447fd661d0c68586e7b991d11d044af133963c04bde38a852", + "affectsGlobalScope": false + }, + "../../out/common/buffer/attributedata.d.ts": { + "version": "421bb313e7b328ba640853d13b584fe7815b818bd02584d020a41b7a7120d262", + "signature": "421bb313e7b328ba640853d13b584fe7815b818bd02584d020a41b7a7120d262", + "affectsGlobalScope": false + }, + "../../out/common/buffer/bufferline.d.ts": { + "version": "baaa0fc61cb33a67caa0abb986740700be9313c6866ed78c17193e87ca7057a1", + "signature": "baaa0fc61cb33a67caa0abb986740700be9313c6866ed78c17193e87ca7057a1", + "affectsGlobalScope": false + }, + "../../out/common/lifecycle.d.ts": { + "version": "0ba457ac19650eb9dffb8216ca42947899613be5aee16f3809fe39187c30423e", + "signature": "0ba457ac19650eb9dffb8216ca42947899613be5aee16f3809fe39187c30423e", + "affectsGlobalScope": false + }, + "../../out/common/inputhandler.d.ts": { + "version": "542507ad71abebbfe8b5da8758e1aa47bfce3acd0da245f10885cab9934b71d6", + "signature": "542507ad71abebbfe8b5da8758e1aa47bfce3acd0da245f10885cab9934b71d6", + "affectsGlobalScope": false + }, + "../../out/common/coreterminal.d.ts": { + "version": "ab615cd4d0ef6f17d26eef27cdf5beec0e081e59b5eefb09ede878c2cabb4c15", + "signature": "ab615cd4d0ef6f17d26eef27cdf5beec0e081e59b5eefb09ede878c2cabb4c15", + "affectsGlobalScope": false + }, + "../../src/headless/terminal.ts": { + "version": "59209d1535dcfbe8bac847ccf13e829a9ea692ce58fdcb3ee3605791ae60b564", + "signature": "5311ffa92a616a0729010de20af2272185a8b65b51ac26a496326b3b32aad8cc", + "affectsGlobalScope": false + }, + "../../src/headless/types.d.ts": { + "version": "d51941b70feb73ac171f24e34f11de9be17d0c4f224da1a6ed39fe8c31ba6695", + "signature": "d51941b70feb73ac171f24e34f11de9be17d0c4f224da1a6ed39fe8c31ba6695", + "affectsGlobalScope": false + }, + "../../out/common/public/buffernamespaceapi.d.ts": { + "version": "1f8e93ce424bd436ad641d8313d849af586a3779adbfd870e1cfee72a212ae57", + "signature": "1f8e93ce424bd436ad641d8313d849af586a3779adbfd870e1cfee72a212ae57", + "affectsGlobalScope": false + }, + "../../out/common/public/parserapi.d.ts": { + "version": "7c0d242565ad3b41ef8666e46fbd88aec222d2e9b2a343ac315b00373401ffc2", + "signature": "7c0d242565ad3b41ef8666e46fbd88aec222d2e9b2a343ac315b00373401ffc2", + "affectsGlobalScope": false + }, + "../../out/common/public/unicodeapi.d.ts": { + "version": "d77b28e85c1bbc95897707b719c4797ac94f5bf76572c81baae195787133826c", + "signature": "d77b28e85c1bbc95897707b719c4797ac94f5bf76572c81baae195787133826c", + "affectsGlobalScope": false + }, + "../../src/headless/public/terminal.ts": { + "version": "fce93b9408e0c088a1c6802aff2cf8cc46ac0feddc59f26b5a3241d0f03c82db", + "signature": "503924e7f37322f587ebce5459da9c47860c843c0d30d6d09b6ba25d5d169ac7", + "affectsGlobalScope": false + }, + "../../typings/xterm.d.ts": { + "version": "d5256f76893350e4897436490570d291be7a2a005d44e3fa221f1a19804b8c5e", + "signature": "d5256f76893350e4897436490570d291be7a2a005d44e3fa221f1a19804b8c5e", + "affectsGlobalScope": false + }, + "../../typings/xterm-core.d.ts": { + "version": "675fd5779b700c3e864a36a14db728d91027632f90e60c7bfd440b5db61e174d", + "signature": "675fd5779b700c3e864a36a14db728d91027632f90e60c7bfd440b5db61e174d", + "affectsGlobalScope": false + }, + "../../node_modules/@types/mocha/index.d.ts": { + "version": "0359800d3b440f8515001431cde1500944e156040577425eb3f7b80af0846612", + "signature": "0359800d3b440f8515001431cde1500944e156040577425eb3f7b80af0846612", + "affectsGlobalScope": true + }, + "../../node_modules/@types/node/globals.d.ts": { + "version": "25b4a0c4fab47c373ee49df4c239826ee3430019fc0c1b5e59edc3e398b7468d", + "signature": "25b4a0c4fab47c373ee49df4c239826ee3430019fc0c1b5e59edc3e398b7468d", + "affectsGlobalScope": true + }, + "../../node_modules/@types/node/async_hooks.d.ts": { + "version": "c9e8a340da877b05a52525554aa255b3f44958c7f6748ebf5cbe0bfbe6766878", + "signature": "c9e8a340da877b05a52525554aa255b3f44958c7f6748ebf5cbe0bfbe6766878", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/buffer.d.ts": { + "version": "a473cf45c3d9809518f8af913312139d9f4db6887dc554e0d06d0f4e52722e6b", + "signature": "a473cf45c3d9809518f8af913312139d9f4db6887dc554e0d06d0f4e52722e6b", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/child_process.d.ts": { + "version": "a668dfae917097b30fc29bbebeeb869cee22529f2aa9976cea03c7e834a1b841", + "signature": "a668dfae917097b30fc29bbebeeb869cee22529f2aa9976cea03c7e834a1b841", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/cluster.d.ts": { + "version": "04eaa93bd75f937f9184dcb95a7983800c5770cf8ddd8ac0f3734dc02f5b20ef", + "signature": "04eaa93bd75f937f9184dcb95a7983800c5770cf8ddd8ac0f3734dc02f5b20ef", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/console.d.ts": { + "version": "c8155caf28fc7b0a564156a5df28ad8a844a3bd32d331d148d8f3ce88025c870", + "signature": "c8155caf28fc7b0a564156a5df28ad8a844a3bd32d331d148d8f3ce88025c870", + "affectsGlobalScope": true + }, + "../../node_modules/@types/node/constants.d.ts": { + "version": "45ac321f2e15d268fd74a90ddaa6467dcaaff2c5b13f95b4b85831520fb7a491", + "signature": "45ac321f2e15d268fd74a90ddaa6467dcaaff2c5b13f95b4b85831520fb7a491", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/crypto.d.ts": { + "version": "0084b54e281a37c75079f92ca20603d5731de063e7a425852b2907de4dd19932", + "signature": "0084b54e281a37c75079f92ca20603d5731de063e7a425852b2907de4dd19932", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/dgram.d.ts": { + "version": "797a9d37eb1f76143311c3f0a186ce5c0d8735e94c0ca08ff8712a876c9b4f9e", + "signature": "797a9d37eb1f76143311c3f0a186ce5c0d8735e94c0ca08ff8712a876c9b4f9e", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/dns.d.ts": { + "version": "bc31e01146eec89eb870b9ad8c55d759bcbc8989a894e6f0f81f832e0d10eb04", + "signature": "bc31e01146eec89eb870b9ad8c55d759bcbc8989a894e6f0f81f832e0d10eb04", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/domain.d.ts": { + "version": "2866a528b2708aa272ec3eaafd3c980abb23aec1ef831cfc5eb2186b98c37ce5", + "signature": "2866a528b2708aa272ec3eaafd3c980abb23aec1ef831cfc5eb2186b98c37ce5", + "affectsGlobalScope": true + }, + "../../node_modules/@types/node/events.d.ts": { + "version": "153d835dc32985120790e10102834b0a5bd979bb5e42bfbb33c0ff6260cf03ce", + "signature": "153d835dc32985120790e10102834b0a5bd979bb5e42bfbb33c0ff6260cf03ce", + "affectsGlobalScope": true + }, + "../../node_modules/@types/node/fs.d.ts": { + "version": "a44c87a409b60f211a240341905d818f5f173420dcf7f989ee6c8a1a3d812ae9", + "signature": "a44c87a409b60f211a240341905d818f5f173420dcf7f989ee6c8a1a3d812ae9", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/fs/promises.d.ts": { + "version": "bdaf554ae2d9d09e2a42f58a29ef7f80e5b5c1d7b96bfb717243dc91a477216e", + "signature": "bdaf554ae2d9d09e2a42f58a29ef7f80e5b5c1d7b96bfb717243dc91a477216e", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/http.d.ts": { + "version": "dce8672a79c7221c10a355b905940ab57505bc480a72a5da33ba24cbf82bb75c", + "signature": "dce8672a79c7221c10a355b905940ab57505bc480a72a5da33ba24cbf82bb75c", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/http2.d.ts": { + "version": "321ea733ae7f611077a2d7b4bc378ac4a6b7e365e1a51c71a7e5b2818e1e310a", + "signature": "321ea733ae7f611077a2d7b4bc378ac4a6b7e365e1a51c71a7e5b2818e1e310a", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/https.d.ts": { + "version": "13257840c0850d4ebd7c2b17604a9e006f752de76c2400ebc752bc465c330452", + "signature": "13257840c0850d4ebd7c2b17604a9e006f752de76c2400ebc752bc465c330452", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/inspector.d.ts": { + "version": "42176966283d3835c34278b9b5c0f470d484c0c0c6a55c20a2c916a1ce69b6e8", + "signature": "42176966283d3835c34278b9b5c0f470d484c0c0c6a55c20a2c916a1ce69b6e8", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/module.d.ts": { + "version": "0cff7901aedfe78e314f7d44088f07e2afa1b6e4f0473a4169b8456ca2fb245d", + "signature": "0cff7901aedfe78e314f7d44088f07e2afa1b6e4f0473a4169b8456ca2fb245d", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/net.d.ts": { + "version": "40b957b502b40dd490ee334aed47a30636f8d14a0267d1b6c088c2be1dcf2757", + "signature": "40b957b502b40dd490ee334aed47a30636f8d14a0267d1b6c088c2be1dcf2757", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/os.d.ts": { + "version": "69640cc2e76dad52daeb9914e6b70c5c9a5591a3a65190a2d3ea432cf0015e16", + "signature": "69640cc2e76dad52daeb9914e6b70c5c9a5591a3a65190a2d3ea432cf0015e16", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/path.d.ts": { + "version": "21e64a125f65dff99cc3ed366c96e922b90daed343eb52ecdace5f220401dcda", + "signature": "21e64a125f65dff99cc3ed366c96e922b90daed343eb52ecdace5f220401dcda", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/perf_hooks.d.ts": { + "version": "4982d94cb6427263c8839d8d6324a8bbe129e931deb61a7380f8fad17ba2cfc0", + "signature": "4982d94cb6427263c8839d8d6324a8bbe129e931deb61a7380f8fad17ba2cfc0", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/process.d.ts": { + "version": "b0b00cf2e8107ab671243a73d2fbd6296a853bebe3fcfaaca293f65aaa245eaf", + "signature": "b0b00cf2e8107ab671243a73d2fbd6296a853bebe3fcfaaca293f65aaa245eaf", + "affectsGlobalScope": true + }, + "../../node_modules/@types/node/punycode.d.ts": { + "version": "7f77304372efe3c9967e5f9ea2061f1b4bf41dc3cda3c83cdd676f2e5af6b7e6", + "signature": "7f77304372efe3c9967e5f9ea2061f1b4bf41dc3cda3c83cdd676f2e5af6b7e6", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/querystring.d.ts": { + "version": "992c6f6be16c0a1d2eec13ece33adeea2c747ba27fcd078353a8f4bb5b4fea58", + "signature": "992c6f6be16c0a1d2eec13ece33adeea2c747ba27fcd078353a8f4bb5b4fea58", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/readline.d.ts": { + "version": "3b790d08129aca55fd5ae1672d1d26594147ac0d5f2eedc30c7575eb18daef7e", + "signature": "3b790d08129aca55fd5ae1672d1d26594147ac0d5f2eedc30c7575eb18daef7e", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/repl.d.ts": { + "version": "64535caf208a02420d2d04eb2029269efedd11eb8597ada0d5e6f3d54ec663ae", + "signature": "64535caf208a02420d2d04eb2029269efedd11eb8597ada0d5e6f3d54ec663ae", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/stream.d.ts": { + "version": "e7b5a3f40f19d9eea71890c70dfb37ac5dd82cbffe5f95bc8f23c536455732d0", + "signature": "e7b5a3f40f19d9eea71890c70dfb37ac5dd82cbffe5f95bc8f23c536455732d0", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/string_decoder.d.ts": { + "version": "4fd3c4debadce3e9ab9dec3eb45f7f5e2e3d4ad65cf975a6d938d883cfb25a50", + "signature": "4fd3c4debadce3e9ab9dec3eb45f7f5e2e3d4ad65cf975a6d938d883cfb25a50", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/timers.d.ts": { + "version": "0953427f9c2498f71dd912fdd8a81b19cf6925de3e1ad67ab9a77b9a0f79bf0b", + "signature": "0953427f9c2498f71dd912fdd8a81b19cf6925de3e1ad67ab9a77b9a0f79bf0b", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/tls.d.ts": { + "version": "f89a6d56f0267f6e73c707f8a89d2f38e9928e10bfa505f39a4f4bf954093aee", + "signature": "f89a6d56f0267f6e73c707f8a89d2f38e9928e10bfa505f39a4f4bf954093aee", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/trace_events.d.ts": { + "version": "7df562288f949945cf69c21cd912100c2afedeeb7cdb219085f7f4b46cb7dde4", + "signature": "7df562288f949945cf69c21cd912100c2afedeeb7cdb219085f7f4b46cb7dde4", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/tty.d.ts": { + "version": "9d16690485ff1eb4f6fc57aebe237728fd8e03130c460919da3a35f4d9bd97f5", + "signature": "9d16690485ff1eb4f6fc57aebe237728fd8e03130c460919da3a35f4d9bd97f5", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/url.d.ts": { + "version": "dcc6910d95a3625fd2b0487fda055988e46ab46c357a1b3618c27b4a8dd739c9", + "signature": "dcc6910d95a3625fd2b0487fda055988e46ab46c357a1b3618c27b4a8dd739c9", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/util.d.ts": { + "version": "e649840284bab8c4d09cadc125cd7fbde7529690cc1a0881872b6a9cd202819b", + "signature": "e649840284bab8c4d09cadc125cd7fbde7529690cc1a0881872b6a9cd202819b", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/v8.d.ts": { + "version": "a364b4a8a015ae377052fa4fac94204d79a69d879567f444c7ceff1b7a18482d", + "signature": "a364b4a8a015ae377052fa4fac94204d79a69d879567f444c7ceff1b7a18482d", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/vm.d.ts": { + "version": "1aa7dbace2b7b2ef60897dcd4f66252ee6ba85e594ded8918c9acdcecda1896c", + "signature": "1aa7dbace2b7b2ef60897dcd4f66252ee6ba85e594ded8918c9acdcecda1896c", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/worker_threads.d.ts": { + "version": "6c63cb179eda2be5ab45dc146fa4151bec8ce4781986935fe40adfc69cbbf214", + "signature": "6c63cb179eda2be5ab45dc146fa4151bec8ce4781986935fe40adfc69cbbf214", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/zlib.d.ts": { + "version": "4926467de88a92a4fc9971d8c6f21b91eca1c0e7fc2a46cc4638ab9440c73875", + "signature": "4926467de88a92a4fc9971d8c6f21b91eca1c0e7fc2a46cc4638ab9440c73875", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/globals.global.d.ts": { + "version": "2708349d5a11a5c2e5f3a0765259ebe7ee00cdcc8161cb9990cb4910328442a1", + "signature": "2708349d5a11a5c2e5f3a0765259ebe7ee00cdcc8161cb9990cb4910328442a1", + "affectsGlobalScope": true + }, + "../../node_modules/@types/node/wasi.d.ts": { + "version": "4e0a4d84b15692ea8669fe4f3d05a4f204567906b1347da7a58b75f45bae48d3", + "signature": "4e0a4d84b15692ea8669fe4f3d05a4f204567906b1347da7a58b75f45bae48d3", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/ts3.6/base.d.ts": { + "version": "ae68a04912ee5a0f589276f9ec60b095f8c40d48128a4575b3fdd7d93806931c", + "signature": "ae68a04912ee5a0f589276f9ec60b095f8c40d48128a4575b3fdd7d93806931c", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/assert.d.ts": { + "version": "b3593bd345ebea5e4d0a894c03251a3774b34df3d6db57075c18e089a599ba76", + "signature": "b3593bd345ebea5e4d0a894c03251a3774b34df3d6db57075c18e089a599ba76", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/base.d.ts": { + "version": "e61a21e9418f279bc480394a94d1581b2dee73747adcbdef999b6737e34d721b", + "signature": "e61a21e9418f279bc480394a94d1581b2dee73747adcbdef999b6737e34d721b", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/index.d.ts": { + "version": "6c137dee82a61e14a1eb6a0ba56925b66fd83abf15acf72fe59a10b15e80e319", + "signature": "6c137dee82a61e14a1eb6a0ba56925b66fd83abf15acf72fe59a10b15e80e319", + "affectsGlobalScope": false + } + }, + "options": { + "target": 1, + "lib": [ + "lib.es2015.d.ts", + "lib.es2016.array.include.d.ts" + ], + "rootDir": "../../src", + "sourceMap": true, + "removeComments": true, + "pretty": true, + "incremental": true, + "experimentalDecorators": true, + "composite": true, + "strict": true, + "declarationMap": true, + "outDir": "..", + "types": [ + "../../node_modules/@types/mocha", + "../../node_modules/@types/node" + ], + "baseUrl": "../../src", + "extendedDiagnostics": true, + "paths": { + "common/*": [ + "./common/*" + ] + }, + "pathsBasePath": "D:/GitHub/Tyriar/xterm.js/src/headless", + "watch": true, + "preserveWatchOutput": true, + "configFilePath": "../../src/headless/tsconfig.json" + }, + "referencedMap": { + "../../node_modules/@types/node/base.d.ts": [ + "../../node_modules/@types/node/assert.d.ts", + "../../node_modules/@types/node/ts3.6/base.d.ts" + ], + "../../node_modules/@types/node/child_process.d.ts": [ + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs.d.ts", + "../../node_modules/@types/node/net.d.ts", + "../../node_modules/@types/node/stream.d.ts" + ], + "../../node_modules/@types/node/cluster.d.ts": [ + "../../node_modules/@types/node/child_process.d.ts", + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/net.d.ts" + ], + "../../node_modules/@types/node/console.d.ts": [ + "../../node_modules/@types/node/util.d.ts" + ], + "../../node_modules/@types/node/constants.d.ts": [ + "../../node_modules/@types/node/crypto.d.ts", + "../../node_modules/@types/node/fs.d.ts", + "../../node_modules/@types/node/os.d.ts" + ], + "../../node_modules/@types/node/crypto.d.ts": [ + "../../node_modules/@types/node/stream.d.ts" + ], + "../../node_modules/@types/node/dgram.d.ts": [ + "../../node_modules/@types/node/dns.d.ts", + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/net.d.ts" + ], + "../../node_modules/@types/node/domain.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/events.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/fs.d.ts": [ + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs/promises.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/fs/promises.d.ts": [ + "../../node_modules/@types/node/fs.d.ts" + ], + "../../node_modules/@types/node/http.d.ts": [ + "../../node_modules/@types/node/net.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/http2.d.ts": [ + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs.d.ts", + "../../node_modules/@types/node/http.d.ts", + "../../node_modules/@types/node/net.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/tls.d.ts", + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/https.d.ts": [ + "../../node_modules/@types/node/http.d.ts", + "../../node_modules/@types/node/tls.d.ts", + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/index.d.ts": [ + "../../node_modules/@types/node/base.d.ts" + ], + "../../node_modules/@types/node/inspector.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/module.d.ts": [ + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/net.d.ts": [ + "../../node_modules/@types/node/dns.d.ts", + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/stream.d.ts" + ], + "../../node_modules/@types/node/perf_hooks.d.ts": [ + "../../node_modules/@types/node/async_hooks.d.ts" + ], + "../../node_modules/@types/node/process.d.ts": [ + "../../node_modules/@types/node/tty.d.ts" + ], + "../../node_modules/@types/node/readline.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/repl.d.ts": [ + "../../node_modules/@types/node/readline.d.ts", + "../../node_modules/@types/node/util.d.ts", + "../../node_modules/@types/node/vm.d.ts" + ], + "../../node_modules/@types/node/stream.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/tls.d.ts": [ + "../../node_modules/@types/node/net.d.ts" + ], + "../../node_modules/@types/node/ts3.6/base.d.ts": [ + "../../node_modules/@types/node/async_hooks.d.ts", + "../../node_modules/@types/node/buffer.d.ts", + "../../node_modules/@types/node/child_process.d.ts", + "../../node_modules/@types/node/cluster.d.ts", + "../../node_modules/@types/node/console.d.ts", + "../../node_modules/@types/node/constants.d.ts", + "../../node_modules/@types/node/crypto.d.ts", + "../../node_modules/@types/node/dgram.d.ts", + "../../node_modules/@types/node/dns.d.ts", + "../../node_modules/@types/node/domain.d.ts", + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs.d.ts", + "../../node_modules/@types/node/fs/promises.d.ts", + "../../node_modules/@types/node/globals.d.ts", + "../../node_modules/@types/node/globals.global.d.ts", + "../../node_modules/@types/node/http.d.ts", + "../../node_modules/@types/node/http2.d.ts", + "../../node_modules/@types/node/https.d.ts", + "../../node_modules/@types/node/inspector.d.ts", + "../../node_modules/@types/node/module.d.ts", + "../../node_modules/@types/node/net.d.ts", + "../../node_modules/@types/node/os.d.ts", + "../../node_modules/@types/node/path.d.ts", + "../../node_modules/@types/node/perf_hooks.d.ts", + "../../node_modules/@types/node/process.d.ts", + "../../node_modules/@types/node/punycode.d.ts", + "../../node_modules/@types/node/querystring.d.ts", + "../../node_modules/@types/node/readline.d.ts", + "../../node_modules/@types/node/repl.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/string_decoder.d.ts", + "../../node_modules/@types/node/timers.d.ts", + "../../node_modules/@types/node/tls.d.ts", + "../../node_modules/@types/node/trace_events.d.ts", + "../../node_modules/@types/node/tty.d.ts", + "../../node_modules/@types/node/url.d.ts", + "../../node_modules/@types/node/util.d.ts", + "../../node_modules/@types/node/v8.d.ts", + "../../node_modules/@types/node/vm.d.ts", + "../../node_modules/@types/node/wasi.d.ts", + "../../node_modules/@types/node/worker_threads.d.ts", + "../../node_modules/@types/node/zlib.d.ts" + ], + "../../node_modules/@types/node/tty.d.ts": [ + "../../node_modules/@types/node/net.d.ts" + ], + "../../node_modules/@types/node/url.d.ts": [ + "../../node_modules/@types/node/querystring.d.ts" + ], + "../../node_modules/@types/node/v8.d.ts": [ + "../../node_modules/@types/node/stream.d.ts" + ], + "../../node_modules/@types/node/worker_threads.d.ts": [ + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs/promises.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/url.d.ts", + "../../node_modules/@types/node/vm.d.ts" + ], + "../../node_modules/@types/node/zlib.d.ts": [ + "../../node_modules/@types/node/stream.d.ts" + ], + "../../out/common/buffer/attributedata.d.ts": [ + "../../out/common/buffer/constants.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/buffer/bufferline.d.ts": [ + "../../out/common/buffer/attributedata.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/circularlist.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/coreterminal.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../out/common/inputhandler.d.ts", + "../../out/common/lifecycle.d.ts", + "../../out/common/services/services.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/parser/types.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/eventemitter.d.ts": [ + "../../src/common/types.d.ts" + ], + "../../out/common/inputhandler.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../out/common/lifecycle.d.ts", + "../../out/common/services/services.d.ts", + "../../src/common/parser/types.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/lifecycle.d.ts": [ + "../../src/common/types.d.ts" + ], + "../../out/common/public/buffernamespaceapi.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../src/common/types.d.ts", + "../../typings/xterm.d.ts" + ], + "../../out/common/public/parserapi.d.ts": [ + "../../src/common/types.d.ts", + "../../typings/xterm.d.ts" + ], + "../../out/common/public/unicodeapi.d.ts": [ + "../../src/common/types.d.ts", + "../../typings/xterm.d.ts" + ], + "../../out/common/services/services.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/types.d.ts" + ], + "../../src/common/buffer/types.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../src/common/types.d.ts" + ], + "../../src/common/parser/types.d.ts": [ + "../../out/common/parser/constants.d.ts", + "../../src/common/types.d.ts" + ], + "../../src/common/types.d.ts": [ + "../../out/common/circularlist.d.ts", + "../../out/common/eventemitter.d.ts", + "../../out/common/services/services.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/parser/types.d.ts", + "../../typings/xterm.d.ts" + ], + "../../src/headless/public/terminal.ts": [ + "../../out/common/eventemitter.d.ts", + "../../out/common/public/buffernamespaceapi.d.ts", + "../../out/common/public/parserapi.d.ts", + "../../out/common/public/unicodeapi.d.ts", + "../../src/headless/terminal.ts", + "../../typings/xterm-core.d.ts" + ], + "../../src/headless/terminal.ts": [ + "../../out/common/buffer/bufferline.d.ts", + "../../out/common/coreterminal.d.ts", + "../../out/common/eventemitter.d.ts", + "../../out/common/services/services.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/types.d.ts" + ], + "../../src/headless/types.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/parser/types.d.ts", + "../../src/common/types.d.ts" + ] + }, + "exportedModulesMap": { + "../../node_modules/@types/node/base.d.ts": [ + "../../node_modules/@types/node/assert.d.ts", + "../../node_modules/@types/node/ts3.6/base.d.ts" + ], + "../../node_modules/@types/node/child_process.d.ts": [ + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs.d.ts", + "../../node_modules/@types/node/net.d.ts", + "../../node_modules/@types/node/stream.d.ts" + ], + "../../node_modules/@types/node/cluster.d.ts": [ + "../../node_modules/@types/node/child_process.d.ts", + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/net.d.ts" + ], + "../../node_modules/@types/node/console.d.ts": [ + "../../node_modules/@types/node/util.d.ts" + ], + "../../node_modules/@types/node/constants.d.ts": [ + "../../node_modules/@types/node/crypto.d.ts", + "../../node_modules/@types/node/fs.d.ts", + "../../node_modules/@types/node/os.d.ts" + ], + "../../node_modules/@types/node/crypto.d.ts": [ + "../../node_modules/@types/node/stream.d.ts" + ], + "../../node_modules/@types/node/dgram.d.ts": [ + "../../node_modules/@types/node/dns.d.ts", + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/net.d.ts" + ], + "../../node_modules/@types/node/domain.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/events.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/fs.d.ts": [ + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs/promises.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/fs/promises.d.ts": [ + "../../node_modules/@types/node/fs.d.ts" + ], + "../../node_modules/@types/node/http.d.ts": [ + "../../node_modules/@types/node/net.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/http2.d.ts": [ + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs.d.ts", + "../../node_modules/@types/node/http.d.ts", + "../../node_modules/@types/node/net.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/tls.d.ts", + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/https.d.ts": [ + "../../node_modules/@types/node/http.d.ts", + "../../node_modules/@types/node/tls.d.ts", + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/index.d.ts": [ + "../../node_modules/@types/node/base.d.ts" + ], + "../../node_modules/@types/node/inspector.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/module.d.ts": [ + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/net.d.ts": [ + "../../node_modules/@types/node/dns.d.ts", + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/stream.d.ts" + ], + "../../node_modules/@types/node/perf_hooks.d.ts": [ + "../../node_modules/@types/node/async_hooks.d.ts" + ], + "../../node_modules/@types/node/process.d.ts": [ + "../../node_modules/@types/node/tty.d.ts" + ], + "../../node_modules/@types/node/readline.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/repl.d.ts": [ + "../../node_modules/@types/node/readline.d.ts", + "../../node_modules/@types/node/util.d.ts", + "../../node_modules/@types/node/vm.d.ts" + ], + "../../node_modules/@types/node/stream.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/tls.d.ts": [ + "../../node_modules/@types/node/net.d.ts" + ], + "../../node_modules/@types/node/ts3.6/base.d.ts": [ + "../../node_modules/@types/node/async_hooks.d.ts", + "../../node_modules/@types/node/buffer.d.ts", + "../../node_modules/@types/node/child_process.d.ts", + "../../node_modules/@types/node/cluster.d.ts", + "../../node_modules/@types/node/console.d.ts", + "../../node_modules/@types/node/constants.d.ts", + "../../node_modules/@types/node/crypto.d.ts", + "../../node_modules/@types/node/dgram.d.ts", + "../../node_modules/@types/node/dns.d.ts", + "../../node_modules/@types/node/domain.d.ts", + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs.d.ts", + "../../node_modules/@types/node/fs/promises.d.ts", + "../../node_modules/@types/node/globals.d.ts", + "../../node_modules/@types/node/globals.global.d.ts", + "../../node_modules/@types/node/http.d.ts", + "../../node_modules/@types/node/http2.d.ts", + "../../node_modules/@types/node/https.d.ts", + "../../node_modules/@types/node/inspector.d.ts", + "../../node_modules/@types/node/module.d.ts", + "../../node_modules/@types/node/net.d.ts", + "../../node_modules/@types/node/os.d.ts", + "../../node_modules/@types/node/path.d.ts", + "../../node_modules/@types/node/perf_hooks.d.ts", + "../../node_modules/@types/node/process.d.ts", + "../../node_modules/@types/node/punycode.d.ts", + "../../node_modules/@types/node/querystring.d.ts", + "../../node_modules/@types/node/readline.d.ts", + "../../node_modules/@types/node/repl.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/string_decoder.d.ts", + "../../node_modules/@types/node/timers.d.ts", + "../../node_modules/@types/node/tls.d.ts", + "../../node_modules/@types/node/trace_events.d.ts", + "../../node_modules/@types/node/tty.d.ts", + "../../node_modules/@types/node/url.d.ts", + "../../node_modules/@types/node/util.d.ts", + "../../node_modules/@types/node/v8.d.ts", + "../../node_modules/@types/node/vm.d.ts", + "../../node_modules/@types/node/wasi.d.ts", + "../../node_modules/@types/node/worker_threads.d.ts", + "../../node_modules/@types/node/zlib.d.ts" + ], + "../../node_modules/@types/node/tty.d.ts": [ + "../../node_modules/@types/node/net.d.ts" + ], + "../../node_modules/@types/node/url.d.ts": [ + "../../node_modules/@types/node/querystring.d.ts" + ], + "../../node_modules/@types/node/v8.d.ts": [ + "../../node_modules/@types/node/stream.d.ts" + ], + "../../node_modules/@types/node/worker_threads.d.ts": [ + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs/promises.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/url.d.ts", + "../../node_modules/@types/node/vm.d.ts" + ], + "../../node_modules/@types/node/zlib.d.ts": [ + "../../node_modules/@types/node/stream.d.ts" + ], + "../../out/common/buffer/attributedata.d.ts": [ + "../../out/common/buffer/constants.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/buffer/bufferline.d.ts": [ + "../../out/common/buffer/attributedata.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/circularlist.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/coreterminal.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../out/common/inputhandler.d.ts", + "../../out/common/lifecycle.d.ts", + "../../out/common/services/services.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/parser/types.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/eventemitter.d.ts": [ + "../../src/common/types.d.ts" + ], + "../../out/common/inputhandler.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../out/common/lifecycle.d.ts", + "../../out/common/services/services.d.ts", + "../../src/common/parser/types.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/lifecycle.d.ts": [ + "../../src/common/types.d.ts" + ], + "../../out/common/public/buffernamespaceapi.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../src/common/types.d.ts", + "../../typings/xterm.d.ts" + ], + "../../out/common/public/parserapi.d.ts": [ + "../../src/common/types.d.ts", + "../../typings/xterm.d.ts" + ], + "../../out/common/public/unicodeapi.d.ts": [ + "../../src/common/types.d.ts", + "../../typings/xterm.d.ts" + ], + "../../out/common/services/services.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/types.d.ts" + ], + "../../src/common/buffer/types.d.ts": [ + "../../src/common/eventemitter.ts", + "../../src/common/types.d.ts" + ], + "../../src/common/parser/types.d.ts": [ + "../../src/common/parser/constants.ts", + "../../src/common/types.d.ts" + ], + "../../src/common/types.d.ts": [ + "../../src/common/buffer/types.d.ts", + "../../src/common/circularlist.ts", + "../../src/common/eventemitter.ts", + "../../src/common/parser/types.d.ts", + "../../src/common/services/services.ts", + "../../typings/xterm.d.ts" + ], + "../../src/headless/public/terminal.ts": [ + "../../out/common/eventemitter.d.ts", + "../../typings/xterm-core.d.ts" + ], + "../../src/headless/terminal.ts": [ + "../../out/common/coreterminal.d.ts", + "../../out/common/eventemitter.d.ts", + "../../out/common/services/services.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/types.d.ts" + ], + "../../src/headless/types.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/parser/types.d.ts", + "../../src/common/types.d.ts" + ] + }, + "semanticDiagnosticsPerFile": [ + "../../node_modules/@types/mocha/index.d.ts", + "../../node_modules/@types/node/assert.d.ts", + "../../node_modules/@types/node/async_hooks.d.ts", + "../../node_modules/@types/node/base.d.ts", + "../../node_modules/@types/node/buffer.d.ts", + "../../node_modules/@types/node/child_process.d.ts", + "../../node_modules/@types/node/cluster.d.ts", + "../../node_modules/@types/node/console.d.ts", + "../../node_modules/@types/node/constants.d.ts", + "../../node_modules/@types/node/crypto.d.ts", + "../../node_modules/@types/node/dgram.d.ts", + "../../node_modules/@types/node/dns.d.ts", + "../../node_modules/@types/node/domain.d.ts", + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs.d.ts", + "../../node_modules/@types/node/fs/promises.d.ts", + "../../node_modules/@types/node/globals.d.ts", + "../../node_modules/@types/node/globals.global.d.ts", + "../../node_modules/@types/node/http.d.ts", + "../../node_modules/@types/node/http2.d.ts", + "../../node_modules/@types/node/https.d.ts", + "../../node_modules/@types/node/index.d.ts", + "../../node_modules/@types/node/inspector.d.ts", + "../../node_modules/@types/node/module.d.ts", + "../../node_modules/@types/node/net.d.ts", + "../../node_modules/@types/node/os.d.ts", + "../../node_modules/@types/node/path.d.ts", + "../../node_modules/@types/node/perf_hooks.d.ts", + "../../node_modules/@types/node/process.d.ts", + "../../node_modules/@types/node/punycode.d.ts", + "../../node_modules/@types/node/querystring.d.ts", + "../../node_modules/@types/node/readline.d.ts", + "../../node_modules/@types/node/repl.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/string_decoder.d.ts", + "../../node_modules/@types/node/timers.d.ts", + "../../node_modules/@types/node/tls.d.ts", + "../../node_modules/@types/node/trace_events.d.ts", + "../../node_modules/@types/node/ts3.6/base.d.ts", + "../../node_modules/@types/node/tty.d.ts", + "../../node_modules/@types/node/url.d.ts", + "../../node_modules/@types/node/util.d.ts", + "../../node_modules/@types/node/v8.d.ts", + "../../node_modules/@types/node/vm.d.ts", + "../../node_modules/@types/node/wasi.d.ts", + "../../node_modules/@types/node/worker_threads.d.ts", + "../../node_modules/@types/node/zlib.d.ts", + "../../node_modules/typescript/lib/lib.dom.d.ts", + "../../node_modules/typescript/lib/lib.es2015.collection.d.ts", + "../../node_modules/typescript/lib/lib.es2015.core.d.ts", + "../../node_modules/typescript/lib/lib.es2015.d.ts", + "../../node_modules/typescript/lib/lib.es2015.generator.d.ts", + "../../node_modules/typescript/lib/lib.es2015.iterable.d.ts", + "../../node_modules/typescript/lib/lib.es2015.promise.d.ts", + "../../node_modules/typescript/lib/lib.es2015.proxy.d.ts", + "../../node_modules/typescript/lib/lib.es2015.reflect.d.ts", + "../../node_modules/typescript/lib/lib.es2015.symbol.d.ts", + "../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts", + "../../node_modules/typescript/lib/lib.es2016.array.include.d.ts", + "../../node_modules/typescript/lib/lib.es2016.d.ts", + "../../node_modules/typescript/lib/lib.es2017.d.ts", + "../../node_modules/typescript/lib/lib.es2017.intl.d.ts", + "../../node_modules/typescript/lib/lib.es2017.object.d.ts", + "../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts", + "../../node_modules/typescript/lib/lib.es2017.string.d.ts", + "../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts", + "../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts", + "../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts", + "../../node_modules/typescript/lib/lib.es2018.d.ts", + "../../node_modules/typescript/lib/lib.es2018.intl.d.ts", + "../../node_modules/typescript/lib/lib.es2018.promise.d.ts", + "../../node_modules/typescript/lib/lib.es2018.regexp.d.ts", + "../../node_modules/typescript/lib/lib.es2020.bigint.d.ts", + "../../node_modules/typescript/lib/lib.es5.d.ts", + "../../node_modules/typescript/lib/lib.esnext.intl.d.ts", + "../../out/common/buffer/attributedata.d.ts", + "../../out/common/buffer/bufferline.d.ts", + "../../out/common/buffer/constants.d.ts", + "../../out/common/circularlist.d.ts", + "../../out/common/coreterminal.d.ts", + "../../out/common/eventemitter.d.ts", + "../../out/common/inputhandler.d.ts", + "../../out/common/lifecycle.d.ts", + "../../out/common/parser/constants.d.ts", + "../../out/common/public/buffernamespaceapi.d.ts", + "../../out/common/public/parserapi.d.ts", + "../../out/common/public/unicodeapi.d.ts", + "../../out/common/services/services.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/parser/types.d.ts", + "../../src/common/types.d.ts", + "../../src/headless/public/terminal.ts", + "../../src/headless/terminal.ts", + "../../src/headless/types.d.ts", + "../../typings/xterm-core.d.ts", + "../../typings/xterm.d.ts" + ] + }, + "version": "4.2.4" +} \ No newline at end of file diff --git a/headless/headless/types.d.ts b/headless/headless/types.d.ts new file mode 100644 index 00000000..a35f3988 --- /dev/null +++ b/headless/headless/types.d.ts @@ -0,0 +1,32 @@ +import { IBuffer, IBufferSet } from 'common/buffer/Types'; +import { IEvent } from 'common/EventEmitter'; +import { IFunctionIdentifier, IParams } from 'common/parser/Types'; +import { ICoreTerminal, IDisposable, IMarker, ITerminalOptions } from 'common/Types'; +export interface ITerminal extends ICoreTerminal { + rows: number; + cols: number; + buffer: IBuffer; + buffers: IBufferSet; + markers: IMarker[]; + options: ITerminalOptions; + onCursorMove: IEvent; + onData: IEvent; + onBinary: IEvent; + onLineFeed: IEvent; + onResize: IEvent<{ + cols: number; + rows: number; + }>; + onTitleChange: IEvent; + resize(columns: number, rows: number): void; + addCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean): IDisposable; + addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean): IDisposable; + addEscHandler(id: IFunctionIdentifier, callback: () => boolean): IDisposable; + addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable; + addMarker(cursorYOffset: number): IMarker | undefined; + dispose(): void; + clear(): void; + write(data: string | Uint8Array, callback?: () => void): void; + reset(): void; +} +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/headless/headless/types.d.ts.map b/headless/headless/types.d.ts.map new file mode 100644 index 00000000..7410b043 --- /dev/null +++ b/headless/headless/types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/headless/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErF,MAAM,WAAW,SAAU,SAAQ,aAAa;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,UAAU,CAAC;IACpB,OAAO,EAAE,OAAO,EAAE,CAAC;IAEnB,OAAO,EAAE,gBAAgB,CAAC;IAE1B,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C,aAAa,CAAC,EAAE,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,GAAG,WAAW,CAAC;IAC5F,aAAa,CAAC,EAAE,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,GAAG,WAAW,CAAC;IACzG,aAAa,CAAC,EAAE,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,OAAO,GAAG,WAAW,CAAC;IAC7E,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,WAAW,CAAC;IAC/E,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IACtD,OAAO,IAAI,IAAI,CAAC;IAChB,KAAK,IAAI,IAAI,CAAC;IACd,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAC9D,KAAK,IAAI,IAAI,CAAC;CACf"} \ No newline at end of file diff --git a/headless/headless/types.js b/headless/headless/types.js new file mode 100644 index 00000000..11e638d1 --- /dev/null +++ b/headless/headless/types.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/headless/headless/types.js.map b/headless/headless/types.js.map new file mode 100644 index 00000000..d651a6aa --- /dev/null +++ b/headless/headless/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/headless/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/src/common/public/tsconfig.json b/src/common/public/tsconfig.json deleted file mode 100644 index 6e14ddf7..00000000 --- a/src/common/public/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "extends": "../../tsconfig-library-base", - "compilerOptions": { - "lib": [ - "es2015", - "es2016.Array.Include" - ], - "outDir": "../../../xterm-core", // Temporary outdir to avoid collisions with 'xterm' - "types": [ - "../../../node_modules/@types/mocha", - "../../../node_modules/@types/node" - ], - "baseUrl": "../../", - "extendedDiagnostics": true - }, - "include": [ - "../**/*", - "../../../typings/xterm-core.d.ts", - "../../../typings/xterm.d.ts", // common/Types.d.ts imports from 'xterm' - ], -} diff --git a/src/common/Terminal.ts b/src/headless/Terminal.ts similarity index 100% rename from src/common/Terminal.ts rename to src/headless/Terminal.ts diff --git a/src/common/public/types.ts b/src/headless/Types.d.ts similarity index 99% rename from src/common/public/types.ts rename to src/headless/Types.d.ts index 1c20bd6d..868e5c17 100644 --- a/src/common/public/types.ts +++ b/src/headless/Types.d.ts @@ -28,4 +28,4 @@ export interface ITerminal extends ICoreTerminal { clear(): void; write(data: string | Uint8Array, callback?: () => void): void; reset(): void; -} \ No newline at end of file +} diff --git a/src/common/public/Terminal.ts b/src/headless/public/Terminal.ts similarity index 98% rename from src/common/public/Terminal.ts rename to src/headless/public/Terminal.ts index 3d195b75..4b27a04b 100644 --- a/src/common/public/Terminal.ts +++ b/src/headless/public/Terminal.ts @@ -8,7 +8,7 @@ import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi'; import { ParserApi } from 'common/public/ParserApi'; import { UnicodeApi } from 'common/public/UnicodeApi'; import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core'; -import { Terminal as TerminalCore } from '../Terminal'; +import { Terminal as TerminalCore } from 'headless/Terminal'; export class Terminal implements ITerminalApi { private _core: TerminalCore; diff --git a/src/headless/tsconfig.json b/src/headless/tsconfig.json new file mode 100644 index 00000000..268bdbdd --- /dev/null +++ b/src/headless/tsconfig.json @@ -0,0 +1,27 @@ +{ + "extends": "../tsconfig-library-base", + "compilerOptions": { + "lib": [ + "es2015", + "es2016.Array.Include" + ], + "outDir": "../../headless", // Temporary outdir to avoid collisions with 'xterm' + "types": [ + "../../node_modules/@types/mocha", + "../../node_modules/@types/node" + ], + "baseUrl": "../", + "extendedDiagnostics": true, + "paths": { + "common/*": [ "./common/*" ] + } + }, + "include": [ + "./**/*", + "../../typings/xterm.d.ts", // common/Types.d.ts imports from 'xterm' + "../../typings/xterm-core.d.ts" + ], + "references": [ + { "path": "../common" } + ] +} diff --git a/tsconfig.all.json b/tsconfig.all.json index 009cd498..6fa02446 100644 --- a/tsconfig.all.json +++ b/tsconfig.all.json @@ -3,6 +3,7 @@ "include": [], "references": [ { "path": "./src/browser" }, + { "path": "./src/headless" }, { "path": "./test/api" }, { "path": "./test/benchmark" }, { "path": "./addons/xterm-addon-attach" }, From 61ede1cc0d7fd40ba5556c93b20911b3cd5aa5de Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 15:41:24 -0700 Subject: [PATCH 246/377] Update instructions to run --- node-test/README.md | 4 ++-- core-webpack.config.js => webpack.config.core.js | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename core-webpack.config.js => webpack.config.core.js (100%) diff --git a/node-test/README.md b/node-test/README.md index e4cf19b0..b7a67aeb 100644 --- a/node-test/README.md +++ b/node-test/README.md @@ -3,8 +3,8 @@ Cursory test that 'xterm-core' works: ``` # From root of this repo npm run compile # Outputs to xterm-core -npx webpack --config core-webpack.config.js # Outputs to lib +npx webpack --config webpack.config.core.js # Outputs to lib cd node-test npm link ../lib/ node index.js -``` \ No newline at end of file +``` diff --git a/core-webpack.config.js b/webpack.config.core.js similarity index 100% rename from core-webpack.config.js rename to webpack.config.core.js From 71179512330199b530fa88bf74d93f22c5feceaf Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 15:52:27 -0700 Subject: [PATCH 247/377] Output headless to out/headless --- headless/headless/Terminal.d.ts | 28 - headless/headless/Terminal.d.ts.map | 1 - headless/headless/Terminal.js | 130 --- headless/headless/Terminal.js.map | 1 - headless/headless/public/Terminal.d.ts | 48 - headless/headless/public/Terminal.d.ts.map | 1 - headless/headless/public/Terminal.js | 147 --- headless/headless/public/Terminal.js.map | 1 - headless/headless/tsconfig.tsbuildinfo | 1120 -------------------- headless/headless/types.d.ts | 32 - headless/headless/types.d.ts.map | 1 - headless/headless/types.js | 3 - headless/headless/types.js.map | 1 - src/headless/tsconfig.json | 3 +- 14 files changed, 1 insertion(+), 1516 deletions(-) delete mode 100644 headless/headless/Terminal.d.ts delete mode 100644 headless/headless/Terminal.d.ts.map delete mode 100644 headless/headless/Terminal.js delete mode 100644 headless/headless/Terminal.js.map delete mode 100644 headless/headless/public/Terminal.d.ts delete mode 100644 headless/headless/public/Terminal.d.ts.map delete mode 100644 headless/headless/public/Terminal.js delete mode 100644 headless/headless/public/Terminal.js.map delete mode 100644 headless/headless/tsconfig.tsbuildinfo delete mode 100644 headless/headless/types.d.ts delete mode 100644 headless/headless/types.d.ts.map delete mode 100644 headless/headless/types.js delete mode 100644 headless/headless/types.js.map diff --git a/headless/headless/Terminal.d.ts b/headless/headless/Terminal.d.ts deleted file mode 100644 index 7ab11fc7..00000000 --- a/headless/headless/Terminal.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { IBuffer } from 'common/buffer/Types'; -import { CoreTerminal } from 'common/CoreTerminal'; -import { IEvent } from 'common/EventEmitter'; -import { ITerminalOptions as IInitializedTerminalOptions } from 'common/services/Services'; -import { IMarker, ITerminalOptions } from 'common/Types'; -export declare class Terminal extends CoreTerminal { - get options(): IInitializedTerminalOptions; - private _onBell; - get onBell(): IEvent; - private _onCursorMove; - get onCursorMove(): IEvent; - private _onTitleChange; - get onTitleChange(): IEvent; - private _onA11yCharEmitter; - get onA11yChar(): IEvent; - private _onA11yTabEmitter; - get onA11yTab(): IEvent; - constructor(options?: ITerminalOptions); - dispose(): void; - get buffer(): IBuffer; - get markers(): IMarker[]; - addMarker(cursorYOffset: number): IMarker | undefined; - bell(): void; - resize(x: number, y: number): void; - clear(): void; - reset(): void; -} -//# sourceMappingURL=Terminal.d.ts.map \ No newline at end of file diff --git a/headless/headless/Terminal.d.ts.map b/headless/headless/Terminal.d.ts.map deleted file mode 100644 index f5020f83..00000000 --- a/headless/headless/Terminal.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Terminal.d.ts","sourceRoot":"","sources":["../../src/headless/Terminal.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAA8B,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,gBAAgB,IAAI,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAgB,MAAM,cAAc,CAAC;AAEvE,qBAAa,QAAS,SAAQ,YAAY;IAExC,IAAW,OAAO,IAAI,2BAA2B,CAAwC;IAGzF,OAAO,CAAC,OAAO,CAA6B;IAC5C,IAAW,MAAM,IAAK,MAAM,CAAC,IAAI,CAAC,CAA+B;IACjE,OAAO,CAAC,aAAa,CAA4B;IACjD,IAAW,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,CAAqC;IAC5E,OAAO,CAAC,cAAc,CAA8B;IACpD,IAAW,aAAa,IAAI,MAAM,CAAC,MAAM,CAAC,CAAsC;IAEhF,OAAO,CAAC,kBAAkB,CAA8B;IACxD,IAAW,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,CAA0C;IACjF,OAAO,CAAC,iBAAiB,CAA8B;IACvD,IAAW,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,CAAyC;gBAe7E,OAAO,GAAE,gBAAqB;IAezB,OAAO,IAAI,IAAI;IAWtB,IAAW,MAAM,IAAI,OAAO,CAE3B;IAED,IAAW,OAAO,IAAI,OAAO,EAAE,CAE9B;IAEM,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IASrD,IAAI,IAAI,IAAI;IAUZ,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAWlC,KAAK,IAAI,IAAI;IAwBb,KAAK,IAAI,IAAI;CAWrB"} \ No newline at end of file diff --git a/headless/headless/Terminal.js b/headless/headless/Terminal.js deleted file mode 100644 index 66f4d364..00000000 --- a/headless/headless/Terminal.js +++ /dev/null @@ -1,130 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Terminal = void 0; -var BufferLine_1 = require("common/buffer/BufferLine"); -var CoreTerminal_1 = require("common/CoreTerminal"); -var EventEmitter_1 = require("common/EventEmitter"); -var Terminal = (function (_super) { - __extends(Terminal, _super); - function Terminal(options) { - if (options === void 0) { options = {}; } - var _this = _super.call(this, options) || this; - _this._onBell = new EventEmitter_1.EventEmitter(); - _this._onCursorMove = new EventEmitter_1.EventEmitter(); - _this._onTitleChange = new EventEmitter_1.EventEmitter(); - _this._onA11yCharEmitter = new EventEmitter_1.EventEmitter(); - _this._onA11yTabEmitter = new EventEmitter_1.EventEmitter(); - _this._setup(); - _this.register(_this._inputHandler.onRequestBell(function () { return _this.bell(); })); - _this.register(_this._inputHandler.onRequestReset(function () { return _this.reset(); })); - _this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onCursorMove, _this._onCursorMove)); - _this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onTitleChange, _this._onTitleChange)); - _this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onA11yChar, _this._onA11yCharEmitter)); - _this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onA11yTab, _this._onA11yTabEmitter)); - return _this; - } - Object.defineProperty(Terminal.prototype, "options", { - get: function () { return this.optionsService.options; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onBell", { - get: function () { return this._onBell.event; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onCursorMove", { - get: function () { return this._onCursorMove.event; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onTitleChange", { - get: function () { return this._onTitleChange.event; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onA11yChar", { - get: function () { return this._onA11yCharEmitter.event; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onA11yTab", { - get: function () { return this._onA11yTabEmitter.event; }, - enumerable: false, - configurable: true - }); - Terminal.prototype.dispose = function () { - if (this._isDisposed) { - return; - } - _super.prototype.dispose.call(this); - this.write = function () { }; - }; - Object.defineProperty(Terminal.prototype, "buffer", { - get: function () { - return this.buffers.active; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "markers", { - get: function () { - return this.buffer.markers; - }, - enumerable: false, - configurable: true - }); - Terminal.prototype.addMarker = function (cursorYOffset) { - if (this.buffer !== this.buffers.normal) { - return; - } - return this.buffer.addMarker(this.buffer.ybase + this.buffer.y + cursorYOffset); - }; - Terminal.prototype.bell = function () { - this._onBell.fire(); - }; - Terminal.prototype.resize = function (x, y) { - if (x === this.cols && y === this.rows) { - return; - } - _super.prototype.resize.call(this, x, y); - }; - Terminal.prototype.clear = function () { - if (this.buffer.ybase === 0 && this.buffer.y === 0) { - return; - } - this.buffer.lines.set(0, this.buffer.lines.get(this.buffer.ybase + this.buffer.y)); - this.buffer.lines.length = 1; - this.buffer.ydisp = 0; - this.buffer.ybase = 0; - this.buffer.y = 0; - for (var i = 1; i < this.rows; i++) { - this.buffer.lines.push(this.buffer.getBlankLine(BufferLine_1.DEFAULT_ATTR_DATA)); - } - this._onScroll.fire({ position: this.buffer.ydisp, source: 0 }); - }; - Terminal.prototype.reset = function () { - this.options.rows = this.rows; - this.options.cols = this.cols; - this._setup(); - _super.prototype.reset.call(this); - }; - return Terminal; -}(CoreTerminal_1.CoreTerminal)); -exports.Terminal = Terminal; -//# sourceMappingURL=Terminal.js.map \ No newline at end of file diff --git a/headless/headless/Terminal.js.map b/headless/headless/Terminal.js.map deleted file mode 100644 index ba7e26de..00000000 --- a/headless/headless/Terminal.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Terminal.js","sourceRoot":"","sources":["../../src/headless/Terminal.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAuBA,uDAA6D;AAE7D,oDAAmD;AACnD,oDAAyE;AAIzE;IAA8B,4BAAY;IA6BxC,kBACE,OAA8B;QAA9B,wBAAA,EAAA,YAA8B;QADhC,YAGE,kBAAM,OAAO,CAAC,SAWf;QAtCO,aAAO,GAAI,IAAI,2BAAY,EAAQ,CAAC;QAEpC,mBAAa,GAAG,IAAI,2BAAY,EAAQ,CAAC;QAEzC,oBAAc,GAAG,IAAI,2BAAY,EAAU,CAAC;QAG5C,wBAAkB,GAAG,IAAI,2BAAY,EAAU,CAAC;QAEhD,uBAAiB,GAAG,IAAI,2BAAY,EAAU,CAAC;QAoBrD,KAAI,CAAC,MAAM,EAAE,CAAC;QAGd,KAAI,CAAC,QAAQ,CAAC,KAAI,CAAC,aAAa,CAAC,aAAa,CAAC,cAAM,OAAA,KAAI,CAAC,IAAI,EAAE,EAAX,CAAW,CAAC,CAAC,CAAC;QACnE,KAAI,CAAC,QAAQ,CAAC,KAAI,CAAC,aAAa,CAAC,cAAc,CAAC,cAAM,OAAA,KAAI,CAAC,KAAK,EAAE,EAAZ,CAAY,CAAC,CAAC,CAAC;QACrE,KAAI,CAAC,QAAQ,CAAC,2BAAY,CAAC,KAAI,CAAC,aAAa,CAAC,YAAY,EAAE,KAAI,CAAC,aAAa,CAAC,CAAC,CAAC;QACjF,KAAI,CAAC,QAAQ,CAAC,2BAAY,CAAC,KAAI,CAAC,aAAa,CAAC,aAAa,EAAE,KAAI,CAAC,cAAc,CAAC,CAAC,CAAC;QACnF,KAAI,CAAC,QAAQ,CAAC,2BAAY,CAAC,KAAI,CAAC,aAAa,CAAC,UAAU,EAAE,KAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACpF,KAAI,CAAC,QAAQ,CAAC,2BAAY,CAAC,KAAI,CAAC,aAAa,CAAC,SAAS,EAAE,KAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;;IACpF,CAAC;IAzCD,sBAAW,6BAAO;aAAlB,cAAoD,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;;;OAAA;IAIzF,sBAAW,4BAAM;aAAjB,cAAqC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IAEjE,sBAAW,kCAAY;aAAvB,cAA0C,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IAE5E,sBAAW,mCAAa;aAAxB,cAA6C,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IAGhF,sBAAW,gCAAU;aAArB,cAA0C,OAAO,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IAEjF,sBAAW,+BAAS;aAApB,cAAyC,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IA8BxE,0BAAO,GAAd;QACE,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,OAAO;SACR;QACD,iBAAM,OAAO,WAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,cAAQ,CAAC,CAAC;IACzB,CAAC;IAKD,sBAAW,4BAAM;aAAjB;YACE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QAC7B,CAAC;;;OAAA;IAED,sBAAW,6BAAO;aAAlB;YACE,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;QAC7B,CAAC;;;OAAA;IAEM,4BAAS,GAAhB,UAAiB,aAAqB;QAEpC,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACvC,OAAO;SACR;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC;IAClF,CAAC;IAEM,uBAAI,GAAX;QACE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;IAQM,yBAAM,GAAb,UAAc,CAAS,EAAE,CAAS;QAChC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE;YACtC,OAAO;SACR;QAED,iBAAM,MAAM,YAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrB,CAAC;IAKM,wBAAK,GAAZ;QACE,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE;YAElD,OAAO;SACR;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,CAAC;QACpF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;YAClC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,8BAAiB,CAAC,CAAC,CAAC;SACrE;QACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAuB,EAAE,CAAC,CAAC;IACtF,CAAC;IAUM,wBAAK,GAAZ;QAKE,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAE9B,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,iBAAM,KAAK,WAAE,CAAC;IAChB,CAAC;IACH,eAAC;AAAD,CAAC,AAjID,CAA8B,2BAAY,GAiIzC;AAjIY,4BAAQ"} \ No newline at end of file diff --git a/headless/headless/public/Terminal.d.ts b/headless/headless/public/Terminal.d.ts deleted file mode 100644 index 669fff57..00000000 --- a/headless/headless/public/Terminal.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { IEvent } from 'common/EventEmitter'; -import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core'; -export declare class Terminal implements ITerminalApi { - private _core; - private _parser; - private _buffer; - constructor(options?: ITerminalOptions); - private _checkProposedApi; - get onCursorMove(): IEvent; - get onLineFeed(): IEvent; - get onData(): IEvent; - get onBinary(): IEvent; - get onTitleChange(): IEvent; - get onResize(): IEvent<{ - cols: number; - rows: number; - }>; - get parser(): IParser; - get unicode(): IUnicodeHandling; - get rows(): number; - get cols(): number; - get buffer(): IBufferNamespaceApi; - get markers(): ReadonlyArray; - resize(columns: number, rows: number): void; - registerMarker(cursorYOffset: number): IMarker | undefined; - addMarker(cursorYOffset: number): IMarker | undefined; - dispose(): void; - clear(): void; - write(data: string | Uint8Array, callback?: () => void): void; - writeUtf8(data: Uint8Array, callback?: () => void): void; - writeln(data: string | Uint8Array, callback?: () => void): void; - getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string; - getOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell'): boolean; - getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; - getOption(key: string): any; - setOption(key: 'bellSound' | 'fontFamily' | 'termName' | 'wordSeparator', value: string): void; - setOption(key: 'fontWeight' | 'fontWeightBold', value: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void; - setOption(key: 'logLevel', value: 'debug' | 'info' | 'warn' | 'error' | 'off'): void; - setOption(key: 'bellStyle', value: 'none' | 'visual' | 'sound' | 'both'): void; - setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void; - setOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell', value: boolean): void; - setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; - setOption(key: 'cols' | 'rows', value: number): void; - setOption(key: string, value: any): void; - reset(): void; - private _verifyIntegers; -} -//# sourceMappingURL=Terminal.d.ts.map \ No newline at end of file diff --git a/headless/headless/public/Terminal.d.ts.map b/headless/headless/public/Terminal.d.ts.map deleted file mode 100644 index b8fda933..00000000 --- a/headless/headless/public/Terminal.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Terminal.d.ts","sourceRoot":"","sources":["../../../src/headless/public/Terminal.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAI7C,OAAO,EAAE,gBAAgB,IAAI,mBAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AAGrJ,qBAAa,QAAS,YAAW,YAAY;IAC3C,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,OAAO,CAAiC;gBAEpC,OAAO,CAAC,EAAE,gBAAgB;IAItC,OAAO,CAAC,iBAAiB;IAMzB,IAAW,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,CAAoC;IAC3E,IAAW,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,CAAkC;IACvE,IAAW,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,CAA8B;IACjE,IAAW,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,CAAgC;IACrE,IAAW,aAAa,IAAI,MAAM,CAAC,MAAM,CAAC,CAAqC;IAC/E,IAAW,QAAQ,IAAI,MAAM,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAgC;IAE7F,IAAW,MAAM,IAAI,OAAO,CAM3B;IACD,IAAW,OAAO,IAAI,gBAAgB,CAGrC;IACD,IAAW,IAAI,IAAI,MAAM,CAA4B;IACrD,IAAW,IAAI,IAAI,MAAM,CAA4B;IACrD,IAAW,MAAM,IAAI,mBAAmB,CAMvC;IACD,IAAW,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAG3C;IACM,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAI3C,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAK1D,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAGrD,OAAO,IAAI,IAAI;IAGf,KAAK,IAAI,IAAI;IAGb,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;IAG7D,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;IAGxD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;IAI/D,SAAS,CAAC,GAAG,EAAE,WAAW,GAAG,WAAW,GAAG,aAAa,GAAG,YAAY,GAAG,UAAU,GAAG,cAAc,GAAG,UAAU,GAAG,eAAe,GAAG,MAAM;IAC7I,SAAS,CAAC,GAAG,EAAE,mBAAmB,GAAG,qBAAqB,GAAG,cAAc,GAAG,YAAY,GAAG,aAAa,GAAG,cAAc,GAAG,iBAAiB,GAAG,uBAAuB,GAAG,WAAW,GAAG,YAAY,GAAG,OAAO;IAChN,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,eAAe,GAAG,YAAY,GAAG,MAAM,GAAG,cAAc,GAAG,YAAY,GAAG,MAAM;IACrH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG;IAI3B,SAAS,CAAC,GAAG,EAAE,WAAW,GAAG,YAAY,GAAG,UAAU,GAAG,eAAe,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAC9F,SAAS,CAAC,GAAG,EAAE,YAAY,GAAG,gBAAgB,EAAE,KAAK,EAAE,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,IAAI;IAChK,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,IAAI;IACpF,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI;IAC9E,SAAS,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,KAAK,GAAG,IAAI;IACzE,SAAS,CAAC,GAAG,EAAE,mBAAmB,GAAG,qBAAqB,GAAG,cAAc,GAAG,YAAY,GAAG,aAAa,GAAG,cAAc,GAAG,iBAAiB,GAAG,uBAAuB,GAAG,WAAW,GAAG,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAC7N,SAAS,CAAC,GAAG,EAAE,UAAU,GAAG,eAAe,GAAG,YAAY,GAAG,cAAc,GAAG,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAChH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IACpD,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAIxC,KAAK,IAAI,IAAI;IAIpB,OAAO,CAAC,eAAe;CAOxB"} \ No newline at end of file diff --git a/headless/headless/public/Terminal.js b/headless/headless/public/Terminal.js deleted file mode 100644 index 1718c3b6..00000000 --- a/headless/headless/public/Terminal.js +++ /dev/null @@ -1,147 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Terminal = void 0; -var BufferNamespaceApi_1 = require("common/public/BufferNamespaceApi"); -var ParserApi_1 = require("common/public/ParserApi"); -var UnicodeApi_1 = require("common/public/UnicodeApi"); -var Terminal_1 = require("headless/Terminal"); -var Terminal = (function () { - function Terminal(options) { - this._core = new Terminal_1.Terminal(options); - } - Terminal.prototype._checkProposedApi = function () { - if (!this._core.optionsService.options.allowProposedApi) { - throw new Error('You must set the allowProposedApi option to true to use proposed API'); - } - }; - Object.defineProperty(Terminal.prototype, "onCursorMove", { - get: function () { return this._core.onCursorMove; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onLineFeed", { - get: function () { return this._core.onLineFeed; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onData", { - get: function () { return this._core.onData; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onBinary", { - get: function () { return this._core.onBinary; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onTitleChange", { - get: function () { return this._core.onTitleChange; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onResize", { - get: function () { return this._core.onResize; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "parser", { - get: function () { - this._checkProposedApi(); - if (!this._parser) { - this._parser = new ParserApi_1.ParserApi(this._core); - } - return this._parser; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "unicode", { - get: function () { - this._checkProposedApi(); - return new UnicodeApi_1.UnicodeApi(this._core); - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "rows", { - get: function () { return this._core.rows; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "cols", { - get: function () { return this._core.cols; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "buffer", { - get: function () { - this._checkProposedApi(); - if (!this._buffer) { - this._buffer = new BufferNamespaceApi_1.BufferNamespaceApi(this._core); - } - return this._buffer; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "markers", { - get: function () { - this._checkProposedApi(); - return this._core.markers; - }, - enumerable: false, - configurable: true - }); - Terminal.prototype.resize = function (columns, rows) { - this._verifyIntegers(columns, rows); - this._core.resize(columns, rows); - }; - Terminal.prototype.registerMarker = function (cursorYOffset) { - this._checkProposedApi(); - this._verifyIntegers(cursorYOffset); - return this._core.addMarker(cursorYOffset); - }; - Terminal.prototype.addMarker = function (cursorYOffset) { - return this.registerMarker(cursorYOffset); - }; - Terminal.prototype.dispose = function () { - this._core.dispose(); - }; - Terminal.prototype.clear = function () { - this._core.clear(); - }; - Terminal.prototype.write = function (data, callback) { - this._core.write(data, callback); - }; - Terminal.prototype.writeUtf8 = function (data, callback) { - this._core.write(data, callback); - }; - Terminal.prototype.writeln = function (data, callback) { - this._core.write(data); - this._core.write('\r\n', callback); - }; - Terminal.prototype.getOption = function (key) { - return this._core.optionsService.getOption(key); - }; - Terminal.prototype.setOption = function (key, value) { - this._core.optionsService.setOption(key, value); - }; - Terminal.prototype.reset = function () { - this._core.reset(); - }; - Terminal.prototype._verifyIntegers = function () { - var values = []; - for (var _i = 0; _i < arguments.length; _i++) { - values[_i] = arguments[_i]; - } - for (var _a = 0, values_1 = values; _a < values_1.length; _a++) { - var value = values_1[_a]; - if (value === Infinity || isNaN(value) || value % 1 !== 0) { - throw new Error('This API only accepts integers'); - } - } - }; - return Terminal; -}()); -exports.Terminal = Terminal; -//# sourceMappingURL=Terminal.js.map \ No newline at end of file diff --git a/headless/headless/public/Terminal.js.map b/headless/headless/public/Terminal.js.map deleted file mode 100644 index 6e27bbc7..00000000 --- a/headless/headless/public/Terminal.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Terminal.js","sourceRoot":"","sources":["../../../src/headless/public/Terminal.ts"],"names":[],"mappings":";;;AAMA,uEAAsE;AACtE,qDAAoD;AACpD,uDAAsD;AAEtD,8CAA6D;AAE7D;IAKE,kBAAY,OAA0B;QACpC,IAAI,CAAC,KAAK,GAAG,IAAI,mBAAY,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAEO,oCAAiB,GAAzB;QACE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,gBAAgB,EAAE;YACvD,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;SACzF;IACH,CAAC;IAED,sBAAW,kCAAY;aAAvB,cAA0C,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;;;OAAA;IAC3E,sBAAW,gCAAU;aAArB,cAAwC,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;;;OAAA;IACvE,sBAAW,4BAAM;aAAjB,cAAsC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;;;OAAA;IACjE,sBAAW,8BAAQ;aAAnB,cAAwC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;;;OAAA;IACrE,sBAAW,mCAAa;aAAxB,cAA6C,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;;;OAAA;IAC/E,sBAAW,8BAAQ;aAAnB,cAAgE,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;;;OAAA;IAE7F,sBAAW,4BAAM;aAAjB;YACE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjB,IAAI,CAAC,OAAO,GAAG,IAAI,qBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAC1C;YACD,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;;;OAAA;IACD,sBAAW,6BAAO;aAAlB;YACE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,OAAO,IAAI,uBAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC;;;OAAA;IACD,sBAAW,0BAAI;aAAf,cAA4B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;;;OAAA;IACrD,sBAAW,0BAAI;aAAf,cAA4B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;;;OAAA;IACrD,sBAAW,4BAAM;aAAjB;YACE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjB,IAAI,CAAC,OAAO,GAAG,IAAI,uCAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACnD;YACD,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;;;OAAA;IACD,sBAAW,6BAAO;aAAlB;YACE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;QAC5B,CAAC;;;OAAA;IACM,yBAAM,GAAb,UAAc,OAAe,EAAE,IAAY;QACzC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IACM,iCAAc,GAArB,UAAsB,aAAqB;QACzC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IAC7C,CAAC;IACM,4BAAS,GAAhB,UAAiB,aAAqB;QACpC,OAAO,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;IAC5C,CAAC;IACM,0BAAO,GAAd;QACE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;IACM,wBAAK,GAAZ;QACE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IACM,wBAAK,GAAZ,UAAa,IAAyB,EAAE,QAAqB;QAC3D,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IACM,4BAAS,GAAhB,UAAiB,IAAgB,EAAE,QAAqB;QACtD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IACM,0BAAO,GAAd,UAAe,IAAyB,EAAE,QAAqB;QAC7D,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACrC,CAAC;IAKM,4BAAS,GAAhB,UAAiB,GAAQ;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAClD,CAAC;IAUM,4BAAS,GAAhB,UAAiB,GAAQ,EAAE,KAAU;QACnC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;IACM,wBAAK,GAAZ;QACE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAEO,kCAAe,GAAvB;QAAwB,gBAAmB;aAAnB,UAAmB,EAAnB,qBAAmB,EAAnB,IAAmB;YAAnB,2BAAmB;;QACzC,KAAoB,UAAM,EAAN,iBAAM,EAAN,oBAAM,EAAN,IAAM,EAAE;YAAvB,IAAM,KAAK,eAAA;YACd,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,KAAK,CAAC,EAAE;gBACzD,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;aACnD;SACF;IACH,CAAC;IACH,eAAC;AAAD,CAAC,AAxGD,IAwGC;AAxGY,4BAAQ"} \ No newline at end of file diff --git a/headless/headless/tsconfig.tsbuildinfo b/headless/headless/tsconfig.tsbuildinfo deleted file mode 100644 index 7307c747..00000000 --- a/headless/headless/tsconfig.tsbuildinfo +++ /dev/null @@ -1,1120 +0,0 @@ -{ - "program": { - "fileInfos": { - "../../node_modules/typescript/lib/lib.es5.d.ts": { - "version": "b3584bc5798ed422ce2516df360ffa9cf2d80b5eae852867db9ba3743145f895", - "signature": "b3584bc5798ed422ce2516df360ffa9cf2d80b5eae852867db9ba3743145f895", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.d.ts": { - "version": "dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6", - "signature": "dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6", - "affectsGlobalScope": false - }, - "../../node_modules/typescript/lib/lib.es2016.d.ts": { - "version": "7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467", - "signature": "7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467", - "affectsGlobalScope": false - }, - "../../node_modules/typescript/lib/lib.es2017.d.ts": { - "version": "8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9", - "signature": "8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9", - "affectsGlobalScope": false - }, - "../../node_modules/typescript/lib/lib.es2018.d.ts": { - "version": "5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06", - "signature": "5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06", - "affectsGlobalScope": false - }, - "../../node_modules/typescript/lib/lib.dom.d.ts": { - "version": "feeeb1dd8a80fb76be42b0426e8f3ffa9bdef3c2f3c12c147e7660b1c5ba8b3b", - "signature": "feeeb1dd8a80fb76be42b0426e8f3ffa9bdef3c2f3c12c147e7660b1c5ba8b3b", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.core.d.ts": { - "version": "46ee15e9fefa913333b61eaf6b18885900b139867d89832a515059b62cf16a17", - "signature": "46ee15e9fefa913333b61eaf6b18885900b139867d89832a515059b62cf16a17", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.collection.d.ts": { - "version": "43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c", - "signature": "43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.generator.d.ts": { - "version": "cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a", - "signature": "cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.iterable.d.ts": { - "version": "8b2a5df1ce95f78f6b74f1a555ccdb6baab0486b42d8345e0871dd82811f9b9a", - "signature": "8b2a5df1ce95f78f6b74f1a555ccdb6baab0486b42d8345e0871dd82811f9b9a", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.promise.d.ts": { - "version": "2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c", - "signature": "2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.proxy.d.ts": { - "version": "810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357", - "signature": "810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.reflect.d.ts": { - "version": "62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6", - "signature": "62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.symbol.d.ts": { - "version": "3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93", - "signature": "3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts": { - "version": "9d122b7e8c1a5c72506eea50c0973cba55b92b5532d5cafa8a6ce2c547d57551", - "signature": "9d122b7e8c1a5c72506eea50c0973cba55b92b5532d5cafa8a6ce2c547d57551", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2016.array.include.d.ts": { - "version": "3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006", - "signature": "3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2017.object.d.ts": { - "version": "17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a", - "signature": "17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts": { - "version": "7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98", - "signature": "7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2017.string.d.ts": { - "version": "6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577", - "signature": "6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2017.intl.d.ts": { - "version": "12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d", - "signature": "12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts": { - "version": "b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e", - "signature": "b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts": { - "version": "0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a", - "signature": "0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts": { - "version": "a40c4d82bf13fcded295ac29f354eb7d40249613c15e07b53f2fc75e45e16359", - "signature": "a40c4d82bf13fcded295ac29f354eb7d40249613c15e07b53f2fc75e45e16359", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2018.intl.d.ts": { - "version": "df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e", - "signature": "df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2018.promise.d.ts": { - "version": "bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c", - "signature": "bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2018.regexp.d.ts": { - "version": "c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8", - "signature": "c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2020.bigint.d.ts": { - "version": "7b5a10e3c897fabece5a51aa85b4111727d7adb53c2734b5d37230ff96802a09", - "signature": "7b5a10e3c897fabece5a51aa85b4111727d7adb53c2734b5d37230ff96802a09", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.esnext.intl.d.ts": { - "version": "506b80b9951c9381dc5f11897b31fca5e2a65731d96ddefa19687fbc26b23c6e", - "signature": "506b80b9951c9381dc5f11897b31fca5e2a65731d96ddefa19687fbc26b23c6e", - "affectsGlobalScope": true - }, - "../../out/common/eventemitter.d.ts": { - "version": "5b03a7f7f7f551e3fe0e92da13d2e17e7ad7ee19c41d0637f4edbc120bc06f66", - "signature": "5b03a7f7f7f551e3fe0e92da13d2e17e7ad7ee19c41d0637f4edbc120bc06f66", - "affectsGlobalScope": false - }, - "../../out/common/circularlist.d.ts": { - "version": "f96222a7fe4af80068de748cd4bd0b247359b303c72cc827e887eaf6ef9fb758", - "signature": "f96222a7fe4af80068de748cd4bd0b247359b303c72cc827e887eaf6ef9fb758", - "affectsGlobalScope": false - }, - "../../out/common/parser/constants.d.ts": { - "version": "ae42446973a3c189ecac84723e74828ee292f9392935db874cb27ee19ca89093", - "signature": "ae42446973a3c189ecac84723e74828ee292f9392935db874cb27ee19ca89093", - "affectsGlobalScope": false - }, - "../../src/common/parser/types.d.ts": { - "version": "55b56377b6fa8b93856027f20ebaccd8e0c77d4327e45e45b5e2041cf94011cc", - "signature": "55b56377b6fa8b93856027f20ebaccd8e0c77d4327e45e45b5e2041cf94011cc", - "affectsGlobalScope": false - }, - "../../src/common/buffer/types.d.ts": { - "version": "5e2f59fc5cb1b39a2e163bafe30139a33dac4033edcb9b1b831d542abb7f7bae", - "signature": "5e2f59fc5cb1b39a2e163bafe30139a33dac4033edcb9b1b831d542abb7f7bae", - "affectsGlobalScope": false - }, - "../../out/common/services/services.d.ts": { - "version": "4672a4d6d71a25b4592922ecd70094e932348a031d39acc4cef027ea9b62cba0", - "signature": "4672a4d6d71a25b4592922ecd70094e932348a031d39acc4cef027ea9b62cba0", - "affectsGlobalScope": false - }, - "../../src/common/types.d.ts": { - "version": "d7d8eb9c47232c80348f2fc6c8eb7d3acb329b6d8fdcf1f1c38d6e5099f8370b", - "signature": "d7d8eb9c47232c80348f2fc6c8eb7d3acb329b6d8fdcf1f1c38d6e5099f8370b", - "affectsGlobalScope": false - }, - "../../out/common/buffer/constants.d.ts": { - "version": "ff74cff1b7fe399447fd661d0c68586e7b991d11d044af133963c04bde38a852", - "signature": "ff74cff1b7fe399447fd661d0c68586e7b991d11d044af133963c04bde38a852", - "affectsGlobalScope": false - }, - "../../out/common/buffer/attributedata.d.ts": { - "version": "421bb313e7b328ba640853d13b584fe7815b818bd02584d020a41b7a7120d262", - "signature": "421bb313e7b328ba640853d13b584fe7815b818bd02584d020a41b7a7120d262", - "affectsGlobalScope": false - }, - "../../out/common/buffer/bufferline.d.ts": { - "version": "baaa0fc61cb33a67caa0abb986740700be9313c6866ed78c17193e87ca7057a1", - "signature": "baaa0fc61cb33a67caa0abb986740700be9313c6866ed78c17193e87ca7057a1", - "affectsGlobalScope": false - }, - "../../out/common/lifecycle.d.ts": { - "version": "0ba457ac19650eb9dffb8216ca42947899613be5aee16f3809fe39187c30423e", - "signature": "0ba457ac19650eb9dffb8216ca42947899613be5aee16f3809fe39187c30423e", - "affectsGlobalScope": false - }, - "../../out/common/inputhandler.d.ts": { - "version": "542507ad71abebbfe8b5da8758e1aa47bfce3acd0da245f10885cab9934b71d6", - "signature": "542507ad71abebbfe8b5da8758e1aa47bfce3acd0da245f10885cab9934b71d6", - "affectsGlobalScope": false - }, - "../../out/common/coreterminal.d.ts": { - "version": "ab615cd4d0ef6f17d26eef27cdf5beec0e081e59b5eefb09ede878c2cabb4c15", - "signature": "ab615cd4d0ef6f17d26eef27cdf5beec0e081e59b5eefb09ede878c2cabb4c15", - "affectsGlobalScope": false - }, - "../../src/headless/terminal.ts": { - "version": "59209d1535dcfbe8bac847ccf13e829a9ea692ce58fdcb3ee3605791ae60b564", - "signature": "5311ffa92a616a0729010de20af2272185a8b65b51ac26a496326b3b32aad8cc", - "affectsGlobalScope": false - }, - "../../src/headless/types.d.ts": { - "version": "d51941b70feb73ac171f24e34f11de9be17d0c4f224da1a6ed39fe8c31ba6695", - "signature": "d51941b70feb73ac171f24e34f11de9be17d0c4f224da1a6ed39fe8c31ba6695", - "affectsGlobalScope": false - }, - "../../out/common/public/buffernamespaceapi.d.ts": { - "version": "1f8e93ce424bd436ad641d8313d849af586a3779adbfd870e1cfee72a212ae57", - "signature": "1f8e93ce424bd436ad641d8313d849af586a3779adbfd870e1cfee72a212ae57", - "affectsGlobalScope": false - }, - "../../out/common/public/parserapi.d.ts": { - "version": "7c0d242565ad3b41ef8666e46fbd88aec222d2e9b2a343ac315b00373401ffc2", - "signature": "7c0d242565ad3b41ef8666e46fbd88aec222d2e9b2a343ac315b00373401ffc2", - "affectsGlobalScope": false - }, - "../../out/common/public/unicodeapi.d.ts": { - "version": "d77b28e85c1bbc95897707b719c4797ac94f5bf76572c81baae195787133826c", - "signature": "d77b28e85c1bbc95897707b719c4797ac94f5bf76572c81baae195787133826c", - "affectsGlobalScope": false - }, - "../../src/headless/public/terminal.ts": { - "version": "fce93b9408e0c088a1c6802aff2cf8cc46ac0feddc59f26b5a3241d0f03c82db", - "signature": "503924e7f37322f587ebce5459da9c47860c843c0d30d6d09b6ba25d5d169ac7", - "affectsGlobalScope": false - }, - "../../typings/xterm.d.ts": { - "version": "d5256f76893350e4897436490570d291be7a2a005d44e3fa221f1a19804b8c5e", - "signature": "d5256f76893350e4897436490570d291be7a2a005d44e3fa221f1a19804b8c5e", - "affectsGlobalScope": false - }, - "../../typings/xterm-core.d.ts": { - "version": "675fd5779b700c3e864a36a14db728d91027632f90e60c7bfd440b5db61e174d", - "signature": "675fd5779b700c3e864a36a14db728d91027632f90e60c7bfd440b5db61e174d", - "affectsGlobalScope": false - }, - "../../node_modules/@types/mocha/index.d.ts": { - "version": "0359800d3b440f8515001431cde1500944e156040577425eb3f7b80af0846612", - "signature": "0359800d3b440f8515001431cde1500944e156040577425eb3f7b80af0846612", - "affectsGlobalScope": true - }, - "../../node_modules/@types/node/globals.d.ts": { - "version": "25b4a0c4fab47c373ee49df4c239826ee3430019fc0c1b5e59edc3e398b7468d", - "signature": "25b4a0c4fab47c373ee49df4c239826ee3430019fc0c1b5e59edc3e398b7468d", - "affectsGlobalScope": true - }, - "../../node_modules/@types/node/async_hooks.d.ts": { - "version": "c9e8a340da877b05a52525554aa255b3f44958c7f6748ebf5cbe0bfbe6766878", - "signature": "c9e8a340da877b05a52525554aa255b3f44958c7f6748ebf5cbe0bfbe6766878", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/buffer.d.ts": { - "version": "a473cf45c3d9809518f8af913312139d9f4db6887dc554e0d06d0f4e52722e6b", - "signature": "a473cf45c3d9809518f8af913312139d9f4db6887dc554e0d06d0f4e52722e6b", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/child_process.d.ts": { - "version": "a668dfae917097b30fc29bbebeeb869cee22529f2aa9976cea03c7e834a1b841", - "signature": "a668dfae917097b30fc29bbebeeb869cee22529f2aa9976cea03c7e834a1b841", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/cluster.d.ts": { - "version": "04eaa93bd75f937f9184dcb95a7983800c5770cf8ddd8ac0f3734dc02f5b20ef", - "signature": "04eaa93bd75f937f9184dcb95a7983800c5770cf8ddd8ac0f3734dc02f5b20ef", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/console.d.ts": { - "version": "c8155caf28fc7b0a564156a5df28ad8a844a3bd32d331d148d8f3ce88025c870", - "signature": "c8155caf28fc7b0a564156a5df28ad8a844a3bd32d331d148d8f3ce88025c870", - "affectsGlobalScope": true - }, - "../../node_modules/@types/node/constants.d.ts": { - "version": "45ac321f2e15d268fd74a90ddaa6467dcaaff2c5b13f95b4b85831520fb7a491", - "signature": "45ac321f2e15d268fd74a90ddaa6467dcaaff2c5b13f95b4b85831520fb7a491", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/crypto.d.ts": { - "version": "0084b54e281a37c75079f92ca20603d5731de063e7a425852b2907de4dd19932", - "signature": "0084b54e281a37c75079f92ca20603d5731de063e7a425852b2907de4dd19932", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/dgram.d.ts": { - "version": "797a9d37eb1f76143311c3f0a186ce5c0d8735e94c0ca08ff8712a876c9b4f9e", - "signature": "797a9d37eb1f76143311c3f0a186ce5c0d8735e94c0ca08ff8712a876c9b4f9e", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/dns.d.ts": { - "version": "bc31e01146eec89eb870b9ad8c55d759bcbc8989a894e6f0f81f832e0d10eb04", - "signature": "bc31e01146eec89eb870b9ad8c55d759bcbc8989a894e6f0f81f832e0d10eb04", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/domain.d.ts": { - "version": "2866a528b2708aa272ec3eaafd3c980abb23aec1ef831cfc5eb2186b98c37ce5", - "signature": "2866a528b2708aa272ec3eaafd3c980abb23aec1ef831cfc5eb2186b98c37ce5", - "affectsGlobalScope": true - }, - "../../node_modules/@types/node/events.d.ts": { - "version": "153d835dc32985120790e10102834b0a5bd979bb5e42bfbb33c0ff6260cf03ce", - "signature": "153d835dc32985120790e10102834b0a5bd979bb5e42bfbb33c0ff6260cf03ce", - "affectsGlobalScope": true - }, - "../../node_modules/@types/node/fs.d.ts": { - "version": "a44c87a409b60f211a240341905d818f5f173420dcf7f989ee6c8a1a3d812ae9", - "signature": "a44c87a409b60f211a240341905d818f5f173420dcf7f989ee6c8a1a3d812ae9", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/fs/promises.d.ts": { - "version": "bdaf554ae2d9d09e2a42f58a29ef7f80e5b5c1d7b96bfb717243dc91a477216e", - "signature": "bdaf554ae2d9d09e2a42f58a29ef7f80e5b5c1d7b96bfb717243dc91a477216e", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/http.d.ts": { - "version": "dce8672a79c7221c10a355b905940ab57505bc480a72a5da33ba24cbf82bb75c", - "signature": "dce8672a79c7221c10a355b905940ab57505bc480a72a5da33ba24cbf82bb75c", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/http2.d.ts": { - "version": "321ea733ae7f611077a2d7b4bc378ac4a6b7e365e1a51c71a7e5b2818e1e310a", - "signature": "321ea733ae7f611077a2d7b4bc378ac4a6b7e365e1a51c71a7e5b2818e1e310a", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/https.d.ts": { - "version": "13257840c0850d4ebd7c2b17604a9e006f752de76c2400ebc752bc465c330452", - "signature": "13257840c0850d4ebd7c2b17604a9e006f752de76c2400ebc752bc465c330452", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/inspector.d.ts": { - "version": "42176966283d3835c34278b9b5c0f470d484c0c0c6a55c20a2c916a1ce69b6e8", - "signature": "42176966283d3835c34278b9b5c0f470d484c0c0c6a55c20a2c916a1ce69b6e8", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/module.d.ts": { - "version": "0cff7901aedfe78e314f7d44088f07e2afa1b6e4f0473a4169b8456ca2fb245d", - "signature": "0cff7901aedfe78e314f7d44088f07e2afa1b6e4f0473a4169b8456ca2fb245d", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/net.d.ts": { - "version": "40b957b502b40dd490ee334aed47a30636f8d14a0267d1b6c088c2be1dcf2757", - "signature": "40b957b502b40dd490ee334aed47a30636f8d14a0267d1b6c088c2be1dcf2757", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/os.d.ts": { - "version": "69640cc2e76dad52daeb9914e6b70c5c9a5591a3a65190a2d3ea432cf0015e16", - "signature": "69640cc2e76dad52daeb9914e6b70c5c9a5591a3a65190a2d3ea432cf0015e16", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/path.d.ts": { - "version": "21e64a125f65dff99cc3ed366c96e922b90daed343eb52ecdace5f220401dcda", - "signature": "21e64a125f65dff99cc3ed366c96e922b90daed343eb52ecdace5f220401dcda", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/perf_hooks.d.ts": { - "version": "4982d94cb6427263c8839d8d6324a8bbe129e931deb61a7380f8fad17ba2cfc0", - "signature": "4982d94cb6427263c8839d8d6324a8bbe129e931deb61a7380f8fad17ba2cfc0", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/process.d.ts": { - "version": "b0b00cf2e8107ab671243a73d2fbd6296a853bebe3fcfaaca293f65aaa245eaf", - "signature": "b0b00cf2e8107ab671243a73d2fbd6296a853bebe3fcfaaca293f65aaa245eaf", - "affectsGlobalScope": true - }, - "../../node_modules/@types/node/punycode.d.ts": { - "version": "7f77304372efe3c9967e5f9ea2061f1b4bf41dc3cda3c83cdd676f2e5af6b7e6", - "signature": "7f77304372efe3c9967e5f9ea2061f1b4bf41dc3cda3c83cdd676f2e5af6b7e6", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/querystring.d.ts": { - "version": "992c6f6be16c0a1d2eec13ece33adeea2c747ba27fcd078353a8f4bb5b4fea58", - "signature": "992c6f6be16c0a1d2eec13ece33adeea2c747ba27fcd078353a8f4bb5b4fea58", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/readline.d.ts": { - "version": "3b790d08129aca55fd5ae1672d1d26594147ac0d5f2eedc30c7575eb18daef7e", - "signature": "3b790d08129aca55fd5ae1672d1d26594147ac0d5f2eedc30c7575eb18daef7e", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/repl.d.ts": { - "version": "64535caf208a02420d2d04eb2029269efedd11eb8597ada0d5e6f3d54ec663ae", - "signature": "64535caf208a02420d2d04eb2029269efedd11eb8597ada0d5e6f3d54ec663ae", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/stream.d.ts": { - "version": "e7b5a3f40f19d9eea71890c70dfb37ac5dd82cbffe5f95bc8f23c536455732d0", - "signature": "e7b5a3f40f19d9eea71890c70dfb37ac5dd82cbffe5f95bc8f23c536455732d0", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/string_decoder.d.ts": { - "version": "4fd3c4debadce3e9ab9dec3eb45f7f5e2e3d4ad65cf975a6d938d883cfb25a50", - "signature": "4fd3c4debadce3e9ab9dec3eb45f7f5e2e3d4ad65cf975a6d938d883cfb25a50", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/timers.d.ts": { - "version": "0953427f9c2498f71dd912fdd8a81b19cf6925de3e1ad67ab9a77b9a0f79bf0b", - "signature": "0953427f9c2498f71dd912fdd8a81b19cf6925de3e1ad67ab9a77b9a0f79bf0b", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/tls.d.ts": { - "version": "f89a6d56f0267f6e73c707f8a89d2f38e9928e10bfa505f39a4f4bf954093aee", - "signature": "f89a6d56f0267f6e73c707f8a89d2f38e9928e10bfa505f39a4f4bf954093aee", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/trace_events.d.ts": { - "version": "7df562288f949945cf69c21cd912100c2afedeeb7cdb219085f7f4b46cb7dde4", - "signature": "7df562288f949945cf69c21cd912100c2afedeeb7cdb219085f7f4b46cb7dde4", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/tty.d.ts": { - "version": "9d16690485ff1eb4f6fc57aebe237728fd8e03130c460919da3a35f4d9bd97f5", - "signature": "9d16690485ff1eb4f6fc57aebe237728fd8e03130c460919da3a35f4d9bd97f5", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/url.d.ts": { - "version": "dcc6910d95a3625fd2b0487fda055988e46ab46c357a1b3618c27b4a8dd739c9", - "signature": "dcc6910d95a3625fd2b0487fda055988e46ab46c357a1b3618c27b4a8dd739c9", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/util.d.ts": { - "version": "e649840284bab8c4d09cadc125cd7fbde7529690cc1a0881872b6a9cd202819b", - "signature": "e649840284bab8c4d09cadc125cd7fbde7529690cc1a0881872b6a9cd202819b", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/v8.d.ts": { - "version": "a364b4a8a015ae377052fa4fac94204d79a69d879567f444c7ceff1b7a18482d", - "signature": "a364b4a8a015ae377052fa4fac94204d79a69d879567f444c7ceff1b7a18482d", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/vm.d.ts": { - "version": "1aa7dbace2b7b2ef60897dcd4f66252ee6ba85e594ded8918c9acdcecda1896c", - "signature": "1aa7dbace2b7b2ef60897dcd4f66252ee6ba85e594ded8918c9acdcecda1896c", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/worker_threads.d.ts": { - "version": "6c63cb179eda2be5ab45dc146fa4151bec8ce4781986935fe40adfc69cbbf214", - "signature": "6c63cb179eda2be5ab45dc146fa4151bec8ce4781986935fe40adfc69cbbf214", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/zlib.d.ts": { - "version": "4926467de88a92a4fc9971d8c6f21b91eca1c0e7fc2a46cc4638ab9440c73875", - "signature": "4926467de88a92a4fc9971d8c6f21b91eca1c0e7fc2a46cc4638ab9440c73875", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/globals.global.d.ts": { - "version": "2708349d5a11a5c2e5f3a0765259ebe7ee00cdcc8161cb9990cb4910328442a1", - "signature": "2708349d5a11a5c2e5f3a0765259ebe7ee00cdcc8161cb9990cb4910328442a1", - "affectsGlobalScope": true - }, - "../../node_modules/@types/node/wasi.d.ts": { - "version": "4e0a4d84b15692ea8669fe4f3d05a4f204567906b1347da7a58b75f45bae48d3", - "signature": "4e0a4d84b15692ea8669fe4f3d05a4f204567906b1347da7a58b75f45bae48d3", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/ts3.6/base.d.ts": { - "version": "ae68a04912ee5a0f589276f9ec60b095f8c40d48128a4575b3fdd7d93806931c", - "signature": "ae68a04912ee5a0f589276f9ec60b095f8c40d48128a4575b3fdd7d93806931c", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/assert.d.ts": { - "version": "b3593bd345ebea5e4d0a894c03251a3774b34df3d6db57075c18e089a599ba76", - "signature": "b3593bd345ebea5e4d0a894c03251a3774b34df3d6db57075c18e089a599ba76", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/base.d.ts": { - "version": "e61a21e9418f279bc480394a94d1581b2dee73747adcbdef999b6737e34d721b", - "signature": "e61a21e9418f279bc480394a94d1581b2dee73747adcbdef999b6737e34d721b", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/index.d.ts": { - "version": "6c137dee82a61e14a1eb6a0ba56925b66fd83abf15acf72fe59a10b15e80e319", - "signature": "6c137dee82a61e14a1eb6a0ba56925b66fd83abf15acf72fe59a10b15e80e319", - "affectsGlobalScope": false - } - }, - "options": { - "target": 1, - "lib": [ - "lib.es2015.d.ts", - "lib.es2016.array.include.d.ts" - ], - "rootDir": "../../src", - "sourceMap": true, - "removeComments": true, - "pretty": true, - "incremental": true, - "experimentalDecorators": true, - "composite": true, - "strict": true, - "declarationMap": true, - "outDir": "..", - "types": [ - "../../node_modules/@types/mocha", - "../../node_modules/@types/node" - ], - "baseUrl": "../../src", - "extendedDiagnostics": true, - "paths": { - "common/*": [ - "./common/*" - ] - }, - "pathsBasePath": "D:/GitHub/Tyriar/xterm.js/src/headless", - "watch": true, - "preserveWatchOutput": true, - "configFilePath": "../../src/headless/tsconfig.json" - }, - "referencedMap": { - "../../node_modules/@types/node/base.d.ts": [ - "../../node_modules/@types/node/assert.d.ts", - "../../node_modules/@types/node/ts3.6/base.d.ts" - ], - "../../node_modules/@types/node/child_process.d.ts": [ - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs.d.ts", - "../../node_modules/@types/node/net.d.ts", - "../../node_modules/@types/node/stream.d.ts" - ], - "../../node_modules/@types/node/cluster.d.ts": [ - "../../node_modules/@types/node/child_process.d.ts", - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/net.d.ts" - ], - "../../node_modules/@types/node/console.d.ts": [ - "../../node_modules/@types/node/util.d.ts" - ], - "../../node_modules/@types/node/constants.d.ts": [ - "../../node_modules/@types/node/crypto.d.ts", - "../../node_modules/@types/node/fs.d.ts", - "../../node_modules/@types/node/os.d.ts" - ], - "../../node_modules/@types/node/crypto.d.ts": [ - "../../node_modules/@types/node/stream.d.ts" - ], - "../../node_modules/@types/node/dgram.d.ts": [ - "../../node_modules/@types/node/dns.d.ts", - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/net.d.ts" - ], - "../../node_modules/@types/node/domain.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/events.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/fs.d.ts": [ - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs/promises.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/fs/promises.d.ts": [ - "../../node_modules/@types/node/fs.d.ts" - ], - "../../node_modules/@types/node/http.d.ts": [ - "../../node_modules/@types/node/net.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/http2.d.ts": [ - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs.d.ts", - "../../node_modules/@types/node/http.d.ts", - "../../node_modules/@types/node/net.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/tls.d.ts", - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/https.d.ts": [ - "../../node_modules/@types/node/http.d.ts", - "../../node_modules/@types/node/tls.d.ts", - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/index.d.ts": [ - "../../node_modules/@types/node/base.d.ts" - ], - "../../node_modules/@types/node/inspector.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/module.d.ts": [ - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/net.d.ts": [ - "../../node_modules/@types/node/dns.d.ts", - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/stream.d.ts" - ], - "../../node_modules/@types/node/perf_hooks.d.ts": [ - "../../node_modules/@types/node/async_hooks.d.ts" - ], - "../../node_modules/@types/node/process.d.ts": [ - "../../node_modules/@types/node/tty.d.ts" - ], - "../../node_modules/@types/node/readline.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/repl.d.ts": [ - "../../node_modules/@types/node/readline.d.ts", - "../../node_modules/@types/node/util.d.ts", - "../../node_modules/@types/node/vm.d.ts" - ], - "../../node_modules/@types/node/stream.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/tls.d.ts": [ - "../../node_modules/@types/node/net.d.ts" - ], - "../../node_modules/@types/node/ts3.6/base.d.ts": [ - "../../node_modules/@types/node/async_hooks.d.ts", - "../../node_modules/@types/node/buffer.d.ts", - "../../node_modules/@types/node/child_process.d.ts", - "../../node_modules/@types/node/cluster.d.ts", - "../../node_modules/@types/node/console.d.ts", - "../../node_modules/@types/node/constants.d.ts", - "../../node_modules/@types/node/crypto.d.ts", - "../../node_modules/@types/node/dgram.d.ts", - "../../node_modules/@types/node/dns.d.ts", - "../../node_modules/@types/node/domain.d.ts", - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs.d.ts", - "../../node_modules/@types/node/fs/promises.d.ts", - "../../node_modules/@types/node/globals.d.ts", - "../../node_modules/@types/node/globals.global.d.ts", - "../../node_modules/@types/node/http.d.ts", - "../../node_modules/@types/node/http2.d.ts", - "../../node_modules/@types/node/https.d.ts", - "../../node_modules/@types/node/inspector.d.ts", - "../../node_modules/@types/node/module.d.ts", - "../../node_modules/@types/node/net.d.ts", - "../../node_modules/@types/node/os.d.ts", - "../../node_modules/@types/node/path.d.ts", - "../../node_modules/@types/node/perf_hooks.d.ts", - "../../node_modules/@types/node/process.d.ts", - "../../node_modules/@types/node/punycode.d.ts", - "../../node_modules/@types/node/querystring.d.ts", - "../../node_modules/@types/node/readline.d.ts", - "../../node_modules/@types/node/repl.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/string_decoder.d.ts", - "../../node_modules/@types/node/timers.d.ts", - "../../node_modules/@types/node/tls.d.ts", - "../../node_modules/@types/node/trace_events.d.ts", - "../../node_modules/@types/node/tty.d.ts", - "../../node_modules/@types/node/url.d.ts", - "../../node_modules/@types/node/util.d.ts", - "../../node_modules/@types/node/v8.d.ts", - "../../node_modules/@types/node/vm.d.ts", - "../../node_modules/@types/node/wasi.d.ts", - "../../node_modules/@types/node/worker_threads.d.ts", - "../../node_modules/@types/node/zlib.d.ts" - ], - "../../node_modules/@types/node/tty.d.ts": [ - "../../node_modules/@types/node/net.d.ts" - ], - "../../node_modules/@types/node/url.d.ts": [ - "../../node_modules/@types/node/querystring.d.ts" - ], - "../../node_modules/@types/node/v8.d.ts": [ - "../../node_modules/@types/node/stream.d.ts" - ], - "../../node_modules/@types/node/worker_threads.d.ts": [ - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs/promises.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/url.d.ts", - "../../node_modules/@types/node/vm.d.ts" - ], - "../../node_modules/@types/node/zlib.d.ts": [ - "../../node_modules/@types/node/stream.d.ts" - ], - "../../out/common/buffer/attributedata.d.ts": [ - "../../out/common/buffer/constants.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/buffer/bufferline.d.ts": [ - "../../out/common/buffer/attributedata.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/circularlist.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/coreterminal.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../out/common/inputhandler.d.ts", - "../../out/common/lifecycle.d.ts", - "../../out/common/services/services.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/parser/types.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/eventemitter.d.ts": [ - "../../src/common/types.d.ts" - ], - "../../out/common/inputhandler.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../out/common/lifecycle.d.ts", - "../../out/common/services/services.d.ts", - "../../src/common/parser/types.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/lifecycle.d.ts": [ - "../../src/common/types.d.ts" - ], - "../../out/common/public/buffernamespaceapi.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../src/common/types.d.ts", - "../../typings/xterm.d.ts" - ], - "../../out/common/public/parserapi.d.ts": [ - "../../src/common/types.d.ts", - "../../typings/xterm.d.ts" - ], - "../../out/common/public/unicodeapi.d.ts": [ - "../../src/common/types.d.ts", - "../../typings/xterm.d.ts" - ], - "../../out/common/services/services.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/types.d.ts" - ], - "../../src/common/buffer/types.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../src/common/types.d.ts" - ], - "../../src/common/parser/types.d.ts": [ - "../../out/common/parser/constants.d.ts", - "../../src/common/types.d.ts" - ], - "../../src/common/types.d.ts": [ - "../../out/common/circularlist.d.ts", - "../../out/common/eventemitter.d.ts", - "../../out/common/services/services.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/parser/types.d.ts", - "../../typings/xterm.d.ts" - ], - "../../src/headless/public/terminal.ts": [ - "../../out/common/eventemitter.d.ts", - "../../out/common/public/buffernamespaceapi.d.ts", - "../../out/common/public/parserapi.d.ts", - "../../out/common/public/unicodeapi.d.ts", - "../../src/headless/terminal.ts", - "../../typings/xterm-core.d.ts" - ], - "../../src/headless/terminal.ts": [ - "../../out/common/buffer/bufferline.d.ts", - "../../out/common/coreterminal.d.ts", - "../../out/common/eventemitter.d.ts", - "../../out/common/services/services.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/types.d.ts" - ], - "../../src/headless/types.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/parser/types.d.ts", - "../../src/common/types.d.ts" - ] - }, - "exportedModulesMap": { - "../../node_modules/@types/node/base.d.ts": [ - "../../node_modules/@types/node/assert.d.ts", - "../../node_modules/@types/node/ts3.6/base.d.ts" - ], - "../../node_modules/@types/node/child_process.d.ts": [ - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs.d.ts", - "../../node_modules/@types/node/net.d.ts", - "../../node_modules/@types/node/stream.d.ts" - ], - "../../node_modules/@types/node/cluster.d.ts": [ - "../../node_modules/@types/node/child_process.d.ts", - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/net.d.ts" - ], - "../../node_modules/@types/node/console.d.ts": [ - "../../node_modules/@types/node/util.d.ts" - ], - "../../node_modules/@types/node/constants.d.ts": [ - "../../node_modules/@types/node/crypto.d.ts", - "../../node_modules/@types/node/fs.d.ts", - "../../node_modules/@types/node/os.d.ts" - ], - "../../node_modules/@types/node/crypto.d.ts": [ - "../../node_modules/@types/node/stream.d.ts" - ], - "../../node_modules/@types/node/dgram.d.ts": [ - "../../node_modules/@types/node/dns.d.ts", - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/net.d.ts" - ], - "../../node_modules/@types/node/domain.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/events.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/fs.d.ts": [ - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs/promises.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/fs/promises.d.ts": [ - "../../node_modules/@types/node/fs.d.ts" - ], - "../../node_modules/@types/node/http.d.ts": [ - "../../node_modules/@types/node/net.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/http2.d.ts": [ - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs.d.ts", - "../../node_modules/@types/node/http.d.ts", - "../../node_modules/@types/node/net.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/tls.d.ts", - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/https.d.ts": [ - "../../node_modules/@types/node/http.d.ts", - "../../node_modules/@types/node/tls.d.ts", - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/index.d.ts": [ - "../../node_modules/@types/node/base.d.ts" - ], - "../../node_modules/@types/node/inspector.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/module.d.ts": [ - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/net.d.ts": [ - "../../node_modules/@types/node/dns.d.ts", - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/stream.d.ts" - ], - "../../node_modules/@types/node/perf_hooks.d.ts": [ - "../../node_modules/@types/node/async_hooks.d.ts" - ], - "../../node_modules/@types/node/process.d.ts": [ - "../../node_modules/@types/node/tty.d.ts" - ], - "../../node_modules/@types/node/readline.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/repl.d.ts": [ - "../../node_modules/@types/node/readline.d.ts", - "../../node_modules/@types/node/util.d.ts", - "../../node_modules/@types/node/vm.d.ts" - ], - "../../node_modules/@types/node/stream.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/tls.d.ts": [ - "../../node_modules/@types/node/net.d.ts" - ], - "../../node_modules/@types/node/ts3.6/base.d.ts": [ - "../../node_modules/@types/node/async_hooks.d.ts", - "../../node_modules/@types/node/buffer.d.ts", - "../../node_modules/@types/node/child_process.d.ts", - "../../node_modules/@types/node/cluster.d.ts", - "../../node_modules/@types/node/console.d.ts", - "../../node_modules/@types/node/constants.d.ts", - "../../node_modules/@types/node/crypto.d.ts", - "../../node_modules/@types/node/dgram.d.ts", - "../../node_modules/@types/node/dns.d.ts", - "../../node_modules/@types/node/domain.d.ts", - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs.d.ts", - "../../node_modules/@types/node/fs/promises.d.ts", - "../../node_modules/@types/node/globals.d.ts", - "../../node_modules/@types/node/globals.global.d.ts", - "../../node_modules/@types/node/http.d.ts", - "../../node_modules/@types/node/http2.d.ts", - "../../node_modules/@types/node/https.d.ts", - "../../node_modules/@types/node/inspector.d.ts", - "../../node_modules/@types/node/module.d.ts", - "../../node_modules/@types/node/net.d.ts", - "../../node_modules/@types/node/os.d.ts", - "../../node_modules/@types/node/path.d.ts", - "../../node_modules/@types/node/perf_hooks.d.ts", - "../../node_modules/@types/node/process.d.ts", - "../../node_modules/@types/node/punycode.d.ts", - "../../node_modules/@types/node/querystring.d.ts", - "../../node_modules/@types/node/readline.d.ts", - "../../node_modules/@types/node/repl.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/string_decoder.d.ts", - "../../node_modules/@types/node/timers.d.ts", - "../../node_modules/@types/node/tls.d.ts", - "../../node_modules/@types/node/trace_events.d.ts", - "../../node_modules/@types/node/tty.d.ts", - "../../node_modules/@types/node/url.d.ts", - "../../node_modules/@types/node/util.d.ts", - "../../node_modules/@types/node/v8.d.ts", - "../../node_modules/@types/node/vm.d.ts", - "../../node_modules/@types/node/wasi.d.ts", - "../../node_modules/@types/node/worker_threads.d.ts", - "../../node_modules/@types/node/zlib.d.ts" - ], - "../../node_modules/@types/node/tty.d.ts": [ - "../../node_modules/@types/node/net.d.ts" - ], - "../../node_modules/@types/node/url.d.ts": [ - "../../node_modules/@types/node/querystring.d.ts" - ], - "../../node_modules/@types/node/v8.d.ts": [ - "../../node_modules/@types/node/stream.d.ts" - ], - "../../node_modules/@types/node/worker_threads.d.ts": [ - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs/promises.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/url.d.ts", - "../../node_modules/@types/node/vm.d.ts" - ], - "../../node_modules/@types/node/zlib.d.ts": [ - "../../node_modules/@types/node/stream.d.ts" - ], - "../../out/common/buffer/attributedata.d.ts": [ - "../../out/common/buffer/constants.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/buffer/bufferline.d.ts": [ - "../../out/common/buffer/attributedata.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/circularlist.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/coreterminal.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../out/common/inputhandler.d.ts", - "../../out/common/lifecycle.d.ts", - "../../out/common/services/services.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/parser/types.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/eventemitter.d.ts": [ - "../../src/common/types.d.ts" - ], - "../../out/common/inputhandler.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../out/common/lifecycle.d.ts", - "../../out/common/services/services.d.ts", - "../../src/common/parser/types.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/lifecycle.d.ts": [ - "../../src/common/types.d.ts" - ], - "../../out/common/public/buffernamespaceapi.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../src/common/types.d.ts", - "../../typings/xterm.d.ts" - ], - "../../out/common/public/parserapi.d.ts": [ - "../../src/common/types.d.ts", - "../../typings/xterm.d.ts" - ], - "../../out/common/public/unicodeapi.d.ts": [ - "../../src/common/types.d.ts", - "../../typings/xterm.d.ts" - ], - "../../out/common/services/services.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/types.d.ts" - ], - "../../src/common/buffer/types.d.ts": [ - "../../src/common/eventemitter.ts", - "../../src/common/types.d.ts" - ], - "../../src/common/parser/types.d.ts": [ - "../../src/common/parser/constants.ts", - "../../src/common/types.d.ts" - ], - "../../src/common/types.d.ts": [ - "../../src/common/buffer/types.d.ts", - "../../src/common/circularlist.ts", - "../../src/common/eventemitter.ts", - "../../src/common/parser/types.d.ts", - "../../src/common/services/services.ts", - "../../typings/xterm.d.ts" - ], - "../../src/headless/public/terminal.ts": [ - "../../out/common/eventemitter.d.ts", - "../../typings/xterm-core.d.ts" - ], - "../../src/headless/terminal.ts": [ - "../../out/common/coreterminal.d.ts", - "../../out/common/eventemitter.d.ts", - "../../out/common/services/services.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/types.d.ts" - ], - "../../src/headless/types.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/parser/types.d.ts", - "../../src/common/types.d.ts" - ] - }, - "semanticDiagnosticsPerFile": [ - "../../node_modules/@types/mocha/index.d.ts", - "../../node_modules/@types/node/assert.d.ts", - "../../node_modules/@types/node/async_hooks.d.ts", - "../../node_modules/@types/node/base.d.ts", - "../../node_modules/@types/node/buffer.d.ts", - "../../node_modules/@types/node/child_process.d.ts", - "../../node_modules/@types/node/cluster.d.ts", - "../../node_modules/@types/node/console.d.ts", - "../../node_modules/@types/node/constants.d.ts", - "../../node_modules/@types/node/crypto.d.ts", - "../../node_modules/@types/node/dgram.d.ts", - "../../node_modules/@types/node/dns.d.ts", - "../../node_modules/@types/node/domain.d.ts", - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs.d.ts", - "../../node_modules/@types/node/fs/promises.d.ts", - "../../node_modules/@types/node/globals.d.ts", - "../../node_modules/@types/node/globals.global.d.ts", - "../../node_modules/@types/node/http.d.ts", - "../../node_modules/@types/node/http2.d.ts", - "../../node_modules/@types/node/https.d.ts", - "../../node_modules/@types/node/index.d.ts", - "../../node_modules/@types/node/inspector.d.ts", - "../../node_modules/@types/node/module.d.ts", - "../../node_modules/@types/node/net.d.ts", - "../../node_modules/@types/node/os.d.ts", - "../../node_modules/@types/node/path.d.ts", - "../../node_modules/@types/node/perf_hooks.d.ts", - "../../node_modules/@types/node/process.d.ts", - "../../node_modules/@types/node/punycode.d.ts", - "../../node_modules/@types/node/querystring.d.ts", - "../../node_modules/@types/node/readline.d.ts", - "../../node_modules/@types/node/repl.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/string_decoder.d.ts", - "../../node_modules/@types/node/timers.d.ts", - "../../node_modules/@types/node/tls.d.ts", - "../../node_modules/@types/node/trace_events.d.ts", - "../../node_modules/@types/node/ts3.6/base.d.ts", - "../../node_modules/@types/node/tty.d.ts", - "../../node_modules/@types/node/url.d.ts", - "../../node_modules/@types/node/util.d.ts", - "../../node_modules/@types/node/v8.d.ts", - "../../node_modules/@types/node/vm.d.ts", - "../../node_modules/@types/node/wasi.d.ts", - "../../node_modules/@types/node/worker_threads.d.ts", - "../../node_modules/@types/node/zlib.d.ts", - "../../node_modules/typescript/lib/lib.dom.d.ts", - "../../node_modules/typescript/lib/lib.es2015.collection.d.ts", - "../../node_modules/typescript/lib/lib.es2015.core.d.ts", - "../../node_modules/typescript/lib/lib.es2015.d.ts", - "../../node_modules/typescript/lib/lib.es2015.generator.d.ts", - "../../node_modules/typescript/lib/lib.es2015.iterable.d.ts", - "../../node_modules/typescript/lib/lib.es2015.promise.d.ts", - "../../node_modules/typescript/lib/lib.es2015.proxy.d.ts", - "../../node_modules/typescript/lib/lib.es2015.reflect.d.ts", - "../../node_modules/typescript/lib/lib.es2015.symbol.d.ts", - "../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts", - "../../node_modules/typescript/lib/lib.es2016.array.include.d.ts", - "../../node_modules/typescript/lib/lib.es2016.d.ts", - "../../node_modules/typescript/lib/lib.es2017.d.ts", - "../../node_modules/typescript/lib/lib.es2017.intl.d.ts", - "../../node_modules/typescript/lib/lib.es2017.object.d.ts", - "../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts", - "../../node_modules/typescript/lib/lib.es2017.string.d.ts", - "../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts", - "../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts", - "../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts", - "../../node_modules/typescript/lib/lib.es2018.d.ts", - "../../node_modules/typescript/lib/lib.es2018.intl.d.ts", - "../../node_modules/typescript/lib/lib.es2018.promise.d.ts", - "../../node_modules/typescript/lib/lib.es2018.regexp.d.ts", - "../../node_modules/typescript/lib/lib.es2020.bigint.d.ts", - "../../node_modules/typescript/lib/lib.es5.d.ts", - "../../node_modules/typescript/lib/lib.esnext.intl.d.ts", - "../../out/common/buffer/attributedata.d.ts", - "../../out/common/buffer/bufferline.d.ts", - "../../out/common/buffer/constants.d.ts", - "../../out/common/circularlist.d.ts", - "../../out/common/coreterminal.d.ts", - "../../out/common/eventemitter.d.ts", - "../../out/common/inputhandler.d.ts", - "../../out/common/lifecycle.d.ts", - "../../out/common/parser/constants.d.ts", - "../../out/common/public/buffernamespaceapi.d.ts", - "../../out/common/public/parserapi.d.ts", - "../../out/common/public/unicodeapi.d.ts", - "../../out/common/services/services.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/parser/types.d.ts", - "../../src/common/types.d.ts", - "../../src/headless/public/terminal.ts", - "../../src/headless/terminal.ts", - "../../src/headless/types.d.ts", - "../../typings/xterm-core.d.ts", - "../../typings/xterm.d.ts" - ] - }, - "version": "4.2.4" -} \ No newline at end of file diff --git a/headless/headless/types.d.ts b/headless/headless/types.d.ts deleted file mode 100644 index a35f3988..00000000 --- a/headless/headless/types.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { IBuffer, IBufferSet } from 'common/buffer/Types'; -import { IEvent } from 'common/EventEmitter'; -import { IFunctionIdentifier, IParams } from 'common/parser/Types'; -import { ICoreTerminal, IDisposable, IMarker, ITerminalOptions } from 'common/Types'; -export interface ITerminal extends ICoreTerminal { - rows: number; - cols: number; - buffer: IBuffer; - buffers: IBufferSet; - markers: IMarker[]; - options: ITerminalOptions; - onCursorMove: IEvent; - onData: IEvent; - onBinary: IEvent; - onLineFeed: IEvent; - onResize: IEvent<{ - cols: number; - rows: number; - }>; - onTitleChange: IEvent; - resize(columns: number, rows: number): void; - addCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean): IDisposable; - addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean): IDisposable; - addEscHandler(id: IFunctionIdentifier, callback: () => boolean): IDisposable; - addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable; - addMarker(cursorYOffset: number): IMarker | undefined; - dispose(): void; - clear(): void; - write(data: string | Uint8Array, callback?: () => void): void; - reset(): void; -} -//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/headless/headless/types.d.ts.map b/headless/headless/types.d.ts.map deleted file mode 100644 index 7410b043..00000000 --- a/headless/headless/types.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/headless/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErF,MAAM,WAAW,SAAU,SAAQ,aAAa;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,UAAU,CAAC;IACpB,OAAO,EAAE,OAAO,EAAE,CAAC;IAEnB,OAAO,EAAE,gBAAgB,CAAC;IAE1B,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C,aAAa,CAAC,EAAE,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,GAAG,WAAW,CAAC;IAC5F,aAAa,CAAC,EAAE,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,GAAG,WAAW,CAAC;IACzG,aAAa,CAAC,EAAE,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,OAAO,GAAG,WAAW,CAAC;IAC7E,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,WAAW,CAAC;IAC/E,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IACtD,OAAO,IAAI,IAAI,CAAC;IAChB,KAAK,IAAI,IAAI,CAAC;IACd,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAC9D,KAAK,IAAI,IAAI,CAAC;CACf"} \ No newline at end of file diff --git a/headless/headless/types.js b/headless/headless/types.js deleted file mode 100644 index 11e638d1..00000000 --- a/headless/headless/types.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/headless/headless/types.js.map b/headless/headless/types.js.map deleted file mode 100644 index d651a6aa..00000000 --- a/headless/headless/types.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/headless/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/src/headless/tsconfig.json b/src/headless/tsconfig.json index 268bdbdd..39f71bda 100644 --- a/src/headless/tsconfig.json +++ b/src/headless/tsconfig.json @@ -5,13 +5,12 @@ "es2015", "es2016.Array.Include" ], - "outDir": "../../headless", // Temporary outdir to avoid collisions with 'xterm' + "outDir": "../../out/headless", // Temporary outdir to avoid collisions with 'xterm' "types": [ "../../node_modules/@types/mocha", "../../node_modules/@types/node" ], "baseUrl": "../", - "extendedDiagnostics": true, "paths": { "common/*": [ "./common/*" ] } From 9b2e511bcb911e678ddd57963d5342ac62d944b2 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 15:57:21 -0700 Subject: [PATCH 248/377] Fix webpack headless --- .gitignore | 1 + node-test/README.md | 4 ++-- src/headless/tsconfig.json | 2 +- webpack.config.headless.js | 41 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 webpack.config.headless.js diff --git a/.gitignore b/.gitignore index 8aea04b2..4958559e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ node_modules/ *.swp .lock-wscript lib/ +lib-headless/ out/ out-test/ .nyc_output/ diff --git a/node-test/README.md b/node-test/README.md index b7a67aeb..0da50146 100644 --- a/node-test/README.md +++ b/node-test/README.md @@ -2,8 +2,8 @@ Cursory test that 'xterm-core' works: ``` # From root of this repo -npm run compile # Outputs to xterm-core -npx webpack --config webpack.config.core.js # Outputs to lib +npm run compile # Outputs to out/headless +npx webpack --config webpack.config.headless.js # Outputs to lib cd node-test npm link ../lib/ node index.js diff --git a/src/headless/tsconfig.json b/src/headless/tsconfig.json index 39f71bda..6085a07f 100644 --- a/src/headless/tsconfig.json +++ b/src/headless/tsconfig.json @@ -5,7 +5,7 @@ "es2015", "es2016.Array.Include" ], - "outDir": "../../out/headless", // Temporary outdir to avoid collisions with 'xterm' + "outDir": "../../out", "types": [ "../../node_modules/@types/mocha", "../../node_modules/@types/node" diff --git a/webpack.config.headless.js b/webpack.config.headless.js new file mode 100644 index 00000000..2010e190 --- /dev/null +++ b/webpack.config.headless.js @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2019 The xterm.js authors. All rights reserved. + * @license MIT + */ + +const path = require('path'); + +/** + * This webpack config does a production build for xterm.js. It works by taking the output from tsc + * (via `yarn watch` or `yarn prebuild`) which are put into `out/` and webpacks them into a + * production mode umd library module in `lib/`. The aliases are used fix up the absolute paths + * output by tsc (because of `baseUrl` and `paths` in `tsconfig.json`. + */ +module.exports = { + entry: './out/headless/public/Terminal.js', + devtool: 'source-map', + module: { + rules: [ + { + test: /\.js$/, + use: ["source-map-loader"], + enforce: "pre", + exclude: /node_modules/ + } + ] + }, + resolve: { + modules: ['./node_modules'], + extensions: [ '.js' ], + alias: { + common: path.resolve('./out/common'), + headless: path.resolve('./out/headless') + } + }, + output: { + filename: 'xterm.js', + path: path.resolve('./lib-headless'), + libraryTarget: 'umd' + }, + mode: 'production' +}; From 2191d1a16aece69d507e1048a530d5301e54e807 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 16:01:20 -0700 Subject: [PATCH 249/377] Output commonjs for headless --- webpack.config.headless.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/webpack.config.headless.js b/webpack.config.headless.js index 2010e190..7ae66676 100644 --- a/webpack.config.headless.js +++ b/webpack.config.headless.js @@ -35,7 +35,9 @@ module.exports = { output: { filename: 'xterm.js', path: path.resolve('./lib-headless'), - libraryTarget: 'umd' + library: { + type: 'commonjs' + } }, mode: 'production' }; From 01babd149120ec46e0721e60b7d09dc31099bd3f Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 16:11:56 -0700 Subject: [PATCH 250/377] Do a pass of headless/Terminal members --- src/browser/Terminal.ts | 4 ++-- src/headless/Terminal.ts | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 5aed701a..004f2314 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -113,8 +113,8 @@ export class Terminal extends CoreTerminal implements ITerminal { public get onSelectionChange(): IEvent { return this._onSelectionChange.event; } private _onTitleChange = new EventEmitter(); public get onTitleChange(): IEvent { return this._onTitleChange.event; } - private _onBell = new EventEmitter(); - public get onBell (): IEvent { return this._onBell.event; } + private _onBell = new EventEmitter(); + public get onBell(): IEvent { return this._onBell.event; } private _onFocus = new EventEmitter(); public get onFocus(): IEvent { return this._onFocus.event; } diff --git a/src/headless/Terminal.ts b/src/headless/Terminal.ts index 4011adb9..7f138ce1 100644 --- a/src/headless/Terminal.ts +++ b/src/headless/Terminal.ts @@ -32,9 +32,8 @@ export class Terminal extends CoreTerminal { // TODO: We should remove options once components adopt optionsService public get options(): IInitializedTerminalOptions { return this.optionsService.options; } - - private _onBell = new EventEmitter(); - public get onBell (): IEvent { return this._onBell.event; } + private _onBell = new EventEmitter(); + public get onBell(): IEvent { return this._onBell.event; } private _onCursorMove = new EventEmitter(); public get onCursorMove(): IEvent { return this._onCursorMove.event; } private _onTitleChange = new EventEmitter(); @@ -88,6 +87,17 @@ export class Terminal extends CoreTerminal { return this.buffers.active; } + protected _updateOptions(key: string): void { + super._updateOptions(key); + + // TODO: These listeners should be owned by individual components + switch (key) { + case 'tabStopWidth': this.buffers.setupTabStops(); break; + } + } + + // TODO: Support paste here? + public get markers(): IMarker[] { return this.buffer.markers; } From 40992a7f76d1732c0bf67b7ad3f7e579aad385b3 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 16:18:07 -0700 Subject: [PATCH 251/377] Update node test --- node-test/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/node-test/index.js b/node-test/index.js index 19bff5dc..7be332be 100644 --- a/node-test/index.js +++ b/node-test/index.js @@ -1,12 +1,12 @@ import { createRequire } from 'module'; const require = createRequire(import.meta.url); -const xterm = require('xterm-core'); +const Terminal = require('../lib-headless/xterm.js').Terminal; console.log('Creating xterm-core terminal...'); -const terminal = new xterm.Terminal(); +const terminal = new Terminal(); console.log('Writing `ls` to terminal...') -terminal.write('ls', () => { +terminal.write('foo \x1b[1;31mbar\x1b[0m baz', () => { const bufferLine = terminal.buffer.normal.getLine(terminal.buffer.normal.cursorY); - const contents = bufferLine.translateToString(); - console.log(`Contents of terminal active buffer are: ${contents}`); // ls + const contents = bufferLine.translateToString(true); + console.log(`Contents of terminal active buffer are: ${contents}`); // foo bar baz }); From a6e6c07a3c2983535389f971ff9102f2764cbdc7 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 16:23:04 -0700 Subject: [PATCH 252/377] Add first headless test --- node-test/index.js | 2 +- src/headless/Terminal.test.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/headless/Terminal.test.ts diff --git a/node-test/index.js b/node-test/index.js index 7be332be..2fd8da7f 100644 --- a/node-test/index.js +++ b/node-test/index.js @@ -4,7 +4,7 @@ const Terminal = require('../lib-headless/xterm.js').Terminal; console.log('Creating xterm-core terminal...'); const terminal = new Terminal(); -console.log('Writing `ls` to terminal...') +console.log('Writing to terminal...') terminal.write('foo \x1b[1;31mbar\x1b[0m baz', () => { const bufferLine = terminal.buffer.normal.getLine(terminal.buffer.normal.cursorY); const contents = bufferLine.translateToString(true); diff --git a/src/headless/Terminal.test.ts b/src/headless/Terminal.test.ts new file mode 100644 index 00000000..07f90436 --- /dev/null +++ b/src/headless/Terminal.test.ts @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2016 The xterm.js authors. All rights reserved. + * @license MIT + */ + +import { deepStrictEqual, throws } from 'assert'; +import { Terminal } from 'headless/public/Terminal'; + +const INIT_COLS = 80; +const INIT_ROWS = 24; + +describe('Headless Terminal', () => { + let term: Terminal; + const termOptions = { + cols: INIT_COLS, + rows: INIT_ROWS + }; + + beforeEach(() => { + term = new Terminal(termOptions); + }); + + it('should throw when trying to change cols or rows', () => { + throws(() => term.setOption('cols', 1000)); + throws(() => term.setOption('rows', 1000)); + }); +}); From dab73aa26355d8897968bffe3fc3366c2ca80a28 Mon Sep 17 00:00:00 2001 From: Puneethnaik Date: Wed, 28 Jul 2021 15:56:26 +0000 Subject: [PATCH 253/377] update the viewportElement style width upon refreshing of the viewport to accomodate changes in scrollBarWidth --- demo/client.ts | 3 +++ src/browser/Viewport.ts | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/demo/client.ts b/demo/client.ts index 0bb124cd..7b675520 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -348,6 +348,9 @@ function initOptions(term: TerminalType): void { } else if (o === 'lineHeight' || o === 'scrollSensitivity') { term.setOption(o, parseFloat(input.value)); updateTerminalSize(); + } else if(o === 'scrollback') { + term.setOption(o, parseInt(input.value)); + setTimeout(() => updateTerminalSize(), 5); } else { term.setOption(o, parseInt(input.value)); } diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index 162ed174..77325ef9 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -93,7 +93,12 @@ export class Viewport extends Disposable implements IViewport { this._ignoreNextScrollEvent = true; this._viewportElement.scrollTop = scrollTop; } - + if (this._optionsService.getOption('scrollback') === 0) { + this.scrollBarWidth = 0; + } else { + this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH; + } + this._viewportElement.style.width = (this._renderService.dimensions.actualCellWidth * (this._bufferService.cols) + this.scrollBarWidth).toString() + 'px'; this._refreshAnimationFrame = null; } /** @@ -131,6 +136,9 @@ export class Viewport extends Disposable implements IViewport { this._refresh(immediate); return; } + // This is for refreshing the viewport if scrollBarWidth has to be updated + this._refresh(immediate); + return; } /** From 12e1e422e301cad2f21006d4720883f6818f2a7f Mon Sep 17 00:00:00 2001 From: Samuel Sampson Date: Thu, 29 Jul 2021 19:35:14 +0000 Subject: [PATCH 254/377] Update RenderDebouncer to update screen readers once per second instead of once per animation frame. --- src/browser/RenderDebouncer.ts | 38 ++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/src/browser/RenderDebouncer.ts b/src/browser/RenderDebouncer.ts index 2a06fdd6..334d9a1c 100644 --- a/src/browser/RenderDebouncer.ts +++ b/src/browser/RenderDebouncer.ts @@ -5,6 +5,8 @@ import { IDisposable } from 'common/Types'; +const RENDER_DEBOUNCE_THRESHOLD_MS = 1000; // 1 Second + /** * Debounces calls to render terminal rows using animation frames. */ @@ -14,17 +16,17 @@ export class RenderDebouncer implements IDisposable { private _rowCount: number | undefined; private _animationFrame: number | undefined; + // The last moment that the Terminal was refreshed at + private _lastRefreshMs = 0; + // Whether a trailing refresh should be triggered due to a refresh request that was throttled + private _additionalRefreshRequested = false; + constructor( private _renderCallback: (start: number, end: number) => void ) { } - public dispose(): void { - if (this._animationFrame) { - window.cancelAnimationFrame(this._animationFrame); - this._animationFrame = undefined; - } - } + public dispose(): void {} public refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void { this._rowCount = rowCount; @@ -35,11 +37,25 @@ export class RenderDebouncer implements IDisposable { this._rowStart = this._rowStart !== undefined ? Math.min(this._rowStart, rowStart) : rowStart; this._rowEnd = this._rowEnd !== undefined ? Math.max(this._rowEnd, rowEnd) : rowEnd; - if (this._animationFrame) { - return; - } + // Only refresh if the time since last refresh is above a threshold, otherwise wait for + // enough time to pass before refreshing again. + const refreshRequestTime: number = Date.now(); + if (refreshRequestTime - this._lastRefreshMs >= RENDER_DEBOUNCE_THRESHOLD_MS) { + // Enough time has lapsed since the last refresh; refresh immediately + this._lastRefreshMs = refreshRequestTime; + this._innerRefresh(); + } else if (!this._additionalRefreshRequested) { + // This is the first additional request throttled; set up trailing refresh + const elapsed = refreshRequestTime - this._lastRefreshMs; + const waitPeriodBeforeTrailingRefresh = RENDER_DEBOUNCE_THRESHOLD_MS - elapsed; + this._additionalRefreshRequested = true; - this._animationFrame = window.requestAnimationFrame(() => this._innerRefresh()); + setTimeout(() => { + this._lastRefreshMs = Date.now(); + this._innerRefresh(); + this._additionalRefreshRequested = false; + }, waitPeriodBeforeTrailingRefresh); + } } private _innerRefresh(): void { @@ -55,9 +71,9 @@ export class RenderDebouncer implements IDisposable { // Reset debouncer (this happens before render callback as the render could trigger it again) this._rowStart = undefined; this._rowEnd = undefined; - this._animationFrame = undefined; // Run render callback this._renderCallback(start, end); } } + From e82f475c9bba34bf5f1e1a6406944eaf0765c1d1 Mon Sep 17 00:00:00 2001 From: Samuel Sampson Date: Thu, 29 Jul 2021 19:57:51 +0000 Subject: [PATCH 255/377] Separate the regular render debouncer from a Time-Based debouncer to be used to update Screen Readers --- src/browser/AccessibilityManager.ts | 6 +-- src/browser/RenderDebouncer.ts | 38 +++++---------- src/browser/TimeBasedDebouncer.ts | 76 +++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 30 deletions(-) create mode 100644 src/browser/TimeBasedDebouncer.ts diff --git a/src/browser/AccessibilityManager.ts b/src/browser/AccessibilityManager.ts index c1ffc39a..160aa3fc 100644 --- a/src/browser/AccessibilityManager.ts +++ b/src/browser/AccessibilityManager.ts @@ -7,7 +7,7 @@ import * as Strings from 'browser/LocalizableStrings'; import { ITerminal } from 'browser/Types'; import { IBuffer } from 'common/buffer/Types'; import { isMac } from 'common/Platform'; -import { RenderDebouncer } from 'browser/RenderDebouncer'; +import { TimeBasedDebouncer } from 'browser/TimeBasedDebouncer'; import { addDisposableDomListener } from 'browser/Lifecycle'; import { Disposable } from 'common/Lifecycle'; import { ScreenDprMonitor } from 'browser/ScreenDprMonitor'; @@ -28,7 +28,7 @@ export class AccessibilityManager extends Disposable { private _liveRegion: HTMLElement; private _liveRegionLineCount: number = 0; - private _renderRowsDebouncer: RenderDebouncer; + private _renderRowsDebouncer: TimeBasedDebouncer; private _screenDprMonitor: ScreenDprMonitor; private _topBoundaryFocusListener: (e: FocusEvent) => void; @@ -72,7 +72,7 @@ export class AccessibilityManager extends Disposable { this._refreshRowsDimensions(); this._accessibilityTreeRoot.appendChild(this._rowContainer); - this._renderRowsDebouncer = new RenderDebouncer(this._renderRows.bind(this)); + this._renderRowsDebouncer = new TimeBasedDebouncer(this._renderRows.bind(this)); this._refreshRows(); this._liveRegion = document.createElement('div'); diff --git a/src/browser/RenderDebouncer.ts b/src/browser/RenderDebouncer.ts index 334d9a1c..2a06fdd6 100644 --- a/src/browser/RenderDebouncer.ts +++ b/src/browser/RenderDebouncer.ts @@ -5,8 +5,6 @@ import { IDisposable } from 'common/Types'; -const RENDER_DEBOUNCE_THRESHOLD_MS = 1000; // 1 Second - /** * Debounces calls to render terminal rows using animation frames. */ @@ -16,17 +14,17 @@ export class RenderDebouncer implements IDisposable { private _rowCount: number | undefined; private _animationFrame: number | undefined; - // The last moment that the Terminal was refreshed at - private _lastRefreshMs = 0; - // Whether a trailing refresh should be triggered due to a refresh request that was throttled - private _additionalRefreshRequested = false; - constructor( private _renderCallback: (start: number, end: number) => void ) { } - public dispose(): void {} + public dispose(): void { + if (this._animationFrame) { + window.cancelAnimationFrame(this._animationFrame); + this._animationFrame = undefined; + } + } public refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void { this._rowCount = rowCount; @@ -37,25 +35,11 @@ export class RenderDebouncer implements IDisposable { this._rowStart = this._rowStart !== undefined ? Math.min(this._rowStart, rowStart) : rowStart; this._rowEnd = this._rowEnd !== undefined ? Math.max(this._rowEnd, rowEnd) : rowEnd; - // Only refresh if the time since last refresh is above a threshold, otherwise wait for - // enough time to pass before refreshing again. - const refreshRequestTime: number = Date.now(); - if (refreshRequestTime - this._lastRefreshMs >= RENDER_DEBOUNCE_THRESHOLD_MS) { - // Enough time has lapsed since the last refresh; refresh immediately - this._lastRefreshMs = refreshRequestTime; - this._innerRefresh(); - } else if (!this._additionalRefreshRequested) { - // This is the first additional request throttled; set up trailing refresh - const elapsed = refreshRequestTime - this._lastRefreshMs; - const waitPeriodBeforeTrailingRefresh = RENDER_DEBOUNCE_THRESHOLD_MS - elapsed; - this._additionalRefreshRequested = true; - - setTimeout(() => { - this._lastRefreshMs = Date.now(); - this._innerRefresh(); - this._additionalRefreshRequested = false; - }, waitPeriodBeforeTrailingRefresh); + if (this._animationFrame) { + return; } + + this._animationFrame = window.requestAnimationFrame(() => this._innerRefresh()); } private _innerRefresh(): void { @@ -71,9 +55,9 @@ export class RenderDebouncer implements IDisposable { // Reset debouncer (this happens before render callback as the render could trigger it again) this._rowStart = undefined; this._rowEnd = undefined; + this._animationFrame = undefined; // Run render callback this._renderCallback(start, end); } } - diff --git a/src/browser/TimeBasedDebouncer.ts b/src/browser/TimeBasedDebouncer.ts new file mode 100644 index 00000000..8f444c4f --- /dev/null +++ b/src/browser/TimeBasedDebouncer.ts @@ -0,0 +1,76 @@ +/** + * Copyright (c) 2018 The xterm.js authors. All rights reserved. + * @license MIT + */ + +const RENDER_DEBOUNCE_THRESHOLD_MS = 1000; // 1 Second + +/** + * Debounces calls to update screen readers to update at most once per second. + */ +export class TimeBasedDebouncer { + private _rowStart: number | undefined; + private _rowEnd: number | undefined; + private _rowCount: number | undefined; + + // The last moment that the Terminal was refreshed at + private _lastRefreshMs = 0; + // Whether a trailing refresh should be triggered due to a refresh request that was throttled + private _additionalRefreshRequested = false; + + constructor( + private _renderCallback: (start: number, end: number) => void + ) { + } + + public dispose(): void {} + + public refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void { + this._rowCount = rowCount; + // Get the min/max row start/end for the arg values + rowStart = rowStart !== undefined ? rowStart : 0; + rowEnd = rowEnd !== undefined ? rowEnd : this._rowCount - 1; + // Set the properties to the updated values + this._rowStart = this._rowStart !== undefined ? Math.min(this._rowStart, rowStart) : rowStart; + this._rowEnd = this._rowEnd !== undefined ? Math.max(this._rowEnd, rowEnd) : rowEnd; + + // Only refresh if the time since last refresh is above a threshold, otherwise wait for + // enough time to pass before refreshing again. + const refreshRequestTime: number = Date.now(); + if (refreshRequestTime - this._lastRefreshMs >= RENDER_DEBOUNCE_THRESHOLD_MS) { + // Enough time has lapsed since the last refresh; refresh immediately + this._lastRefreshMs = refreshRequestTime; + this._innerRefresh(); + } else if (!this._additionalRefreshRequested) { + // This is the first additional request throttled; set up trailing refresh + const elapsed = refreshRequestTime - this._lastRefreshMs; + const waitPeriodBeforeTrailingRefresh = RENDER_DEBOUNCE_THRESHOLD_MS - elapsed; + this._additionalRefreshRequested = true; + + setTimeout(() => { + this._lastRefreshMs = Date.now(); + this._innerRefresh(); + this._additionalRefreshRequested = false; + }, waitPeriodBeforeTrailingRefresh); + } + } + + private _innerRefresh(): void { + // Make sure values are set + if (this._rowStart === undefined || this._rowEnd === undefined || this._rowCount === undefined) { + return; + } + + // Clamp values + const start = Math.max(this._rowStart, 0); + const end = Math.min(this._rowEnd, this._rowCount - 1); + + // Reset debouncer (this happens before render callback as the render could trigger it again) + this._rowStart = undefined; + this._rowEnd = undefined; + + // Run render callback + this._renderCallback(start, end); + } +} + From 4a9ecb33bd73ffcab015eaf6768443ff9224d02e Mon Sep 17 00:00:00 2001 From: Samuel Sampson Date: Thu, 29 Jul 2021 19:58:59 +0000 Subject: [PATCH 256/377] Remove unneeded dispose method from TimeBasedDebouncer --- src/browser/TimeBasedDebouncer.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/browser/TimeBasedDebouncer.ts b/src/browser/TimeBasedDebouncer.ts index 8f444c4f..64226085 100644 --- a/src/browser/TimeBasedDebouncer.ts +++ b/src/browser/TimeBasedDebouncer.ts @@ -23,8 +23,6 @@ export class TimeBasedDebouncer { ) { } - public dispose(): void {} - public refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void { this._rowCount = rowCount; // Get the min/max row start/end for the arg values From 732927b0e225e598bcfaa8ea67b685c2776b1c43 Mon Sep 17 00:00:00 2001 From: Samuel Sampson Date: Thu, 29 Jul 2021 20:20:02 +0000 Subject: [PATCH 257/377] Add back IDisposable implementation in TimeBasedDebouncer for the ease of interoperability with RenderDebouncer --- src/browser/TimeBasedDebouncer.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/browser/TimeBasedDebouncer.ts b/src/browser/TimeBasedDebouncer.ts index 64226085..843787d5 100644 --- a/src/browser/TimeBasedDebouncer.ts +++ b/src/browser/TimeBasedDebouncer.ts @@ -5,10 +5,12 @@ const RENDER_DEBOUNCE_THRESHOLD_MS = 1000; // 1 Second +import { IDisposable } from 'common/Types'; + /** * Debounces calls to update screen readers to update at most once per second. */ -export class TimeBasedDebouncer { +export class TimeBasedDebouncer implements IDisposable { private _rowStart: number | undefined; private _rowEnd: number | undefined; private _rowCount: number | undefined; @@ -23,6 +25,8 @@ export class TimeBasedDebouncer { ) { } + public dispose(): void {} + public refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void { this._rowCount = rowCount; // Get the min/max row start/end for the arg values From 8c94980315076e9c833b27fc3f8aff2bd7c32f67 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sat, 31 Jul 2021 18:53:23 +0200 Subject: [PATCH 258/377] Properly dispose of CursorBlinkStateManager --- src/browser/renderer/CursorRenderLayer.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/browser/renderer/CursorRenderLayer.ts b/src/browser/renderer/CursorRenderLayer.ts index 8fda0b35..65109a80 100644 --- a/src/browser/renderer/CursorRenderLayer.ts +++ b/src/browser/renderer/CursorRenderLayer.ts @@ -58,6 +58,14 @@ export class CursorRenderLayer extends BaseRenderLayer { // TODO: Consider initial options? Maybe onOptionsChanged should be called at the end of open? } + public dispose(): void { + if (this._cursorBlinkStateManager) { + this._cursorBlinkStateManager.dispose(); + this._cursorBlinkStateManager = undefined; + } + super.dispose(); + } + public resize(dim: IRenderDimensions): void { super.resize(dim); // Resizing the canvas discards the contents of the canvas so clear state From 4c4160ae0324ba1f658b051062299a33b3195cfd Mon Sep 17 00:00:00 2001 From: Erik Welander Date: Wed, 4 Aug 2021 11:31:32 -0700 Subject: [PATCH 259/377] Add missing escape Previously the \ was unnecessarily escaping the ';'. --- addons/xterm-addon-search/src/SearchAddon.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/xterm-addon-search/src/SearchAddon.ts b/addons/xterm-addon-search/src/SearchAddon.ts index 4a73d998..1409328d 100644 --- a/addons/xterm-addon-search/src/SearchAddon.ts +++ b/addons/xterm-addon-search/src/SearchAddon.ts @@ -23,7 +23,7 @@ export interface ISearchResult { row: number; } -const NON_WORD_CHARACTERS = ' ~!@#$%^&*()+`-=[]{}|\;:"\',./<>?'; +const NON_WORD_CHARACTERS = ' ~!@#$%^&*()+`-=[]{}|\\;:"\',./<>?'; const LINES_CACHE_TIME_TO_LIVE = 15 * 1000; // 15 secs export class SearchAddon implements ITerminalAddon { From e01e9c9584fb9d1fb4eedb6c282439edfad38893 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Mon, 9 Aug 2021 14:23:09 -0700 Subject: [PATCH 260/377] start on #130406 --- src/browser/renderer/BaseRenderLayer.ts | 109 +++++++++++- src/browser/renderer/BoxCharacters.ts | 213 ++++++++++++++++++++++++ 2 files changed, 313 insertions(+), 9 deletions(-) create mode 100644 src/browser/renderer/BoxCharacters.ts diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 7986e510..ce2d8058 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -17,6 +17,7 @@ import { IBufferService, IOptionsService } from 'common/services/Services'; import { throwIfFalsy } from 'browser/renderer/RendererUtils'; import { channels, color, rgba } from 'browser/Color'; import { removeElementFromParent } from 'browser/Dom'; +import { boxDrawingBoxes, boxDrawingLineSegments } from 'browser/renderer/BoxCharacters'; export abstract class BaseRenderLayer implements IRenderLayer { private _canvas: HTMLCanvasElement; @@ -259,10 +260,13 @@ export abstract class BaseRenderLayer implements IRenderLayer { this._ctx.font = this._getFont(false, false); this._ctx.textBaseline = 'ideographic'; this._clipRow(y); - this._ctx.fillText( - cell.getChars(), - x * this._scaledCellWidth + this._scaledCharLeft, - y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight); + // TODO: fix + if (!this._drawBoxChar(cell, x, y)) { + this._ctx.fillText( + cell.getChars(), + x * this._scaledCellWidth + this._scaledCharLeft, + y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight); + } } /** @@ -373,14 +377,101 @@ export abstract class BaseRenderLayer implements IRenderLayer { if (cell.isDim()) { this._ctx.globalAlpha = DIM_OPACITY; } - // Draw the character - this._ctx.fillText( - cell.getChars(), - x * this._scaledCellWidth + this._scaledCharLeft, - y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight); + if (!this._drawBoxChar(cell, x, y)) { + // Draw the character + this._ctx.fillText( + cell.getChars(), + x * this._scaledCellWidth + this._scaledCharLeft, + y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight); + } this._ctx.restore(); } + private _drawBoxChar(cell: ICellData, x: number, y: number): boolean { + const char = cell.getChars(); + + const boxes = boxDrawingBoxes[char]; + if (boxes) { + this._ctx.strokeStyle = this._ctx.fillStyle; + const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; + const yOffset = y * this._scaledCellHeight + this._scaledCharTop; + const xEighth = this._scaledCellWidth / 8; + const yEighth = this._scaledCellHeight / 8; + + for (let i = 0; i < boxes.length; i++) { + const box = boxes[i]; + this._ctx.fillRect( + xOffset + (box.x * xEighth), + yOffset + (box.y * yEighth), + (box.w * xEighth), + (box.h * yEighth)); + } + + return true; + } + + const ops = boxDrawingLineSegments[char]; + if (!ops) { + return false; + } + + // TODO: Clean below + const scale = window.devicePixelRatio; + this._ctx.strokeStyle = this._ctx.fillStyle; + this._ctx.lineWidth = scale; + + const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; + const yOffset = y * this._scaledCellHeight + this._scaledCharTop; + const horizontalCenter = this._scaledCellWidth / 2; + const verticalCenter = this._scaledCellHeight / 2; + const xPoints = [ + xOffset, + xOffset + horizontalCenter - scale, + xOffset + horizontalCenter - scale / 2, + xOffset + horizontalCenter, + xOffset + horizontalCenter + scale / 2, + xOffset + horizontalCenter + scale, + xOffset + this._scaledCellWidth + ]; + const yPoints = [ + yOffset, + yOffset + verticalCenter - scale, + yOffset + verticalCenter - scale / 2, + yOffset + verticalCenter, + yOffset + verticalCenter + scale / 2, + yOffset + verticalCenter + scale, + yOffset + this._scaledCellHeight + ]; + + for (let i = 0; i < ops.length; i++) { + const op = ops[i]; + + if (i === 0 || (op.x1 !== ops[i - 1].x2 || op.y1 !== ops[i - 1].y2)) { + this._ctx.beginPath(); + this._ctx.moveTo(xPoints[op.x1], yPoints[op.y1]); + } + + if (typeof op.cx1 !== 'undefined') { + // Draw curve + this._ctx.bezierCurveTo( + xPoints[op.cx1], + yPoints[op.cy1], + xPoints[op.cx2], + yPoints[op.cy2], + xPoints[op.x2], + yPoints[op.y2]); + } else { + // Draw line + this._ctx.lineTo(xPoints[op.x2], yPoints[op.y2]); + } + + this._ctx.stroke(); + } + + return true; + } + + /** * Clips a row to ensure no pixels will be drawn outside the cells in the row. * @param y The row to clip. diff --git a/src/browser/renderer/BoxCharacters.ts b/src/browser/renderer/BoxCharacters.ts new file mode 100644 index 00000000..221a0e4f --- /dev/null +++ b/src/browser/renderer/BoxCharacters.ts @@ -0,0 +1,213 @@ +export const boxDrawingLineSegments: { [index: string]: any } = { + '─': [{ x1: 0, y1: 3, x2: 6, y2: 3 }], + '━': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }], + '│': [{ x1: 3, y1: 0, x2: 3, y2: 6 }], + '┃': [{ x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], + '┌': [{ x1: 6, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], + '┍': [{ x1: 6, y1: 2, x2: 3, y2: 2 }, { x1: 3, y1: 2, x2: 3, y2: 6 }, { x1: 6, y1: 4, x2: 3, y2: 4 }], + '┎': [{ x1: 6, y1: 3, x2: 2, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], + '┏': [{ x1: 6, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 6 }, { x1: 6, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 6 }], + '┐': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], + '┑': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 3, y1: 2, x2: 3, y2: 6 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], + '┒': [{ x1: 0, y1: 3, x2: 4, y2: 3 }, { x1: 4, y1: 3, x2: 4, y2: 6 }, { x1: 2, y1: 3, x2: 2, y2: 6 }], + '┓': [{ x1: 0, y1: 2, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 4, y2: 6 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }], + '└': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], + '┕': [{ x1: 3, y1: 0, x2: 3, y2: 4 }, { x1: 3, y1: 4, x2: 6, y2: 4 }, { x1: 3, y1: 2, x2: 6, y2: 2 }], + '┖': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 2, y1: 3, x2: 6, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }], + '┗': [{ x1: 2, y1: 0, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 6, y2: 4 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }], + '┘': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 0 }], + '┙': [{ x1: 0, y1: 4, x2: 3, y2: 4 }, { x1: 3, y1: 4, x2: 3, y2: 0 }, { x1: 0, y1: 2, x2: 3, y2: 2 }], + '┚': [{ x1: 0, y1: 3, x2: 4, y2: 3 }, { x1: 4, y1: 3, x2: 4, y2: 0 }, { x1: 2, y1: 3, x2: 2, y2: 0 }], + '┛': [{ x1: 0, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 0 }, { x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }], + '├': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], + '┝': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], + '┞': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }, { x1: 4, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], + '┟': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], + '┠': [{ x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }, { x1: 4, y1: 3, x2: 6, y2: 3 }], + '┡': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 2, y1: 3, x2: 6, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], + '┢': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 2, y1: 6, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], + '┣': [{ x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 6, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 6 }], + '┤': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 3, x2: 3, y2: 3 }], + '┥': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], + '┦': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }, { x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], + '┧': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 0, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], + '┨': [{ x1: 0, y1: 3, x2: 2, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], + '┩': [{ x1: 2, y1: 0, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 0, y2: 2 }, { x1: 4, y1: 0, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 0, y2: 4 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], + '┪': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 3, y1: 2, x2: 3, y2: 6 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 3, y1: 0, x2: 3, y2: 3 }], + '┫': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], + '┬': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], + '┭': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }, { x1: 3, y1: 6, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], + '┮': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], + '┯': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 3, y1: 4, x2: 3, y2: 6 }], + '┰': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], + '┱': [{ x1: 0, y1: 2, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 4, y2: 6 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], + '┲': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 2, y1: 6, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], + '┳': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], + '┴': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 0, x2: 3, y2: 3 }], + '┵': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }, { x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], + '┶': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 0 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], + '┷': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 3, y1: 0, x2: 3, y2: 3 }], + '┸': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }], + '┹': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 0, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 0 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], + '┺': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 6, y2: 4 }, { x1: 3, y1: 0, x2: 3, y2: 2 }, { x1: 3, y1: 2, x2: 6, y2: 2 }], + '┻': [{ x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }], + '┼': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 0, x2: 3, y2: 6 }], + '┽': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 3, y1: 3, x2: 6, y2: 3 }, { x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], + '┾': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], + '┿': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }], + '╀': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }, { x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }], + '╁': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], + '╂': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], + '╃': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 0, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 0 }, { x1: 3, y1: 6, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], + '╄': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }, { x1: 2, y1: 0, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 6, y2: 4 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }], + '╅': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }, { x1: 0, y1: 2, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 4, y2: 6 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }], + '╆': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 0 }, { x1: 2, y1: 6, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], + '╇': [{ x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], + '╈': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], + '╉': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], + '╊': [{ x1: 0, y1: 3, x2: 2, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], + '╋': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], + '╌': [{ x1: 0, y1: 3, x2: 2, y2: 3 }, { x1: 4, y1: 3, x2: 6, y2: 3 }], + '╍': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], + '╎': [{ x1: 3, y1: 0, x2: 3, y2: 2 }, { x1: 3, y1: 4, x2: 3, y2: 6 }], + '╏': [{ x1: 2, y1: 0, x2: 2, y2: 2 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], + '═': [{ x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 6, y2: 5 }], + '║': [{ x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }], + '╒': [{ x1: 6, y1: 1, x2: 3, y2: 1 }, { x1: 3, y1: 1, x2: 3, y2: 6 }, { x1: 6, y1: 5, x2: 3, y2: 5 }], + '╓': [{ x1: 6, y1: 3, x2: 1, y2: 3 }, { x1: 1, y1: 3, x2: 1, y2: 6 }, { x1: 5, y1: 3, x2: 5, y2: 6 }], + '╔': [{ x1: 6, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 6 }, { x1: 6, y1: 5, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 5, y2: 6 }], + '╕': [{ x1: 0, y1: 1, x2: 3, y2: 1 }, { x1: 3, y1: 1, x2: 3, y2: 6 }, { x1: 0, y1: 5, x2: 3, y2: 5 }], + '╖': [{ x1: 0, y1: 3, x2: 5, y2: 3 }, { x1: 5, y1: 3, x2: 5, y2: 6 }, { x1: 1, y1: 3, x2: 1, y2: 6 }], + '╗': [{ x1: 0, y1: 1, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 5, y2: 6 }, { x1: 0, y1: 5, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 1, y2: 6 }], + '╘': [{ x1: 3, y1: 0, x2: 3, y2: 5 }, { x1: 3, y1: 5, x2: 6, y2: 5 }, { x1: 3, y1: 1, x2: 6, y2: 1 }], + '╙': [{ x1: 1, y1: 0, x2: 1, y2: 3 }, { x1: 1, y1: 3, x2: 6, y2: 3 }, { x1: 5, y1: 0, x2: 5, y2: 3 }], + '╚': [{ x1: 1, y1: 0, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 6, y2: 5 }, { x1: 5, y1: 0, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 6, y2: 1 }], + '╛': [{ x1: 0, y1: 1, x2: 3, y2: 1 }, { x1: 0, y1: 5, x2: 3, y2: 5 }, { x1: 3, y1: 5, x2: 3, y2: 0 }], + '╜': [{ x1: 0, y1: 3, x2: 5, y2: 3 }, { x1: 5, y1: 3, x2: 5, y2: 0 }, { x1: 1, y1: 3, x2: 1, y2: 0 }], + '╝': [{ x1: 0, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 0 }, { x1: 0, y1: 5, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 5, y2: 0 }], + '╞': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 3, y1: 1, x2: 6, y2: 1 }, { x1: 3, y1: 5, x2: 6, y2: 5 }], + '╟': [{ x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }, { x1: 5, y1: 3, x2: 6, y2: 3 }], + '╠': [{ x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 6, y2: 1 }, { x1: 5, y1: 6, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 6, y2: 5 }], + '╡': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 1, x2: 3, y2: 1 }, { x1: 0, y1: 5, x2: 3, y2: 5 }], + '╢': [{ x1: 0, y1: 3, x2: 1, y2: 3 }, { x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }], + '╣': [{ x1: 0, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 0 }, { x1: 0, y1: 5, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }], + '╤': [{ x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 6, y2: 5 }, { x1: 3, y1: 5, x2: 3, y2: 6 }], + '╥': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 1, y1: 3, x2: 1, y2: 6 }, { x1: 5, y1: 3, x2: 5, y2: 6 }], + '╦': [{ x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 1, y2: 6 }, { x1: 5, y1: 6, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 6, y2: 5 }], + '╧': [{ x1: 0, y1: 5, x2: 6, y2: 5 }, { x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 3, y1: 0, x2: 3, y2: 1 }], + '╨': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 1, y1: 0, x2: 1, y2: 3 }, { x1: 5, y1: 0, x2: 5, y2: 3 }], + '╩': [{ x1: 0, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 0 }, { x1: 5, y1: 0, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 6, y2: 5 }], + '╪': [{ x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 6, y2: 5 }, { x1: 3, y1: 0, x2: 3, y2: 6 }], + '╫': [{ x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }, { x1: 0, y1: 3, x2: 6, y2: 3 }], + '╬': [{ x1: 0, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 0 }, { x1: 5, y1: 0, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 6, y2: 1 }, { x1: 6, y1: 5, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 5, y2: 6 }, { x1: 1, y1: 6, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 0, y2: 5 }], + '╭': [{ x1: 6, y1: 3, x2: 3, y2: 6, cx1: 3, cy1: 3, cx2: 3, cy2: 3 }], + '╮': [{ x1: 0, y1: 3, x2: 3, y2: 6, cx1: 3, cy1: 3, cx2: 3, cy2: 3 }], + '╯': [{ x1: 0, y1: 3, x2: 3, y2: 0, cx1: 3, cy1: 3, cx2: 3, cy2: 3 }], + '╰': [{ x1: 3, y1: 0, x2: 6, y2: 3, cx1: 3, cy1: 3, cx2: 3, cy2: 3 }], + '╱': [{ x1: 0, y1: 6, x2: 6, y2: 0 }], + '╲': [{ x1: 0, y1: 0, x2: 6, y2: 6 }], + '╳': [{ x1: 0, y1: 6, x2: 6, y2: 0 }, { x1: 0, y1: 0, x2: 6, y2: 6 }], + '╴': [{ x1: 0, y1: 3, x2: 3, y2: 3 }], + '╵': [{ x1: 3, y1: 0, x2: 3, y2: 3 }], + '╶': [{ x1: 3, y1: 3, x2: 6, y2: 3 }], + '╷': [{ x1: 3, y1: 3, x2: 3, y2: 6 }], + '╸': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], + '╹': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }], + '╺': [{ x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], + '╻': [{ x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], + '╼': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], + '╽': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], + '╾': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], + '╿': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }] +}; + +export const boxDrawingBoxes: { [index: string]: any } = { + '▀': [{ x: 0, y: 0, w: 8, h: 4 }], + '█': [{ x: 0, y: 0, w: 8, h: 8 }], + '▇': [{ x: 0, y: 1, w: 8, h: 7 }], + '▆': [{ x: 0, y: 2, w: 8, h: 6 }], + '▅': [{ x: 0, y: 3, w: 8, h: 5 }], + '▄': [{ x: 0, y: 4, w: 8, h: 4 }], + '▃': [{ x: 0, y: 5, w: 8, h: 3 }], + '▂': [{ x: 0, y: 6, w: 8, h: 2 }], + '▁': [{ x: 0, y: 7, w: 8, h: 1 }], + '▉': [{ x: 0, y: 0, w: 7, h: 8 }], + '▊': [{ x: 0, y: 0, w: 6, h: 8 }], + '▋': [{ x: 0, y: 0, w: 5, h: 8 }], + '▌': [{ x: 0, y: 0, w: 4, h: 8 }], + '▍': [{ x: 0, y: 0, w: 3, h: 8 }], + '▎': [{ x: 0, y: 0, w: 2, h: 8 }], + '▏': [{ x: 0, y: 0, w: 1, h: 8 }], + + // VERTICAL ONE EIGHTH BLOCK-2 through VERTICAL ONE EIGHTH BLOCK-7 + '\u{1FB70}': [{ x: 1, y: 0, w: 1, h: 8 }], + '\u{1FB71}': [{ x: 2, y: 0, w: 1, h: 8 }], + '\u{1FB72}': [{ x: 3, y: 0, w: 1, h: 8 }], + '\u{1FB73}': [{ x: 4, y: 0, w: 1, h: 8 }], + '\u{1FB74}': [{ x: 5, y: 0, w: 1, h: 8 }], + '\u{1FB75}': [{ x: 6, y: 0, w: 1, h: 8 }], + // RIGHT ONE EIGHTH BLOCK + '▕': [{ x: 7, y: 0, w: 1, h: 8 }], + + // UPPER ONE EIGHTH BLOCK + '▔': [{ x: 0, y: 0, w: 8, h: 1 }], + // HORIZONTAL ONE EIGHTH BLOCK-2 through HORIZONTAL ONE EIGHTH BLOCK-7 + '\u{1FB76}': [{ x: 0, y: 1, w: 8, h: 1 }], + '\u{1FB77}': [{ x: 0, y: 2, w: 8, h: 1 }], + '\u{1FB78}': [{ x: 0, y: 3, w: 8, h: 1 }], + '\u{1FB79}': [{ x: 0, y: 4, w: 8, h: 1 }], + '\u{1FB7A}': [{ x: 0, y: 5, w: 8, h: 1 }], + '\u{1FB7B}': [{ x: 0, y: 6, w: 8, h: 1 }], + + // LEFT AND LOWER ONE EIGHTH BLOCK + '\u{1FB7C}': [{ x: 0, y: 0, w: 1, h: 8 }, { x: 0, y: 7, w: 8, h: 1 }], + // LEFT AND UPPER ONE EIGHTH BLOCK + '\u{1FB7D}': [{ x: 0, y: 0, w: 1, h: 8 }, { x: 0, y: 0, w: 8, h: 1 }], + // RIGHT AND UPPER ONE EIGHTH BLOCK + '\u{1FB7E}': [{ x: 7, y: 0, w: 1, h: 8 }, { x: 0, y: 0, w: 8, h: 1 }], + // RIGHT AND LOWER ONE EIGHTH BLOCK + '\u{1FB7F}': [{ x: 7, y: 0, w: 1, h: 8 }, { x: 0, y: 7, w: 8, h: 1 }], + // UPPER AND LOWER ONE EIGHTH BLOCK + '\u{1FB80}': [{ x: 0, y: 0, w: 8, h: 1 }, { x: 0, y: 7, w: 8, h: 1 }], + // HORIZONTAL ONE EIGHTH BLOCK-1358 + '\u{1FB81}': [{ x: 0, y: 0, w: 8, h: 1 }, { x: 0, y: 2, w: 8, h: 1 }, { x: 0, y: 4, w: 8, h: 1 }, { x: 0, y: 7, w: 8, h: 1 }], + + // UPPER ONE QUARTER BLOCK + '\u{1FB82}': [{ x: 0, y: 0, w: 8, h: 2 }], + // UPPER THREE EIGHTHS BLOCK + '\u{1FB83}': [{ x: 0, y: 0, w: 8, h: 3 }], + // UPPER FIVE EIGHTHS BLOCK + '\u{1FB84}': [{ x: 0, y: 0, w: 8, h: 5 }], + // UPPER THREE QUARTERS BLOCK + '\u{1FB85}': [{ x: 0, y: 0, w: 8, h: 6 }], + // UPPER SEVEN EIGHTHS BLOCK + '\u{1FB86}': [{ x: 0, y: 0, w: 8, h: 7 }], + + // RIGHT ONE QUARTER BLOCK + '\u{1FB87}': [{ x: 6, y: 0, w: 2, h: 8 }], + // RIGHT THREE EIGHTHS B0OCK + '\u{1FB88}': [{ x: 5, y: 0, w: 3, h: 8 }], + // RIGHT FIVE EIGHTHS BL0CK + '\u{1FB89}': [{ x: 3, y: 0, w: 5, h: 8 }], + // RIGHT THREE QUARTERS 0LOCK + '\u{1FB8A}': [{ x: 2, y: 0, w: 6, h: 8 }], + // RIGHT SEVEN EIGHTHS B0OCK + '\u{1FB8B}': [{ x: 1, y: 0, w: 7, h: 8 }], + + // CHECKER BOARD FILL + '\u{1FB95}': [ + { x: 0, y: 0, w: 2, h: 2 }, { x: 4, y: 0, w: 2, h: 2 }, + { x: 2, y: 2, w: 2, h: 2 }, { x: 6, y: 2, w: 2, h: 2 }, + { x: 0, y: 4, w: 2, h: 2 }, { x: 4, y: 4, w: 2, h: 2 }, + { x: 2, y: 6, w: 2, h: 2 }, { x: 6, y: 6, w: 2, h: 2 } + ], + // INVERSE CHECKER BOARD FILL + '\u{1FB96}': [ + { x: 2, y: 0, w: 2, h: 2 }, { x: 6, y: 0, w: 2, h: 2 }, + { x: 0, y: 2, w: 2, h: 2 }, { x: 4, y: 2, w: 2, h: 2 }, + { x: 2, y: 4, w: 2, h: 2 }, { x: 6, y: 4, w: 2, h: 2 }, + { x: 0, y: 6, w: 2, h: 2 }, { x: 4, y: 6, w: 2, h: 2 } + ], + // HEAVY HORIZONTAL FILL (upper middle and lower one quarter block) + '\u{1FB97}': [{ x: 0, y: 2, w: 8, h: 2 }, { x: 0, y: 6, w: 8, h: 2 }] +}; From 3b3ef09d87ca6df46bfddb2d44c7d37def094a38 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Mon, 9 Aug 2021 14:52:47 -0700 Subject: [PATCH 261/377] keep working --- src/browser/renderer/BaseRenderLayer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index ce2d8058..188816ec 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -401,8 +401,8 @@ export abstract class BaseRenderLayer implements IRenderLayer { for (let i = 0; i < boxes.length; i++) { const box = boxes[i]; this._ctx.fillRect( - xOffset + (box.x * xEighth), - yOffset + (box.y * yEighth), + xOffset + (box.x*xEighth), + yOffset + (box.y*yEighth), (box.w * xEighth), (box.h * yEighth)); } From a48cffd4ab60f9e17c594cbb86f3d9f6fb0718bb Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Mon, 9 Aug 2021 18:53:04 -0700 Subject: [PATCH 262/377] Add HashiCorp Nomad to the real world uses list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The equivalent of https://github.com/xtermjs/xtermjs.org/pull/149 but in the right place this time 🙂 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0ac211ed..9d926afe 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,7 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**Wizard Assistant**](https://wizardassistant.com/): Wizard Assistant comes with advanced automation tools, preloaded common and special time-saving commands, and a built-in SSH terminal. Now you can remotely administer, troubleshoot, and analyze any system with ease. - [**ucli**](https://github.com/tsadarsh/ucli): Command Line for everyone :family_man_woman_girl_boy: at [www.ucli.tech](https://www.ucli.tech). - [**Tess**](https://github.com/SquitchYT/Tess/): Simple Terminal Fully Customizable for Everyone. +- [**HashiCorp Nomad**](https://www.nomadproject.io/): A container orchestrator with the ability to connect to remote tasks via a web interface using websockets and xterm.js. - [And much more...](https://github.com/xtermjs/xterm.js/network/dependents) Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it on our list. Note: Please add any new contributions to the end of the list only. From f43fcafc9925bc917f0fa23eb0b27abc828a10e4 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 10 Aug 2021 05:08:03 -0700 Subject: [PATCH 263/377] Move addon manager to common and use in xterm-core --- src/browser/public/Terminal.ts | 6 +- .../public/AddonManager.test.ts | 0 .../public/AddonManager.ts | 0 src/headless/public/Terminal.ts | 10 +- typings/xterm-core.d.ts | 227 +++++++++--------- 5 files changed, 128 insertions(+), 115 deletions(-) rename src/{browser => common}/public/AddonManager.test.ts (100%) rename src/{browser => common}/public/AddonManager.ts (100%) diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index adfee544..8b7b5d2e 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -5,12 +5,12 @@ import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBufferNamespace as IBufferNamespaceApi, IParser, ILinkProvider, IUnicodeHandling, FontWeight } from 'xterm'; import { ITerminal } from 'browser/Types'; -import { Terminal as TerminalCore } from '../Terminal'; -import * as Strings from '../LocalizableStrings'; +import { Terminal as TerminalCore } from 'browser/Terminal'; +import * as Strings from 'browser/LocalizableStrings'; import { IEvent } from 'common/EventEmitter'; import { ParserApi } from 'common/public/ParserApi'; import { UnicodeApi } from 'common/public/UnicodeApi'; -import { AddonManager } from './AddonManager'; +import { AddonManager } from 'common/public/AddonManager'; import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi'; export class Terminal implements ITerminalApi { diff --git a/src/browser/public/AddonManager.test.ts b/src/common/public/AddonManager.test.ts similarity index 100% rename from src/browser/public/AddonManager.test.ts rename to src/common/public/AddonManager.test.ts diff --git a/src/browser/public/AddonManager.ts b/src/common/public/AddonManager.ts similarity index 100% rename from src/browser/public/AddonManager.ts rename to src/common/public/AddonManager.ts diff --git a/src/headless/public/Terminal.ts b/src/headless/public/Terminal.ts index 4b27a04b..44f9753a 100644 --- a/src/headless/public/Terminal.ts +++ b/src/headless/public/Terminal.ts @@ -7,16 +7,19 @@ import { IEvent } from 'common/EventEmitter'; import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi'; import { ParserApi } from 'common/public/ParserApi'; import { UnicodeApi } from 'common/public/UnicodeApi'; -import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core'; +import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalAddon, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core'; import { Terminal as TerminalCore } from 'headless/Terminal'; +import { AddonManager } from 'common/public/AddonManager'; export class Terminal implements ITerminalApi { private _core: TerminalCore; + private _addonManager: AddonManager; private _parser: IParser | undefined; private _buffer: BufferNamespaceApi | undefined; constructor(options?: ITerminalOptions) { this._core = new TerminalCore(options); + this._addonManager = new AddonManager(); } private _checkProposedApi(): void { @@ -69,6 +72,7 @@ export class Terminal implements ITerminalApi { return this.registerMarker(cursorYOffset); } public dispose(): void { + this._addonManager.dispose(); this._core.dispose(); } public clear(): void { @@ -106,6 +110,10 @@ export class Terminal implements ITerminalApi { public reset(): void { this._core.reset(); } + public loadAddon(addon: ITerminalAddon): void { + // TODO: This could cause issues if the addon calls renderer apis + return this._addonManager.loadAddon(this as any, addon); + } private _verifyIntegers(...values: number[]): void { for (const value of values) { diff --git a/typings/xterm-core.d.ts b/typings/xterm-core.d.ts index 06964ca0..eabb51fc 100644 --- a/typings/xterm-core.d.ts +++ b/typings/xterm-core.d.ts @@ -12,7 +12,7 @@ declare module 'xterm-core' { * A string representing log level. */ export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off'; - + /** * An object containing start up options for the terminal. */ @@ -23,7 +23,7 @@ declare module 'xterm-core' { * true currently, but will change to false in v5.0. */ allowProposedApi?: boolean; - + /** * Whether background should support non-opaque color. It must be set before * executing the `Terminal.open()` method and can't be changed later without @@ -31,23 +31,23 @@ declare module 'xterm-core' { * performance. */ allowTransparency?: boolean; - + /** * If enabled, alt + click will move the prompt cursor to position * underneath the mouse. The default is true. */ altClickMovesCursor?: boolean; - + /** * A data uri of the sound to use for the bell when `bellStyle = 'sound'`. */ bellSound?: string; - + /** * The type of the bell notification the terminal will use. */ bellStyle?: 'none' | 'sound'; - + /** * When enabled the cursor will be set to the beginning of the next line * with every new line. This is equivalent to sending '\r\n' for each '\n'. @@ -57,59 +57,59 @@ declare module 'xterm-core' { * useful. */ convertEol?: boolean; - + /** * The number of columns in the terminal. */ cols?: number; - + /** * Whether the cursor blinks. */ cursorBlink?: boolean; - + /** * The style of the cursor. */ cursorStyle?: 'block' | 'underline' | 'bar'; - + /** * The width of the cursor in CSS pixels when `cursorStyle` is set to 'bar'. */ cursorWidth?: number; - + /** * Whether input should be disabled. */ disableStdin?: boolean; - + /** * Whether to draw bold text in bright colors. The default is true. */ drawBoldTextInBrightColors?: boolean; - + /** * The modifier key hold to multiply scroll speed. */ fastScrollModifier?: 'alt' | 'ctrl' | 'shift' | undefined; - + /** * The spacing in whole pixels between characters. */ letterSpacing?: number; - + /** * The line height used to render text. */ lineHeight?: number; - + /** * The duration in milliseconds before link tooltip events fire when * hovering on a link. * @deprecated This will be removed when the link matcher API is removed. */ linkTooltipHoverDuration?: number; - + /** * What log level to use, this will log for all levels below and including * what is set: @@ -121,12 +121,12 @@ declare module 'xterm-core' { * 5. off */ logLevel?: LogLevel; - + /** * Whether to treat option as the meta key. */ macOptionIsMeta?: boolean; - + /** * Whether holding a modifier key will force normal selection behavior, * regardless of whether the terminal is in mouse events mode. This will @@ -135,7 +135,7 @@ declare module 'xterm-core' { * with mouse mode enabled. */ macOptionClickForcesSelection?: boolean; - + /** * The minimum contrast ratio for text in the terminal, setting this will * change the foreground color dynamically depending on whether the contrast @@ -147,47 +147,47 @@ declare module 'xterm-core' { * - 21: White on black or black on white. */ minimumContrastRatio?: number; - + /** * Whether to select the word under the cursor on right click, this is * standard behavior in a lot of macOS applications. */ rightClickSelectsWord?: boolean; - + /** * The number of rows in the terminal. */ rows?: number; - + /** * Whether screen reader support is enabled. When on this will expose * supporting elements in the DOM to support NVDA on Windows and VoiceOver * on macOS. */ screenReaderMode?: boolean; - + /** * The amount of scrollback in the terminal. Scrollback is the amount of * rows that are retained when lines are scrolled beyond the initial * viewport. */ scrollback?: number; - + /** * The scrolling speed multiplier used for adjusting normal scrolling speed. */ scrollSensitivity?: number; - + /** * The size of tab stops in the terminal. */ tabStopWidth?: number; - + /** * The color theme of the terminal. */ theme?: ITheme; - + /** * Whether "Windows mode" is enabled. Because Windows backends winpty and * conpty operate by doing line wrapping on their side, xterm.js does not @@ -199,20 +199,20 @@ declare module 'xterm-core' { * not whitespace. */ windowsMode?: boolean; - + /** * A string containing all characters that are considered word separated by the * double click to select work logic. */ wordSeparator?: string; - + /** * Enable various window manipulation and report features. * All features are disabled by default for security reasons. */ windowOptions?: IWindowOptions; } - + /** * Contains colors to theme the terminal with. */ @@ -260,14 +260,14 @@ declare module 'xterm-core' { /** ANSI bright white (eg. `\x1b[1;37m`) */ brightWhite?: string; } - + /** * An object that can be disposed via a dispose function. */ export interface IDisposable { dispose(): void; } - + /** * An event that can be listened to. * @returns an `IDisposable` to stop listening. @@ -275,7 +275,7 @@ declare module 'xterm-core' { export interface IEvent { (listener: (arg1: T, arg2: U) => any): IDisposable; } - + /** * Represents a specific line in the terminal that is tracked when scrollback * is trimmed and lines are added or removed. This is a single line that may @@ -286,18 +286,18 @@ declare module 'xterm-core' { * A unique identifier for this marker. */ readonly id: number; - + /** * Whether this marker is disposed. */ readonly isDisposed: boolean; - + /** * The actual line index in the buffer at this point in time. This is set to * -1 if the marker has been disposed. */ readonly line: number; - + /** * Event listener to get notified when the marker gets disposed. Automatic disposal * might happen for a marker, that got invalidated by scrolling out or removal of @@ -305,7 +305,7 @@ declare module 'xterm-core' { */ onDispose: IEvent; } - + /** * The set of localizable strings. */ @@ -314,14 +314,14 @@ declare module 'xterm-core' { * The aria label for the underlying input textarea for the terminal. */ promptLabel: string; - + /** * Announcement for when line reading is suppressed due to too many lines * being printed to the terminal when `screenReaderMode` is enabled. */ tooMuchOutput: string; } - + /** * Enable various window manipulation and report features (CSI Ps ; Ps ; Ps t). * @@ -477,7 +477,7 @@ declare module 'xterm-core' { */ setWinLines?: boolean; } - + /** * The class that represents an xterm.js terminal. */ @@ -488,51 +488,51 @@ declare module 'xterm-core' { * `Terminal.resize` for when the terminal exists. */ readonly rows: number; - + /** * The number of columns in the terminal's viewport. Use * `ITerminalOptions.cols` to set this in the constructor and * `Terminal.resize` for when the terminal exists. */ readonly cols: number; - + /** * (EXPERIMENTAL) The terminal's current buffer, this might be either the * normal buffer or the alt buffer depending on what's running in the * terminal. */ readonly buffer: IBufferNamespace; - + /** * (EXPERIMENTAL) Get all markers registered against the buffer. If the alt * buffer is active this will always return []. */ readonly markers: ReadonlyArray; - + /** * (EXPERIMENTAL) Get the parser interface to register * custom escape sequence handlers. */ readonly parser: IParser; - + /** * (EXPERIMENTAL) Get the Unicode handling interface * to register and switch Unicode version. */ readonly unicode: IUnicodeHandling; - + /** * Natural language strings that can be localized. */ static strings: ILocalizableStrings; - + /** * Creates a new `Terminal` object. * * @param options An object containing a set of options. */ constructor(options?: ITerminalOptions); - + /** * Adds an event listener for when a binary event fires. This is used to * enable non UTF-8 conformant binary messages to be sent to the backend. @@ -543,13 +543,13 @@ declare module 'xterm-core' { * @returns an `IDisposable` to stop listening. */ onBinary: IEvent; - + /** * Adds an event listener for the cursor moves. * @returns an `IDisposable` to stop listening. */ onCursorMove: IEvent; - + /** * Adds an event listener for when a data event fires. This happens for * example when the user types or pastes into the terminal. The event value @@ -558,20 +558,20 @@ declare module 'xterm-core' { * @returns an `IDisposable` to stop listening. */ onData: IEvent; - + /** * Adds an event listener for when a line feed is added. * @returns an `IDisposable` to stop listening. */ onLineFeed: IEvent; - + /** * Adds an event listener for when the terminal is resized. The event value * contains the new size. * @returns an `IDisposable` to stop listening. */ onResize: IEvent<{ cols: number, rows: number }>; - + /** * Adds an event listener for when an OSC 0 or OSC 2 title change occurs. * The event value is the new title. @@ -595,7 +595,7 @@ declare module 'xterm-core' { * @returns The new marker or undefined. */ registerMarker(cursorYOffset: number): IMarker | undefined; - + /** * @deprecated use `registerMarker` instead. */ @@ -611,7 +611,7 @@ declare module 'xterm-core' { * Clear the entire buffer, making the prompt line the new first line. */ clear(): void; - + /** * Write data to the terminal. * @param data The data to write to the terminal. This can either be raw @@ -621,7 +621,7 @@ declare module 'xterm-core' { * by the parser. */ write(data: string | Uint8Array, callback?: () => void): void; - + /** * Writes data to the terminal, followed by a break line character (\n). * @param data The data to write to the terminal. This can either be raw @@ -631,7 +631,7 @@ declare module 'xterm-core' { * by the parser. */ writeln(data: string | Uint8Array, callback?: () => void): void; - + /** * Write UTF8 data to the terminal. * @param data The data to write to the terminal. @@ -639,7 +639,7 @@ declare module 'xterm-core' { * @deprecated use `write` instead */ writeUtf8(data: Uint8Array, callback?: () => void): void; - + /** * Retrieves an option's value from the terminal. * @param key The option key. @@ -660,7 +660,7 @@ declare module 'xterm-core' { * @param key The option key. */ getOption(key: string): any; - + /** * Sets an option on the terminal. * @param key The option key. @@ -721,13 +721,19 @@ declare module 'xterm-core' { * @param value The option value. */ setOption(key: string, value: any): void; - + /** * Perform a full reset (RIS, aka '\x1bc'). */ reset(): void; + + /** + * Loads an addon into this instance of xterm.js. + * @param addon The addon to load. + */ + loadAddon(addon: ITerminalAddon): void; } - + /** * An addon that can provide additional functionality to the terminal. */ @@ -737,7 +743,7 @@ declare module 'xterm-core' { */ activate(terminal: Terminal): void; } - + /** * An object representing a selection within the terminal. */ @@ -746,23 +752,23 @@ declare module 'xterm-core' { * The start column of the selection. */ startColumn: number; - + /** * The start row of the selection. */ startRow: number; - + /** * The end column of the selection. */ endColumn: number; - + /** * The end row of the selection. */ endRow: number; } - + /** * An object representing a range within the viewport of the terminal. */ @@ -771,13 +777,13 @@ declare module 'xterm-core' { * The start of the range. */ start: IViewportRangePosition; - + /** * The end of the range. */ end: IViewportRangePosition; } - + /** * An object representing a cell position within the viewport of the terminal. */ @@ -790,14 +796,14 @@ declare module 'xterm-core' { * a text editor. */ x: number; - + /** * The y position of the cell. This is a 0-based index that refers to a * specific row. */ y: number; } - + /** * A range within a buffer. */ @@ -806,13 +812,13 @@ declare module 'xterm-core' { * The start position of the range. */ start: IBufferCellPosition; - + /** * The end position of the range. */ end: IBufferCellPosition; } - + /** * A position within a buffer. */ @@ -821,13 +827,13 @@ declare module 'xterm-core' { * The x position within the buffer. */ x: number; - + /** * The y position within the buffer. */ y: number; } - + /** * Represents a terminal buffer. */ @@ -836,36 +842,36 @@ declare module 'xterm-core' { * The type of the buffer. */ readonly type: 'normal' | 'alternate'; - + /** * The y position of the cursor. This ranges between `0` (when the * cursor is at baseY) and `Terminal.rows - 1` (when the cursor is on the * last row). */ readonly cursorY: number; - + /** * The x position of the cursor. This ranges between `0` (left side) and * `Terminal.cols` (after last cell of the row). */ readonly cursorX: number; - + /** * The line within the buffer where the top of the viewport is. */ readonly viewportY: number; - + /** * The line within the buffer where the top of the bottom page is (when * fully scrolled down). */ readonly baseY: number; - + /** * The amount of lines in the buffer. */ readonly length: number; - + /** * Gets a line from the buffer, or undefined if the line index does not * exist. @@ -877,7 +883,7 @@ declare module 'xterm-core' { * @param y The line index to get. */ getLine(y: number): IBufferLine | undefined; - + /** * Creates an empty cell object suitable as a cell reference in * `line.getCell(x, cell)`. Use this to avoid costly recreation of @@ -885,7 +891,7 @@ declare module 'xterm-core' { */ getNullCell(): IBufferCell; } - + /** * Represents the terminal's set of buffers. */ @@ -894,25 +900,25 @@ declare module 'xterm-core' { * The active buffer, this will either be the normal or alternate buffers. */ readonly active: IBuffer; - + /** * The normal buffer. */ readonly normal: IBuffer; - + /** * The alternate buffer, this becomes the active buffer when an application * enters this mode via DECSET (`CSI ? 4 7 h`) */ readonly alternate: IBuffer; - + /** * Adds an event listener for when the active buffer changes. * @returns an `IDisposable` to stop listening. */ onBufferChange: IEvent; } - + /** * Represents a line in the terminal's buffer. */ @@ -921,13 +927,13 @@ declare module 'xterm-core' { * Whether the line is wrapped from the previous line. */ readonly isWrapped: boolean; - + /** * The length of the line, all call to getCell beyond the length will result * in `undefined`. */ readonly length: number; - + /** * Gets a cell from the line, or undefined if the line index does not exist. * @@ -941,7 +947,7 @@ declare module 'xterm-core' { * looped over to avoid creating new objects for every cell. */ getCell(x: number, cell?: IBufferCell): IBufferCell | undefined; - + /** * Gets the line as a string. Note that this is gets only the string for the * line, not taking isWrapped into account. @@ -952,7 +958,7 @@ declare module 'xterm-core' { */ translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string; } - + /** * Represents a single cell in the terminal's buffer. */ @@ -965,7 +971,7 @@ declare module 'xterm-core' { * - `0` for cells immediately following cells with a width of `2`. */ getWidth(): number; - + /** * The character(s) within the cell. Examples of what this can contain: * @@ -974,13 +980,13 @@ declare module 'xterm-core' { * - An emoji */ getChars(): string; - + /** * Gets the UTF32 codepoint of single characters, if content is a combined * string it returns the codepoint of the last character in the string. */ getCode(): number; - + /** * Gets the number representation of the foreground color mode, this can be * used to perform quick comparisons of 2 cells to see if they're the same. @@ -988,7 +994,7 @@ declare module 'xterm-core' { * a cell is. */ getFgColorMode(): number; - + /** * Gets the number representation of the background color mode, this can be * used to perform quick comparisons of 2 cells to see if they're the same. @@ -996,7 +1002,7 @@ declare module 'xterm-core' { * a cell is. */ getBgColorMode(): number; - + /** * Gets a cell's foreground color number, this differs depending on what the * color mode of the cell is: @@ -1009,7 +1015,7 @@ declare module 'xterm-core' { * (CSI 3 8 ; 2 ; Pi ; Pr ; Pg ; Pb) */ getFgColor(): number; - + /** * Gets a cell's background color number, this differs depending on what the * color mode of the cell is: @@ -1022,7 +1028,7 @@ declare module 'xterm-core' { * (CSI 4 8 ; 2 ; Pi ; Pr ; Pg ; Pb) */ getBgColor(): number; - + /** Whether the cell has the bold attribute (CSI 1 m). */ isBold(): number; /** Whether the cell has the inverse attribute (CSI 3 m). */ @@ -1037,7 +1043,7 @@ declare module 'xterm-core' { isInverse(): number; /** Whether the cell has the inverse attribute (CSI 8 m). */ isInvisible(): number; - + /** Whether the cell is using the RGB foreground color mode. */ isFgRGB(): boolean; /** Whether the cell is using the RGB background color mode. */ @@ -1050,11 +1056,11 @@ declare module 'xterm-core' { isFgDefault(): boolean; /** Whether the cell is using the default background color mode. */ isBgDefault(): boolean; - + /** Whether the cell has the default attribute (no color or style). */ isAttributeDefault(): boolean; } - + /** * Data type to register a CSI, DCS or ESC callback in the parser * in the form: @@ -1098,7 +1104,7 @@ declare module 'xterm-core' { */ final: string; } - + /** * Allows hooking into the parser for custom handling of escape sequences. */ @@ -1116,7 +1122,7 @@ declare module 'xterm-core' { * @return An IDisposable you can call to remove this handler. */ registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable; - + /** * Adds a handler for DCS escape sequences. * @param id Specifies the function identifier under which the callback @@ -1135,7 +1141,7 @@ declare module 'xterm-core' { * @return An IDisposable you can call to remove this handler. */ registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable; - + /** * Adds a handler for ESC escape sequences. * @param id Specifies the function identifier under which the callback @@ -1148,7 +1154,7 @@ declare module 'xterm-core' { * @return An IDisposable you can call to remove this handler. */ registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable; - + /** * Adds a handler for OSC escape sequences. * @param ident The number (first parameter) of the sequence. @@ -1167,7 +1173,7 @@ declare module 'xterm-core' { */ registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable; } - + /** * (EXPERIMENTAL) Unicode version provider. * Used to register custom Unicode versions with `Terminal.unicode.register`. @@ -1177,13 +1183,13 @@ declare module 'xterm-core' { * String indicating the Unicode version provided. */ readonly version: string; - + /** * Unicode version dependent wcwidth implementation. */ wcwidth(codepoint: number): 0 | 1 | 2; } - + /** * (EXPERIMENTAL) Unicode handling interface. */ @@ -1192,16 +1198,15 @@ declare module 'xterm-core' { * Register a custom Unicode version provider. */ register(provider: IUnicodeVersionProvider): void; - + /** * Registered Unicode versions. */ readonly versions: ReadonlyArray; - + /** * Getter/setter for active Unicode version. */ activeVersion: string; } } - \ No newline at end of file From 3b8218e36e5da16c9724c7b812672879a3779b3e Mon Sep 17 00:00:00 2001 From: meganrogge Date: Tue, 10 Aug 2021 10:03:38 -0700 Subject: [PATCH 264/377] work with Daniel --- src/browser/renderer/BaseRenderLayer.ts | 45 +++++++++++-------- ...Characters.ts => BoxAndBlockCharacters.ts} | 0 src/common/CoreTerminal.ts | 11 +++++ 3 files changed, 38 insertions(+), 18 deletions(-) rename src/browser/renderer/{BoxCharacters.ts => BoxAndBlockCharacters.ts} (100%) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 188816ec..e6ad0af0 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -17,7 +17,7 @@ import { IBufferService, IOptionsService } from 'common/services/Services'; import { throwIfFalsy } from 'browser/renderer/RendererUtils'; import { channels, color, rgba } from 'browser/Color'; import { removeElementFromParent } from 'browser/Dom'; -import { boxDrawingBoxes, boxDrawingLineSegments } from 'browser/renderer/BoxCharacters'; +import { boxDrawingBoxes, boxDrawingLineSegments } from 'browser/renderer/BoxAndBlockCharacters'; export abstract class BaseRenderLayer implements IRenderLayer { private _canvas: HTMLCanvasElement; @@ -395,18 +395,16 @@ export abstract class BaseRenderLayer implements IRenderLayer { this._ctx.strokeStyle = this._ctx.fillStyle; const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; const yOffset = y * this._scaledCellHeight + this._scaledCharTop; - const xEighth = this._scaledCellWidth / 8; - const yEighth = this._scaledCellHeight / 8; - for (let i = 0; i < boxes.length; i++) { const box = boxes[i]; + const xEighth = this._scaledCellWidth / 8; + const yEighth = this._scaledCellHeight / 8; this._ctx.fillRect( - xOffset + (box.x*xEighth), - yOffset + (box.y*yEighth), - (box.w * xEighth), - (box.h * yEighth)); + xOffset, + yOffset, + box.w * xEighth, + box.h * yEighth); } - return true; } @@ -418,28 +416,30 @@ export abstract class BaseRenderLayer implements IRenderLayer { // TODO: Clean below const scale = window.devicePixelRatio; this._ctx.strokeStyle = this._ctx.fillStyle; - this._ctx.lineWidth = scale; + + // increase # of pixels when font size incremented by 10 + this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; const yOffset = y * this._scaledCellHeight + this._scaledCharTop; - const horizontalCenter = this._scaledCellWidth / 2; - const verticalCenter = this._scaledCellHeight / 2; + const horizontalCenter = Math.round(this._scaledCellWidth / 2); + const verticalCenter = Math.round(this._scaledCellHeight / 2); const xPoints = [ xOffset, + xOffset + horizontalCenter - scale * 2, xOffset + horizontalCenter - scale, - xOffset + horizontalCenter - scale / 2, xOffset + horizontalCenter, - xOffset + horizontalCenter + scale / 2, xOffset + horizontalCenter + scale, + xOffset + horizontalCenter + scale * 2, xOffset + this._scaledCellWidth ]; const yPoints = [ yOffset, + yOffset + verticalCenter - scale * 2, yOffset + verticalCenter - scale, - yOffset + verticalCenter - scale / 2, yOffset + verticalCenter, - yOffset + verticalCenter + scale / 2, yOffset + verticalCenter + scale, + yOffset + verticalCenter + scale * 2, yOffset + this._scaledCellHeight ]; @@ -448,7 +448,12 @@ export abstract class BaseRenderLayer implements IRenderLayer { if (i === 0 || (op.x1 !== ops[i - 1].x2 || op.y1 !== ops[i - 1].y2)) { this._ctx.beginPath(); - this._ctx.moveTo(xPoints[op.x1], yPoints[op.y1]); + if (this._ctx.lineWidth % 2 === 1) { + + this._ctx.moveTo(op.x1 === 0 ? xPoints[op.x1] : xPoints[op.x1] + .5, yPoints[op.y1] + .5); + } else { + this._ctx.moveTo(xPoints[op.x1], yPoints[op.y1]); + } } if (typeof op.cx1 !== 'undefined') { @@ -462,7 +467,11 @@ export abstract class BaseRenderLayer implements IRenderLayer { yPoints[op.y2]); } else { // Draw line - this._ctx.lineTo(xPoints[op.x2], yPoints[op.y2]); + if (this._ctx.lineWidth % 2 === 1) { + this._ctx.lineTo(op.x2 === 0 ? xPoints[op.x2] : xPoints[op.x2] + .5, yPoints[op.y2] + .5); + } else { + this._ctx.lineTo(xPoints[op.x2], yPoints[op.y2]); + } } this._ctx.stroke(); diff --git a/src/browser/renderer/BoxCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts similarity index 100% rename from src/browser/renderer/BoxCharacters.ts rename to src/browser/renderer/BoxAndBlockCharacters.ts diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index e61a8e16..14b08abd 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -132,6 +132,17 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { // Setup WriteBuffer this._writeBuffer = new WriteBuffer((data, promiseResult) => this._inputHandler.parse(data, promiseResult)); + setTimeout(() => { + this.write('─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏\r\n'); + this.write('┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟\r\n'); + this.write('┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯\r\n'); + this.write('┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿\r\n'); + this.write('╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏\r\n'); + this.write('═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟\r\n'); + this.write('╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯\r\n'); + this.write('╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\r\n'); + this.write('└─┐╘═╕╚═╕╗'); + }, 1500); } public dispose(): void { From f769d03e0c32ee1155ecdcf956b7b8b9ca8e3654 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 10 Aug 2021 12:27:43 -0700 Subject: [PATCH 265/377] xterm-core -> xterm-headless --- node-test/README.md | 2 +- node-test/index.js | 2 +- package.json | 1 + src/headless/public/Terminal.ts | 2 +- src/headless/tsconfig.json | 2 +- .../{xterm-core.d.ts => xterm-headless.d.ts} | 2 +- webpack.config.core.js | 41 ------------------- webpack.config.headless.js | 8 ++-- 8 files changed, 10 insertions(+), 50 deletions(-) rename typings/{xterm-core.d.ts => xterm-headless.d.ts} (99%) delete mode 100644 webpack.config.core.js diff --git a/node-test/README.md b/node-test/README.md index 0da50146..cd346848 100644 --- a/node-test/README.md +++ b/node-test/README.md @@ -1,4 +1,4 @@ -Cursory test that 'xterm-core' works: +Cursory test that 'xterm-headless' works: ``` # From root of this repo diff --git a/node-test/index.js b/node-test/index.js index 2fd8da7f..55359c8e 100644 --- a/node-test/index.js +++ b/node-test/index.js @@ -2,7 +2,7 @@ import { createRequire } from 'module'; const require = createRequire(import.meta.url); const Terminal = require('../lib-headless/xterm.js').Terminal; -console.log('Creating xterm-core terminal...'); +console.log('Creating xterm-headless terminal...'); const terminal = new Terminal(); console.log('Writing to terminal...') terminal.write('foo \x1b[1;31mbar\x1b[0m baz', () => { diff --git a/package.json b/package.json index 47fd0a89..beffc66b 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "scripts": { "prepackage": "npm run build", "package": "webpack", + "package-headless": "webpack --config ./webpack.config.headless.js", "compile": "tsc -b ./src/common/public/tsconfig.json", "start": "node demo/start", "start-debug": "node --inspect-brk demo/start", diff --git a/src/headless/public/Terminal.ts b/src/headless/public/Terminal.ts index 44f9753a..f14bdd55 100644 --- a/src/headless/public/Terminal.ts +++ b/src/headless/public/Terminal.ts @@ -7,7 +7,7 @@ import { IEvent } from 'common/EventEmitter'; import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi'; import { ParserApi } from 'common/public/ParserApi'; import { UnicodeApi } from 'common/public/UnicodeApi'; -import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalAddon, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core'; +import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalAddon, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-headless'; import { Terminal as TerminalCore } from 'headless/Terminal'; import { AddonManager } from 'common/public/AddonManager'; diff --git a/src/headless/tsconfig.json b/src/headless/tsconfig.json index 6085a07f..b579af97 100644 --- a/src/headless/tsconfig.json +++ b/src/headless/tsconfig.json @@ -18,7 +18,7 @@ "include": [ "./**/*", "../../typings/xterm.d.ts", // common/Types.d.ts imports from 'xterm' - "../../typings/xterm-core.d.ts" + "../../typings/xterm-headless.d.ts" ], "references": [ { "path": "../common" } diff --git a/typings/xterm-core.d.ts b/typings/xterm-headless.d.ts similarity index 99% rename from typings/xterm-core.d.ts rename to typings/xterm-headless.d.ts index eabb51fc..3dd9d69e 100644 --- a/typings/xterm-core.d.ts +++ b/typings/xterm-headless.d.ts @@ -7,7 +7,7 @@ * to be stable and consumed by external programs. */ -declare module 'xterm-core' { +declare module 'xterm-headless' { /** * A string representing log level. */ diff --git a/webpack.config.core.js b/webpack.config.core.js deleted file mode 100644 index 85c37ff1..00000000 --- a/webpack.config.core.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2019 The xterm.js authors. All rights reserved. - * @license MIT - */ - -const path = require('path'); - -/** - * This webpack config does a production build for xterm-core.js. It works by taking the output from tsc - * (via `yarn watch` or `yarn prebuild`) which are put into `xterm-core/` and webpacks them into a - * production mode commonjs library module in `lib/`. The aliases are used fix up the absolute paths - * output by tsc (because of `baseUrl` and `paths` in `tsconfig.json`. - */ -module.exports = { - entry: './xterm-core/common/public/Terminal.js', - devtool: 'source-map', - module: { - rules: [ - { - test: /\.js$/, - use: ["source-map-loader"], - enforce: "pre", - exclude: /node_modules/ - } - ] - }, - resolve: { - modules: ['./node_modules'], - extensions: [ '.js' ], - alias: { - common: path.resolve('./xterm-core/common') - } - }, - output: { - filename: 'xterm-core.js', - path: path.resolve('./lib'), - libraryTarget: 'commonjs' - }, - mode: 'production', - target: 'node', -}; diff --git a/webpack.config.headless.js b/webpack.config.headless.js index 7ae66676..805b9a3e 100644 --- a/webpack.config.headless.js +++ b/webpack.config.headless.js @@ -6,10 +6,10 @@ const path = require('path'); /** - * This webpack config does a production build for xterm.js. It works by taking the output from tsc - * (via `yarn watch` or `yarn prebuild`) which are put into `out/` and webpacks them into a - * production mode umd library module in `lib/`. The aliases are used fix up the absolute paths - * output by tsc (because of `baseUrl` and `paths` in `tsconfig.json`. + * This webpack config does a production build for xterm.js headless. It works by taking the output + * from tsc (via `yarn watch` or `yarn prebuild`) which are put into `out/` and webpacks them into a + * production mode umd library module in `lib-headless/`. The aliases are used fix up the absolute + * paths output by tsc (because of `baseUrl` and `paths` in `tsconfig.json`. */ module.exports = { entry: './out/headless/public/Terminal.js', From 4a200e59acc6e655e05e78767cbbae5f3a5318fb Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 10 Aug 2021 12:50:22 -0700 Subject: [PATCH 266/377] Create headless package script --- bin/package_headless.js | 40 ++++++++++++++++++++++++++++++++++++++++ headless/.gitignore | 2 ++ headless/README.md | 5 +++++ 3 files changed, 47 insertions(+) create mode 100644 bin/package_headless.js create mode 100644 headless/.gitignore create mode 100644 headless/README.md diff --git a/bin/package_headless.js b/bin/package_headless.js new file mode 100644 index 00000000..27613200 --- /dev/null +++ b/bin/package_headless.js @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2021 The xterm.js authors. All rights reserved. + * @license MIT + */ + +const fs = require('fs'); +const { join } = require('path'); + +const repoRoot = join(__dirname, '..'); +const headlessRoot = join(repoRoot, 'headless'); + +// Create headless/package.json +console.log('> Creating headless/package.json'); +const xtermPackageJson = require('../package.json'); +const xtermHeadlessPackageJson = { + ...xtermPackageJson, + name: 'xterm-headless', + description: 'A headless terminal component that runs in Node.js', + main: 'lib/xterm-headless.js', + types: 'typings/xterm-headless.d.ts', +}; +delete xtermHeadlessPackageJson['scripts']; +delete xtermHeadlessPackageJson['devDependencies']; +delete xtermHeadlessPackageJson['style']; +xtermHeadlessPackageJson.version += '-alpha'; +fs.writeFileSync(join(headlessRoot, 'package.json'), JSON.stringify(xtermHeadlessPackageJson, null, 1)); +console.log(fs.readFileSync(join(headlessRoot, 'package.json')).toString()); + +console.log('> Creating headless/typings'); +mkdirF(join(headlessRoot, 'typings')); +fs.copyFileSync( + join(repoRoot, 'typings/xterm-headless.d.ts'), + join(headlessRoot, 'typings/xterm-headless.d.ts') +); + +function mkdirF(p) { + if (!fs.existsSync(p)) { + fs.mkdirSync(p); + } +} diff --git a/headless/.gitignore b/headless/.gitignore new file mode 100644 index 00000000..9b8b2749 --- /dev/null +++ b/headless/.gitignore @@ -0,0 +1,2 @@ +typings/ +package.json diff --git a/headless/README.md b/headless/README.md new file mode 100644 index 00000000..de22b47a --- /dev/null +++ b/headless/README.md @@ -0,0 +1,5 @@ +# [![xterm.js logo](../logo-full.png)](https://xtermjs.org) + +⚠ This package is a work in progress + +`xterm-headless` is a headless terminal that can be run in node.js. This is useful in combination with the frontend [`xterm`](https://www.npmjs.com/package/xterm) for example to keep track of a terminal's state on a remote server where the process is hosted. From 15bd827c2ee6c516a32b05dcdd7652db76d26b69 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 10 Aug 2021 12:57:45 -0700 Subject: [PATCH 267/377] Improve headless packaging --- .gitignore | 1 - bin/package_headless.js | 2 +- headless/.gitignore | 1 + package.json | 1 + webpack.config.headless.js | 2 +- 5 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 4958559e..8aea04b2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ node_modules/ *.swp .lock-wscript lib/ -lib-headless/ out/ out-test/ .nyc_output/ diff --git a/bin/package_headless.js b/bin/package_headless.js index 27613200..104844e2 100644 --- a/bin/package_headless.js +++ b/bin/package_headless.js @@ -16,7 +16,7 @@ const xtermHeadlessPackageJson = { ...xtermPackageJson, name: 'xterm-headless', description: 'A headless terminal component that runs in Node.js', - main: 'lib/xterm-headless.js', + main: 'lib-headless/xterm-headless.js', types: 'typings/xterm-headless.d.ts', }; delete xtermHeadlessPackageJson['scripts']; diff --git a/headless/.gitignore b/headless/.gitignore index 9b8b2749..4aba0be5 100644 --- a/headless/.gitignore +++ b/headless/.gitignore @@ -1,2 +1,3 @@ +lib-headless/ typings/ package.json diff --git a/package.json b/package.json index beffc66b..2d128b08 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "prepackage": "npm run build", "package": "webpack", "package-headless": "webpack --config ./webpack.config.headless.js", + "postpackage-headless": "node ./bin/package_headless.js", "compile": "tsc -b ./src/common/public/tsconfig.json", "start": "node demo/start", "start-debug": "node --inspect-brk demo/start", diff --git a/webpack.config.headless.js b/webpack.config.headless.js index 805b9a3e..2fe75915 100644 --- a/webpack.config.headless.js +++ b/webpack.config.headless.js @@ -34,7 +34,7 @@ module.exports = { }, output: { filename: 'xterm.js', - path: path.resolve('./lib-headless'), + path: path.resolve('./headless/lib-headless'), library: { type: 'commonjs' } From 6aa0782ce34fa02171d09b9b1df4d33d012e3018 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 10 Aug 2021 13:14:05 -0700 Subject: [PATCH 268/377] Publish dry run in package_headless --- bin/package_headless.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bin/package_headless.js b/bin/package_headless.js index 104844e2..37d846df 100644 --- a/bin/package_headless.js +++ b/bin/package_headless.js @@ -3,6 +3,7 @@ * @license MIT */ +const { spawn, exec } = require('child_process'); const fs = require('fs'); const { join } = require('path'); @@ -38,3 +39,15 @@ function mkdirF(p) { fs.mkdirSync(p); } } + +console.log('> Publish dry run'); +exec('npm publish --dry-run', { cwd: headlessRoot }, (error, stdout, stderr) => { + if (error) { + console.log(`error: ${error.message}`); + return; + } + if (stderr) { + console.error(`stderr:\n${stderr}`); + } + console.log(`stdout:\n${stdout}`); +}); From ee759e245dee465b4bad879ae65fe7d99bd8fd40 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Tue, 10 Aug 2021 13:41:03 -0700 Subject: [PATCH 269/377] line up vertically --- src/browser/renderer/BaseRenderLayer.ts | 35 ++++++++++++------------- src/common/CoreTerminal.ts | 7 ++++- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index e6ad0af0..aefc0369 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -408,8 +408,8 @@ export abstract class BaseRenderLayer implements IRenderLayer { return true; } - const ops = boxDrawingLineSegments[char]; - if (!ops) { + const lineSegments = boxDrawingLineSegments[char]; + if (!lineSegments) { return false; } @@ -434,7 +434,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { xOffset + this._scaledCellWidth ]; const yPoints = [ - yOffset, + yOffset - 1, yOffset + verticalCenter - scale * 2, yOffset + verticalCenter - scale, yOffset + verticalCenter, @@ -443,34 +443,33 @@ export abstract class BaseRenderLayer implements IRenderLayer { yOffset + this._scaledCellHeight ]; - for (let i = 0; i < ops.length; i++) { - const op = ops[i]; + for (let i = 0; i < lineSegments.length; i++) { + const line = lineSegments[i]; - if (i === 0 || (op.x1 !== ops[i - 1].x2 || op.y1 !== ops[i - 1].y2)) { + if (i === 0 || (line.x1 !== lineSegments[i - 1].x2 || line.y1 !== lineSegments[i - 1].y2)) { this._ctx.beginPath(); if (this._ctx.lineWidth % 2 === 1) { - - this._ctx.moveTo(op.x1 === 0 ? xPoints[op.x1] : xPoints[op.x1] + .5, yPoints[op.y1] + .5); + this._ctx.moveTo(line.x1 === 0 ? xPoints[line.x1] : xPoints[line.x1] + .5, yPoints[line.y1] + .5); } else { - this._ctx.moveTo(xPoints[op.x1], yPoints[op.y1]); + this._ctx.moveTo(xPoints[line.x1], yPoints[line.y1]); } } - if (typeof op.cx1 !== 'undefined') { + if (typeof line.cx1 !== 'undefined') { // Draw curve this._ctx.bezierCurveTo( - xPoints[op.cx1], - yPoints[op.cy1], - xPoints[op.cx2], - yPoints[op.cy2], - xPoints[op.x2], - yPoints[op.y2]); + xPoints[line.cx1], + yPoints[line.cy1], + xPoints[line.cx2], + yPoints[line.cy2], + xPoints[line.x2], + yPoints[line.y2]); } else { // Draw line if (this._ctx.lineWidth % 2 === 1) { - this._ctx.lineTo(op.x2 === 0 ? xPoints[op.x2] : xPoints[op.x2] + .5, yPoints[op.y2] + .5); + this._ctx.lineTo(line.x2 === 0 ? xPoints[line.x2] : xPoints[line.x2] + .5, yPoints[line.y2] + .5); } else { - this._ctx.lineTo(xPoints[op.x2], yPoints[op.y2]); + this._ctx.lineTo(xPoints[line.x2], yPoints[line.y2]); } } diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 14b08abd..5758957e 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -141,7 +141,12 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this.write('═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟\r\n'); this.write('╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯\r\n'); this.write('╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\r\n'); - this.write('└─┐╘═╕╚═╕╗'); + this.write('▇▇▇▇▇▇▇▇▇'); + this.write(' ╔═════════════════════════════════════════════════════════╕\r\n'); + this.write(' ║ │\r\n'); + this.write(' ║ ╔═══════════════╦════════╤════════╗ │\r\n'); + this.write(' ║ ║ ║ │ ║ │\r\n'); + this.write(' ║ ║ ║ │ ║ │\r\n'); }, 1500); } From 69ce01c794e965847bfaea4747318a62e0856e68 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Aug 2021 22:58:26 +0000 Subject: [PATCH 270/377] Bump path-parse from 1.0.6 to 1.0.7 Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index ee0f0558..571f8a90 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3356,9 +3356,9 @@ path-key@^3.0.0, path-key@^3.1.0: integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== path-parse@^1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" - integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== + version "1.0.7" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" + integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== path-to-regexp@0.1.7: version "0.1.7" From 83ddf0fc4bf299507002f00bc88743c2e538ebd7 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 04:46:27 -0700 Subject: [PATCH 271/377] Force publish of headless even in PR --- bin/publish.js | 8 ++++++-- node-test/index.js | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/publish.js b/bin/publish.js index 64336fdc..fc4ad99c 100644 --- a/bin/publish.js +++ b/bin/publish.js @@ -6,6 +6,7 @@ const cp = require('child_process'); const fs = require('fs'); const os = require('os'); +const { basename } = require('path'); const path = require('path'); // Setup auth @@ -22,6 +23,7 @@ const changedFiles = getChangedFilesInCommit('HEAD'); let isStableRelease = false; if (changedFiles.some(e => e.search(/^addons\//) === -1)) { isStableRelease = checkAndPublishPackage(path.resolve(__dirname, '..')); + checkAndPublishPackage(path.resolve(__dirname, '../headless')); } // Publish addons if any files were changed inside of the addon @@ -70,11 +72,13 @@ function checkAndPublishPackage(packageDir) { // Publish const args = ['publish']; - if (!isStableRelease) { + if (basename(packageDir) === 'headless') { + args.push('--tag', 'beta'); + } else if (!isStableRelease) { args.push('--tag', 'beta'); } console.log(`Spawn: npm ${args.join(' ')}`); - if (!isDryRun) { + if (!isDryRun || basename(packageDir) === 'headless') { const result = cp.spawnSync('npm', args, { cwd: packageDir, stdio: 'inherit' diff --git a/node-test/index.js b/node-test/index.js index 55359c8e..021f2ecd 100644 --- a/node-test/index.js +++ b/node-test/index.js @@ -1,6 +1,6 @@ import { createRequire } from 'module'; const require = createRequire(import.meta.url); -const Terminal = require('../lib-headless/xterm.js').Terminal; +const Terminal = require('../headless/lib-headless/xterm.js').Terminal; console.log('Creating xterm-headless terminal...'); const terminal = new Terminal(); From f685d8eb21263732cbb4e3c6941ae2851b6c68be Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 04:52:37 -0700 Subject: [PATCH 272/377] Force publish --- azure-pipelines.yml | 2 +- bin/publish.js | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f4220176..0cd932df 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -145,7 +145,7 @@ jobs: - Linux_IntegrationTests - macOS_IntegrationTests - Windows_IntegrationTests - condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['FORCE_RELEASE'], 'true'))) + # condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['FORCE_RELEASE'], 'true'))) pool: vmImage: 'ubuntu-16.04' steps: diff --git a/bin/publish.js b/bin/publish.js index fc4ad99c..357e2892 100644 --- a/bin/publish.js +++ b/bin/publish.js @@ -22,20 +22,20 @@ const changedFiles = getChangedFilesInCommit('HEAD'); // Publish xterm if any files were changed outside of the addons directory let isStableRelease = false; if (changedFiles.some(e => e.search(/^addons\//) === -1)) { - isStableRelease = checkAndPublishPackage(path.resolve(__dirname, '..')); + // isStableRelease = checkAndPublishPackage(path.resolve(__dirname, '..')); checkAndPublishPackage(path.resolve(__dirname, '../headless')); } // Publish addons if any files were changed inside of the addon const addonPackageDirs = [ - path.resolve(__dirname, '../addons/xterm-addon-attach'), - path.resolve(__dirname, '../addons/xterm-addon-fit'), - path.resolve(__dirname, '../addons/xterm-addon-ligatures'), - path.resolve(__dirname, '../addons/xterm-addon-search'), - path.resolve(__dirname, '../addons/xterm-addon-serialize'), - path.resolve(__dirname, '../addons/xterm-addon-unicode11'), - path.resolve(__dirname, '../addons/xterm-addon-web-links'), - path.resolve(__dirname, '../addons/xterm-addon-webgl') + // path.resolve(__dirname, '../addons/xterm-addon-attach'), + // path.resolve(__dirname, '../addons/xterm-addon-fit'), + // path.resolve(__dirname, '../addons/xterm-addon-ligatures'), + // path.resolve(__dirname, '../addons/xterm-addon-search'), + // path.resolve(__dirname, '../addons/xterm-addon-serialize'), + // path.resolve(__dirname, '../addons/xterm-addon-unicode11'), + // path.resolve(__dirname, '../addons/xterm-addon-web-links'), + // path.resolve(__dirname, '../addons/xterm-addon-webgl') ]; console.log(`Checking if addons need to be published`); for (const p of addonPackageDirs) { @@ -48,7 +48,7 @@ for (const p of addonPackageDirs) { // Publish website if it's a stable release if (isStableRelease) { - updateWebsite(); + // updateWebsite(); } function checkAndPublishPackage(packageDir) { @@ -72,11 +72,11 @@ function checkAndPublishPackage(packageDir) { // Publish const args = ['publish']; - if (basename(packageDir) === 'headless') { - args.push('--tag', 'beta'); - } else if (!isStableRelease) { - args.push('--tag', 'beta'); - } + args.push('--tag', 'beta'); + // if (basename(packageDir) === 'headless') { + // } else if (!isStableRelease) { + // args.push('--tag', 'beta'); + // } console.log(`Spawn: npm ${args.join(' ')}`); if (!isDryRun || basename(packageDir) === 'headless') { const result = cp.spawnSync('npm', args, { From 97fa4a59b700f25f244a20dc8d2beaad1c790fca Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 05:54:37 -0700 Subject: [PATCH 273/377] Package headless in release step --- azure-pipelines.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0cd932df..95a97e59 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -164,5 +164,7 @@ jobs: displayName: Cache node modules - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' + - script: node ./bin/package_headless.js + displayName: 'Package xterm-headless' - script: NPM_AUTH_TOKEN="$(NPM_AUTH_TOKEN)" node ./bin/publish.js displayName: 'Package and publish to npm' From b6e54307025be84c5eaf7230783cded7a028374f Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 06:04:48 -0700 Subject: [PATCH 274/377] Revert "Force publish" This reverts commit f685d8eb21263732cbb4e3c6941ae2851b6c68be. --- azure-pipelines.yml | 2 +- bin/publish.js | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 95a97e59..c87496b2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -145,7 +145,7 @@ jobs: - Linux_IntegrationTests - macOS_IntegrationTests - Windows_IntegrationTests - # condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['FORCE_RELEASE'], 'true'))) + condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['FORCE_RELEASE'], 'true'))) pool: vmImage: 'ubuntu-16.04' steps: diff --git a/bin/publish.js b/bin/publish.js index 357e2892..fc4ad99c 100644 --- a/bin/publish.js +++ b/bin/publish.js @@ -22,20 +22,20 @@ const changedFiles = getChangedFilesInCommit('HEAD'); // Publish xterm if any files were changed outside of the addons directory let isStableRelease = false; if (changedFiles.some(e => e.search(/^addons\//) === -1)) { - // isStableRelease = checkAndPublishPackage(path.resolve(__dirname, '..')); + isStableRelease = checkAndPublishPackage(path.resolve(__dirname, '..')); checkAndPublishPackage(path.resolve(__dirname, '../headless')); } // Publish addons if any files were changed inside of the addon const addonPackageDirs = [ - // path.resolve(__dirname, '../addons/xterm-addon-attach'), - // path.resolve(__dirname, '../addons/xterm-addon-fit'), - // path.resolve(__dirname, '../addons/xterm-addon-ligatures'), - // path.resolve(__dirname, '../addons/xterm-addon-search'), - // path.resolve(__dirname, '../addons/xterm-addon-serialize'), - // path.resolve(__dirname, '../addons/xterm-addon-unicode11'), - // path.resolve(__dirname, '../addons/xterm-addon-web-links'), - // path.resolve(__dirname, '../addons/xterm-addon-webgl') + path.resolve(__dirname, '../addons/xterm-addon-attach'), + path.resolve(__dirname, '../addons/xterm-addon-fit'), + path.resolve(__dirname, '../addons/xterm-addon-ligatures'), + path.resolve(__dirname, '../addons/xterm-addon-search'), + path.resolve(__dirname, '../addons/xterm-addon-serialize'), + path.resolve(__dirname, '../addons/xterm-addon-unicode11'), + path.resolve(__dirname, '../addons/xterm-addon-web-links'), + path.resolve(__dirname, '../addons/xterm-addon-webgl') ]; console.log(`Checking if addons need to be published`); for (const p of addonPackageDirs) { @@ -48,7 +48,7 @@ for (const p of addonPackageDirs) { // Publish website if it's a stable release if (isStableRelease) { - // updateWebsite(); + updateWebsite(); } function checkAndPublishPackage(packageDir) { @@ -72,11 +72,11 @@ function checkAndPublishPackage(packageDir) { // Publish const args = ['publish']; - args.push('--tag', 'beta'); - // if (basename(packageDir) === 'headless') { - // } else if (!isStableRelease) { - // args.push('--tag', 'beta'); - // } + if (basename(packageDir) === 'headless') { + args.push('--tag', 'beta'); + } else if (!isStableRelease) { + args.push('--tag', 'beta'); + } console.log(`Spawn: npm ${args.join(' ')}`); if (!isDryRun || basename(packageDir) === 'headless') { const result = cp.spawnSync('npm', args, { From 5affa70097e154dc56118302942428e891331c2d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 06:06:06 -0700 Subject: [PATCH 275/377] Undo headless force publish changes --- bin/publish.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bin/publish.js b/bin/publish.js index fc4ad99c..aaf9cac0 100644 --- a/bin/publish.js +++ b/bin/publish.js @@ -72,13 +72,11 @@ function checkAndPublishPackage(packageDir) { // Publish const args = ['publish']; - if (basename(packageDir) === 'headless') { - args.push('--tag', 'beta'); - } else if (!isStableRelease) { + if (!isStableRelease) { args.push('--tag', 'beta'); } console.log(`Spawn: npm ${args.join(' ')}`); - if (!isDryRun || basename(packageDir) === 'headless') { + if (!isDryRun) { const result = cp.spawnSync('npm', args, { cwd: packageDir, stdio: 'inherit' From 3e9b1bafbe5c4771165f3cb23bf38e99487a76b7 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 06:10:12 -0700 Subject: [PATCH 276/377] Remove force publish changes --- bin/publish.js | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/publish.js b/bin/publish.js index aaf9cac0..3c729f6c 100644 --- a/bin/publish.js +++ b/bin/publish.js @@ -6,7 +6,6 @@ const cp = require('child_process'); const fs = require('fs'); const os = require('os'); -const { basename } = require('path'); const path = require('path'); // Setup auth From 370d0c562ad059961bfa62147c455e8592a80985 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 06:19:53 -0700 Subject: [PATCH 277/377] Copy logo-full.png --- bin/package_headless.js | 15 ++++++++++----- headless/.gitignore | 1 + headless/README.md | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bin/package_headless.js b/bin/package_headless.js index 37d846df..0d4170df 100644 --- a/bin/package_headless.js +++ b/bin/package_headless.js @@ -3,15 +3,14 @@ * @license MIT */ -const { spawn, exec } = require('child_process'); +const { exec } = require('child_process'); const fs = require('fs'); const { join } = require('path'); const repoRoot = join(__dirname, '..'); const headlessRoot = join(repoRoot, 'headless'); -// Create headless/package.json -console.log('> Creating headless/package.json'); +console.log('> headless/package.json'); const xtermPackageJson = require('../package.json'); const xtermHeadlessPackageJson = { ...xtermPackageJson, @@ -23,17 +22,23 @@ const xtermHeadlessPackageJson = { delete xtermHeadlessPackageJson['scripts']; delete xtermHeadlessPackageJson['devDependencies']; delete xtermHeadlessPackageJson['style']; -xtermHeadlessPackageJson.version += '-alpha'; +xtermHeadlessPackageJson.version += '-alpha1'; fs.writeFileSync(join(headlessRoot, 'package.json'), JSON.stringify(xtermHeadlessPackageJson, null, 1)); console.log(fs.readFileSync(join(headlessRoot, 'package.json')).toString()); -console.log('> Creating headless/typings'); +console.log('> headless/typings/'); mkdirF(join(headlessRoot, 'typings')); fs.copyFileSync( join(repoRoot, 'typings/xterm-headless.d.ts'), join(headlessRoot, 'typings/xterm-headless.d.ts') ); +console.log('> headless/logo-full.png'); +fs.copyFileSync( + join(repoRoot, 'logo-full.png'), + join(headlessRoot, 'logo-full.png') +); + function mkdirF(p) { if (!fs.existsSync(p)) { fs.mkdirSync(p); diff --git a/headless/.gitignore b/headless/.gitignore index 4aba0be5..aa6706ab 100644 --- a/headless/.gitignore +++ b/headless/.gitignore @@ -1,3 +1,4 @@ lib-headless/ typings/ +logo-full.png package.json diff --git a/headless/README.md b/headless/README.md index de22b47a..358c97ef 100644 --- a/headless/README.md +++ b/headless/README.md @@ -1,4 +1,4 @@ -# [![xterm.js logo](../logo-full.png)](https://xtermjs.org) +# [![xterm.js logo](logo-full.png)](https://xtermjs.org) ⚠ This package is a work in progress From be164293170735ab635438d87316083b2f1f0fa9 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 06:23:42 -0700 Subject: [PATCH 278/377] Remove unused compile script --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 2d128b08..71a0f308 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,6 @@ "package": "webpack", "package-headless": "webpack --config ./webpack.config.headless.js", "postpackage-headless": "node ./bin/package_headless.js", - "compile": "tsc -b ./src/common/public/tsconfig.json", "start": "node demo/start", "start-debug": "node --inspect-brk demo/start", "lint": "eslint -c .eslintrc.json --max-warnings 0 --ext .ts src/ addons/", From 454c2726a5e0532f93dcf2e5e0ebc0e7cad6b129 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 06:30:15 -0700 Subject: [PATCH 279/377] Add npmignore --- headless/.npmignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 headless/.npmignore diff --git a/headless/.npmignore b/headless/.npmignore new file mode 100644 index 00000000..41f2a3a9 --- /dev/null +++ b/headless/.npmignore @@ -0,0 +1,2 @@ +# Include +!typings/*.d.ts From dda4904d9daa4bb403c3b3d1ebb178c23acd02fa Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 06:42:00 -0700 Subject: [PATCH 280/377] Fix xterm-headless lib file --- webpack.config.headless.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack.config.headless.js b/webpack.config.headless.js index 2fe75915..d5bb97b7 100644 --- a/webpack.config.headless.js +++ b/webpack.config.headless.js @@ -33,7 +33,7 @@ module.exports = { } }, output: { - filename: 'xterm.js', + filename: 'xterm-headless.js', path: path.resolve('./headless/lib-headless'), library: { type: 'commonjs' From 12980fbe0c020f4087320e69c85b01b7ede919b4 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 11 Aug 2021 11:18:47 -0700 Subject: [PATCH 281/377] start from scratch, some progress --- src/browser/renderer/BaseRenderLayer.ts | 131 +++++++------- src/browser/renderer/BoxAndBlockCharacters.ts | 162 ++++++++++++++++++ src/common/CoreTerminal.ts | 31 ++-- 3 files changed, 250 insertions(+), 74 deletions(-) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index aefc0369..0fbd9455 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -17,7 +17,7 @@ import { IBufferService, IOptionsService } from 'common/services/Services'; import { throwIfFalsy } from 'browser/renderer/RendererUtils'; import { channels, color, rgba } from 'browser/Color'; import { removeElementFromParent } from 'browser/Dom'; -import { boxDrawingBoxes, boxDrawingLineSegments } from 'browser/renderer/BoxAndBlockCharacters'; +import { boxDrawingBoxes, boxDrawingLineSegments, draw } from 'browser/renderer/BoxAndBlockCharacters'; export abstract class BaseRenderLayer implements IRenderLayer { private _canvas: HTMLCanvasElement; @@ -412,71 +412,84 @@ export abstract class BaseRenderLayer implements IRenderLayer { if (!lineSegments) { return false; } + const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; + const verticalCenter = Math.round(this._scaledCellHeight / 2); - // TODO: Clean below - const scale = window.devicePixelRatio; + const yOffset = y * this._scaledCellHeight + this._scaledCharTop + verticalCenter; + // const scale = window.devicePixelRatio; this._ctx.strokeStyle = this._ctx.fillStyle; // increase # of pixels when font size incremented by 10 this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); - - const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; - const yOffset = y * this._scaledCellHeight + this._scaledCharTop; const horizontalCenter = Math.round(this._scaledCellWidth / 2); - const verticalCenter = Math.round(this._scaledCellHeight / 2); - const xPoints = [ - xOffset, - xOffset + horizontalCenter - scale * 2, - xOffset + horizontalCenter - scale, - xOffset + horizontalCenter, - xOffset + horizontalCenter + scale, - xOffset + horizontalCenter + scale * 2, - xOffset + this._scaledCellWidth - ]; - const yPoints = [ - yOffset - 1, - yOffset + verticalCenter - scale * 2, - yOffset + verticalCenter - scale, - yOffset + verticalCenter, - yOffset + verticalCenter + scale, - yOffset + verticalCenter + scale * 2, - yOffset + this._scaledCellHeight - ]; - - for (let i = 0; i < lineSegments.length; i++) { - const line = lineSegments[i]; - - if (i === 0 || (line.x1 !== lineSegments[i - 1].x2 || line.y1 !== lineSegments[i - 1].y2)) { - this._ctx.beginPath(); - if (this._ctx.lineWidth % 2 === 1) { - this._ctx.moveTo(line.x1 === 0 ? xPoints[line.x1] : xPoints[line.x1] + .5, yPoints[line.y1] + .5); - } else { - this._ctx.moveTo(xPoints[line.x1], yPoints[line.y1]); - } - } - - if (typeof line.cx1 !== 'undefined') { - // Draw curve - this._ctx.bezierCurveTo( - xPoints[line.cx1], - yPoints[line.cy1], - xPoints[line.cx2], - yPoints[line.cy2], - xPoints[line.x2], - yPoints[line.y2]); - } else { - // Draw line - if (this._ctx.lineWidth % 2 === 1) { - this._ctx.lineTo(line.x2 === 0 ? xPoints[line.x2] : xPoints[line.x2] + .5, yPoints[line.y2] + .5); - } else { - this._ctx.lineTo(xPoints[line.x2], yPoints[line.y2]); - } - } - - this._ctx.stroke(); - } - + draw(this._ctx, char, xOffset, yOffset - verticalCenter, this._scaledCellWidth, this._scaledCellHeight); return true; + + + // // TODO: Clean below + // const scale = window.devicePixelRatio; + // this._ctx.strokeStyle = this._ctx.fillStyle; + + // // increase # of pixels when font size incremented by 10 + // this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); + + // const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; + // const yOffset = y * this._scaledCellHeight + this._scaledCharTop; + // const horizontalCenter = Math.round(this._scaledCellWidth / 2); + // const verticalCenter = Math.round(this._scaledCellHeight / 2); + // const xPoints = [ + // xOffset, + // xOffset + horizontalCenter - scale * 2, + // xOffset + horizontalCenter - scale, + // xOffset + horizontalCenter, + // xOffset + horizontalCenter + scale, + // xOffset + horizontalCenter + scale * 2, + // xOffset + this._scaledCellWidth + // ]; + // const yPoints = [ + // yOffset - 1, + // yOffset + verticalCenter - scale * 2, + // yOffset + verticalCenter - scale, + // yOffset + verticalCenter, + // yOffset + verticalCenter + scale, + // yOffset + verticalCenter + scale * 2, + // yOffset + this._scaledCellHeight + // ]; + + // for (let i = 0; i < lineSegments.length; i++) { + // const line = lineSegments[i]; + + // if (i === 0 || (line.x1 !== lineSegments[i - 1].x2 || line.y1 !== lineSegments[i - 1].y2)) { + // this._ctx.beginPath(); + // if (this._ctx.lineWidth % 2 === 1) { + // this._ctx.moveTo(line.x1 === 0 ? xPoints[line.x1] : xPoints[line.x1] + .5, yPoints[line.y1] + .5); + // } else { + // this._ctx.moveTo(xPoints[line.x1], yPoints[line.y1]); + // } + // } + + // if (typeof line.cx1 !== 'undefined') { + // // Draw curve + // this._ctx.bezierCurveTo( + // xPoints[line.cx1], + // yPoints[line.cy1], + // xPoints[line.cx2], + // yPoints[line.cy2], + // xPoints[line.x2], + // yPoints[line.y2]); + // } else { + // // Draw line + // if (this._ctx.lineWidth % 2 === 1) { + // this._ctx.lineTo(line.x2 === 0 ? xPoints[line.x2] : xPoints[line.x2] + .5, yPoints[line.y2] + .5); + // } else { + // this._ctx.lineTo(xPoints[line.x2], yPoints[line.y2]); + // } + // } + + // this._ctx.stroke(); + // } + + // return true; } diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 221a0e4f..eda53725 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -211,3 +211,165 @@ export const boxDrawingBoxes: { [index: string]: any } = { // HEAVY HORIZONTAL FILL (upper middle and lower one quarter block) '\u{1FB97}': [{ x: 0, y: 2, w: 8, h: 2 }, { x: 0, y: 6, w: 8, h: 2 }] }; + +export const chars: { [index: string]: string } = { + '━': 'M0,.5, L1,.5 z', + '│': 'M0,0, L0,2 z', + '┃': 'M0,0, L0,2 z!', + '┌': 'M , L , z', + '┍': 'M , L , z', + '┎': 'M , L , z', + '┏': 'M , L , z', + '┐': 'M , L , z', + '┑': 'M , L , z', + '┒': 'M , L , z', + '┓': 'M , L , z', + '└': 'M , L , z', + '┕': 'M , L , z', + '┖': 'M , L , z', + '┗': 'M , L , z', + '┘': 'M , L , z', + '┙': 'M , L , z', + '┚': 'M , L , z', + '┛': 'M , L , z', + '├': 'M , L , z', + '┝': 'M , L , z', + '┞': 'M , L , z', + '┟': 'M , L , z', + '┠': 'M , L , z', + '┡': 'M , L , z', + '┢': 'M , L , z', + '┣': 'M , L , z', + '┤': 'M , L , z', + '┥': 'M , L , z', + '┦': 'M , L , z', + '┧': 'M , L , z', + '┨': 'M , L , z', + '┩': 'M , L , z', + '┪': 'M , L , z', + '┫': 'M , L , z', + '┬': 'M , L , z', + '┭': 'M , L , z', + '┮': 'M , L , z', + '┯': 'M , L , z', + '┰': 'M , L , z', + '┱': 'M , L , z', + '┲': 'M , L , z', + '┳': 'M , L , z', + '┴': 'M , L , z', + '┵': 'M , L , z', + '┶': 'M , L , z', + '┷': 'M , L , z', + '┸': 'M , L , z', + '┹': 'M , L , z', + '┺': 'M , L , z', + '┻': 'M , L , z', + '┼': 'M , L , z', + '┽': 'M , L , z', + '┾': 'M , L , z', + '┿': 'M , L , z', + '╀': 'M , L , z', + '╁': 'M , L , z', + '╂': 'M , L , z', + '╃': 'M , L , z', + '╄': 'M , L , z', + '╅': 'M , L , z', + '╆': 'M , L , z', + '╇': 'M , L , z', + '╈': 'M , L , z', + '╉': 'M , L , z', + '╊': 'M , L , z', + '╋': 'M , L , z', + '╌': 'M , L , z', + '╍': 'M , L , z', + '╎': 'M , L , z', + '╏': 'M , L , z', + '═': 'M , L , z', + '║': 'M , L , z', + '╒': 'M , L , z', + '╓': 'M , L , z', + '╔': 'M , L , z', + '╕': 'M , L , z', + '╖': 'M , L , z', + '╗': 'M , L , z', + '╘': 'M , L , z', + '╙': 'M , L , z', + '╚': 'M , L , z', + '╛': 'M , L , z', + '╜': 'M , L , z', + '╝': 'M , L , z', + '╞': 'M , L , z', + '╟': 'M , L , z', + '╠': 'M , L , z', + '╡': 'M , L , z', + '╢': 'M , L , z', + '╣': 'M , L , z', + '╤': 'M , L , z', + '╥': 'M , L , z', + '╦': 'M , L , z', + '╧': 'M , L , z', + '╨': 'M , L , z', + '╩': 'M , L , z', + '╪': 'M , L , z', + '╫': 'M , L , z', + '╬': 'M , L , z', + '╭': 'M , L , z', + '╮': 'M , L , z', + '╯': 'M , L , z', + '╰': 'M , L , z', + '╱': 'M , L , z', + '╲': 'M , L , z', + '╳': 'M , L , z', + '╴': 'M , L , z', + '╵': 'M , L , z', + '╶': 'M , L , z', + '╷': 'M , L , z', + '╸': 'M , L , z', + '╹': 'M , L , z', + '╺': 'M , L , z', + '╻': 'M , L , z', + '╼': 'M , L , z', + '╽': 'M , L , z', + '╾': 'M , L , z', + '╿': 'M0,0, L0,10 z' +}; + +export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { + const entry = chars[c]; + console.log(c); + if (!entry) { + return; + } + const instructions = entry.split(' '); + for (const instruction of instructions) { + if (instruction.endsWith('!')) { + ctx.lineWidth = ctx.lineWidth * 2; + } + const type = instruction[0]; + const spec = instructionMap[type]; + const coords: string[] = instruction.substring(1).split(','); + if (!coords[0] || !coords[1]) { + continue; + } + + + const numX = Number.parseFloat(coords[0].toString()) || Number.parseInt(coords[0].toString()); + const numY = Number.parseFloat(coords[1].toString()) || Number.parseInt(coords[1].toString()); + spec(ctx, xOffset + Math.round((numX)*cellWidth), yOffset + ((numY))*cellHeight); + } + ctx.stroke(); +} + +const instructionMap: { [index: string]: any } = { + 'M': (ctx: CanvasRenderingContext2D, x: number, y: number) => { + ctx.beginPath(); + ctx.moveTo(x, y); + }, + 'L': (ctx: CanvasRenderingContext2D, x: number, y: number) => { + ctx.lineTo(x, y); + }, + 'z': (ctx: CanvasRenderingContext2D) => { + ctx.closePath(); + console.log('closing path'); + } +}; diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 5758957e..710f6164 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -133,21 +133,22 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { // Setup WriteBuffer this._writeBuffer = new WriteBuffer((data, promiseResult) => this._inputHandler.parse(data, promiseResult)); setTimeout(() => { - this.write('─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏\r\n'); - this.write('┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟\r\n'); - this.write('┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯\r\n'); - this.write('┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿\r\n'); - this.write('╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏\r\n'); - this.write('═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟\r\n'); - this.write('╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯\r\n'); - this.write('╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\r\n'); - this.write('▇▇▇▇▇▇▇▇▇'); - this.write(' ╔═════════════════════════════════════════════════════════╕\r\n'); - this.write(' ║ │\r\n'); - this.write(' ║ ╔═══════════════╦════════╤════════╗ │\r\n'); - this.write(' ║ ║ ║ │ ║ │\r\n'); - this.write(' ║ ║ ║ │ ║ │\r\n'); - }, 1500); + // this.write('─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏\r\n'); + // this.write('┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟\r\n'); + // this.write('┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯\r\n'); + // this.write('┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿\r\n'); + // this.write('╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏\r\n'); + // this.write('═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟\r\n'); + // this.write('╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯\r\n'); + // this.write('╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\r\n'); + // this.write(' ╔═════════════════════════════════════════════════════════╕\r\n'); + // this.write(' ║ │\r\n'); + // this.write(' ║ ╔═══════════════╦════════╤════════╗ │\r\n'); + // this.write(' ║ ║ ║ │ ║ │\r\n'); + // this.write(' ║ ║ ║ │ ║ │\r\n'); + // this.write('▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇'); + this.write('━│┃'); + }, 1000); } public dispose(): void { From db845a6f24c9492199081eb0f569acc0871e4de7 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 11 Aug 2021 14:14:17 -0700 Subject: [PATCH 282/377] make a bunch of progress --- src/browser/renderer/BaseRenderLayer.ts | 3 +- src/browser/renderer/BoxAndBlockCharacters.ts | 282 ++++++++++-------- src/common/CoreTerminal.ts | 4 +- 3 files changed, 156 insertions(+), 133 deletions(-) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 0fbd9455..39819353 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -422,7 +422,8 @@ export abstract class BaseRenderLayer implements IRenderLayer { // increase # of pixels when font size incremented by 10 this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); const horizontalCenter = Math.round(this._scaledCellWidth / 2); - draw(this._ctx, char, xOffset, yOffset - verticalCenter, this._scaledCellWidth, this._scaledCellHeight); + // yOffset - verticalCenter + draw(this._ctx, char, xOffset, y * this._scaledCellHeight + this._scaledCharTop, this._scaledCellWidth, this._scaledCellHeight); return true; diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index eda53725..de8a349c 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -212,152 +212,173 @@ export const boxDrawingBoxes: { [index: string]: any } = { '\u{1FB97}': [{ x: 0, y: 2, w: 8, h: 2 }, { x: 0, y: 6, w: 8, h: 2 }] }; +export const enum CENTER { + BOTTOM ='.5,1', + TOP = '.5,0', + MIDDLE = '.5,.5' +} + +export const enum LEFT { + BOTTOM = '0,1', + TOP = '0,0', + MIDDLE = '0,.5' +} + +export const enum RIGHT { + BOTTOM = '1,1', + TOP = '1,0', + MIDDLE = '1,.5' +} + +const MOVE = 'M'; +const TO = 'L'; +const BOLD = '!'; + export const chars: { [index: string]: string } = { - '━': 'M0,.5, L1,.5 z', - '│': 'M0,0, L0,2 z', - '┃': 'M0,0, L0,2 z!', - '┌': 'M , L , z', - '┍': 'M , L , z', - '┎': 'M , L , z', - '┏': 'M , L , z', - '┐': 'M , L , z', - '┑': 'M , L , z', - '┒': 'M , L , z', - '┓': 'M , L , z', - '└': 'M , L , z', - '┕': 'M , L , z', - '┖': 'M , L , z', - '┗': 'M , L , z', - '┘': 'M , L , z', - '┙': 'M , L , z', - '┚': 'M , L , z', - '┛': 'M , L , z', - '├': 'M , L , z', - '┝': 'M , L , z', - '┞': 'M , L , z', - '┟': 'M , L , z', - '┠': 'M , L , z', - '┡': 'M , L , z', - '┢': 'M , L , z', - '┣': 'M , L , z', - '┤': 'M , L , z', - '┥': 'M , L , z', - '┦': 'M , L , z', - '┧': 'M , L , z', - '┨': 'M , L , z', - '┩': 'M , L , z', - '┪': 'M , L , z', - '┫': 'M , L , z', - '┬': 'M , L , z', - '┭': 'M , L , z', - '┮': 'M , L , z', - '┯': 'M , L , z', - '┰': 'M , L , z', - '┱': 'M , L , z', - '┲': 'M , L , z', - '┳': 'M , L , z', - '┴': 'M , L , z', - '┵': 'M , L , z', - '┶': 'M , L , z', - '┷': 'M , L , z', - '┸': 'M , L , z', - '┹': 'M , L , z', - '┺': 'M , L , z', - '┻': 'M , L , z', - '┼': 'M , L , z', - '┽': 'M , L , z', - '┾': 'M , L , z', - '┿': 'M , L , z', - '╀': 'M , L , z', - '╁': 'M , L , z', - '╂': 'M , L , z', - '╃': 'M , L , z', - '╄': 'M , L , z', - '╅': 'M , L , z', - '╆': 'M , L , z', - '╇': 'M , L , z', - '╈': 'M , L , z', - '╉': 'M , L , z', - '╊': 'M , L , z', - '╋': 'M , L , z', - '╌': 'M , L , z', - '╍': 'M , L , z', - '╎': 'M , L , z', - '╏': 'M , L , z', - '═': 'M , L , z', - '║': 'M , L , z', - '╒': 'M , L , z', - '╓': 'M , L , z', - '╔': 'M , L , z', - '╕': 'M , L , z', - '╖': 'M , L , z', - '╗': 'M , L , z', - '╘': 'M , L , z', - '╙': 'M , L , z', - '╚': 'M , L , z', - '╛': 'M , L , z', - '╜': 'M , L , z', - '╝': 'M , L , z', - '╞': 'M , L , z', - '╟': 'M , L , z', - '╠': 'M , L , z', - '╡': 'M , L , z', - '╢': 'M , L , z', - '╣': 'M , L , z', - '╤': 'M , L , z', - '╥': 'M , L , z', - '╦': 'M , L , z', - '╧': 'M , L , z', - '╨': 'M , L , z', - '╩': 'M , L , z', - '╪': 'M , L , z', - '╫': 'M , L , z', - '╬': 'M , L , z', - '╭': 'M , L , z', - '╮': 'M , L , z', - '╯': 'M , L , z', - '╰': 'M , L , z', - '╱': 'M , L , z', - '╲': 'M , L , z', - '╳': 'M , L , z', - '╴': 'M , L , z', - '╵': 'M , L , z', - '╶': 'M , L , z', - '╷': 'M , L , z', - '╸': 'M , L , z', - '╹': 'M , L , z', - '╺': 'M , L , z', - '╻': 'M , L , z', - '╼': 'M , L , z', - '╽': 'M , L , z', - '╾': 'M , L , z', - '╿': 'M0,0, L0,10 z' + '━': `${MOVE}${LEFT.MIDDLE} ${TO}${RIGHT.MIDDLE}`, + '│': `${MOVE}${CENTER.TOP} ${TO}${CENTER.BOTTOM}`, + '┃': `${MOVE}${CENTER.TOP} ${TO}${CENTER.BOTTOM}${BOLD}`, + '┌': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE} ${TO}${RIGHT.MIDDLE}`, + '┍': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE} ${TO}${RIGHT.MIDDLE}${BOLD}`, + '┎': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}${BOLD} ${TO}${RIGHT.MIDDLE}`, + '┏': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}${BOLD} ${TO}${RIGHT.MIDDLE}${BOLD}`, + '┐': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE} ${TO}${LEFT.MIDDLE}`, + '┑': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE} ${TO}${LEFT.MIDDLE}${BOLD}`, + '┒': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}${BOLD} ${TO}${LEFT.MIDDLE}`, + '┓': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}${BOLD} ${TO}${LEFT.MIDDLE}${BOLD}` + // '└': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┕': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┖': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┗': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┘': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┙': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┚': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┛': `${MOVE}${} ${TO}${} ${TO}${}`, + // '├': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┝': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┞': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┟': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┠': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┡': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┢': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┣': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┤': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┥': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┦': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┧': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┨': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┩': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┪': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┫': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┬': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┭': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┮': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┯': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┰': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┱': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┲': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┳': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┴': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┵': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┶': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┷': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┸': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┹': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┺': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┻': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┼': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┽': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┾': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┿': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╀': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╁': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╂': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╃': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╄': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╅': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╆': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╇': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╈': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╉': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╊': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╋': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╌': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╍': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╎': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╏': `${MOVE}${} ${TO}${} ${TO}${}`, + // '═': `${MOVE}${} ${TO}${} ${TO}${}`, + // '║': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╒': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╓': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╔': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╕': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╖': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╗': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╘': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╙': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╚': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╛': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╜': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╝': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╞': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╟': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╠': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╡': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╢': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╣': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╤': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╥': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╦': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╧': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╨': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╩': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╪': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╫': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╬': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╭': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╮': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╯': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╰': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╱': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╲': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╳': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╴': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╵': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╶': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╷': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╸': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╹': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╺': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╻': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╼': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╽': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╾': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╿': `${MOVE}${} ${TO}${} ${TO}${}` }; export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { const entry = chars[c]; - console.log(c); if (!entry) { return; } + const lineWidth = ctx.lineWidth; const instructions = entry.split(' '); for (const instruction of instructions) { - if (instruction.endsWith('!')) { - ctx.lineWidth = ctx.lineWidth * 2; - } const type = instruction[0]; const spec = instructionMap[type]; const coords: string[] = instruction.substring(1).split(','); if (!coords[0] || !coords[1]) { continue; } - - const numX = Number.parseFloat(coords[0].toString()) || Number.parseInt(coords[0].toString()); const numY = Number.parseFloat(coords[1].toString()) || Number.parseInt(coords[1].toString()); - spec(ctx, xOffset + Math.round((numX)*cellWidth), yOffset + ((numY))*cellHeight); + if (instruction.endsWith(BOLD)) { + ctx.lineWidth = lineWidth * 2; + } else { + ctx.lineWidth = lineWidth; + } + spec(ctx, xOffset + Math.round((numX) * cellWidth), yOffset + ((numY)) * cellHeight); } - ctx.stroke(); } const instructionMap: { [index: string]: any } = { @@ -367,9 +388,8 @@ const instructionMap: { [index: string]: any } = { }, 'L': (ctx: CanvasRenderingContext2D, x: number, y: number) => { ctx.lineTo(x, y); - }, - 'z': (ctx: CanvasRenderingContext2D) => { - ctx.closePath(); - console.log('closing path'); + ctx.stroke(); + ctx.beginPath(); + ctx.moveTo(x, y); } }; diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 710f6164..32341d8d 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -147,7 +147,9 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { // this.write(' ║ ║ ║ │ ║ │\r\n'); // this.write(' ║ ║ ║ │ ║ │\r\n'); // this.write('▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇'); - this.write('━│┃'); + this.write('━━│┃\r\n'); + this.write(' ━━│┃┌┍┎┏\r\n'); + this.write(' ━━│┃┌┐┍┑┎┒┏┓'); }, 1000); } From 57c7e6af4703cd4040da36baa36bd3f47a166e14 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 11 Aug 2021 15:19:12 -0700 Subject: [PATCH 283/377] add more characters --- src/browser/renderer/BoxAndBlockCharacters.ts | 147 ++++++++++-------- src/common/CoreTerminal.ts | 7 +- 2 files changed, 84 insertions(+), 70 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index de8a349c..b57a9c56 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -232,76 +232,85 @@ export const enum RIGHT { const MOVE = 'M'; const TO = 'L'; -const BOLD = '!'; +const THICK = '!'; + +const yAxis = `${MOVE}${CENTER.TOP} ${TO}${CENTER.BOTTOM}`; +const xAxis = `${MOVE}${LEFT.MIDDLE} ${TO}${RIGHT.MIDDLE}`; +const bottomYAxisFromBottom = `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}`; +const bottomYAxisFromMiddle = `${MOVE}${CENTER.MIDDLE} ${TO}${CENTER.BOTTOM}`; +const topYAxisFromTop = `${MOVE}${CENTER.TOP} ${TO}${CENTER.MIDDLE}`; +const topYAxisFromMiddle = `${MOVE}${CENTER.TOP} ${TO}${CENTER.MIDDLE}`; +const rightMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${RIGHT.MIDDLE}`; +const leftMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${LEFT.MIDDLE}`; export const chars: { [index: string]: string } = { - '━': `${MOVE}${LEFT.MIDDLE} ${TO}${RIGHT.MIDDLE}`, - '│': `${MOVE}${CENTER.TOP} ${TO}${CENTER.BOTTOM}`, - '┃': `${MOVE}${CENTER.TOP} ${TO}${CENTER.BOTTOM}${BOLD}`, - '┌': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE} ${TO}${RIGHT.MIDDLE}`, - '┍': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE} ${TO}${RIGHT.MIDDLE}${BOLD}`, - '┎': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}${BOLD} ${TO}${RIGHT.MIDDLE}`, - '┏': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}${BOLD} ${TO}${RIGHT.MIDDLE}${BOLD}`, - '┐': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE} ${TO}${LEFT.MIDDLE}`, - '┑': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE} ${TO}${LEFT.MIDDLE}${BOLD}`, - '┒': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}${BOLD} ${TO}${LEFT.MIDDLE}`, - '┓': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}${BOLD} ${TO}${LEFT.MIDDLE}${BOLD}` - // '└': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┕': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┖': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┗': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┘': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┙': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┚': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┛': `${MOVE}${} ${TO}${} ${TO}${}`, - // '├': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┝': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┞': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┟': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┠': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┡': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┢': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┣': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┤': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┥': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┦': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┧': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┨': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┩': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┪': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┫': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┬': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┭': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┮': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┯': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┰': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┱': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┲': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┳': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┴': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┵': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┶': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┷': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┸': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┹': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┺': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┻': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┼': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┽': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┾': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┿': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╀': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╁': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╂': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╃': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╄': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╅': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╆': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╇': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╈': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╉': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╊': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╋': `${MOVE}${} ${TO}${} ${TO}${}`, + '━': `${xAxis}`, + '│': `${yAxis}`, + '┃': `${yAxis}${THICK}`, + '┌': `${bottomYAxisFromBottom} ${TO}${RIGHT.MIDDLE}`, + '┍': `${bottomYAxisFromBottom} ${TO}${RIGHT.MIDDLE}${THICK}`, + '┎': `${bottomYAxisFromBottom}${THICK} ${TO}${RIGHT.MIDDLE}`, + '┏': `${bottomYAxisFromBottom}${THICK} ${TO}${RIGHT.MIDDLE}${THICK}`, + '┐': `${bottomYAxisFromBottom} ${TO}${LEFT.MIDDLE}`, + '┑': `${bottomYAxisFromBottom} ${TO}${LEFT.MIDDLE}${THICK}`, + '┒': `${bottomYAxisFromBottom}${THICK} ${TO}${LEFT.MIDDLE}`, + '┓': `${bottomYAxisFromBottom}${THICK} ${TO}${LEFT.MIDDLE}${THICK}`, + '└': `${topYAxisFromTop} ${TO}${RIGHT.MIDDLE}`, + '┕': `${topYAxisFromTop} ${TO}${RIGHT.MIDDLE}${THICK}`, + '┖': `${topYAxisFromTop}${THICK} ${TO}${RIGHT.MIDDLE}`, + '┗': `${topYAxisFromTop}${THICK} ${TO}${RIGHT.MIDDLE}${THICK}`, + '┘': `${topYAxisFromTop} ${TO}${LEFT.MIDDLE}`, + '┙': `${topYAxisFromTop} ${TO}${LEFT.MIDDLE}${THICK}`, + '┚': `${topYAxisFromTop}${THICK} ${TO}${LEFT.MIDDLE}`, + '┛': `${topYAxisFromTop}${THICK} ${TO}${LEFT.MIDDLE}${THICK}`, + '├': `${yAxis} ${rightMiddleXAxis}`, + '┝': `${yAxis} ${rightMiddleXAxis}${THICK}`, + '┞': `${topYAxisFromTop}${THICK} ${bottomYAxisFromMiddle} ${rightMiddleXAxis}`, + '┟': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${rightMiddleXAxis}${THICK}`, + '┠': `${yAxis}${THICK} ${rightMiddleXAxis}`, + '┡': `${bottomYAxisFromBottom} ${topYAxisFromMiddle}${THICK} ${rightMiddleXAxis}${THICK}`, + '┢': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${rightMiddleXAxis}${THICK}`, + '┣': `${yAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + '┤': `${yAxis} ${leftMiddleXAxis}`, + '┥': `${yAxis} ${leftMiddleXAxis}${THICK}`, + '┦': `${topYAxisFromTop}${THICK} ${bottomYAxisFromMiddle} ${leftMiddleXAxis}`, + '┧': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${leftMiddleXAxis}${THICK}`, + '┨': `${yAxis}${THICK} ${leftMiddleXAxis}`, + '┩': `${bottomYAxisFromBottom} ${topYAxisFromMiddle}${THICK} ${leftMiddleXAxis}${THICK}`, + '┪': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${leftMiddleXAxis}${THICK}`, + '┫': `${yAxis}${THICK} ${leftMiddleXAxis}${THICK}`, + '┬': `${bottomYAxisFromBottom} ${xAxis}`, + '┭': `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + '┮': `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + '┯': `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + '┰': `${bottomYAxisFromBottom}${THICK} ${xAxis}`, + '┱': `${bottomYAxisFromBottom}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + '┲': `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + '┳': `${bottomYAxisFromBottom}${THICK} ${xAxis}${THICK}`, + '┴': `${topYAxisFromTop} ${xAxis}`, + '┵': `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + '┶': `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + '┷': `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + '┸': `${topYAxisFromTop}${THICK} ${xAxis}`, + '┹': `${topYAxisFromTop}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + '┺': `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + '┻': `${topYAxisFromTop}${THICK} ${xAxis}${THICK}`, + '┼': `${yAxis} ${xAxis}`, + '┽': `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + '┾': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + '┿': `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + '╀': `${yAxis}${THICK} ${xAxis}`, + '╁': `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + '╂': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + '╃': `${yAxis}${THICK} ${xAxis}${THICK}`, + '╄': `${yAxis} ${xAxis}`, + '╅': `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + '╆': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + '╇': `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + '╈': `${yAxis}${THICK} ${xAxis}`, + '╉': `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + '╊': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + '╋': `${yAxis}${THICK} ${xAxis}${THICK}` // '╌': `${MOVE}${} ${TO}${} ${TO}${}`, // '╍': `${MOVE}${} ${TO}${} ${TO}${}`, // '╎': `${MOVE}${} ${TO}${} ${TO}${}`, @@ -372,7 +381,7 @@ export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, } const numX = Number.parseFloat(coords[0].toString()) || Number.parseInt(coords[0].toString()); const numY = Number.parseFloat(coords[1].toString()) || Number.parseInt(coords[1].toString()); - if (instruction.endsWith(BOLD)) { + if (instruction.endsWith(THICK)) { ctx.lineWidth = lineWidth * 2; } else { ctx.lineWidth = lineWidth; diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 32341d8d..7c3f0e03 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -149,7 +149,12 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { // this.write('▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇'); this.write('━━│┃\r\n'); this.write(' ━━│┃┌┍┎┏\r\n'); - this.write(' ━━│┃┌┐┍┑┎┒┏┓'); + this.write(' ━━│┃┌┐┍┑┎┒┏┓\r\n'); + this.write(' └┘┕┙┖┚┗┛\r\n'); + this.write('├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋╌╍╎╏═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬╭╮╯╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿\r\n'); + this.write('├ ┝ ┞ ┟ ┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯ ┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻\r\n'); + this.write('┼ ┽ ┾ ┿ ╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋\r\n'); + this.write('╌ ╍ ╎ ╏ ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯ ╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\r\n'); }, 1000); } From 927a1424809d2cbbb4888923cbcf0fd9b32eca5a Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 11 Aug 2021 15:36:29 -0700 Subject: [PATCH 284/377] add more --- src/browser/renderer/BoxAndBlockCharacters.ts | 34 +++++++++---------- src/common/CoreTerminal.ts | 6 ++-- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index b57a9c56..bbba5090 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -310,11 +310,11 @@ export const chars: { [index: string]: string } = { '╈': `${yAxis}${THICK} ${xAxis}`, '╉': `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, '╊': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '╋': `${yAxis}${THICK} ${xAxis}${THICK}` - // '╌': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╍': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╎': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╏': `${MOVE}${} ${TO}${} ${TO}${}`, + '╋': `${yAxis}${THICK} ${xAxis}${THICK}`, + '╌': `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}`, + '╍': `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'}${THICK} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}${THICK}`, + '╎':`${MOVE}${CENTER.BOTTOM} ${TO}${'.5,.3'} ${MOVE}${'.5,.7'} ${TO}${CENTER.TOP}`, + '╏':`${MOVE}${CENTER.BOTTOM} ${TO}${'.5,.3'}${THICK} ${MOVE}${'.5,.7'} ${TO}${CENTER.TOP}${THICK}`, // '═': `${MOVE}${} ${TO}${} ${TO}${}`, // '║': `${MOVE}${} ${TO}${} ${TO}${}`, // '╒': `${MOVE}${} ${TO}${} ${TO}${}`, @@ -351,18 +351,18 @@ export const chars: { [index: string]: string } = { // '╱': `${MOVE}${} ${TO}${} ${TO}${}`, // '╲': `${MOVE}${} ${TO}${} ${TO}${}`, // '╳': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╴': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╵': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╶': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╷': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╸': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╹': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╺': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╻': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╼': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╽': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╾': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╿': `${MOVE}${} ${TO}${} ${TO}${}` + '╴': `${leftMiddleXAxis}`, + '╵': `${topYAxisFromMiddle}`, + '╶': `${rightMiddleXAxis}`, + '╷': `${bottomYAxisFromMiddle}`, + '╸': `${leftMiddleXAxis}${THICK}`, + '╹': `${topYAxisFromMiddle}${THICK}`, + '╺': `${rightMiddleXAxis}${THICK}`, + '╻': `${bottomYAxisFromMiddle}${THICK}`, + '╼': `${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + '╽': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle}`, + '╾': `${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + '╿': `${bottomYAxisFromBottom} ${topYAxisFromMiddle}${THICK}` }; export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 7c3f0e03..a3026016 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -151,10 +151,12 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this.write(' ━━│┃┌┍┎┏\r\n'); this.write(' ━━│┃┌┐┍┑┎┒┏┓\r\n'); this.write(' └┘┕┙┖┚┗┛\r\n'); - this.write('├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋╌╍╎╏═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬╭╮╯╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿\r\n'); + this.write('├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋ ╌ ╍╎╏═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬\r\n'); + this.write('╭╮╯╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿\r\n'); this.write('├ ┝ ┞ ┟ ┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯ ┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻\r\n'); this.write('┼ ┽ ┾ ┿ ╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋\r\n'); - this.write('╌ ╍ ╎ ╏ ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯ ╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\r\n'); + this.write(' ╌ ╍ ╎ ╏ ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬\r\n'); + this.write('╭ ╮ ╯ ╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\r\n'); }, 1000); } From 46cb37876deea04f11401aad6a365f06a3a0b555 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 11 Aug 2021 15:46:50 -0700 Subject: [PATCH 285/377] more working --- src/browser/renderer/BoxAndBlockCharacters.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index bbba5090..379bc2d7 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -311,10 +311,10 @@ export const chars: { [index: string]: string } = { '╉': `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, '╊': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, '╋': `${yAxis}${THICK} ${xAxis}${THICK}`, - '╌': `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}`, - '╍': `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'}${THICK} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}${THICK}`, - '╎':`${MOVE}${CENTER.BOTTOM} ${TO}${'.5,.3'} ${MOVE}${'.5,.7'} ${TO}${CENTER.TOP}`, - '╏':`${MOVE}${CENTER.BOTTOM} ${TO}${'.5,.3'}${THICK} ${MOVE}${'.5,.7'} ${TO}${CENTER.TOP}${THICK}`, + '╌': `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}`, + '╍': `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'}${THICK} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}${THICK}`, + '╎':`${MOVE}${CENTER.TOP} ${TO}${'.5,.47'} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}`, + '╏':`${MOVE}${CENTER.TOP} ${TO}${'.5,.47'}${THICK} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}${THICK}`, // '═': `${MOVE}${} ${TO}${} ${TO}${}`, // '║': `${MOVE}${} ${TO}${} ${TO}${}`, // '╒': `${MOVE}${} ${TO}${} ${TO}${}`, From 34d6449d076d740a6e2e7fcebe311feb2624042a Mon Sep 17 00:00:00 2001 From: Chad Smith Date: Wed, 11 Aug 2021 23:40:25 -0700 Subject: [PATCH 286/377] add TermPair and gdbgui to real world uses list --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9d926afe..479c8113 100644 --- a/README.md +++ b/README.md @@ -162,21 +162,23 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**CoCalc**](https://cocalc.com/): Lots of free software pre-installed, to chat, collaborate, develop, program, publish, research, share, teach, in C++, HTML, Julia, Jupyter, LaTeX, Markdown, Python, R, SageMath, Scala, ... - [**Dank Domain**](https://www.DDgame.us/): Open source multiuser medieval game supporting old & new terminal emulation. - [**DockerStacks**](https://docker-stacks.com/): Local LAMP/LEMP development studio -- [**Codecademy**](https://codecademy.com/): Uses xterm.js in its courses on Bash. +- [**Codecademy**](https://codecademy.com/): Uses xterm.js in its courses on Bash. - [**Laravel Ssh Web Client**](https://github.com/roke22/Laravel-ssh-client): Laravel server inventory with ssh web client to connect at server using xterm.js - [**Repl.it**](https://repl.it): Collaborative browser based IDE with support for 50+ different languages. - [**TeleType**](https://github.com/akshaykmr/TeleType): cli tool that allows you to share your terminal online conveniently. Show off mad cli-fu, help a colleague, teach, or troubleshoot. - [**Intervue**](https://www.intervue.io): Pair programming for interviews. Multiple programming languages are supported, with results displayed by xterm.js. -- [**TRASA**](https://trasa.io): Zero trust access to Web, SSH, RDP, and Database services. +- [**TRASA**](https://trasa.io): Zero trust access to Web, SSH, RDP, and Database services. - [**Commas**](https://github.com/CyanSalt/commas): Commas is a hackable terminal and command runner. -- [**Devtron**](https://github.com/devtron-labs/devtron): Software Delivery Workflow For Kubernetes. +- [**Devtron**](https://github.com/devtron-labs/devtron): Software Delivery Workflow For Kubernetes. - [**NxShell**](https://github.com/nxshell/nxshell): An easy to use new terminal for SSH. - [**gifcast**](https://dstein64.github.io/gifcast/): Converts an asciinema cast to an animated GIF. - [**WizardWebssh**](https://gitlab.com/mikeramsey/wizardwebssh): A terminal with Pyqt5 Widget for embedding, which can be used as an ssh client to connect to your ssh servers. It is written in Python, based on tornado, paramiko, and xterm.js. -- [**Wizard Assistant**](https://wizardassistant.com/): Wizard Assistant comes with advanced automation tools, preloaded common and special time-saving commands, and a built-in SSH terminal. Now you can remotely administer, troubleshoot, and analyze any system with ease. +- [**Wizard Assistant**](https://wizardassistant.com/): Wizard Assistant comes with advanced automation tools, preloaded common and special time-saving commands, and a built-in SSH terminal. Now you can remotely administer, troubleshoot, and analyze any system with ease. - [**ucli**](https://github.com/tsadarsh/ucli): Command Line for everyone :family_man_woman_girl_boy: at [www.ucli.tech](https://www.ucli.tech). - [**Tess**](https://github.com/SquitchYT/Tess/): Simple Terminal Fully Customizable for Everyone. - [**HashiCorp Nomad**](https://www.nomadproject.io/): A container orchestrator with the ability to connect to remote tasks via a web interface using websockets and xterm.js. +- [**TermPair**](https://github.com/cs01/termpair): View and control terminals from your browser with end-to-end encryption +- [**gdbgui**](https://github.com/cs01/gdbgui): Browser-based frontend to gdb (gnu debugger) - [And much more...](https://github.com/xtermjs/xterm.js/network/dependents) Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it on our list. Note: Please add any new contributions to the end of the list only. From 7e7dcd991752be5c5e765e6878c607bc162844fe Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 04:51:21 -0700 Subject: [PATCH 287/377] Move node-test into headless folder --- bin/package_headless.js | 2 +- headless/.gitignore | 2 +- headless/.npmignore | 3 +++ headless/package.json | 9 +++++++++ headless/test/README.md | 9 +++++++++ {node-test => headless/test}/index.js | 0 {node-test => headless/test}/package.json | 0 node-test/README.md | 10 ---------- 8 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 headless/package.json create mode 100644 headless/test/README.md rename {node-test => headless/test}/index.js (100%) rename {node-test => headless/test}/package.json (100%) delete mode 100644 node-test/README.md diff --git a/bin/package_headless.js b/bin/package_headless.js index 0d4170df..0dcec90b 100644 --- a/bin/package_headless.js +++ b/bin/package_headless.js @@ -22,7 +22,7 @@ const xtermHeadlessPackageJson = { delete xtermHeadlessPackageJson['scripts']; delete xtermHeadlessPackageJson['devDependencies']; delete xtermHeadlessPackageJson['style']; -xtermHeadlessPackageJson.version += '-alpha1'; +xtermHeadlessPackageJson.version += '-alpha3'; fs.writeFileSync(join(headlessRoot, 'package.json'), JSON.stringify(xtermHeadlessPackageJson, null, 1)); console.log(fs.readFileSync(join(headlessRoot, 'package.json')).toString()); diff --git a/headless/.gitignore b/headless/.gitignore index aa6706ab..f1cf6c8d 100644 --- a/headless/.gitignore +++ b/headless/.gitignore @@ -1,4 +1,4 @@ lib-headless/ typings/ logo-full.png -package.json +./package.json diff --git a/headless/.npmignore b/headless/.npmignore index 41f2a3a9..c6b33260 100644 --- a/headless/.npmignore +++ b/headless/.npmignore @@ -1,2 +1,5 @@ # Include !typings/*.d.ts + +# Exclude +test/ diff --git a/headless/package.json b/headless/package.json new file mode 100644 index 00000000..d53761e7 --- /dev/null +++ b/headless/package.json @@ -0,0 +1,9 @@ +{ + "name": "xterm-headless", + "description": "A headless terminal component that runs in Node.js", + "version": "4.13.0-alpha3", + "main": "lib-headless/xterm-headless.js", + "types": "typings/xterm-headless.d.ts", + "repository": "https://github.com/xtermjs/xterm.js", + "license": "MIT" +} \ No newline at end of file diff --git a/headless/test/README.md b/headless/test/README.md new file mode 100644 index 00000000..e48da411 --- /dev/null +++ b/headless/test/README.md @@ -0,0 +1,9 @@ +This is a basic manual test for 'xterm-headless': + +```sh +# From repo root +yarn build +yarn package-headless +cd headless/test +node index.js +``` diff --git a/node-test/index.js b/headless/test/index.js similarity index 100% rename from node-test/index.js rename to headless/test/index.js diff --git a/node-test/package.json b/headless/test/package.json similarity index 100% rename from node-test/package.json rename to headless/test/package.json diff --git a/node-test/README.md b/node-test/README.md deleted file mode 100644 index cd346848..00000000 --- a/node-test/README.md +++ /dev/null @@ -1,10 +0,0 @@ -Cursory test that 'xterm-headless' works: - -``` -# From root of this repo -npm run compile # Outputs to out/headless -npx webpack --config webpack.config.headless.js # Outputs to lib -cd node-test -npm link ../lib/ -node index.js -``` From ec80fc9421e910bc97fc99fea4ba51ea00f7bdcf Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 04:51:49 -0700 Subject: [PATCH 288/377] Remove alpha from package.json version --- bin/package_headless.js | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/package_headless.js b/bin/package_headless.js index 0dcec90b..d002a95e 100644 --- a/bin/package_headless.js +++ b/bin/package_headless.js @@ -22,7 +22,6 @@ const xtermHeadlessPackageJson = { delete xtermHeadlessPackageJson['scripts']; delete xtermHeadlessPackageJson['devDependencies']; delete xtermHeadlessPackageJson['style']; -xtermHeadlessPackageJson.version += '-alpha3'; fs.writeFileSync(join(headlessRoot, 'package.json'), JSON.stringify(xtermHeadlessPackageJson, null, 1)); console.log(fs.readFileSync(join(headlessRoot, 'package.json')).toString()); From e96b472edea9305ea306b6bddb6ef584fe481fa9 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 05:35:20 -0700 Subject: [PATCH 289/377] Start on headless unit tests --- src/headless/Terminal.test.ts | 27 -- src/headless/public/Terminal.test.ts | 547 +++++++++++++++++++++++++++ test/api/Terminal.api.ts | 18 +- 3 files changed, 553 insertions(+), 39 deletions(-) delete mode 100644 src/headless/Terminal.test.ts create mode 100644 src/headless/public/Terminal.test.ts diff --git a/src/headless/Terminal.test.ts b/src/headless/Terminal.test.ts deleted file mode 100644 index 07f90436..00000000 --- a/src/headless/Terminal.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2016 The xterm.js authors. All rights reserved. - * @license MIT - */ - -import { deepStrictEqual, throws } from 'assert'; -import { Terminal } from 'headless/public/Terminal'; - -const INIT_COLS = 80; -const INIT_ROWS = 24; - -describe('Headless Terminal', () => { - let term: Terminal; - const termOptions = { - cols: INIT_COLS, - rows: INIT_ROWS - }; - - beforeEach(() => { - term = new Terminal(termOptions); - }); - - it('should throw when trying to change cols or rows', () => { - throws(() => term.setOption('cols', 1000)); - throws(() => term.setOption('rows', 1000)); - }); -}); diff --git a/src/headless/public/Terminal.test.ts b/src/headless/public/Terminal.test.ts new file mode 100644 index 00000000..9f45b78e --- /dev/null +++ b/src/headless/public/Terminal.test.ts @@ -0,0 +1,547 @@ +/** + * Copyright (c) 2019 The xterm.js authors. All rights reserved. + * @license MIT + */ + +import { strictEqual, throws } from 'assert'; +import { Terminal } from 'headless/public/Terminal'; + +let term: Terminal; + +describe.only('Headless API Tests', function(): void { + beforeEach(() => { + // Create default terminal to be used by most tests + term = new Terminal(); + }); + + it('Default options', async () => { + strictEqual(term.cols, 80); + strictEqual(term.rows, 24); + }); + + it('Proposed API check', async () => { + term = new Terminal({ allowProposedApi: false }); + throws(() => term.buffer, (error) => error.message === 'You must set the allowProposedApi option to true to use proposed API'); + }); + + it('write', async () => { + await writeSync('foo'); + await writeSync('bar'); + await writeSync('文'); + lineEquals(0, 'foobar文'); + }); + + it('write with callback', async () => { + let result: string | undefined; + await new Promise(r => { + term.write('foo', () => { result = 'a'; }); + term.write('bar', () => { result += 'b'; }); + term.write('文', () => { + result += 'c'; + r(); + }); + }); + lineEquals(0, 'foobar文'); + strictEqual(result, 'abc'); + }); + + it('write - bytes (UTF8)', async () => { + await writeSync(new Uint8Array([102, 111, 111])); // foo + await writeSync(new Uint8Array([98, 97, 114])); // bar + await writeSync(new Uint8Array([230, 150, 135])); // 文 + lineEquals(0, 'foobar文'); + }); + + it('write - bytes (UTF8) with callback', async () => { + let result: string | undefined; + await new Promise(r => { + term.write(new Uint8Array([102, 111, 111]), () => { result = 'A'; }); // foo + term.write(new Uint8Array([98, 97, 114]), () => { result += 'B'; }); // bar + term.write(new Uint8Array([230, 150, 135]), () => { // 文 + result += 'C'; + r(); + }); + }); + lineEquals(0, 'foobar文'); + strictEqual(result, 'ABC'); + }); + + it('writeln', async () => { + await writelnSync('foo'); + await writelnSync('bar'); + await writelnSync('文'); + lineEquals(0, 'foo'); + lineEquals(1, 'bar'); + lineEquals(2, '文'); + }); + + it('writeln with callback', async () => { + let result: string | undefined; + await new Promise(r => { + term.writeln('foo', () => { result = '1'; }); + term.writeln('bar', () => { result += '2'; }); + term.writeln('文', () => { + result += '3'; + r(); + }); + }); + lineEquals(0, 'foo'); + lineEquals(1, 'bar'); + lineEquals(2, '文'); + strictEqual(result, '123'); + }); + + it('writeln - bytes (UTF8)', async () => { + await writelnSync(new Uint8Array([102, 111, 111])); + await writelnSync(new Uint8Array([98, 97, 114])); + await writelnSync(new Uint8Array([230, 150, 135])); + lineEquals(0, 'foo'); + lineEquals(1, 'bar'); + lineEquals(2, '文'); + }); + + it('clear', async () => { + term = new Terminal({ rows: 5 }); + for (let i = 0; i < 10; i++) { + await writeSync('\n\rtest' + i); + } + term.clear(); + strictEqual(term.buffer.active.length, 5); + lineEquals(0, 'test9'); + for (let i = 1; i < 5; i++) { + lineEquals(i, ''); + } + }); + + // it('getOption, setOption', async () => { + // await openTerminal(page); + // assert.equal(await page.evaluate(`window.term.getOption('rendererType')`), 'canvas'); + // await page.evaluate(`window.term.setOption('rendererType', 'dom')`); + // assert.equal(await page.evaluate(`window.term.getOption('rendererType')`), 'dom'); + // }); + + // describe('renderer', () => { + // it('foreground', async () => { + // await openTerminal(page, { rendererType: 'dom' }); + // await writeSync(page, '\\x1b[30m0\\x1b[31m1\\x1b[32m2\\x1b[33m3\\x1b[34m4\\x1b[35m5\\x1b[36m6\\x1b[37m7'); + // await pollFor(page, `document.querySelectorAll('.xterm-rows > :nth-child(1) > *').length`, 9); + // assert.deepEqual(await page.evaluate(` + // [ + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(1)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(2)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(3)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(4)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(5)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(6)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(7)').className + // ] + // `), [ + // 'xterm-fg-0', + // 'xterm-fg-1', + // 'xterm-fg-2', + // 'xterm-fg-3', + // 'xterm-fg-4', + // 'xterm-fg-5', + // 'xterm-fg-6' + // ]); + // }); + + // it('background', async () => { + // await openTerminal(page, { rendererType: 'dom' }); + // await writeSync(page, '\\x1b[40m0\\x1b[41m1\\x1b[42m2\\x1b[43m3\\x1b[44m4\\x1b[45m5\\x1b[46m6\\x1b[47m7'); + // await pollFor(page, `document.querySelectorAll('.xterm-rows > :nth-child(1) > *').length`, 9); + // assert.deepEqual(await page.evaluate(` + // [ + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(1)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(2)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(3)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(4)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(5)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(6)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(7)').className + // ] + // `), [ + // 'xterm-bg-0', + // 'xterm-bg-1', + // 'xterm-bg-2', + // 'xterm-bg-3', + // 'xterm-bg-4', + // 'xterm-bg-5', + // 'xterm-bg-6' + // ]); + // }); + // }); + + // it('selection', async () => { + // await openTerminal(page, { rows: 5, cols: 5 }); + // await writeSync(page, `\\n\\nfoo\\n\\n\\rbar\\n\\n\\rbaz`); + // assert.equal(await page.evaluate(`window.term.hasSelection()`), false); + // assert.equal(await page.evaluate(`window.term.getSelection()`), ''); + // assert.deepEqual(await page.evaluate(`window.term.getSelectionPosition()`), undefined); + // await page.evaluate(`window.term.selectAll()`); + // assert.equal(await page.evaluate(`window.term.hasSelection()`), true); + // if (process.platform === 'win32') { + // assert.equal(await page.evaluate(`window.term.getSelection()`), '\r\n\r\nfoo\r\n\r\nbar\r\n\r\nbaz'); + // } else { + // assert.equal(await page.evaluate(`window.term.getSelection()`), '\n\nfoo\n\nbar\n\nbaz'); + // } + // assert.deepEqual(await page.evaluate(`window.term.getSelectionPosition()`), { startColumn: 0, startRow: 0, endColumn: 5, endRow: 6 }); + // await page.evaluate(`window.term.clearSelection()`); + // assert.equal(await page.evaluate(`window.term.hasSelection()`), false); + // assert.equal(await page.evaluate(`window.term.getSelection()`), ''); + // assert.deepEqual(await page.evaluate(`window.term.getSelectionPosition()`), undefined); + // await page.evaluate(`window.term.select(1, 2, 2)`); + // assert.equal(await page.evaluate(`window.term.hasSelection()`), true); + // assert.equal(await page.evaluate(`window.term.getSelection()`), 'oo'); + // assert.deepEqual(await page.evaluate(`window.term.getSelectionPosition()`), { startColumn: 1, startRow: 2, endColumn: 3, endRow: 2 }); + // }); + + // it('focus, blur', async () => { + // await openTerminal(page); + // assert.equal(await page.evaluate(`document.activeElement.className`), ''); + // await page.evaluate(`window.term.focus()`); + // assert.equal(await page.evaluate(`document.activeElement.className`), 'xterm-helper-textarea'); + // await page.evaluate(`window.term.blur()`); + // assert.equal(await page.evaluate(`document.activeElement.className`), ''); + // }); + + // describe('loadAddon', () => { + // it('constructor', async () => { + // await openTerminal(page, { cols: 5 }); + // await page.evaluate(` + // window.cols = 0; + // window.term.loadAddon({ + // activate: (t) => window.cols = t.cols, + // dispose: () => {} + // }); + // `); + // assert.equal(await page.evaluate(`window.cols`), 5); + // }); + + // it('dispose (addon)', async () => { + // await openTerminal(page); + // await page.evaluate(` + // window.disposeCalled = false + // window.addon = { + // activate: () => {}, + // dispose: () => window.disposeCalled = true + // }; + // window.term.loadAddon(window.addon); + // `); + // assert.equal(await page.evaluate(`window.disposeCalled`), false); + // await page.evaluate(`window.addon.dispose()`); + // assert.equal(await page.evaluate(`window.disposeCalled`), true); + // }); + + // it('dispose (terminal)', async () => { + // await openTerminal(page); + // await page.evaluate(` + // window.disposeCalled = false + // window.term.loadAddon({ + // activate: () => {}, + // dispose: () => window.disposeCalled = true + // }); + // `); + // assert.equal(await page.evaluate(`window.disposeCalled`), false); + // await page.evaluate(`window.term.dispose()`); + // assert.equal(await page.evaluate(`window.disposeCalled`), true); + // }); + // }); + + // describe('Events', () => { + // it('onCursorMove', async () => { + // await openTerminal(page); + // await page.evaluate(` + // window.callCount = 0; + // window.term.onCursorMove(e => window.callCount++); + // window.term.write('foo'); + // `); + // await pollFor(page, `window.callCount`, 1); + // await page.evaluate(`window.term.write('bar')`); + // await pollFor(page, `window.callCount`, 2); + // }); + + // it('onData', async () => { + // await openTerminal(page); + // await page.evaluate(` + // window.calls = []; + // window.term.onData(e => calls.push(e)); + // `); + // await page.type('.xterm-helper-textarea', 'foo'); + // assert.deepEqual(await page.evaluate(`window.calls`), ['f', 'o', 'o']); + // }); + + // it('onKey', async () => { + // await openTerminal(page); + // await page.evaluate(` + // window.calls = []; + // window.term.onKey(e => calls.push(e.key)); + // `); + // await page.type('.xterm-helper-textarea', 'foo'); + // assert.deepEqual(await page.evaluate(`window.calls`), ['f', 'o', 'o']); + // }); + + // it('onLineFeed', async () => { + // await openTerminal(page); + // await page.evaluate(` + // window.callCount = 0; + // window.term.onLineFeed(() => callCount++); + // window.term.writeln('foo'); + // `); + // await pollFor(page, `window.callCount`, 1); + // await page.evaluate(`window.term.writeln('bar')`); + // await pollFor(page, `window.callCount`, 2); + // }); + + // it('onScroll', async () => { + // await openTerminal(page, { rows: 5 }); + // await page.evaluate(` + // window.calls = []; + // window.term.onScroll(e => window.calls.push(e)); + // for (let i = 0; i < 4; i++) { + // window.term.writeln('foo'); + // } + // `); + // await pollFor(page, `window.calls`, []); + // await page.evaluate(`window.term.writeln('bar')`); + // await pollFor(page, `window.calls`, [1]); + // await page.evaluate(`window.term.writeln('baz')`); + // await pollFor(page, `window.calls`, [1, 2]); + // }); + + // it('onSelectionChange', async () => { + // await openTerminal(page); + // await page.evaluate(` + // window.callCount = 0; + // window.term.onSelectionChange(() => window.callCount++); + // `); + // await pollFor(page, `window.callCount`, 0); + // await page.evaluate(`window.term.selectAll()`); + // await pollFor(page, `window.callCount`, 1); + // await page.evaluate(`window.term.clearSelection()`); + // await pollFor(page, `window.callCount`, 2); + // }); + + // it('onRender', async function(): Promise { + // this.retries(3); + // await openTerminal(page); + // await timeout(20); // Ensure all init events are fired + // await page.evaluate(` + // window.calls = []; + // window.term.onRender(e => window.calls.push([e.start, e.end])); + // `); + // await pollFor(page, `window.calls`, []); + // await page.evaluate(`window.term.write('foo')`); + // await pollFor(page, `window.calls`, [[0, 0]]); + // await page.evaluate(`window.term.write('bar\\n\\nbaz')`); + // await pollFor(page, `window.calls`, [[0, 0], [0, 2]]); + // }); + + // it('onResize', async () => { + // await openTerminal(page); + // await timeout(20); // Ensure all init events are fired + // await page.evaluate(` + // window.calls = []; + // window.term.onResize(e => window.calls.push([e.cols, e.rows])); + // `); + // await pollFor(page, `window.calls`, []); + // await page.evaluate(`window.term.resize(10, 5)`); + // await pollFor(page, `window.calls`, [[10, 5]]); + // await page.evaluate(`window.term.resize(20, 15)`); + // await pollFor(page, `window.calls`, [[10, 5], [20, 15]]); + // }); + + // it('onTitleChange', async () => { + // await openTerminal(page); + // await page.evaluate(` + // window.calls = []; + // window.term.onTitleChange(e => window.calls.push(e)); + // `); + // await pollFor(page, `window.calls`, []); + // await page.evaluate(`window.term.write('\\x1b]2;foo\\x9c')`); + // await pollFor(page, `window.calls`, ['foo']); + // }); + // it('onBell', async () => { + // await openTerminal(page); + // await page.evaluate(` + // window.calls = []; + // window.term.onBell(() => window.calls.push(true)); + // `); + // await pollFor(page, `window.calls`, []); + // await page.evaluate(`window.term.write('\\x07')`); + // await pollFor(page, `window.calls`, [true]); + // }); + // }); + + // describe('buffer', () => { + // it('cursorX, cursorY', async () => { + // await openTerminal(page, { rows: 5, cols: 5 }); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 0); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 0); + // await writeSync(page, 'foo'); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 3); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 0); + // await writeSync(page, '\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 3); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 1); + // await writeSync(page, '\\r'); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 0); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 1); + // await writeSync(page, 'abcde'); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 5); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 1); + // await writeSync(page, '\\n\\r\\n\\n\\n\\n\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 0); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 4); + // }); + + // it('viewportY', async () => { + // await openTerminal(page, { rows: 5 }); + // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 0); + // await writeSync(page, '\\n\\n\\n\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 0); + // await writeSync(page, '\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 1); + // await writeSync(page, '\\n\\n\\n\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 5); + // await page.evaluate(`window.term.scrollLines(-1)`); + // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 4); + // await page.evaluate(`window.term.scrollToTop()`); + // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 0); + // }); + + // it('baseY', async () => { + // await openTerminal(page, { rows: 5 }); + // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 0); + // await writeSync(page, '\\n\\n\\n\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 0); + // await writeSync(page, '\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 1); + // await writeSync(page, '\\n\\n\\n\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 5); + // await page.evaluate(`window.term.scrollLines(-1)`); + // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 5); + // await page.evaluate(`window.term.scrollToTop()`); + // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 5); + // }); + + // it('length', async () => { + // await openTerminal(page, { rows: 5 }); + // assert.equal(await page.evaluate(`window.term.buffer.active.length`), 5); + // await writeSync(page, '\\n\\n\\n\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.length`), 5); + // await writeSync(page, '\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.length`), 6); + // await writeSync(page, '\\n\\n\\n\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.length`), 10); + // }); + + // describe('getLine', () => { + // it('invalid index', async () => { + // await openTerminal(page, { rows: 5 }); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(-1)`), undefined); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(5)`), undefined); + // }); + + // it('isWrapped', async () => { + // await openTerminal(page, { cols: 5 }); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).isWrapped`), false); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(1).isWrapped`), false); + // await writeSync(page, 'abcde'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).isWrapped`), false); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(1).isWrapped`), false); + // await writeSync(page, 'f'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).isWrapped`), false); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(1).isWrapped`), true); + // }); + + // it('translateToString', async () => { + // await openTerminal(page, { cols: 5 }); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), ' '); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(true)`), ''); + // await writeSync(page, 'foo'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'foo '); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(true)`), 'foo'); + // await writeSync(page, 'bar'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'fooba'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(true)`), 'fooba'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(1).translateToString(true)`), 'r'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(false, 1)`), 'ooba'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(false, 1, 3)`), 'oo'); + // }); + + // it('getCell', async () => { + // await openTerminal(page, { cols: 5 }); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(-1)`), undefined); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(5)`), undefined); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(0).getChars()`), ''); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(0).getWidth()`), 1); + // await writeSync(page, 'a文'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(0).getChars()`), 'a'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(0).getWidth()`), 1); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(1).getChars()`), '文'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(1).getWidth()`), 2); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(2).getChars()`), ''); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(2).getWidth()`), 0); + // }); + // }); + + // it('active, normal, alternate', async () => { + // await openTerminal(page, { cols: 5 }); + // assert.equal(await page.evaluate(`window.term.buffer.active.type`), 'normal'); + // assert.equal(await page.evaluate(`window.term.buffer.normal.type`), 'normal'); + // assert.equal(await page.evaluate(`window.term.buffer.alternate.type`), 'alternate'); + + // await writeSync(page, 'norm '); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'norm '); + // assert.equal(await page.evaluate(`window.term.buffer.normal.getLine(0).translateToString()`), 'norm '); + // assert.equal(await page.evaluate(`window.term.buffer.alternate.getLine(0)`), undefined); + + // await writeSync(page, '\\x1b[?47h\\r'); // use alternate screen buffer + // assert.equal(await page.evaluate(`window.term.buffer.active.type`), 'alternate'); + // assert.equal(await page.evaluate(`window.term.buffer.normal.type`), 'normal'); + // assert.equal(await page.evaluate(`window.term.buffer.alternate.type`), 'alternate'); + + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), ' '); + // await writeSync(page, 'alt '); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'alt '); + // assert.equal(await page.evaluate(`window.term.buffer.normal.getLine(0).translateToString()`), 'norm '); + // assert.equal(await page.evaluate(`window.term.buffer.alternate.getLine(0).translateToString()`), 'alt '); + + // await writeSync(page, '\\x1b[?47l\\r'); // use normal screen buffer + // assert.equal(await page.evaluate(`window.term.buffer.active.type`), 'normal'); + // assert.equal(await page.evaluate(`window.term.buffer.normal.type`), 'normal'); + // assert.equal(await page.evaluate(`window.term.buffer.alternate.type`), 'alternate'); + + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'norm '); + // assert.equal(await page.evaluate(`window.term.buffer.normal.getLine(0).translateToString()`), 'norm '); + // assert.equal(await page.evaluate(`window.term.buffer.alternate.getLine(0)`), undefined); + // }); + // }); + + // it('dispose', async () => { + // await page.evaluate(` + // window.term = new Terminal(); + // window.term.dispose(); + // `); + // assert.equal(await page.evaluate(`window.term._core._isDisposed`), true); + // }); + + // it('dispose (opened)', async () => { + // await openTerminal(page); + // await page.evaluate(`window.term.dispose()`); + // assert.equal(await page.evaluate(`window.term._core._isDisposed`), true); + // }); +}); + +function writeSync(text: string | Uint8Array): Promise { + return new Promise(r => term.write(text, r)); +} + +function writelnSync(text: string | Uint8Array): Promise { + return new Promise(r => term.writeln(text, r)); +} + +function lineEquals(index: number, text: string): void { + strictEqual(term.buffer.active.getLine(index)!.translateToString(true), text); +} diff --git a/test/api/Terminal.api.ts b/test/api/Terminal.api.ts index 9e951ffe..75399b73 100644 --- a/test/api/Terminal.api.ts +++ b/test/api/Terminal.api.ts @@ -69,12 +69,9 @@ describe('API Integration Tests', function(): void { it('write - bytes (UTF8)', async () => { await openTerminal(page); await page.evaluate(` - // foo - window.term.write(new Uint8Array([102, 111, 111])); - // bar - window.term.write(new Uint8Array([98, 97, 114])); - // 文 - window.term.write(new Uint8Array([230, 150, 135])); + window.term.write(new Uint8Array([102, 111, 111])); // foo + window.term.write(new Uint8Array([98, 97, 114])); // bar + window.term.write(new Uint8Array([230, 150, 135])); // 文 `); await pollFor(page, `window.term.buffer.active.getLine(0).translateToString(true)`, 'foobar文'); }); @@ -82,12 +79,9 @@ describe('API Integration Tests', function(): void { it('write - bytes (UTF8) with callback', async () => { await openTerminal(page); await page.evaluate(` - // foo - window.term.write(new Uint8Array([102, 111, 111]), () => { window.__x = 'A'; }); - // bar - window.term.write(new Uint8Array([98, 97, 114]), () => { window.__x += 'B'; }); - // 文 - window.term.write(new Uint8Array([230, 150, 135]), () => { window.__x += 'C'; }); + window.term.write(new Uint8Array([102, 111, 111]), () => { window.__x = 'A'; }); // foo + window.term.write(new Uint8Array([98, 97, 114]), () => { window.__x += 'B'; }); // bar + window.term.write(new Uint8Array([230, 150, 135]), () => { window.__x += 'C'; }); // 文 `); await pollFor(page, `window.term.buffer.active.getLine(0).translateToString(true)`, 'foobar文'); await pollFor(page, `window.__x`, 'ABC'); From df48e9f6d5f54f30ad4b2fe15f0d978f68adef9d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 05:52:40 -0700 Subject: [PATCH 290/377] Headless event tests --- src/browser/public/Terminal.ts | 14 +- src/headless/public/Terminal.test.ts | 348 ++++++++------------------- src/headless/public/Terminal.ts | 10 +- typings/xterm-headless.d.ts | 13 + typings/xterm.d.ts | 38 +-- 5 files changed, 143 insertions(+), 280 deletions(-) diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index 8b7b5d2e..6af9db71 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -30,17 +30,17 @@ export class Terminal implements ITerminalApi { } } - public get onCursorMove(): IEvent { return this._core.onCursorMove; } - public get onLineFeed(): IEvent { return this._core.onLineFeed; } - public get onSelectionChange(): IEvent { return this._core.onSelectionChange; } - public get onData(): IEvent { return this._core.onData; } - public get onBinary(): IEvent { return this._core.onBinary; } - public get onTitleChange(): IEvent { return this._core.onTitleChange; } public get onBell(): IEvent { return this._core.onBell; } - public get onScroll(): IEvent { return this._core.onScroll; } + public get onBinary(): IEvent { return this._core.onBinary; } + public get onCursorMove(): IEvent { return this._core.onCursorMove; } + public get onData(): IEvent { return this._core.onData; } public get onKey(): IEvent<{ key: string, domEvent: KeyboardEvent }> { return this._core.onKey; } + public get onLineFeed(): IEvent { return this._core.onLineFeed; } public get onRender(): IEvent<{ start: number, end: number }> { return this._core.onRender; } public get onResize(): IEvent<{ cols: number, rows: number }> { return this._core.onResize; } + public get onScroll(): IEvent { return this._core.onScroll; } + public get onSelectionChange(): IEvent { return this._core.onSelectionChange; } + public get onTitleChange(): IEvent { return this._core.onTitleChange; } public get element(): HTMLElement | undefined { return this._core.element; } public get parser(): IParser { diff --git a/src/headless/public/Terminal.test.ts b/src/headless/public/Terminal.test.ts index 9f45b78e..f70a8127 100644 --- a/src/headless/public/Terminal.test.ts +++ b/src/headless/public/Terminal.test.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { strictEqual, throws } from 'assert'; +import { deepStrictEqual, strictEqual, throws } from 'assert'; import { Terminal } from 'headless/public/Terminal'; let term: Terminal; @@ -113,265 +113,113 @@ describe.only('Headless API Tests', function(): void { } }); - // it('getOption, setOption', async () => { - // await openTerminal(page); - // assert.equal(await page.evaluate(`window.term.getOption('rendererType')`), 'canvas'); - // await page.evaluate(`window.term.setOption('rendererType', 'dom')`); - // assert.equal(await page.evaluate(`window.term.getOption('rendererType')`), 'dom'); - // }); + it('getOption, setOption', async () => { + strictEqual(term.getOption('scrollback'), 1000); + term.setOption('scrollback', 50); + strictEqual(term.getOption('scrollback'), 50); + }); - // describe('renderer', () => { - // it('foreground', async () => { - // await openTerminal(page, { rendererType: 'dom' }); - // await writeSync(page, '\\x1b[30m0\\x1b[31m1\\x1b[32m2\\x1b[33m3\\x1b[34m4\\x1b[35m5\\x1b[36m6\\x1b[37m7'); - // await pollFor(page, `document.querySelectorAll('.xterm-rows > :nth-child(1) > *').length`, 9); - // assert.deepEqual(await page.evaluate(` - // [ - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(1)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(2)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(3)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(4)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(5)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(6)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(7)').className - // ] - // `), [ - // 'xterm-fg-0', - // 'xterm-fg-1', - // 'xterm-fg-2', - // 'xterm-fg-3', - // 'xterm-fg-4', - // 'xterm-fg-5', - // 'xterm-fg-6' - // ]); - // }); + describe('loadAddon', () => { + it('constructor', async () => { + term = new Terminal({ cols: 5 }); + let cols = 0; + term.loadAddon({ + activate: (t) => cols = t.cols, + dispose: () => {} + }); + strictEqual(cols, 5); + }); - // it('background', async () => { - // await openTerminal(page, { rendererType: 'dom' }); - // await writeSync(page, '\\x1b[40m0\\x1b[41m1\\x1b[42m2\\x1b[43m3\\x1b[44m4\\x1b[45m5\\x1b[46m6\\x1b[47m7'); - // await pollFor(page, `document.querySelectorAll('.xterm-rows > :nth-child(1) > *').length`, 9); - // assert.deepEqual(await page.evaluate(` - // [ - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(1)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(2)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(3)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(4)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(5)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(6)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(7)').className - // ] - // `), [ - // 'xterm-bg-0', - // 'xterm-bg-1', - // 'xterm-bg-2', - // 'xterm-bg-3', - // 'xterm-bg-4', - // 'xterm-bg-5', - // 'xterm-bg-6' - // ]); - // }); - // }); + it('dispose (addon)', async () => { + let disposeCalled = false; + const addon = { + activate: () => {}, + dispose: () => disposeCalled = true + }; + term.loadAddon(addon); + strictEqual(disposeCalled, false); + addon.dispose(); + strictEqual(disposeCalled, true); + }); - // it('selection', async () => { - // await openTerminal(page, { rows: 5, cols: 5 }); - // await writeSync(page, `\\n\\nfoo\\n\\n\\rbar\\n\\n\\rbaz`); - // assert.equal(await page.evaluate(`window.term.hasSelection()`), false); - // assert.equal(await page.evaluate(`window.term.getSelection()`), ''); - // assert.deepEqual(await page.evaluate(`window.term.getSelectionPosition()`), undefined); - // await page.evaluate(`window.term.selectAll()`); - // assert.equal(await page.evaluate(`window.term.hasSelection()`), true); - // if (process.platform === 'win32') { - // assert.equal(await page.evaluate(`window.term.getSelection()`), '\r\n\r\nfoo\r\n\r\nbar\r\n\r\nbaz'); - // } else { - // assert.equal(await page.evaluate(`window.term.getSelection()`), '\n\nfoo\n\nbar\n\nbaz'); - // } - // assert.deepEqual(await page.evaluate(`window.term.getSelectionPosition()`), { startColumn: 0, startRow: 0, endColumn: 5, endRow: 6 }); - // await page.evaluate(`window.term.clearSelection()`); - // assert.equal(await page.evaluate(`window.term.hasSelection()`), false); - // assert.equal(await page.evaluate(`window.term.getSelection()`), ''); - // assert.deepEqual(await page.evaluate(`window.term.getSelectionPosition()`), undefined); - // await page.evaluate(`window.term.select(1, 2, 2)`); - // assert.equal(await page.evaluate(`window.term.hasSelection()`), true); - // assert.equal(await page.evaluate(`window.term.getSelection()`), 'oo'); - // assert.deepEqual(await page.evaluate(`window.term.getSelectionPosition()`), { startColumn: 1, startRow: 2, endColumn: 3, endRow: 2 }); - // }); + it('dispose (terminal)', async () => { + let disposeCalled = false; + term.loadAddon({ + activate: () => {}, + dispose: () => disposeCalled = true + }); + strictEqual(disposeCalled, false); + term.dispose(); + strictEqual(disposeCalled, true); + }); + }); - // it('focus, blur', async () => { - // await openTerminal(page); - // assert.equal(await page.evaluate(`document.activeElement.className`), ''); - // await page.evaluate(`window.term.focus()`); - // assert.equal(await page.evaluate(`document.activeElement.className`), 'xterm-helper-textarea'); - // await page.evaluate(`window.term.blur()`); - // assert.equal(await page.evaluate(`document.activeElement.className`), ''); - // }); + describe('Events', () => { + it('onCursorMove', async () => { + let callCount = 0; + term.onCursorMove(e => callCount++); + await writeSync('foo'); + strictEqual(callCount, 1); + await writeSync('bar'); + strictEqual(callCount, 2); + }); - // describe('loadAddon', () => { - // it('constructor', async () => { - // await openTerminal(page, { cols: 5 }); - // await page.evaluate(` - // window.cols = 0; - // window.term.loadAddon({ - // activate: (t) => window.cols = t.cols, - // dispose: () => {} - // }); - // `); - // assert.equal(await page.evaluate(`window.cols`), 5); - // }); + it('onData', async () => { + const calls: string[] = []; + term.onData(e => calls.push(e)); + await writeSync('\x1b[5n'); // DSR Status Report + deepStrictEqual(calls, ['\x1b[0n']); + }); - // it('dispose (addon)', async () => { - // await openTerminal(page); - // await page.evaluate(` - // window.disposeCalled = false - // window.addon = { - // activate: () => {}, - // dispose: () => window.disposeCalled = true - // }; - // window.term.loadAddon(window.addon); - // `); - // assert.equal(await page.evaluate(`window.disposeCalled`), false); - // await page.evaluate(`window.addon.dispose()`); - // assert.equal(await page.evaluate(`window.disposeCalled`), true); - // }); + it('onLineFeed', async () => { + let callCount = 0; + term.onLineFeed(() => callCount++); + await writelnSync('foo'); + strictEqual(callCount, 1); + await writelnSync('bar'); + strictEqual(callCount, 2); + }); - // it('dispose (terminal)', async () => { - // await openTerminal(page); - // await page.evaluate(` - // window.disposeCalled = false - // window.term.loadAddon({ - // activate: () => {}, - // dispose: () => window.disposeCalled = true - // }); - // `); - // assert.equal(await page.evaluate(`window.disposeCalled`), false); - // await page.evaluate(`window.term.dispose()`); - // assert.equal(await page.evaluate(`window.disposeCalled`), true); - // }); - // }); + it('onScroll', async () => { + term = new Terminal({ rows: 5 }); + const calls: number[] = []; + term.onScroll(e => calls.push(e)); + for (let i = 0; i < 4; i++) { + await writelnSync('foo'); + } + deepStrictEqual(calls, []); + await writelnSync('bar'); + deepStrictEqual(calls, [1]); + await writelnSync('baz'); + deepStrictEqual(calls, [1, 2]); + }); - // describe('Events', () => { - // it('onCursorMove', async () => { - // await openTerminal(page); - // await page.evaluate(` - // window.callCount = 0; - // window.term.onCursorMove(e => window.callCount++); - // window.term.write('foo'); - // `); - // await pollFor(page, `window.callCount`, 1); - // await page.evaluate(`window.term.write('bar')`); - // await pollFor(page, `window.callCount`, 2); - // }); + it('onResize', async () => { + const calls: [number, number][] = []; + term.onResize(e => calls.push([e.cols, e.rows])); + deepStrictEqual(calls, []); + term.resize(10, 5); + deepStrictEqual(calls, [[10, 5]]); + term.resize(20, 15); + deepStrictEqual(calls, [[10, 5], [20, 15]]); + }); - // it('onData', async () => { - // await openTerminal(page); - // await page.evaluate(` - // window.calls = []; - // window.term.onData(e => calls.push(e)); - // `); - // await page.type('.xterm-helper-textarea', 'foo'); - // assert.deepEqual(await page.evaluate(`window.calls`), ['f', 'o', 'o']); - // }); + it('onTitleChange', async () => { + const calls: string[] = []; + term.onTitleChange(e => calls.push(e)); + deepStrictEqual(calls, []); + await writeSync('\x1b]2;foo\x9c'); + deepStrictEqual(calls, ['foo']); + }); - // it('onKey', async () => { - // await openTerminal(page); - // await page.evaluate(` - // window.calls = []; - // window.term.onKey(e => calls.push(e.key)); - // `); - // await page.type('.xterm-helper-textarea', 'foo'); - // assert.deepEqual(await page.evaluate(`window.calls`), ['f', 'o', 'o']); - // }); - - // it('onLineFeed', async () => { - // await openTerminal(page); - // await page.evaluate(` - // window.callCount = 0; - // window.term.onLineFeed(() => callCount++); - // window.term.writeln('foo'); - // `); - // await pollFor(page, `window.callCount`, 1); - // await page.evaluate(`window.term.writeln('bar')`); - // await pollFor(page, `window.callCount`, 2); - // }); - - // it('onScroll', async () => { - // await openTerminal(page, { rows: 5 }); - // await page.evaluate(` - // window.calls = []; - // window.term.onScroll(e => window.calls.push(e)); - // for (let i = 0; i < 4; i++) { - // window.term.writeln('foo'); - // } - // `); - // await pollFor(page, `window.calls`, []); - // await page.evaluate(`window.term.writeln('bar')`); - // await pollFor(page, `window.calls`, [1]); - // await page.evaluate(`window.term.writeln('baz')`); - // await pollFor(page, `window.calls`, [1, 2]); - // }); - - // it('onSelectionChange', async () => { - // await openTerminal(page); - // await page.evaluate(` - // window.callCount = 0; - // window.term.onSelectionChange(() => window.callCount++); - // `); - // await pollFor(page, `window.callCount`, 0); - // await page.evaluate(`window.term.selectAll()`); - // await pollFor(page, `window.callCount`, 1); - // await page.evaluate(`window.term.clearSelection()`); - // await pollFor(page, `window.callCount`, 2); - // }); - - // it('onRender', async function(): Promise { - // this.retries(3); - // await openTerminal(page); - // await timeout(20); // Ensure all init events are fired - // await page.evaluate(` - // window.calls = []; - // window.term.onRender(e => window.calls.push([e.start, e.end])); - // `); - // await pollFor(page, `window.calls`, []); - // await page.evaluate(`window.term.write('foo')`); - // await pollFor(page, `window.calls`, [[0, 0]]); - // await page.evaluate(`window.term.write('bar\\n\\nbaz')`); - // await pollFor(page, `window.calls`, [[0, 0], [0, 2]]); - // }); - - // it('onResize', async () => { - // await openTerminal(page); - // await timeout(20); // Ensure all init events are fired - // await page.evaluate(` - // window.calls = []; - // window.term.onResize(e => window.calls.push([e.cols, e.rows])); - // `); - // await pollFor(page, `window.calls`, []); - // await page.evaluate(`window.term.resize(10, 5)`); - // await pollFor(page, `window.calls`, [[10, 5]]); - // await page.evaluate(`window.term.resize(20, 15)`); - // await pollFor(page, `window.calls`, [[10, 5], [20, 15]]); - // }); - - // it('onTitleChange', async () => { - // await openTerminal(page); - // await page.evaluate(` - // window.calls = []; - // window.term.onTitleChange(e => window.calls.push(e)); - // `); - // await pollFor(page, `window.calls`, []); - // await page.evaluate(`window.term.write('\\x1b]2;foo\\x9c')`); - // await pollFor(page, `window.calls`, ['foo']); - // }); - // it('onBell', async () => { - // await openTerminal(page); - // await page.evaluate(` - // window.calls = []; - // window.term.onBell(() => window.calls.push(true)); - // `); - // await pollFor(page, `window.calls`, []); - // await page.evaluate(`window.term.write('\\x07')`); - // await pollFor(page, `window.calls`, [true]); - // }); - // }); + it('onBell', async () => { + const calls: boolean[] = []; + term.onBell(() => calls.push(true)); + deepStrictEqual(calls, []); + await writeSync('\x07'); + deepStrictEqual(calls, [true]); + }); + }); // describe('buffer', () => { // it('cursorX, cursorY', async () => { diff --git a/src/headless/public/Terminal.ts b/src/headless/public/Terminal.ts index f14bdd55..7a92da15 100644 --- a/src/headless/public/Terminal.ts +++ b/src/headless/public/Terminal.ts @@ -28,12 +28,14 @@ export class Terminal implements ITerminalApi { } } - public get onCursorMove(): IEvent { return this._core.onCursorMove; } - public get onLineFeed(): IEvent { return this._core.onLineFeed; } - public get onData(): IEvent { return this._core.onData; } + public get onBell(): IEvent { return this._core.onBell; } public get onBinary(): IEvent { return this._core.onBinary; } - public get onTitleChange(): IEvent { return this._core.onTitleChange; } + public get onCursorMove(): IEvent { return this._core.onCursorMove; } + public get onData(): IEvent { return this._core.onData; } + public get onLineFeed(): IEvent { return this._core.onLineFeed; } public get onResize(): IEvent<{ cols: number, rows: number }> { return this._core.onResize; } + public get onScroll(): IEvent { return this._core.onScroll; } + public get onTitleChange(): IEvent { return this._core.onTitleChange; } public get parser(): IParser { this._checkProposedApi(); diff --git a/typings/xterm-headless.d.ts b/typings/xterm-headless.d.ts index 3dd9d69e..66d8f191 100644 --- a/typings/xterm-headless.d.ts +++ b/typings/xterm-headless.d.ts @@ -533,6 +533,12 @@ declare module 'xterm-headless' { */ constructor(options?: ITerminalOptions); + /** + * Adds an event listener for when the bell is triggered. + * @returns an `IDisposable` to stop listening. + */ + onBell: IEvent; + /** * Adds an event listener for when a binary event fires. This is used to * enable non UTF-8 conformant binary messages to be sent to the backend. @@ -572,6 +578,13 @@ declare module 'xterm-headless' { */ onResize: IEvent<{ cols: number, rows: number }>; + /** + * Adds an event listener for when a scroll occurs. The event value is the + * new position of the viewport. + * @returns an `IDisposable` to stop listening. + */ + onScroll: IEvent; + /** * Adds an event listener for when an OSC 0 or OSC 2 title change occurs. * The event value is the new title. diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 6bfb71ae..035748fc 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -634,6 +634,12 @@ declare module 'xterm' { */ constructor(options?: ITerminalOptions); + /** + * Adds an event listener for when the bell is triggered. + * @returns an `IDisposable` to stop listening. + */ + onBell: IEvent; + /** * Adds an event listener for when a binary event fires. This is used to * enable non UTF-8 conformant binary messages to be sent to the backend. @@ -674,19 +680,6 @@ declare module 'xterm' { */ onLineFeed: IEvent; - /** - * Adds an event listener for when a scroll occurs. The event value is the - * new position of the viewport. - * @returns an `IDisposable` to stop listening. - */ - onScroll: IEvent; - - /** - * Adds an event listener for when a selection change occurs. - * @returns an `IDisposable` to stop listening. - */ - onSelectionChange: IEvent; - /** * Adds an event listener for when rows are rendered. The event value * contains the start row and end rows of the rendered area (ranges from `0` @@ -702,6 +695,19 @@ declare module 'xterm' { */ onResize: IEvent<{ cols: number, rows: number }>; + /** + * Adds an event listener for when a scroll occurs. The event value is the + * new position of the viewport. + * @returns an `IDisposable` to stop listening. + */ + onScroll: IEvent; + + /** + * Adds an event listener for when a selection change occurs. + * @returns an `IDisposable` to stop listening. + */ + onSelectionChange: IEvent; + /** * Adds an event listener for when an OSC 0 or OSC 2 title change occurs. * The event value is the new title. @@ -709,12 +715,6 @@ declare module 'xterm' { */ onTitleChange: IEvent; - /** - * Adds an event listener for when the bell is triggered. - * @returns an `IDisposable` to stop listening. - */ - onBell: IEvent; - /** * Unfocus the terminal. */ From f8066d6dee944799fc10ae118501f6515ca16700 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 06:00:55 -0700 Subject: [PATCH 291/377] Full tests for xterm-headless --- src/headless/public/Terminal.test.ts | 283 +++++++++++++-------------- src/headless/public/Terminal.ts | 18 ++ typings/xterm-headless.d.ts | 28 +++ 3 files changed, 183 insertions(+), 146 deletions(-) diff --git a/src/headless/public/Terminal.test.ts b/src/headless/public/Terminal.test.ts index f70a8127..15e1efba 100644 --- a/src/headless/public/Terminal.test.ts +++ b/src/headless/public/Terminal.test.ts @@ -8,7 +8,7 @@ import { Terminal } from 'headless/public/Terminal'; let term: Terminal; -describe.only('Headless API Tests', function(): void { +describe('Headless API Tests', function(): void { beforeEach(() => { // Create default terminal to be used by most tests term = new Terminal(); @@ -221,165 +221,156 @@ describe.only('Headless API Tests', function(): void { }); }); - // describe('buffer', () => { - // it('cursorX, cursorY', async () => { - // await openTerminal(page, { rows: 5, cols: 5 }); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 0); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 0); - // await writeSync(page, 'foo'); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 3); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 0); - // await writeSync(page, '\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 3); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 1); - // await writeSync(page, '\\r'); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 0); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 1); - // await writeSync(page, 'abcde'); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 5); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 1); - // await writeSync(page, '\\n\\r\\n\\n\\n\\n\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 0); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 4); - // }); + describe('buffer', () => { + it('cursorX, cursorY', async () => { + term = new Terminal({ rows: 5, cols: 5 }); + strictEqual(term.buffer.active.cursorX, 0); + strictEqual(term.buffer.active.cursorY, 0); + await writeSync('foo'); + strictEqual(term.buffer.active.cursorX, 3); + strictEqual(term.buffer.active.cursorY, 0); + await writeSync('\n'); + strictEqual(term.buffer.active.cursorX, 3); + strictEqual(term.buffer.active.cursorY, 1); + await writeSync('\r'); + strictEqual(term.buffer.active.cursorX, 0); + strictEqual(term.buffer.active.cursorY, 1); + await writeSync('abcde'); + strictEqual(term.buffer.active.cursorX, 5); + strictEqual(term.buffer.active.cursorY, 1); + await writeSync('\n\r\n\n\n\n\n'); + strictEqual(term.buffer.active.cursorX, 0); + strictEqual(term.buffer.active.cursorY, 4); + }); - // it('viewportY', async () => { - // await openTerminal(page, { rows: 5 }); - // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 0); - // await writeSync(page, '\\n\\n\\n\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 0); - // await writeSync(page, '\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 1); - // await writeSync(page, '\\n\\n\\n\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 5); - // await page.evaluate(`window.term.scrollLines(-1)`); - // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 4); - // await page.evaluate(`window.term.scrollToTop()`); - // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 0); - // }); + it('viewportY', async () => { + term = new Terminal({ rows: 5 }); + strictEqual(term.buffer.active.viewportY, 0); + await writeSync('\n\n\n\n'); + strictEqual(term.buffer.active.viewportY, 0); + await writeSync('\n'); + strictEqual(term.buffer.active.viewportY, 1); + await writeSync('\n\n\n\n'); + strictEqual(term.buffer.active.viewportY, 5); + term.scrollLines(-1); + strictEqual(term.buffer.active.viewportY, 4); + term.scrollToTop(); + strictEqual(term.buffer.active.viewportY, 0); + }); - // it('baseY', async () => { - // await openTerminal(page, { rows: 5 }); - // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 0); - // await writeSync(page, '\\n\\n\\n\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 0); - // await writeSync(page, '\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 1); - // await writeSync(page, '\\n\\n\\n\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 5); - // await page.evaluate(`window.term.scrollLines(-1)`); - // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 5); - // await page.evaluate(`window.term.scrollToTop()`); - // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 5); - // }); + it('baseY', async () => { + term = new Terminal({ rows: 5 }); + strictEqual(term.buffer.active.baseY, 0); + await writeSync('\n\n\n\n'); + strictEqual(term.buffer.active.baseY, 0); + await writeSync('\n'); + strictEqual(term.buffer.active.baseY, 1); + await writeSync('\n\n\n\n'); + strictEqual(term.buffer.active.baseY, 5); + term.scrollLines(-1); + strictEqual(term.buffer.active.baseY, 5); + term.scrollToTop(); + strictEqual(term.buffer.active.baseY, 5); + }); - // it('length', async () => { - // await openTerminal(page, { rows: 5 }); - // assert.equal(await page.evaluate(`window.term.buffer.active.length`), 5); - // await writeSync(page, '\\n\\n\\n\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.length`), 5); - // await writeSync(page, '\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.length`), 6); - // await writeSync(page, '\\n\\n\\n\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.length`), 10); - // }); + it('length', async () => { + term = new Terminal({ rows: 5 }); + strictEqual(term.buffer.active.length, 5); + await writeSync('\n\n\n\n'); + strictEqual(term.buffer.active.length, 5); + await writeSync('\n'); + strictEqual(term.buffer.active.length, 6); + await writeSync('\n\n\n\n'); + strictEqual(term.buffer.active.length, 10); + }); - // describe('getLine', () => { - // it('invalid index', async () => { - // await openTerminal(page, { rows: 5 }); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(-1)`), undefined); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(5)`), undefined); - // }); + describe('getLine', () => { + it('invalid index', async () => { + term = new Terminal({ rows: 5 }); + strictEqual(term.buffer.active.getLine(-1), undefined); + strictEqual(term.buffer.active.getLine(5), undefined); + }); - // it('isWrapped', async () => { - // await openTerminal(page, { cols: 5 }); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).isWrapped`), false); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(1).isWrapped`), false); - // await writeSync(page, 'abcde'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).isWrapped`), false); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(1).isWrapped`), false); - // await writeSync(page, 'f'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).isWrapped`), false); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(1).isWrapped`), true); - // }); + it('isWrapped', async () => { + term = new Terminal({ cols: 5 }); + strictEqual(term.buffer.active.getLine(0)!.isWrapped, false); + strictEqual(term.buffer.active.getLine(1)!.isWrapped, false); + await writeSync('abcde'); + strictEqual(term.buffer.active.getLine(0)!.isWrapped, false); + strictEqual(term.buffer.active.getLine(1)!.isWrapped, false); + await writeSync('f'); + strictEqual(term.buffer.active.getLine(0)!.isWrapped, false); + strictEqual(term.buffer.active.getLine(1)!.isWrapped, true); + }); - // it('translateToString', async () => { - // await openTerminal(page, { cols: 5 }); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), ' '); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(true)`), ''); - // await writeSync(page, 'foo'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'foo '); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(true)`), 'foo'); - // await writeSync(page, 'bar'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'fooba'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(true)`), 'fooba'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(1).translateToString(true)`), 'r'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(false, 1)`), 'ooba'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(false, 1, 3)`), 'oo'); - // }); + it('translateToString', async () => { + term = new Terminal({ cols: 5 }); + strictEqual(term.buffer.active.getLine(0)!.translateToString(), ' '); + strictEqual(term.buffer.active.getLine(0)!.translateToString(true), ''); + await writeSync('foo'); + strictEqual(term.buffer.active.getLine(0)!.translateToString(), 'foo '); + strictEqual(term.buffer.active.getLine(0)!.translateToString(true), 'foo'); + await writeSync('bar'); + strictEqual(term.buffer.active.getLine(0)!.translateToString(), 'fooba'); + strictEqual(term.buffer.active.getLine(0)!.translateToString(true), 'fooba'); + strictEqual(term.buffer.active.getLine(1)!.translateToString(true), 'r'); + strictEqual(term.buffer.active.getLine(0)!.translateToString(false, 1), 'ooba'); + strictEqual(term.buffer.active.getLine(0)!.translateToString(false, 1, 3), 'oo'); + }); - // it('getCell', async () => { - // await openTerminal(page, { cols: 5 }); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(-1)`), undefined); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(5)`), undefined); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(0).getChars()`), ''); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(0).getWidth()`), 1); - // await writeSync(page, 'a文'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(0).getChars()`), 'a'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(0).getWidth()`), 1); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(1).getChars()`), '文'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(1).getWidth()`), 2); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(2).getChars()`), ''); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(2).getWidth()`), 0); - // }); - // }); + it('getCell', async () => { + term = new Terminal({ cols: 5 }); + strictEqual(term.buffer.active.getLine(0)!.getCell(-1), undefined); + strictEqual(term.buffer.active.getLine(0)!.getCell(5), undefined); + strictEqual(term.buffer.active.getLine(0)!.getCell(0)!.getChars(), ''); + strictEqual(term.buffer.active.getLine(0)!.getCell(0)!.getWidth(), 1); + await writeSync('a文'); + strictEqual(term.buffer.active.getLine(0)!.getCell(0)!.getChars(), 'a'); + strictEqual(term.buffer.active.getLine(0)!.getCell(0)!.getWidth(), 1); + strictEqual(term.buffer.active.getLine(0)!.getCell(1)!.getChars(), '文'); + strictEqual(term.buffer.active.getLine(0)!.getCell(1)!.getWidth(), 2); + strictEqual(term.buffer.active.getLine(0)!.getCell(2)!.getChars(), ''); + strictEqual(term.buffer.active.getLine(0)!.getCell(2)!.getWidth(), 0); + }); + }); - // it('active, normal, alternate', async () => { - // await openTerminal(page, { cols: 5 }); - // assert.equal(await page.evaluate(`window.term.buffer.active.type`), 'normal'); - // assert.equal(await page.evaluate(`window.term.buffer.normal.type`), 'normal'); - // assert.equal(await page.evaluate(`window.term.buffer.alternate.type`), 'alternate'); + it('active, normal, alternate', async () => { + term = new Terminal({ cols: 5 }); + strictEqual(term.buffer.active.type, 'normal'); + strictEqual(term.buffer.normal.type, 'normal'); + strictEqual(term.buffer.alternate.type, 'alternate'); - // await writeSync(page, 'norm '); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'norm '); - // assert.equal(await page.evaluate(`window.term.buffer.normal.getLine(0).translateToString()`), 'norm '); - // assert.equal(await page.evaluate(`window.term.buffer.alternate.getLine(0)`), undefined); + await writeSync('norm '); + strictEqual(term.buffer.active.getLine(0)!.translateToString(), 'norm '); + strictEqual(term.buffer.normal.getLine(0)!.translateToString(), 'norm '); + strictEqual(term.buffer.alternate.getLine(0), undefined); - // await writeSync(page, '\\x1b[?47h\\r'); // use alternate screen buffer - // assert.equal(await page.evaluate(`window.term.buffer.active.type`), 'alternate'); - // assert.equal(await page.evaluate(`window.term.buffer.normal.type`), 'normal'); - // assert.equal(await page.evaluate(`window.term.buffer.alternate.type`), 'alternate'); + await writeSync('\x1b[?47h\r'); // use alternate screen buffer + strictEqual(term.buffer.active.type, 'alternate'); + strictEqual(term.buffer.normal.type, 'normal'); + strictEqual(term.buffer.alternate.type, 'alternate'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), ' '); - // await writeSync(page, 'alt '); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'alt '); - // assert.equal(await page.evaluate(`window.term.buffer.normal.getLine(0).translateToString()`), 'norm '); - // assert.equal(await page.evaluate(`window.term.buffer.alternate.getLine(0).translateToString()`), 'alt '); + strictEqual(term.buffer.active.getLine(0)!.translateToString(), ' '); + await writeSync('alt '); + strictEqual(term.buffer.active.getLine(0)!.translateToString(), 'alt '); + strictEqual(term.buffer.normal.getLine(0)!.translateToString(), 'norm '); + strictEqual(term.buffer.alternate.getLine(0)!.translateToString(), 'alt '); - // await writeSync(page, '\\x1b[?47l\\r'); // use normal screen buffer - // assert.equal(await page.evaluate(`window.term.buffer.active.type`), 'normal'); - // assert.equal(await page.evaluate(`window.term.buffer.normal.type`), 'normal'); - // assert.equal(await page.evaluate(`window.term.buffer.alternate.type`), 'alternate'); + await writeSync('\x1b[?47l\r'); // use normal screen buffer + strictEqual(term.buffer.active.type, 'normal'); + strictEqual(term.buffer.normal.type, 'normal'); + strictEqual(term.buffer.alternate.type, 'alternate'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'norm '); - // assert.equal(await page.evaluate(`window.term.buffer.normal.getLine(0).translateToString()`), 'norm '); - // assert.equal(await page.evaluate(`window.term.buffer.alternate.getLine(0)`), undefined); - // }); - // }); + strictEqual(term.buffer.active.getLine(0)!.translateToString(), 'norm '); + strictEqual(term.buffer.normal.getLine(0)!.translateToString(), 'norm '); + strictEqual(term.buffer.alternate.getLine(0), undefined); + }); + }); - // it('dispose', async () => { - // await page.evaluate(` - // window.term = new Terminal(); - // window.term.dispose(); - // `); - // assert.equal(await page.evaluate(`window.term._core._isDisposed`), true); - // }); - - // it('dispose (opened)', async () => { - // await openTerminal(page); - // await page.evaluate(`window.term.dispose()`); - // assert.equal(await page.evaluate(`window.term._core._isDisposed`), true); - // }); + it('dispose', async () => { + term.dispose(); + strictEqual((term as any)._core._isDisposed, true); + }); }); function writeSync(text: string | Uint8Array): Promise { diff --git a/src/headless/public/Terminal.ts b/src/headless/public/Terminal.ts index 7a92da15..a1de7fdb 100644 --- a/src/headless/public/Terminal.ts +++ b/src/headless/public/Terminal.ts @@ -77,6 +77,24 @@ export class Terminal implements ITerminalApi { this._addonManager.dispose(); this._core.dispose(); } + public scrollLines(amount: number): void { + this._verifyIntegers(amount); + this._core.scrollLines(amount); + } + public scrollPages(pageCount: number): void { + this._verifyIntegers(pageCount); + this._core.scrollPages(pageCount); + } + public scrollToTop(): void { + this._core.scrollToTop(); + } + public scrollToBottom(): void { + this._core.scrollToBottom(); + } + public scrollToLine(line: number): void { + this._verifyIntegers(line); + this._core.scrollToLine(line); + } public clear(): void { this._core.clear(); } diff --git a/typings/xterm-headless.d.ts b/typings/xterm-headless.d.ts index 66d8f191..03e7567a 100644 --- a/typings/xterm-headless.d.ts +++ b/typings/xterm-headless.d.ts @@ -620,6 +620,34 @@ declare module 'xterm-headless' { */ dispose(): void; + /** + * Scroll the display of the terminal + * @param amount The number of lines to scroll down (negative scroll up). + */ + scrollLines(amount: number): void; + + /** + * Scroll the display of the terminal by a number of pages. + * @param pageCount The number of pages to scroll (negative scrolls up). + */ + scrollPages(pageCount: number): void; + + /** + * Scrolls the display of the terminal to the top. + */ + scrollToTop(): void; + + /** + * Scrolls the display of the terminal to the bottom. + */ + scrollToBottom(): void; + + /** + * Scrolls to a line within the buffer. + * @param line The 0-based line index to scroll to. + */ + scrollToLine(line: number): void; + /** * Clear the entire buffer, making the prompt line the new first line. */ From f45f5b4b9f7f9923124f44f9f5d71afbde6ad068 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 06:11:30 -0700 Subject: [PATCH 292/377] Remove unneeded manual headless test --- headless/test/README.md | 9 --------- headless/test/index.js | 12 ------------ headless/test/package.json | 11 ----------- 3 files changed, 32 deletions(-) delete mode 100644 headless/test/README.md delete mode 100644 headless/test/index.js delete mode 100644 headless/test/package.json diff --git a/headless/test/README.md b/headless/test/README.md deleted file mode 100644 index e48da411..00000000 --- a/headless/test/README.md +++ /dev/null @@ -1,9 +0,0 @@ -This is a basic manual test for 'xterm-headless': - -```sh -# From repo root -yarn build -yarn package-headless -cd headless/test -node index.js -``` diff --git a/headless/test/index.js b/headless/test/index.js deleted file mode 100644 index 021f2ecd..00000000 --- a/headless/test/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import { createRequire } from 'module'; -const require = createRequire(import.meta.url); -const Terminal = require('../headless/lib-headless/xterm.js').Terminal; - -console.log('Creating xterm-headless terminal...'); -const terminal = new Terminal(); -console.log('Writing to terminal...') -terminal.write('foo \x1b[1;31mbar\x1b[0m baz', () => { - const bufferLine = terminal.buffer.normal.getLine(terminal.buffer.normal.cursorY); - const contents = bufferLine.translateToString(true); - console.log(`Contents of terminal active buffer are: ${contents}`); // foo bar baz -}); diff --git a/headless/test/package.json b/headless/test/package.json deleted file mode 100644 index 93549623..00000000 --- a/headless/test/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "test", - "version": "1.0.0", - "description": "", - "main": "index.js", - "type": "module", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "" -} From d694febdbff05268c99a048663be2f82d9fde4bc Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 06:19:15 -0700 Subject: [PATCH 293/377] Polish readme --- headless/README.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/headless/README.md b/headless/README.md index 358c97ef..1d2d6156 100644 --- a/headless/README.md +++ b/headless/README.md @@ -1,5 +1,31 @@ # [![xterm.js logo](logo-full.png)](https://xtermjs.org) -⚠ This package is a work in progress +⚠ This package is experimental `xterm-headless` is a headless terminal that can be run in node.js. This is useful in combination with the frontend [`xterm`](https://www.npmjs.com/package/xterm) for example to keep track of a terminal's state on a remote server where the process is hosted. + +## Getting Started + +First, you need to install the module, we ship exclusively through npm, so you need that installed and then add xterm.js as a dependency by running: + +```sh +npm install xterm-headless +``` + +Then import as you would a regular node package. The recommended way to load `xterm-headless` is with TypeScript and the ES6 module syntax: + +```javascript +import { Terminal } from 'xterm-headless'; +``` + +## API + +The full API for `xterm-headless` is contained within the [TypeScript declaration file](https://github.com/xtermjs/xterm.js/blob/master/typings/xterm-headless.d.ts), use the branch/tag picker in GitHub (`w`) to navigate to the correct version of the API. + +Note that some APIs are marked *experimental*, these are added to enable experimentation with new ideas without committing to support it like a normal [semver](https://semver.org/) API. Note that these APIs can change radically between versions, so be sure to read release notes if you plan on using experimental APIs. + +### Addons + +Addons in `xterm-headless` work the [same as in `xterm`](https://github.com/xtermjs/xterm.js/blob/master/README.md#addons) with the one caveat being that the addon needs to be packaged for node.js and not use any DOM APIs. + +Currently no official addons are packaged on npm. From 7f5af09f52279bb973c614ce907c0332fcf6447a Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 06:53:59 -0700 Subject: [PATCH 294/377] Include lib-headless in xterm-headless Part of #3212 --- headless/.npmignore | 1 + 1 file changed, 1 insertion(+) diff --git a/headless/.npmignore b/headless/.npmignore index c6b33260..83e9f201 100644 --- a/headless/.npmignore +++ b/headless/.npmignore @@ -1,5 +1,6 @@ # Include !typings/*.d.ts +!lib-headless/ # Exclude test/ From 0a287e01abcf82eb8bebf049f084abdb5c0cef44 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 07:20:38 -0700 Subject: [PATCH 295/377] Run yarn package before publishing Part of #2749 --- azure-pipelines.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c87496b2..5d4e9918 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -164,7 +164,9 @@ jobs: displayName: Cache node modules - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - - script: node ./bin/package_headless.js + - script: | + yarn package-headless + node ./bin/package_headless.js displayName: 'Package xterm-headless' - script: NPM_AUTH_TOKEN="$(NPM_AUTH_TOKEN)" node ./bin/publish.js displayName: 'Package and publish to npm' From d13afa1b37afc43f505ed573db576a469c75e2cf Mon Sep 17 00:00:00 2001 From: meganrogge Date: Thu, 12 Aug 2021 10:12:43 -0700 Subject: [PATCH 296/377] get things to work Co-authored-by: Daniel Imms --- src/browser/renderer/BaseRenderLayer.ts | 6 ++--- src/browser/renderer/BoxAndBlockCharacters.ts | 25 +++++++++++++++---- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 39819353..3d0128fe 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -412,7 +412,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { if (!lineSegments) { return false; } - const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; + const xOffset = x * this._scaledCellWidth; const verticalCenter = Math.round(this._scaledCellHeight / 2); const yOffset = y * this._scaledCellHeight + this._scaledCharTop + verticalCenter; @@ -420,10 +420,10 @@ export abstract class BaseRenderLayer implements IRenderLayer { this._ctx.strokeStyle = this._ctx.fillStyle; // increase # of pixels when font size incremented by 10 - this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); + // this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); const horizontalCenter = Math.round(this._scaledCellWidth / 2); // yOffset - verticalCenter - draw(this._ctx, char, xOffset, y * this._scaledCellHeight + this._scaledCharTop, this._scaledCellWidth, this._scaledCellHeight); + draw(this._ctx, char, xOffset, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); return true; diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 379bc2d7..0bbc487f 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -372,6 +372,7 @@ export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, } const lineWidth = ctx.lineWidth; const instructions = entry.split(' '); + for (const instruction of instructions) { const type = instruction[0]; const spec = instructionMap[type]; @@ -379,17 +380,31 @@ export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, if (!coords[0] || !coords[1]) { continue; } - const numX = Number.parseFloat(coords[0].toString()) || Number.parseInt(coords[0].toString()); - const numY = Number.parseFloat(coords[1].toString()) || Number.parseInt(coords[1].toString()); + let numX = Number.parseFloat(coords[0].toString()) || Number.parseInt(coords[0].toString()); + let numY = Number.parseFloat(coords[1].toString()) || Number.parseInt(coords[1].toString()); if (instruction.endsWith(THICK)) { - ctx.lineWidth = lineWidth * 2; + ctx.lineWidth = window.devicePixelRatio * 2; } else { - ctx.lineWidth = lineWidth; + ctx.lineWidth = window.devicePixelRatio; } - spec(ctx, xOffset + Math.round((numX) * cellWidth), yOffset + ((numY)) * cellHeight); + + numX *= cellWidth; + numY *= cellHeight; + + if (numY !== 0) { + numY = clamp(Math.round(numY + .5) - .5, cellHeight, 0); + } + if (numX !== 0) { + numX = clamp(Math.round(numX + .5) - .5, cellWidth, 0); + } + spec(ctx, xOffset + numX, yOffset + numY); } } +function clamp(value: number, max: number, min: number = 0): number { + return Math.max(Math.min(value, max), min); +} + const instructionMap: { [index: string]: any } = { 'M': (ctx: CanvasRenderingContext2D, x: number, y: number) => { ctx.beginPath(); From 91043858837b64d3c402d14d95d7686c9069baf0 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Thu, 12 Aug 2021 11:38:45 -0700 Subject: [PATCH 297/377] convert a bunch of them --- src/browser/renderer/BaseRenderLayer.ts | 67 --- src/browser/renderer/BoxAndBlockCharacters.ts | 515 +++++++++++++----- 2 files changed, 364 insertions(+), 218 deletions(-) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 3d0128fe..31773f64 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -421,76 +421,9 @@ export abstract class BaseRenderLayer implements IRenderLayer { // increase # of pixels when font size incremented by 10 // this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); - const horizontalCenter = Math.round(this._scaledCellWidth / 2); // yOffset - verticalCenter draw(this._ctx, char, xOffset, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); return true; - - - // // TODO: Clean below - // const scale = window.devicePixelRatio; - // this._ctx.strokeStyle = this._ctx.fillStyle; - - // // increase # of pixels when font size incremented by 10 - // this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); - - // const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; - // const yOffset = y * this._scaledCellHeight + this._scaledCharTop; - // const horizontalCenter = Math.round(this._scaledCellWidth / 2); - // const verticalCenter = Math.round(this._scaledCellHeight / 2); - // const xPoints = [ - // xOffset, - // xOffset + horizontalCenter - scale * 2, - // xOffset + horizontalCenter - scale, - // xOffset + horizontalCenter, - // xOffset + horizontalCenter + scale, - // xOffset + horizontalCenter + scale * 2, - // xOffset + this._scaledCellWidth - // ]; - // const yPoints = [ - // yOffset - 1, - // yOffset + verticalCenter - scale * 2, - // yOffset + verticalCenter - scale, - // yOffset + verticalCenter, - // yOffset + verticalCenter + scale, - // yOffset + verticalCenter + scale * 2, - // yOffset + this._scaledCellHeight - // ]; - - // for (let i = 0; i < lineSegments.length; i++) { - // const line = lineSegments[i]; - - // if (i === 0 || (line.x1 !== lineSegments[i - 1].x2 || line.y1 !== lineSegments[i - 1].y2)) { - // this._ctx.beginPath(); - // if (this._ctx.lineWidth % 2 === 1) { - // this._ctx.moveTo(line.x1 === 0 ? xPoints[line.x1] : xPoints[line.x1] + .5, yPoints[line.y1] + .5); - // } else { - // this._ctx.moveTo(xPoints[line.x1], yPoints[line.y1]); - // } - // } - - // if (typeof line.cx1 !== 'undefined') { - // // Draw curve - // this._ctx.bezierCurveTo( - // xPoints[line.cx1], - // yPoints[line.cy1], - // xPoints[line.cx2], - // yPoints[line.cy2], - // xPoints[line.x2], - // yPoints[line.y2]); - // } else { - // // Draw line - // if (this._ctx.lineWidth % 2 === 1) { - // this._ctx.lineTo(line.x2 === 0 ? xPoints[line.x2] : xPoints[line.x2] + .5, yPoints[line.y2] + .5); - // } else { - // this._ctx.lineTo(xPoints[line.x2], yPoints[line.y2]); - // } - // } - - // this._ctx.stroke(); - // } - - // return true; } diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 0bbc487f..1b6fef41 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -243,161 +243,378 @@ const topYAxisFromMiddle = `${MOVE}${CENTER.TOP} ${TO}${CENTER.MIDDLE}`; const rightMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${RIGHT.MIDDLE}`; const leftMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${LEFT.MIDDLE}`; -export const chars: { [index: string]: string } = { - '━': `${xAxis}`, - '│': `${yAxis}`, - '┃': `${yAxis}${THICK}`, - '┌': `${bottomYAxisFromBottom} ${TO}${RIGHT.MIDDLE}`, - '┍': `${bottomYAxisFromBottom} ${TO}${RIGHT.MIDDLE}${THICK}`, - '┎': `${bottomYAxisFromBottom}${THICK} ${TO}${RIGHT.MIDDLE}`, - '┏': `${bottomYAxisFromBottom}${THICK} ${TO}${RIGHT.MIDDLE}${THICK}`, - '┐': `${bottomYAxisFromBottom} ${TO}${LEFT.MIDDLE}`, - '┑': `${bottomYAxisFromBottom} ${TO}${LEFT.MIDDLE}${THICK}`, - '┒': `${bottomYAxisFromBottom}${THICK} ${TO}${LEFT.MIDDLE}`, - '┓': `${bottomYAxisFromBottom}${THICK} ${TO}${LEFT.MIDDLE}${THICK}`, - '└': `${topYAxisFromTop} ${TO}${RIGHT.MIDDLE}`, - '┕': `${topYAxisFromTop} ${TO}${RIGHT.MIDDLE}${THICK}`, - '┖': `${topYAxisFromTop}${THICK} ${TO}${RIGHT.MIDDLE}`, - '┗': `${topYAxisFromTop}${THICK} ${TO}${RIGHT.MIDDLE}${THICK}`, - '┘': `${topYAxisFromTop} ${TO}${LEFT.MIDDLE}`, - '┙': `${topYAxisFromTop} ${TO}${LEFT.MIDDLE}${THICK}`, - '┚': `${topYAxisFromTop}${THICK} ${TO}${LEFT.MIDDLE}`, - '┛': `${topYAxisFromTop}${THICK} ${TO}${LEFT.MIDDLE}${THICK}`, - '├': `${yAxis} ${rightMiddleXAxis}`, - '┝': `${yAxis} ${rightMiddleXAxis}${THICK}`, - '┞': `${topYAxisFromTop}${THICK} ${bottomYAxisFromMiddle} ${rightMiddleXAxis}`, - '┟': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${rightMiddleXAxis}${THICK}`, - '┠': `${yAxis}${THICK} ${rightMiddleXAxis}`, - '┡': `${bottomYAxisFromBottom} ${topYAxisFromMiddle}${THICK} ${rightMiddleXAxis}${THICK}`, - '┢': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${rightMiddleXAxis}${THICK}`, - '┣': `${yAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - '┤': `${yAxis} ${leftMiddleXAxis}`, - '┥': `${yAxis} ${leftMiddleXAxis}${THICK}`, - '┦': `${topYAxisFromTop}${THICK} ${bottomYAxisFromMiddle} ${leftMiddleXAxis}`, - '┧': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${leftMiddleXAxis}${THICK}`, - '┨': `${yAxis}${THICK} ${leftMiddleXAxis}`, - '┩': `${bottomYAxisFromBottom} ${topYAxisFromMiddle}${THICK} ${leftMiddleXAxis}${THICK}`, - '┪': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${leftMiddleXAxis}${THICK}`, - '┫': `${yAxis}${THICK} ${leftMiddleXAxis}${THICK}`, - '┬': `${bottomYAxisFromBottom} ${xAxis}`, - '┭': `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - '┮': `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '┯': `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - '┰': `${bottomYAxisFromBottom}${THICK} ${xAxis}`, - '┱': `${bottomYAxisFromBottom}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - '┲': `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '┳': `${bottomYAxisFromBottom}${THICK} ${xAxis}${THICK}`, - '┴': `${topYAxisFromTop} ${xAxis}`, - '┵': `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - '┶': `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '┷': `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - '┸': `${topYAxisFromTop}${THICK} ${xAxis}`, - '┹': `${topYAxisFromTop}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - '┺': `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '┻': `${topYAxisFromTop}${THICK} ${xAxis}${THICK}`, - '┼': `${yAxis} ${xAxis}`, - '┽': `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - '┾': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '┿': `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - '╀': `${yAxis}${THICK} ${xAxis}`, - '╁': `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - '╂': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '╃': `${yAxis}${THICK} ${xAxis}${THICK}`, - '╄': `${yAxis} ${xAxis}`, - '╅': `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - '╆': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '╇': `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - '╈': `${yAxis}${THICK} ${xAxis}`, - '╉': `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - '╊': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '╋': `${yAxis}${THICK} ${xAxis}${THICK}`, - '╌': `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}`, - '╍': `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'}${THICK} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}${THICK}`, - '╎':`${MOVE}${CENTER.TOP} ${TO}${'.5,.47'} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}`, - '╏':`${MOVE}${CENTER.TOP} ${TO}${'.5,.47'}${THICK} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}${THICK}`, - // '═': `${MOVE}${} ${TO}${} ${TO}${}`, - // '║': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╒': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╓': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╔': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╕': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╖': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╗': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╘': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╙': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╚': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╛': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╜': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╝': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╞': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╟': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╠': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╡': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╢': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╣': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╤': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╥': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╦': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╧': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╨': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╩': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╪': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╫': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╬': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╭': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╮': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╯': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╰': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╱': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╲': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╳': `${MOVE}${} ${TO}${} ${TO}${}`, - '╴': `${leftMiddleXAxis}`, - '╵': `${topYAxisFromMiddle}`, - '╶': `${rightMiddleXAxis}`, - '╷': `${bottomYAxisFromMiddle}`, - '╸': `${leftMiddleXAxis}${THICK}`, - '╹': `${topYAxisFromMiddle}${THICK}`, - '╺': `${rightMiddleXAxis}${THICK}`, - '╻': `${bottomYAxisFromMiddle}${THICK}`, - '╼': `${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '╽': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle}`, - '╾': `${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - '╿': `${bottomYAxisFromBottom} ${topYAxisFromMiddle}${THICK}` +const map: { [character: string]: { [fontWeight: number]: string } } = { + '━': { + 1: `${xAxis}` + }, + '│': { + 1: `${yAxis}` + }, + '┃': { + 2: `${yAxis}` + }, + '┌': { + 1: `${bottomYAxisFromBottom} ${TO}${RIGHT.MIDDLE}` + }, + '┍': { + 1: `${bottomYAxisFromBottom}`, + 2: `${rightMiddleXAxis}` + }, + '┎': { + 1: `${rightMiddleXAxis}`, + 2: `${bottomYAxisFromBottom}` + }, + '┏': { + 2: `${bottomYAxisFromBottom} ${TO}${RIGHT.MIDDLE}` + }, + '┐': { + 1: `${bottomYAxisFromBottom} ${TO}${LEFT.MIDDLE}` + }, + '┑': { + 1: `${bottomYAxisFromBottom}`, + 2: `${leftMiddleXAxis}` + }, + '┒': { + 1: `${leftMiddleXAxis}`, + 2: `${bottomYAxisFromBottom}` + }, + '┓': { + 2: `${bottomYAxisFromBottom} ${TO}${LEFT.MIDDLE}` + }, + '└': { + 1: `${topYAxisFromTop} ${TO}${RIGHT.MIDDLE}` + }, + '┕': { + 1: `${topYAxisFromTop}`, + 2: `${rightMiddleXAxis}` + }, + '┖': { + 1: `${rightMiddleXAxis}`, + 2: `${topYAxisFromTop}` + }, + '┗': { + 2: `${topYAxisFromTop} ${TO}${RIGHT.MIDDLE}` + }, + '┘': { + 1: `${topYAxisFromTop} ${TO}${LEFT.MIDDLE}` + }, + '┙': { + 1: `${topYAxisFromTop}`, + 2: `${leftMiddleXAxis}` + }, + '┚': { + 1: `${leftMiddleXAxis}`, + 2: `${topYAxisFromTop}` + }, + '┛': { + 2: `${topYAxisFromTop} ${TO}${LEFT.MIDDLE}` + }, + '├': { + 1: `${yAxis} ${rightMiddleXAxis}` + }, + '┝': { + 1: `${yAxis}`, + 2: `${rightMiddleXAxis}` + }, + '┞': { + 1: `${bottomYAxisFromMiddle} ${rightMiddleXAxis}`, + 2: `${topYAxisFromTop}` + }, + '┟': { + 1: `${topYAxisFromMiddle} ${rightMiddleXAxis}`, + 2: `${bottomYAxisFromBottom}` + }, + '┠': { + 1: `${rightMiddleXAxis}`, + 2: `${yAxis}` + }, + '┡': { + 1: `${bottomYAxisFromBottom}`, + 2: `${topYAxisFromMiddle} ${rightMiddleXAxis}` + }, + '┢': { + 1: `${topYAxisFromMiddle}`, + 2: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` + }, + '┣': { + 2: `${yAxis} ${rightMiddleXAxis}` + }, + '┤': { + 1: `${yAxis} ${leftMiddleXAxis}` + }, + '┥': { + 1: `${yAxis}`, + 2: `${leftMiddleXAxis}` + }, + '┦': { + 1: `${bottomYAxisFromMiddle} ${leftMiddleXAxis}`, + 2: `${topYAxisFromTop}` + }, + '┧': { + 1: `${topYAxisFromMiddle}`, + 2: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` + }, + '┨': { + 1: `${leftMiddleXAxis}`, + 2: `${yAxis}` + }, + '┩': { + 2: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, + 1: `${bottomYAxisFromMiddle}` + } +}; + +const chars: { [index: string]: string } = { + + + // } // '┩{ + // 1: ': `${leftMiddleXAxis}${THICK} ${topYAxisFromMiddle}${THICK} ${MOVE}${CENTER.MIDDLE} ${bottomYAxisFromMiddle + // 1: ': `${leftMiddleXAxis}${THICK} ${topYAxisFromMiddle}${THICK} ${MOVE}${CENTER.MIDDLE} ${bottomYAxisFromMiddle + // }`, + + // } '┪': { + // 1: `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${leftMiddleXAxis}${THICK}`, + // 1: `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${leftMiddleXAxis}${THICK}`, + // } + // '┫': { + // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK}`, + // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK}`, + // } + // '┬': { + // 1: `${bottomYAxisFromBottom} ${xAxis}`, + // 1: `${bottomYAxisFromBottom} ${xAxis}`, + // } + // '┭': { + // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // } + // '┮': { + // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // } + // '┯': { + // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + // } + // '┰': { + // 1: `${bottomYAxisFromBottom}${THICK} ${xAxis}`, + // 1: `${bottomYAxisFromBottom}${THICK} ${xAxis}`, + // } + // '┱': { + // 1: `${bottomYAxisFromBottom}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // 1: `${bottomYAxisFromBottom}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // } + // '┲': { + // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // } + // '┳': { + // 1: `${bottomYAxisFromBottom}${THICK} ${xAxis}${THICK}`, + // 1: `${bottomYAxisFromBottom}${THICK} ${xAxis}${THICK}`, + // } + // '┴': { + // 1: `${topYAxisFromTop} ${xAxis}`, + // 1: `${topYAxisFromTop} ${xAxis}`, + // } + // '┵': { + // 1: `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // 1: `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // } + // '┶': { + // 1: `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // 1: `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // } + // '┷': { + // 1: `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + // 1: `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + // } + // '┸': { + // 1: `${topYAxisFromTop}${THICK} ${xAxis}`, + // 1: `${topYAxisFromTop}${THICK} ${xAxis}`, + // } + // '┹': { + // 1: `${topYAxisFromTop}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // 1: `${topYAxisFromTop}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // } + // '┺': { + // 1: `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // 1: `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // } + // '┻': { + // 1: `${topYAxisFromTop}${THICK} ${xAxis}${THICK}`, + // 1: `${topYAxisFromTop}${THICK} ${xAxis}${THICK}`, + // } + // '┼': { + // 1: `${yAxis} ${xAxis}`, + // 1: `${yAxis} ${xAxis}`, + // } + // '┽': { + // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // } + // '┾': { + // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // } + // '┿': { + // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + // } + // '╀': { + // 1: `${yAxis}${THICK} ${xAxis}`, + // 1: `${yAxis}${THICK} ${xAxis}`, + // } + // '╁': { + // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // } + // '╂': { + // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // } + // '╃': { + // 1: `${yAxis}${THICK} ${xAxis}${THICK}`, + // 1: `${yAxis}${THICK} ${xAxis}${THICK}`, + // } + // '╄': { + // 1: `${yAxis} ${xAxis}`, + // 1: `${yAxis} ${xAxis}`, + // } + // '╅': { + // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // } + // '╆': { + // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // } + // '╇': { + // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + // } + // '╈': { + // 1: `${yAxis}${THICK} ${xAxis}`, + // 1: `${yAxis}${THICK} ${xAxis}`, + // } + // '╉': { + // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // } + // '╊': { + // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // } + // '╋': { + // 1: `${yAxis}${THICK} ${xAxis}${THICK}`, + // 1: `${yAxis}${THICK} ${xAxis}${THICK}`, + // } + // '╌': { + // 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}`, + // 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}`, + // } + // '╍': { + // 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'}${THICK} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}${THICK}`, + // 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'}${THICK} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}${THICK}`, + // } + // '╎':`{ + // 1: ${MOVE}${CENTER.TOP} ${TO}${'.5,.47'} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}` + // 1: ${MOVE}${CENTER.TOP} ${TO}${'.5,.47'} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}` + // }, + // '╏':`{ + // 1: ${MOVE}${CENTER.TOP} ${TO}${'.5,.47'}${THICK} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}${THICK}` + // 1: ${MOVE}${CENTER.TOP} ${TO}${'.5,.47'}${THICK} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}${THICK}` + // }, + // // '═{ + // 1: ': `${MOVE}${} ${TO}${} ${TO}${ + // 1: ': `${MOVE}${} ${TO}${} ${TO}${ + + // }`, + + // } // '║{ + // 1: ': `${MOVE}${} ${TO}${} ${TO}${ + // 1: ': `${MOVE}${} ${TO}${} ${TO}${ + + // }`, + +// } // '╒': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╓': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╔': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╕': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╖': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╗': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╘': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╙': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╚': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╛': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╜': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╝': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╞': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╟': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╠': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╡': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╢': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╣': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╤': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╥': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╦': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╧': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╨': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╩': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╪': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╫': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╬': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╭': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╮': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╯': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╰': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╱': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╲': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╳': `${MOVE}${} ${TO}${} ${TO}${}`, +// '╴': `${leftMiddleXAxis}`, +// '╵': `${topYAxisFromMiddle}`, +// '╶': `${rightMiddleXAxis}`, +// '╷': `${bottomYAxisFromMiddle}`, +// '╸': `${leftMiddleXAxis}${THICK}`, +// '╹': `${topYAxisFromMiddle}${THICK}`, +// '╺': `${rightMiddleXAxis}${THICK}`, +// '╻': `${bottomYAxisFromMiddle}${THICK}`, +// '╼': `${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, +// '╽': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle}`, +// '╾': `${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, +// '╿': `${bottomYAxisFromBottom} ${topYAxisFromMiddle}${THICK}` }; export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { - const entry = chars[c]; - if (!entry) { + const match: { [fontWeight: number]: string } = map[c]; + if (!match) { return; } - const lineWidth = ctx.lineWidth; - const instructions = entry.split(' '); + for (const [fontWeight, instructions] of Object.entries(match)) { + ctx.beginPath(); + ctx.lineWidth = window.devicePixelRatio * Number.parseInt(fontWeight); + for (const instruction of instructions.split(' ')) { + const type = instruction[0]; + const f = instructionMap[type]; + const coords: string[] = instruction.substring(1).split(','); + if (!coords[0] || !coords[1]) { + continue; + } + let x = Number.parseFloat(coords[0].toString()) || Number.parseInt(coords[0].toString()); + let y = Number.parseFloat(coords[1].toString()) || Number.parseInt(coords[1].toString()); - for (const instruction of instructions) { - const type = instruction[0]; - const spec = instructionMap[type]; - const coords: string[] = instruction.substring(1).split(','); - if (!coords[0] || !coords[1]) { - continue; - } - let numX = Number.parseFloat(coords[0].toString()) || Number.parseInt(coords[0].toString()); - let numY = Number.parseFloat(coords[1].toString()) || Number.parseInt(coords[1].toString()); - if (instruction.endsWith(THICK)) { - ctx.lineWidth = window.devicePixelRatio * 2; - } else { - ctx.lineWidth = window.devicePixelRatio; - } + x *= cellWidth; + y *= cellHeight; - numX *= cellWidth; - numY *= cellHeight; - - if (numY !== 0) { - numY = clamp(Math.round(numY + .5) - .5, cellHeight, 0); + if (y !== 0) { + y = clamp(Math.round(y + .5) - .5, cellHeight, 0); + } + if (x !== 0) { + x = clamp(Math.round(x + .5) - .5, cellWidth, 0); + } + f(ctx, xOffset + x, yOffset + y); } - if (numX !== 0) { - numX = clamp(Math.round(numX + .5) - .5, cellWidth, 0); - } - spec(ctx, xOffset + numX, yOffset + numY); + ctx.stroke(); + ctx.closePath(); } } @@ -407,13 +624,9 @@ function clamp(value: number, max: number, min: number = 0): number { const instructionMap: { [index: string]: any } = { 'M': (ctx: CanvasRenderingContext2D, x: number, y: number) => { - ctx.beginPath(); ctx.moveTo(x, y); }, 'L': (ctx: CanvasRenderingContext2D, x: number, y: number) => { ctx.lineTo(x, y); - ctx.stroke(); - ctx.beginPath(); - ctx.moveTo(x, y); } }; From 07513c927f851f47fd76ca8adf7cf9a8c2cdd4f8 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Thu, 12 Aug 2021 11:46:52 -0700 Subject: [PATCH 298/377] more --- src/browser/renderer/BoxAndBlockCharacters.ts | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 1b6fef41..b6ac8dc9 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -361,25 +361,17 @@ const map: { [character: string]: { [fontWeight: number]: string } } = { '┩': { 2: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, 1: `${bottomYAxisFromMiddle}` + }, + '┪': { + 1: `${topYAxisFromMiddle}`, + 2: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` + }, + '┫': { + 2: `${yAxis} ${leftMiddleXAxis}` } }; const chars: { [index: string]: string } = { - - - // } // '┩{ - // 1: ': `${leftMiddleXAxis}${THICK} ${topYAxisFromMiddle}${THICK} ${MOVE}${CENTER.MIDDLE} ${bottomYAxisFromMiddle - // 1: ': `${leftMiddleXAxis}${THICK} ${topYAxisFromMiddle}${THICK} ${MOVE}${CENTER.MIDDLE} ${bottomYAxisFromMiddle - // }`, - - // } '┪': { - // 1: `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${leftMiddleXAxis}${THICK}`, - // 1: `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${leftMiddleXAxis}${THICK}`, - // } - // '┫': { - // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK}`, - // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK}`, - // } // '┬': { // 1: `${bottomYAxisFromBottom} ${xAxis}`, // 1: `${bottomYAxisFromBottom} ${xAxis}`, From d8899b0b5d461bd2d1d3dd2c63e6ef4223f92d7e Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 12:59:22 -0700 Subject: [PATCH 299/377] Fix eslint errors in test/benchmark --- .../EscapeSequenceParser.benchmark.ts | 172 +++++++++--------- test/benchmark/Terminal.benchmark.ts | 12 +- 2 files changed, 92 insertions(+), 92 deletions(-) diff --git a/test/benchmark/EscapeSequenceParser.benchmark.ts b/test/benchmark/EscapeSequenceParser.benchmark.ts index c2707f19..10c44797 100644 --- a/test/benchmark/EscapeSequenceParser.benchmark.ts +++ b/test/benchmark/EscapeSequenceParser.benchmark.ts @@ -40,42 +40,42 @@ perfContext('Parser throughput - 50MB data', () => { beforeEach(() => { parser = new EscapeSequenceParser(); parser.setPrintHandler((data, start, end) => {}); - parser.registerCsiHandler({final: '@'}, params => true); - parser.registerCsiHandler({final: 'A'}, params => true); - parser.registerCsiHandler({final: 'B'}, params => true); - parser.registerCsiHandler({final: 'C'}, params => true); - parser.registerCsiHandler({final: 'D'}, params => true); - parser.registerCsiHandler({final: 'E'}, params => true); - parser.registerCsiHandler({final: 'F'}, params => true); - parser.registerCsiHandler({final: 'G'}, params => true); - parser.registerCsiHandler({final: 'H'}, params => true); - parser.registerCsiHandler({final: 'I'}, params => true); - parser.registerCsiHandler({final: 'J'}, params => true); - parser.registerCsiHandler({final: 'K'}, params => true); - parser.registerCsiHandler({final: 'L'}, params => true); - parser.registerCsiHandler({final: 'M'}, params => true); - parser.registerCsiHandler({final: 'P'}, params => true); - parser.registerCsiHandler({final: 'S'}, params => true); - parser.registerCsiHandler({final: 'T'}, params => true); - parser.registerCsiHandler({final: 'X'}, params => true); - parser.registerCsiHandler({final: 'Z'}, params => true); - parser.registerCsiHandler({final: '`'}, params => true); - parser.registerCsiHandler({final: 'a'}, params => true); - parser.registerCsiHandler({final: 'b'}, params => true); - parser.registerCsiHandler({final: 'c'}, params => true); - parser.registerCsiHandler({final: 'd'}, params => true); - parser.registerCsiHandler({final: 'e'}, params => true); - parser.registerCsiHandler({final: 'f'}, params => true); - parser.registerCsiHandler({final: 'g'}, params => true); - parser.registerCsiHandler({final: 'h'}, params => true); - parser.registerCsiHandler({final: 'l'}, params => true); - parser.registerCsiHandler({final: 'm'}, params => true); - parser.registerCsiHandler({final: 'n'}, params => true); - parser.registerCsiHandler({final: 'p'}, params => true); - parser.registerCsiHandler({final: 'q'}, params => true); - parser.registerCsiHandler({final: 'r'}, params => true); - parser.registerCsiHandler({final: 's'}, params => true); - parser.registerCsiHandler({final: 'u'}, params => true); + parser.registerCsiHandler({ final: '@' }, params => true); + parser.registerCsiHandler({ final: 'A' }, params => true); + parser.registerCsiHandler({ final: 'B' }, params => true); + parser.registerCsiHandler({ final: 'C' }, params => true); + parser.registerCsiHandler({ final: 'D' }, params => true); + parser.registerCsiHandler({ final: 'E' }, params => true); + parser.registerCsiHandler({ final: 'F' }, params => true); + parser.registerCsiHandler({ final: 'G' }, params => true); + parser.registerCsiHandler({ final: 'H' }, params => true); + parser.registerCsiHandler({ final: 'I' }, params => true); + parser.registerCsiHandler({ final: 'J' }, params => true); + parser.registerCsiHandler({ final: 'K' }, params => true); + parser.registerCsiHandler({ final: 'L' }, params => true); + parser.registerCsiHandler({ final: 'M' }, params => true); + parser.registerCsiHandler({ final: 'P' }, params => true); + parser.registerCsiHandler({ final: 'S' }, params => true); + parser.registerCsiHandler({ final: 'T' }, params => true); + parser.registerCsiHandler({ final: 'X' }, params => true); + parser.registerCsiHandler({ final: 'Z' }, params => true); + parser.registerCsiHandler({ final: '`' }, params => true); + parser.registerCsiHandler({ final: 'a' }, params => true); + parser.registerCsiHandler({ final: 'b' }, params => true); + parser.registerCsiHandler({ final: 'c' }, params => true); + parser.registerCsiHandler({ final: 'd' }, params => true); + parser.registerCsiHandler({ final: 'e' }, params => true); + parser.registerCsiHandler({ final: 'f' }, params => true); + parser.registerCsiHandler({ final: 'g' }, params => true); + parser.registerCsiHandler({ final: 'h' }, params => true); + parser.registerCsiHandler({ final: 'l' }, params => true); + parser.registerCsiHandler({ final: 'm' }, params => true); + parser.registerCsiHandler({ final: 'n' }, params => true); + parser.registerCsiHandler({ final: 'p' }, params => true); + parser.registerCsiHandler({ final: 'q' }, params => true); + parser.registerCsiHandler({ final: 'r' }, params => true); + parser.registerCsiHandler({ final: 's' }, params => true); + parser.registerCsiHandler({ final: 'u' }, params => true); parser.setExecuteHandler(C0.BEL, () => true); parser.setExecuteHandler(C0.LF, () => true); parser.setExecuteHandler(C0.VT, () => true); @@ -90,24 +90,24 @@ perfContext('Parser throughput - 50MB data', () => { parser.setExecuteHandler(C1.HTS, () => true); parser.registerOscHandler(0, new OscHandler(data => true)); parser.registerOscHandler(1, new FastOscHandler()); - parser.registerEscHandler({final: '7'}, () => true); - parser.registerEscHandler({final: '8'}, () => true); - parser.registerEscHandler({final: 'D'}, () => true); - parser.registerEscHandler({final: 'E'}, () => true); - parser.registerEscHandler({final: 'H'}, () => true); - parser.registerEscHandler({final: 'M'}, () => true); - parser.registerEscHandler({final: '='}, () => true); - parser.registerEscHandler({final: '>'}, () => true); - parser.registerEscHandler({final: 'c'}, () => true); - parser.registerEscHandler({final: 'n'}, () => true); - parser.registerEscHandler({final: 'o'}, () => true); - parser.registerEscHandler({final: '|'}, () => true); - parser.registerEscHandler({final: '}'}, () => true); - parser.registerEscHandler({final: '~'}, () => true); - parser.registerEscHandler({intermediates: '%', final: '@'}, () => true); - parser.registerEscHandler({intermediates: '%', final: 'G'}, () => true); - parser.registerDcsHandler({final: 'p'}, new DcsHandler(data => true)); - parser.registerDcsHandler({final: 'q'}, new FastDcsHandler()); + parser.registerEscHandler({ final: '7' }, () => true); + parser.registerEscHandler({ final: '8' }, () => true); + parser.registerEscHandler({ final: 'D' }, () => true); + parser.registerEscHandler({ final: 'E' }, () => true); + parser.registerEscHandler({ final: 'H' }, () => true); + parser.registerEscHandler({ final: 'M' }, () => true); + parser.registerEscHandler({ final: '=' }, () => true); + parser.registerEscHandler({ final: '>' }, () => true); + parser.registerEscHandler({ final: 'c' }, () => true); + parser.registerEscHandler({ final: 'n' }, () => true); + parser.registerEscHandler({ final: 'o' }, () => true); + parser.registerEscHandler({ final: '|' }, () => true); + parser.registerEscHandler({ final: '}' }, () => true); + parser.registerEscHandler({ final: '~' }, () => true); + parser.registerEscHandler({ intermediates: '%', final: '@' }, () => true); + parser.registerEscHandler({ intermediates: '%', final: 'G' }, () => true); + parser.registerDcsHandler({ final: 'p' }, new DcsHandler(data => true)); + parser.registerDcsHandler({ final: 'q' }, new FastDcsHandler()); }); perfContext('PRINT - a', () => { @@ -121,8 +121,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', async () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('EXECUTE - \\n', () => { @@ -136,8 +136,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('ESCAPE - ESC E', () => { @@ -151,8 +151,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('ESCAPE with collect - ESC % G', () => { @@ -166,8 +166,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('CSI - CSI A', () => { @@ -181,8 +181,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('CSI with collect - CSI ? p', () => { @@ -196,8 +196,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('CSI with params (short) - CSI 1;2 m', () => { @@ -211,8 +211,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('CSI with params (long) - CSI 1;2;3;4;5;6;7;8;9;0 m', () => { @@ -226,8 +226,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('OSC string interface (short seq) - OSC 0;hi ST', () => { @@ -241,8 +241,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('OSC string interface (long seq) - OSC 0; ST', () => { @@ -256,8 +256,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('OSC class interface (short seq) - OSC 0;hi ST', () => { @@ -271,8 +271,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('OSC class interface (long seq) - OSC 0; ST', () => { @@ -286,8 +286,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('DCS string interface (short seq)', () => { @@ -301,8 +301,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', async () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('DCS string interface (long seq)', () => { @@ -316,8 +316,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', async () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('DCS class interface (short seq)', () => { @@ -331,8 +331,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', async () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('DCS class interface (long seq)', () => { @@ -346,7 +346,7 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', async () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); }); diff --git a/test/benchmark/Terminal.benchmark.ts b/test/benchmark/Terminal.benchmark.ts index 40a3c208..578a83d0 100644 --- a/test/benchmark/Terminal.benchmark.ts +++ b/test/benchmark/Terminal.benchmark.ts @@ -47,22 +47,22 @@ perfContext('Terminal: ls -lR /usr/lib', () => { perfContext('write/string/async', () => { let terminal: Terminal; before(() => { - terminal = new Terminal({cols: 80, rows: 25, scrollback: 1000}); + terminal = new Terminal({ cols: 80, rows: 25, scrollback: 1000 }); }); new ThroughputRuntimeCase('', async () => { await new Promise(res => terminal.write(content, res)); - return {payloadSize: contentUtf8.length}; - }, {fork: false}).showAverageThroughput(); + return { payloadSize: contentUtf8.length }; + }, { fork: false }).showAverageThroughput(); }); perfContext('write/Utf8/async', () => { let terminal: Terminal; before(() => { - terminal = new Terminal({cols: 80, rows: 25, scrollback: 1000}); + terminal = new Terminal({ cols: 80, rows: 25, scrollback: 1000 }); }); new ThroughputRuntimeCase('', async () => { await new Promise(res => terminal.write(content, res)); - return {payloadSize: contentUtf8.length}; - }, {fork: false}).showAverageThroughput(); + return { payloadSize: contentUtf8.length }; + }, { fork: false }).showAverageThroughput(); }); }); From 6b7b279742fdd57d0d627c5038a3c2b2a5f006f0 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Fri, 13 Aug 2021 10:47:30 -0700 Subject: [PATCH 300/377] refactor --- src/browser/renderer/BoxAndBlockCharacters.ts | 414 ++++++++++-------- 1 file changed, 234 insertions(+), 180 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index b6ac8dc9..a3d88351 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -243,6 +243,24 @@ const topYAxisFromMiddle = `${MOVE}${CENTER.TOP} ${TO}${CENTER.MIDDLE}`; const rightMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${RIGHT.MIDDLE}`; const leftMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${LEFT.MIDDLE}`; +const topXLine = `${MOVE}${'0,.45'} ${TO}${'1,.45'}`; +const bottomXLine = `${MOVE}${'0,.55'} ${TO}${'1,.55'}`; +const leftYLine = `${MOVE}${'.35,0'} ${TO}${'.35,1'}`; +const rightYLine = `${MOVE}${'.65,0'} ${TO}${'.65,1'}`; + +const leftTopXLine = `${MOVE}${'0,.45'} ${TO}${'.5,.45'}`; +const rightTopXLine = `${MOVE}${'.5,.45'} ${TO}${'1,.45'}`; + +const leftBottomXLine = `${MOVE}${'0,.55'} ${TO}${'.5,.55'}`; +const rightBottomXLine = `${MOVE}${'.5,.55'} ${TO}${'1,.55'}`; + +const bottomLeftYLine = `${MOVE}${'.35,.5'} ${TO}${'.35,1'}`; +const topLeftYLine = `${MOVE}${'.35,0'} ${TO}${'.35,.5'}`; + +const bottomRightYLine = `${MOVE}${'.65,.5'} ${TO}${'.65,1'}`; +const topRightYLine = `${MOVE}${'.65,0'} ${TO}${'.65,.5'}`; + + const map: { [character: string]: { [fontWeight: number]: string } } = { '━': { 1: `${xAxis}` @@ -368,178 +386,226 @@ const map: { [character: string]: { [fontWeight: number]: string } } = { }, '┫': { 2: `${yAxis} ${leftMiddleXAxis}` + }, + '┬': { + 1: `${bottomYAxisFromBottom} ${xAxis}` + }, + '┭': { + 1: `${bottomYAxisFromBottom} ${rightMiddleXAxis}`, + 2: `${leftMiddleXAxis}` + }, + '┮': { + 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}`, + 2: `${rightMiddleXAxis}` + }, + '┯': { + 1: `${bottomYAxisFromBottom}`, + 2: `${leftMiddleXAxis} ${rightMiddleXAxis}` + }, + '┰': { + 1: `${xAxis}`, + 2: `${bottomYAxisFromBottom}` + }, + '┱': { + 1: `${rightMiddleXAxis}`, + 2: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` + }, + '┲': { + 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}`, + 2: `${rightMiddleXAxis}` + }, + '┳': { + 2: `${bottomYAxisFromBottom} ${xAxis}` + }, + '┴': { + 1: `${topYAxisFromMiddle} ${xAxis}` + }, + '┵': { + 1: `${topYAxisFromMiddle} ${rightMiddleXAxis}`, + 2: `${leftMiddleXAxis}` + }, + '┶': { + 1: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, + 2: `${rightMiddleXAxis}` + }, + '┷': { + 1: `${topYAxisFromMiddle}`, + 2: `${leftMiddleXAxis} ${rightMiddleXAxis}` + }, + '┸': { + 1: `${xAxis}`, + 2: `${topYAxisFromMiddle}` + }, + '┹': { + 1: `${rightMiddleXAxis}`, + 2: `${topYAxisFromMiddle} ${leftMiddleXAxis}` + }, + '┺': { + 1: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, + 2: `${rightMiddleXAxis}` + }, + '┻': { + 2: `${topYAxisFromMiddle} ${xAxis}` + }, + '┼': { + 1: `${yAxis} ${xAxis}` + }, + '┽': { + 1: `${yAxis} ${rightMiddleXAxis}`, + 2: `${leftMiddleXAxis}` + }, + '┾': { + 1: `${yAxis} ${leftMiddleXAxis}`, + 2: `${rightMiddleXAxis}` + }, + '┿': { + 1: `${yAxis}`, + 2: `${leftMiddleXAxis} ${rightMiddleXAxis}` + }, + '╀': { + 1: `${xAxis}`, + 2: `${yAxis}` + }, + '╁': { + 1: `${rightMiddleXAxis}`, + 2: `${yAxis} ${leftMiddleXAxis}` + }, + '╂': { + 1: `${yAxis} ${leftMiddleXAxis}`, + 2: `${rightMiddleXAxis}` + }, + '╃': { + 1: `${bottomYAxisFromBottom} ${rightMiddleXAxis}`, + 2: `${topYAxisFromTop} ${leftMiddleXAxis}` + }, + '╄': { + 1: `${topYAxisFromTop} ${leftMiddleXAxis}`, + 2: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` + }, + '╅': { + 1: `${topYAxisFromTop} ${rightMiddleXAxis}`, + 2: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` + }, + '╆': { + 1: `${topYAxisFromTop} ${leftMiddleXAxis}`, + 2: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` + }, + '╇': { + 1: `${bottomYAxisFromBottom}`, + 2: `${leftMiddleXAxis} ${topYAxisFromTop} ${rightMiddleXAxis}` + }, + '╈': { + 1: `${topYAxisFromTop}`, + 2: `${leftMiddleXAxis} ${bottomYAxisFromBottom} ${rightMiddleXAxis}` + }, + '╉': { + 1: `${rightMiddleXAxis}`, + 2: `${leftMiddleXAxis} ${yAxis}` + }, + '╊': { + 1: `${leftMiddleXAxis}`, + 2: `${rightMiddleXAxis} ${yAxis}` + }, + '╋': { + 2: `${yAxis} ${xAxis}` + }, + '╌': { + 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` + }, + '╍': { + 2: `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` + }, + '╎': { + 1: `${MOVE}${CENTER.TOP} ${TO}${'.5,.45'} ${MOVE}${'.5,.55'} ${TO}${CENTER.BOTTOM}` + }, + '╏': { + 2: `${MOVE}${CENTER.TOP} ${TO}${'.5,.45'} ${MOVE}${'.5,.55'} ${TO}${CENTER.BOTTOM}` + }, + '═': { + 1: `${MOVE}${'0,.45'} ${TO}${'1,.45'} ${MOVE}${'0,.55'} ${TO}${'1,.55'}` + }, + '║': { + 1: `${MOVE}${'.35,0'} ${TO}${'.35,1'} ${MOVE}${'.65,0'} ${TO}${'.65,1'}` + }, + '╒': { + 1: `${rightTopXLine} ${rightBottomXLine} ${MOVE}${'.55,1'} ${TO}${'.55,.45'}` + }, + '╓': { + 1: `${bottomLeftYLine} ${bottomRightYLine} ${MOVE}${'.3,.5'} ${TO}${'1,.5'}` + }, + '╔': { + 1: `${MOVE}${'.35,.45'} ${TO}${'1,.45'} ${MOVE}${'.35,.45'} ${TO}${'.35,1'} ${MOVE}${'.65,.65'} ${TO}${'1,.65'} ${MOVE}${'.65,.625'} ${TO}${'.65,1'}` + }, + '╕': { + 1: `${leftTopXLine} ${leftBottomXLine} ${MOVE}${'.55,1'} ${TO}${'.55,.45'}` + }, + '╖': { + 1: `${bottomLeftYLine} ${bottomRightYLine} ${MOVE}${'0,.5'} ${TO}${'.7,.5'}` + }, + '╗': { + 1: `${MOVE}${'.35,.45'} ${TO}${'1,.45'} ${MOVE}${'1,.45'} ${TO}${'1,1'} ${MOVE}${'.35,.65'} ${TO}${'.7,.65'} ${MOVE}${'.7,.65'} ${TO}${'.7,1'}` + }, + '╘': { + 1: `${MOVE}${'0,.85'} ${TO}${'.5,.85'} ${MOVE}${'0,1'} ${TO}${'.5,1'} ${MOVE}${'0,.5'} ${TO}${'0,1'}` + }, + '╙': { + 1: `${MOVE}${'0,.5'} ${TO}${'0,1'} ${MOVE}${'.35,.5'} ${TO}${'.35,1'} ${MOVE}${'0,1'} ${TO}${'.7,1'}` + }, + '╚': { + 1: `${MOVE}${'0,.5'} ${TO}${'0,1'} ${MOVE}${'.35,.5'} ${TO}${'.35,.85'} ${MOVE}${'0,1'} ${TO}${'.7,1'} ${MOVE}${'.5,.85'} ${TO}${'1,.85'}` + }, + '╛': { + 1: `${MOVE}${'0,.85'} ${TO}${'.5,.85'} ${MOVE}${'0,1'} ${TO}${'.5,1'} ${MOVE}${'.55,1'} ${TO}${'.55,.45'}` + }, + '╜': { + 1: `${bottomLeftYLine} ${bottomRightYLine} ${MOVE}${'0,1'} ${TO}${'.7,1'}` + }, + '╝': { + 1: `${MOVE}${'.35,.45'} ${TO}${'.35,.85'} ${MOVE}${'.65,.45'} ${TO} ${'.65,1'} ${MOVE}${'0,.85'} ${TO}${'.45,.85'} ${MOVE}${'0,1'} ${TO}${'.65,1'}` + }, + '╴': { + 1: `${leftMiddleXAxis}` + }, + '╵': { + 1: `${topYAxisFromMiddle}` + }, + '╶': { + 1: `${rightMiddleXAxis}` + }, + '╷': { + 1: `${bottomYAxisFromMiddle}` + }, + '╸': { + 2: `${leftMiddleXAxis}` + }, + '╹': { + 2: `${topYAxisFromMiddle}` + }, + '╺': { + 2: `${rightMiddleXAxis}` + }, + '╻': { + 2: `${bottomYAxisFromMiddle}` + }, + '╼': { + 1: `${leftMiddleXAxis}`, + 2: `${rightMiddleXAxis}` + }, + '╽': { + 1: `${topYAxisFromMiddle}`, + 2: `${bottomYAxisFromBottom}` + }, + '╾': { + 1: `${rightMiddleXAxis}`, + 2: `${leftMiddleXAxis}` + }, + '╿': { + 1: `${bottomYAxisFromBottom}`, + 2: `${topYAxisFromMiddle}` } }; const chars: { [index: string]: string } = { - // '┬': { - // 1: `${bottomYAxisFromBottom} ${xAxis}`, - // 1: `${bottomYAxisFromBottom} ${xAxis}`, - // } - // '┭': { - // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // } - // '┮': { - // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // } - // '┯': { - // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - // } - // '┰': { - // 1: `${bottomYAxisFromBottom}${THICK} ${xAxis}`, - // 1: `${bottomYAxisFromBottom}${THICK} ${xAxis}`, - // } - // '┱': { - // 1: `${bottomYAxisFromBottom}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // 1: `${bottomYAxisFromBottom}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // } - // '┲': { - // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // } - // '┳': { - // 1: `${bottomYAxisFromBottom}${THICK} ${xAxis}${THICK}`, - // 1: `${bottomYAxisFromBottom}${THICK} ${xAxis}${THICK}`, - // } - // '┴': { - // 1: `${topYAxisFromTop} ${xAxis}`, - // 1: `${topYAxisFromTop} ${xAxis}`, - // } - // '┵': { - // 1: `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // 1: `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // } - // '┶': { - // 1: `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // 1: `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // } - // '┷': { - // 1: `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - // 1: `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - // } - // '┸': { - // 1: `${topYAxisFromTop}${THICK} ${xAxis}`, - // 1: `${topYAxisFromTop}${THICK} ${xAxis}`, - // } - // '┹': { - // 1: `${topYAxisFromTop}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // 1: `${topYAxisFromTop}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // } - // '┺': { - // 1: `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // 1: `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // } - // '┻': { - // 1: `${topYAxisFromTop}${THICK} ${xAxis}${THICK}`, - // 1: `${topYAxisFromTop}${THICK} ${xAxis}${THICK}`, - // } - // '┼': { - // 1: `${yAxis} ${xAxis}`, - // 1: `${yAxis} ${xAxis}`, - // } - // '┽': { - // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // } - // '┾': { - // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // } - // '┿': { - // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - // } - // '╀': { - // 1: `${yAxis}${THICK} ${xAxis}`, - // 1: `${yAxis}${THICK} ${xAxis}`, - // } - // '╁': { - // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // } - // '╂': { - // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // } - // '╃': { - // 1: `${yAxis}${THICK} ${xAxis}${THICK}`, - // 1: `${yAxis}${THICK} ${xAxis}${THICK}`, - // } - // '╄': { - // 1: `${yAxis} ${xAxis}`, - // 1: `${yAxis} ${xAxis}`, - // } - // '╅': { - // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // } - // '╆': { - // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // } - // '╇': { - // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - // } - // '╈': { - // 1: `${yAxis}${THICK} ${xAxis}`, - // 1: `${yAxis}${THICK} ${xAxis}`, - // } - // '╉': { - // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // } - // '╊': { - // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // } - // '╋': { - // 1: `${yAxis}${THICK} ${xAxis}${THICK}`, - // 1: `${yAxis}${THICK} ${xAxis}${THICK}`, - // } - // '╌': { - // 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}`, - // 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}`, - // } - // '╍': { - // 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'}${THICK} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}${THICK}`, - // 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'}${THICK} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}${THICK}`, - // } - // '╎':`{ - // 1: ${MOVE}${CENTER.TOP} ${TO}${'.5,.47'} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}` - // 1: ${MOVE}${CENTER.TOP} ${TO}${'.5,.47'} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}` - // }, - // '╏':`{ - // 1: ${MOVE}${CENTER.TOP} ${TO}${'.5,.47'}${THICK} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}${THICK}` - // 1: ${MOVE}${CENTER.TOP} ${TO}${'.5,.47'}${THICK} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}${THICK}` - // }, - // // '═{ - // 1: ': `${MOVE}${} ${TO}${} ${TO}${ - // 1: ': `${MOVE}${} ${TO}${} ${TO}${ - - // }`, - - // } // '║{ - // 1: ': `${MOVE}${} ${TO}${} ${TO}${ - // 1: ': `${MOVE}${} ${TO}${} ${TO}${ - - // }`, - -// } // '╒': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╓': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╔': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╕': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╖': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╗': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╘': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╙': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╚': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╛': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╜': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╝': `${MOVE}${} ${TO}${} ${TO}${}`, // // '╞': `${MOVE}${} ${TO}${} ${TO}${}`, // // '╟': `${MOVE}${} ${TO}${} ${TO}${}`, // // '╠': `${MOVE}${} ${TO}${} ${TO}${}`, @@ -562,18 +628,6 @@ const chars: { [index: string]: string } = { // // '╱': `${MOVE}${} ${TO}${} ${TO}${}`, // // '╲': `${MOVE}${} ${TO}${} ${TO}${}`, // // '╳': `${MOVE}${} ${TO}${} ${TO}${}`, -// '╴': `${leftMiddleXAxis}`, -// '╵': `${topYAxisFromMiddle}`, -// '╶': `${rightMiddleXAxis}`, -// '╷': `${bottomYAxisFromMiddle}`, -// '╸': `${leftMiddleXAxis}${THICK}`, -// '╹': `${topYAxisFromMiddle}${THICK}`, -// '╺': `${rightMiddleXAxis}${THICK}`, -// '╻': `${bottomYAxisFromMiddle}${THICK}`, -// '╼': `${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, -// '╽': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle}`, -// '╾': `${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, -// '╿': `${bottomYAxisFromBottom} ${topYAxisFromMiddle}${THICK}` }; export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { From 263e5b95cf177c78acc09fa4fbe449102b2e806a Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 13 Aug 2021 12:52:50 -0700 Subject: [PATCH 301/377] Improve testing characters and use fake terminal for demo --- demo/client.ts | 53 +++++++++++++++++++++++++++----------- src/common/CoreTerminal.ts | 26 ------------------- 2 files changed, 38 insertions(+), 41 deletions(-) diff --git a/demo/client.ts b/demo/client.ts index 0bb124cd..d7c0f840 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -214,16 +214,17 @@ function createTerminal(): void { // Set terminal size again to set the specific dimensions on the demo updateTerminalSize(); - fetch('/terminals?cols=' + term.cols + '&rows=' + term.rows, {method: 'POST'}).then((res) => { - res.text().then((processId) => { - pid = processId; - socketURL += processId; - socket = new WebSocket(socketURL); - socket.onopen = runRealTerminal; - socket.onclose = runFakeTerminal; - socket.onerror = runFakeTerminal; - }); - }); + // fetch('/terminals?cols=' + term.cols + '&rows=' + term.rows, {method: 'POST'}).then((res) => { + // res.text().then((processId) => { + // pid = processId; + // socketURL += processId; + // socket = new WebSocket(socketURL); + // socket.onopen = runRealTerminal; + // socket.onclose = runFakeTerminal; + // socket.onerror = runFakeTerminal; + // }); + // }); + runFakeTerminal(); }, 0); } @@ -246,11 +247,33 @@ function runFakeTerminal(): void { term.write('\r\n$ '); }; - term.writeln('Welcome to xterm.js'); - term.writeln('This is a local terminal emulation, without a real terminal in the back-end.'); - term.writeln('Type some keys and commands to play around.'); - term.writeln(''); - term.prompt(); + // term.writeln('Welcome to xterm.js'); + // term.writeln('This is a local terminal emulation, without a real terminal in the back-end.'); + // term.writeln('Type some keys and commands to play around.'); + // term.writeln(''); + // term.prompt(); + + term.write('Box styles: ┎┰┒┍┯┑╓╥╖╒╤╕ ┏┳┓┌┲┓┌┬┐┏┱┐\n\r'); + term.write('┌─┬─┐ ┏━┳━┓ ╔═╦═╗ ┠╂┨┝┿┥╟╫╢╞╪╡ ┡╇┩├╊┫┢╈┪┣╉┤\n\r'); + term.write('│ │ │ ┃ ┃ ┃ ║ ║ ║ ┖┸┚┕┷┙╙╨╜╘╧╛ └┴┘└┺┛┗┻┛┗┹┘\n\r'); + term.write('├─┼─┤ ┣━╋━┫ ╠═╬═╣ ┏┱┐┌┲┓┌┬┐┌┬┐ ┏┳┓┌┮┓┌┬┐┏┭┐\n\r'); + term.write('│ │ │ ┃ ┃ ┃ ║ ║ ║ ┡╃┤├╄┩├╆┪┢╅┤ ┞╀┦├┾┫┟╁┧┣┽┤\n\r'); + term.write('└─┴─┘ ┗━┻━┛ ╚═╩═╝ └┴┘└┴┘└┺┛┗┹┘ └┴┘└┶┛┗┻┛┗┵┘\n\r'); + term.write('\n\r'); + term.write('Other:\n\r'); + term.write('╭─╮ ╲ ╱ ╷╻╎╏┆┇┊┋ ╺╾╴ ╌╌ ┄┄ ┈┈\n\r'); + term.write('│ │ ╳ ╽╿╎╏┆┇┊┋ ╶╼╸ ╍╍ ┅┅ ┉┉\n\r'); + term.write('╰─╯ ╱ ╲ ╹╵╎╏┆┇┊┋\n\r'); + term.write('\n\r'); + term.write('All box drawing characters:\n\r'); + term.write('─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏\n\r'); + term.write('┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟\n\r'); + term.write('┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯\n\r'); + term.write('┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿\n\r'); + term.write('╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏\n\r'); + term.write('═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟\n\r'); + term.write('╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯\n\r'); + term.write('╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\n\r'); term.onKey((e: { key: string, domEvent: KeyboardEvent }) => { const ev = e.domEvent; diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index a3026016..e61a8e16 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -132,32 +132,6 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { // Setup WriteBuffer this._writeBuffer = new WriteBuffer((data, promiseResult) => this._inputHandler.parse(data, promiseResult)); - setTimeout(() => { - // this.write('─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏\r\n'); - // this.write('┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟\r\n'); - // this.write('┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯\r\n'); - // this.write('┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿\r\n'); - // this.write('╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏\r\n'); - // this.write('═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟\r\n'); - // this.write('╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯\r\n'); - // this.write('╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\r\n'); - // this.write(' ╔═════════════════════════════════════════════════════════╕\r\n'); - // this.write(' ║ │\r\n'); - // this.write(' ║ ╔═══════════════╦════════╤════════╗ │\r\n'); - // this.write(' ║ ║ ║ │ ║ │\r\n'); - // this.write(' ║ ║ ║ │ ║ │\r\n'); - // this.write('▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇'); - this.write('━━│┃\r\n'); - this.write(' ━━│┃┌┍┎┏\r\n'); - this.write(' ━━│┃┌┐┍┑┎┒┏┓\r\n'); - this.write(' └┘┕┙┖┚┗┛\r\n'); - this.write('├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋ ╌ ╍╎╏═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬\r\n'); - this.write('╭╮╯╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿\r\n'); - this.write('├ ┝ ┞ ┟ ┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯ ┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻\r\n'); - this.write('┼ ┽ ┾ ┿ ╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋\r\n'); - this.write(' ╌ ╍ ╎ ╏ ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬\r\n'); - this.write('╭ ╮ ╯ ╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\r\n'); - }, 1000); } public dispose(): void { From f83ebdbe67fcdf6631322485a57d9c689dadb146 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 13 Aug 2021 14:53:45 -0700 Subject: [PATCH 302/377] Refactors and implementing new shapes Co-authored-by: Megan Rogge --- src/browser/renderer/BoxAndBlockCharacters.ts | 525 ++++++------------ 1 file changed, 179 insertions(+), 346 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index a3d88351..c220c9aa 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -260,349 +260,170 @@ const topLeftYLine = `${MOVE}${'.35,0'} ${TO}${'.35,.5'}`; const bottomRightYLine = `${MOVE}${'.65,.5'} ${TO}${'.65,1'}`; const topRightYLine = `${MOVE}${'.65,0'} ${TO}${'.65,.5'}`; +const enum Shapes { + /** │ */ TOP_TO_BOTTOM = 'M.5,0 L.5,1', + /** ─ */ LEFT_TO_RIGHT = 'M0,.5 L1,.5', -const map: { [character: string]: { [fontWeight: number]: string } } = { - '━': { - 1: `${xAxis}` - }, - '│': { - 1: `${yAxis}` - }, - '┃': { - 2: `${yAxis}` - }, - '┌': { - 1: `${bottomYAxisFromBottom} ${TO}${RIGHT.MIDDLE}` - }, - '┍': { - 1: `${bottomYAxisFromBottom}`, - 2: `${rightMiddleXAxis}` - }, - '┎': { - 1: `${rightMiddleXAxis}`, - 2: `${bottomYAxisFromBottom}` - }, - '┏': { - 2: `${bottomYAxisFromBottom} ${TO}${RIGHT.MIDDLE}` - }, - '┐': { - 1: `${bottomYAxisFromBottom} ${TO}${LEFT.MIDDLE}` - }, - '┑': { - 1: `${bottomYAxisFromBottom}`, - 2: `${leftMiddleXAxis}` - }, - '┒': { - 1: `${leftMiddleXAxis}`, - 2: `${bottomYAxisFromBottom}` - }, - '┓': { - 2: `${bottomYAxisFromBottom} ${TO}${LEFT.MIDDLE}` - }, - '└': { - 1: `${topYAxisFromTop} ${TO}${RIGHT.MIDDLE}` - }, - '┕': { - 1: `${topYAxisFromTop}`, - 2: `${rightMiddleXAxis}` - }, - '┖': { - 1: `${rightMiddleXAxis}`, - 2: `${topYAxisFromTop}` - }, - '┗': { - 2: `${topYAxisFromTop} ${TO}${RIGHT.MIDDLE}` - }, - '┘': { - 1: `${topYAxisFromTop} ${TO}${LEFT.MIDDLE}` - }, - '┙': { - 1: `${topYAxisFromTop}`, - 2: `${leftMiddleXAxis}` - }, - '┚': { - 1: `${leftMiddleXAxis}`, - 2: `${topYAxisFromTop}` - }, - '┛': { - 2: `${topYAxisFromTop} ${TO}${LEFT.MIDDLE}` - }, - '├': { - 1: `${yAxis} ${rightMiddleXAxis}` - }, - '┝': { - 1: `${yAxis}`, - 2: `${rightMiddleXAxis}` - }, - '┞': { - 1: `${bottomYAxisFromMiddle} ${rightMiddleXAxis}`, - 2: `${topYAxisFromTop}` - }, - '┟': { - 1: `${topYAxisFromMiddle} ${rightMiddleXAxis}`, - 2: `${bottomYAxisFromBottom}` - }, - '┠': { - 1: `${rightMiddleXAxis}`, - 2: `${yAxis}` - }, - '┡': { - 1: `${bottomYAxisFromBottom}`, - 2: `${topYAxisFromMiddle} ${rightMiddleXAxis}` - }, - '┢': { - 1: `${topYAxisFromMiddle}`, - 2: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` - }, - '┣': { - 2: `${yAxis} ${rightMiddleXAxis}` - }, - '┤': { - 1: `${yAxis} ${leftMiddleXAxis}` - }, - '┥': { - 1: `${yAxis}`, - 2: `${leftMiddleXAxis}` - }, - '┦': { - 1: `${bottomYAxisFromMiddle} ${leftMiddleXAxis}`, - 2: `${topYAxisFromTop}` - }, - '┧': { - 1: `${topYAxisFromMiddle}`, - 2: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` - }, - '┨': { - 1: `${leftMiddleXAxis}`, - 2: `${yAxis}` - }, - '┩': { - 2: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, - 1: `${bottomYAxisFromMiddle}` - }, - '┪': { - 1: `${topYAxisFromMiddle}`, - 2: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` - }, - '┫': { - 2: `${yAxis} ${leftMiddleXAxis}` - }, - '┬': { - 1: `${bottomYAxisFromBottom} ${xAxis}` - }, - '┭': { - 1: `${bottomYAxisFromBottom} ${rightMiddleXAxis}`, - 2: `${leftMiddleXAxis}` - }, - '┮': { - 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}`, - 2: `${rightMiddleXAxis}` - }, - '┯': { - 1: `${bottomYAxisFromBottom}`, - 2: `${leftMiddleXAxis} ${rightMiddleXAxis}` - }, - '┰': { - 1: `${xAxis}`, - 2: `${bottomYAxisFromBottom}` - }, - '┱': { - 1: `${rightMiddleXAxis}`, - 2: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` - }, - '┲': { - 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}`, - 2: `${rightMiddleXAxis}` - }, - '┳': { - 2: `${bottomYAxisFromBottom} ${xAxis}` - }, - '┴': { - 1: `${topYAxisFromMiddle} ${xAxis}` - }, - '┵': { - 1: `${topYAxisFromMiddle} ${rightMiddleXAxis}`, - 2: `${leftMiddleXAxis}` - }, - '┶': { - 1: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, - 2: `${rightMiddleXAxis}` - }, - '┷': { - 1: `${topYAxisFromMiddle}`, - 2: `${leftMiddleXAxis} ${rightMiddleXAxis}` - }, - '┸': { - 1: `${xAxis}`, - 2: `${topYAxisFromMiddle}` - }, - '┹': { - 1: `${rightMiddleXAxis}`, - 2: `${topYAxisFromMiddle} ${leftMiddleXAxis}` - }, - '┺': { - 1: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, - 2: `${rightMiddleXAxis}` - }, - '┻': { - 2: `${topYAxisFromMiddle} ${xAxis}` - }, - '┼': { - 1: `${yAxis} ${xAxis}` - }, - '┽': { - 1: `${yAxis} ${rightMiddleXAxis}`, - 2: `${leftMiddleXAxis}` - }, - '┾': { - 1: `${yAxis} ${leftMiddleXAxis}`, - 2: `${rightMiddleXAxis}` - }, - '┿': { - 1: `${yAxis}`, - 2: `${leftMiddleXAxis} ${rightMiddleXAxis}` - }, - '╀': { - 1: `${xAxis}`, - 2: `${yAxis}` - }, - '╁': { - 1: `${rightMiddleXAxis}`, - 2: `${yAxis} ${leftMiddleXAxis}` - }, - '╂': { - 1: `${yAxis} ${leftMiddleXAxis}`, - 2: `${rightMiddleXAxis}` - }, - '╃': { - 1: `${bottomYAxisFromBottom} ${rightMiddleXAxis}`, - 2: `${topYAxisFromTop} ${leftMiddleXAxis}` - }, - '╄': { - 1: `${topYAxisFromTop} ${leftMiddleXAxis}`, - 2: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` - }, - '╅': { - 1: `${topYAxisFromTop} ${rightMiddleXAxis}`, - 2: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` - }, - '╆': { - 1: `${topYAxisFromTop} ${leftMiddleXAxis}`, - 2: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` - }, - '╇': { - 1: `${bottomYAxisFromBottom}`, - 2: `${leftMiddleXAxis} ${topYAxisFromTop} ${rightMiddleXAxis}` - }, - '╈': { - 1: `${topYAxisFromTop}`, - 2: `${leftMiddleXAxis} ${bottomYAxisFromBottom} ${rightMiddleXAxis}` - }, - '╉': { - 1: `${rightMiddleXAxis}`, - 2: `${leftMiddleXAxis} ${yAxis}` - }, - '╊': { - 1: `${leftMiddleXAxis}`, - 2: `${rightMiddleXAxis} ${yAxis}` - }, - '╋': { - 2: `${yAxis} ${xAxis}` - }, - '╌': { - 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` - }, - '╍': { - 2: `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` - }, - '╎': { - 1: `${MOVE}${CENTER.TOP} ${TO}${'.5,.45'} ${MOVE}${'.5,.55'} ${TO}${CENTER.BOTTOM}` - }, - '╏': { - 2: `${MOVE}${CENTER.TOP} ${TO}${'.5,.45'} ${MOVE}${'.5,.55'} ${TO}${CENTER.BOTTOM}` - }, - '═': { - 1: `${MOVE}${'0,.45'} ${TO}${'1,.45'} ${MOVE}${'0,.55'} ${TO}${'1,.55'}` - }, - '║': { - 1: `${MOVE}${'.35,0'} ${TO}${'.35,1'} ${MOVE}${'.65,0'} ${TO}${'.65,1'}` - }, - '╒': { - 1: `${rightTopXLine} ${rightBottomXLine} ${MOVE}${'.55,1'} ${TO}${'.55,.45'}` - }, - '╓': { - 1: `${bottomLeftYLine} ${bottomRightYLine} ${MOVE}${'.3,.5'} ${TO}${'1,.5'}` - }, - '╔': { - 1: `${MOVE}${'.35,.45'} ${TO}${'1,.45'} ${MOVE}${'.35,.45'} ${TO}${'.35,1'} ${MOVE}${'.65,.65'} ${TO}${'1,.65'} ${MOVE}${'.65,.625'} ${TO}${'.65,1'}` - }, - '╕': { - 1: `${leftTopXLine} ${leftBottomXLine} ${MOVE}${'.55,1'} ${TO}${'.55,.45'}` - }, - '╖': { - 1: `${bottomLeftYLine} ${bottomRightYLine} ${MOVE}${'0,.5'} ${TO}${'.7,.5'}` - }, - '╗': { - 1: `${MOVE}${'.35,.45'} ${TO}${'1,.45'} ${MOVE}${'1,.45'} ${TO}${'1,1'} ${MOVE}${'.35,.65'} ${TO}${'.7,.65'} ${MOVE}${'.7,.65'} ${TO}${'.7,1'}` - }, - '╘': { - 1: `${MOVE}${'0,.85'} ${TO}${'.5,.85'} ${MOVE}${'0,1'} ${TO}${'.5,1'} ${MOVE}${'0,.5'} ${TO}${'0,1'}` - }, - '╙': { - 1: `${MOVE}${'0,.5'} ${TO}${'0,1'} ${MOVE}${'.35,.5'} ${TO}${'.35,1'} ${MOVE}${'0,1'} ${TO}${'.7,1'}` - }, - '╚': { - 1: `${MOVE}${'0,.5'} ${TO}${'0,1'} ${MOVE}${'.35,.5'} ${TO}${'.35,.85'} ${MOVE}${'0,1'} ${TO}${'.7,1'} ${MOVE}${'.5,.85'} ${TO}${'1,.85'}` - }, - '╛': { - 1: `${MOVE}${'0,.85'} ${TO}${'.5,.85'} ${MOVE}${'0,1'} ${TO}${'.5,1'} ${MOVE}${'.55,1'} ${TO}${'.55,.45'}` - }, - '╜': { - 1: `${bottomLeftYLine} ${bottomRightYLine} ${MOVE}${'0,1'} ${TO}${'.7,1'}` - }, - '╝': { - 1: `${MOVE}${'.35,.45'} ${TO}${'.35,.85'} ${MOVE}${'.65,.45'} ${TO} ${'.65,1'} ${MOVE}${'0,.85'} ${TO}${'.45,.85'} ${MOVE}${'0,1'} ${TO}${'.65,1'}` - }, - '╴': { - 1: `${leftMiddleXAxis}` - }, - '╵': { - 1: `${topYAxisFromMiddle}` - }, - '╶': { - 1: `${rightMiddleXAxis}` - }, - '╷': { - 1: `${bottomYAxisFromMiddle}` - }, - '╸': { - 2: `${leftMiddleXAxis}` - }, - '╹': { - 2: `${topYAxisFromMiddle}` - }, - '╺': { - 2: `${rightMiddleXAxis}` - }, - '╻': { - 2: `${bottomYAxisFromMiddle}` - }, - '╼': { - 1: `${leftMiddleXAxis}`, - 2: `${rightMiddleXAxis}` - }, - '╽': { - 1: `${topYAxisFromMiddle}`, - 2: `${bottomYAxisFromBottom}` - }, - '╾': { - 1: `${rightMiddleXAxis}`, - 2: `${leftMiddleXAxis}` - }, - '╿': { - 1: `${bottomYAxisFromBottom}`, - 2: `${topYAxisFromMiddle}` - } + /** └ */ TOP_TO_RIGHT = 'M.5,0 L.5,.5 L1,.5', + /** ┘ */ TOP_TO_LEFT = 'M.5,0 L.5,.5 L0,.5', + /** ┐ */ LEFT_TO_BOTTOM = 'M0,.5 L.5,.5 L.5,1', + /** ┌ */ RIGHT_TO_BOTTOM = 'M0.5,1 L.5,.5 L1,.5', + + /** ╵ */ MIDDLE_TO_TOP = 'M.5,.5 L0,.5', + /** ╴ */ MIDDLE_TO_LEFT = 'M.5,.5 L.5,0', + /** ╶ */ MIDDLE_TO_RIGHT = 'M.5,.5 L1,.5', + /** ╷ */ MIDDLE_TO_BOTTOM = 'M.5,.5 L.5,1', + + /** ┴ */ T_TOP = 'M0,.5 L1,.5 M.5,.5 L.5,0', + /** ┤ */ T_LEFT = 'M.5,0 L.5,1 M.5,.5 L0,.5', + /** ├ */ T_RIGHT = 'M.5,0 L.5,1 M.5,.5 L1,.5', + /** ┬ */ T_BOTTOM = 'M0,.5 L1,.5 M.5,.5 L.5,1', + + /** ┼ */ CROSS = 'M0,.5 L1,.5 M.5,0 L.5,1', +} + +const enum Style { + NORMAL = 1, + BOLD = 2 +} + +// TODO: Tweak normal and bold weights +const map: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } } = { + // Uniform normal and bold + '─': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT }, + '━': { [Style.BOLD]: Shapes.LEFT_TO_RIGHT }, + '│': { [Style.NORMAL]: Shapes.TOP_TO_BOTTOM }, + '┃': { [Style.BOLD]: Shapes.TOP_TO_BOTTOM }, + '┌': { [Style.NORMAL]: Shapes.RIGHT_TO_BOTTOM }, + '┏': { [Style.BOLD]: Shapes.RIGHT_TO_BOTTOM }, + '┐': { [Style.NORMAL]: Shapes.LEFT_TO_BOTTOM }, + '┓': { [Style.BOLD]: Shapes.LEFT_TO_BOTTOM }, + '└': { [Style.NORMAL]: Shapes.TOP_TO_RIGHT }, + '┗': { [Style.BOLD]: Shapes.TOP_TO_RIGHT }, + '┘': { [Style.NORMAL]: Shapes.TOP_TO_LEFT }, + '┛': { [Style.BOLD]: Shapes.TOP_TO_LEFT }, + '├': { [Style.NORMAL]: Shapes.T_RIGHT }, + '┣': { [Style.BOLD]: Shapes.T_RIGHT }, + '┤': { [Style.NORMAL]: Shapes.T_LEFT }, + '┫': { [Style.BOLD]: Shapes.T_LEFT }, + '┬': { [Style.NORMAL]: Shapes.T_BOTTOM }, + '┳': { [Style.BOLD]: Shapes.T_BOTTOM }, + '┴': { [Style.NORMAL]: Shapes.T_TOP }, + '┻': { [Style.BOLD]: Shapes.T_TOP }, + '┼': { [Style.NORMAL]: Shapes.CROSS }, + '╋': { [Style.BOLD]: Shapes.CROSS }, + '╴': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT }, + '╸': { [Style.BOLD]: Shapes.MIDDLE_TO_LEFT }, + '╵': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP }, + '╹': { [Style.BOLD]: Shapes.MIDDLE_TO_TOP }, + '╶': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT }, + '╺': { [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, + '╷': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM }, + '╻': { [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, + + // Mixed normal/bold + '┍': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, + '┎': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, + + // Double border + '═': { [Style.NORMAL]: (xp, yp) => `M0,${.5 - yp} L1,${.5 - yp} M0,${.5 + yp} L1,${.5 + yp}` }, + '║': { [Style.NORMAL]: (xp, yp) => `M${.5 - xp},0 L${.5 - xp},1 M${.5 + xp},0 L${.5 + xp},1` }, + '╒': { [Style.NORMAL]: (xp, yp) => `M.5,1 L.5,${.5 - yp} L1,${.5 - yp} M.5,${.5 + yp} L1,${.5 + yp}` }, + '╓': { [Style.NORMAL]: (xp, yp) => `M${.5 - xp},1 L${.5 - xp},.5 L1,.5 M${.5 + xp},.5 L${.5 + xp},1` }, + '╔': { [Style.NORMAL]: (xp, yp) => `M1,${.5 - yp} L${.5 - xp},${.5 - yp} L${.5 - xp},1 M1,${.5 + yp} L${.5 + xp},${.5 + yp} L${.5 + xp},1` }, + '╕': { [Style.NORMAL]: (xp, yp) => `M0,${.5 - yp} L.5,${.5 - yp} L.5,1 M0,${.5 + yp} L.5,${.5 + yp}` }, + '╖': { [Style.NORMAL]: (xp, yp) => `M${.5 + xp},1 L${.5 + xp},.5 L0,.5 M${.5 - xp},.5 L${.5 - xp},1` }, + '╗': { [Style.NORMAL]: (xp, yp) => `M0,${.5 + yp} L${.5 - xp},${.5 + yp} L${.5 - xp},1 M0,${.5 - yp} L${.5 + xp},${.5 - yp} L${.5 + xp},1` }, + '╘': { [Style.NORMAL]: (xp, yp) => `M.5,0 L.5,${.5 + yp} L1,${.5 + yp} M.5,${.5 - yp} L1,${.5 - yp}` }, + '╙': { [Style.NORMAL]: (xp, yp) => `M1,.5 L${.5 - xp},.5 L${.5 - xp},0 M${.5 + xp},.5 L${.5 + xp},0` }, + '╚': { [Style.NORMAL]: (xp, yp) => `M1,${.5 - yp} L${.5 + xp},${.5 - yp} L${.5 + xp},0 M1,${.5 + yp} L${.5 - xp},${.5 + yp} L${.5 - xp},0` }, + '╛': { [Style.NORMAL]: (xp, yp) => `M0,${.5 + yp} L.5,${.5 + yp} L.5,0 M0,${.5 - yp} L.5,${.5 - yp}` }, + '╜': { [Style.NORMAL]: (xp, yp) => `M0,.5 L${.5 + xp},.5 L${.5 + xp},0 M${.5 - xp},.5 L${.5 - xp},0 ` }, + '╝': { [Style.NORMAL]: (xp, yp) => `M0,${.5 - yp} L${.5 - xp},${.5 - yp} L${.5 - xp},0 M0,${.5 + yp} L${.5 + xp},${.5 + yp} L${.5 + xp},0` }, + '╞': { [Style.NORMAL]: (xp, yp) => `${Shapes.TOP_TO_BOTTOM} M.5,${.5 - yp} L1,${.5 - yp} M.5,${.5 + yp} L1,${.5 + yp}` }, + '╟': { [Style.NORMAL]: (xp, yp) => `M${.5 - xp},0 L${.5 - xp},1 M${.5 + xp},0 L${.5 + xp},1 M${.5 + xp},.5 L1,.5` }, + '╠': { [Style.NORMAL]: (xp, yp) => `M${.5 - xp},0 L${.5 - xp},1 M1,${.5 + yp} L${.5 + xp},${.5 + yp} L${.5 + xp},1 M1,${.5 - yp} L${.5 + xp},${.5 - yp} L${.5 + xp},0` }, + '╡': { [Style.NORMAL]: (xp, yp) => `${Shapes.TOP_TO_BOTTOM} M0,${.5 - yp} L.5,${.5 - yp} M0,${.5 + yp} L.5,${.5 + yp}` }, + '╢': { [Style.NORMAL]: (xp, yp) => `M0,.5 L${.5 - xp},.5 M${.5 - xp},0 L${.5 - xp},1 M${.5 + xp},0 L${.5 + xp},1` }, + '╣': { [Style.NORMAL]: (xp, yp) => `M${.5 + xp},0 L${.5 + xp},1 M0,${.5 + yp} L${.5 - xp},${.5 + yp} L${.5 - xp},1 M0,${.5 - yp} L${.5 - xp},${.5 - yp} L${.5 - xp},0` }, + '╤': { [Style.NORMAL]: (xp, yp) => `M0,${.5 - yp} L1,${.5 - yp} M0,${.5 + yp} L1,${.5 + yp} M.5,${.5 + yp} L.5,1` }, + '╥': { [Style.NORMAL]: (xp, yp) => `${Shapes.LEFT_TO_RIGHT} M${.5 - xp},.5 L${.5 - xp},1 M${.5 + xp},.5 L${.5 + xp},1` }, + '╦': { [Style.NORMAL]: (xp, yp) => `M0,${.5 - yp} L1,${.5 - yp} M0,${.5 + yp} L${.5 - xp},${.5 + yp} L${.5 - xp},1 M1,${.5 + yp} L${.5 + xp},${.5 + yp} L${.5 + xp},1` }, + '╧': { [Style.NORMAL]: (xp, yp) => `M.5,0 L.5,${.5 - yp} M0,${.5 - yp} L1,${.5 - yp} M0,${.5 + yp} L1,${.5 + yp}` }, + '╨': { [Style.NORMAL]: (xp, yp) => `${Shapes.LEFT_TO_RIGHT} M${.5 - xp},.5 L${.5 - xp},0 M${.5 + xp},.5 L${.5 + xp},0` }, + '╩': { [Style.NORMAL]: (xp, yp) => `M0,${.5 + yp} L1,${.5 + yp} M0,${.5 - yp} L${.5 - xp},${.5 - yp} L${.5 - xp},0 M1,${.5 - yp} L${.5 + xp},${.5 - yp} L${.5 + xp},0` }, + '╪': { [Style.NORMAL]: (xp, yp) => `${Shapes.TOP_TO_BOTTOM} M0,${.5 - yp} L1,${.5 - yp} M0,${.5 + yp} L1,${.5 + yp}` }, + '╫': { [Style.NORMAL]: (xp, yp) => `${Shapes.LEFT_TO_RIGHT} M${.5 - xp},0 L${.5 - xp},1 M${.5 + xp},0 L${.5 + xp},1` }, + '╬': { [Style.NORMAL]: (xp, yp) => `M0,${.5 + yp} L${.5 - xp},${.5 + yp} L${.5 - xp},1 M1,${.5 + yp} L${.5 + xp},${.5 + yp} L${.5 + xp},1 M0,${.5 - yp} L${.5 - xp},${.5 - yp} L${.5 - xp},0 M1,${.5 - yp} L${.5 + xp},${.5 - yp} L${.5 + xp},0` }, + + // Diagonal + '╱': { [Style.NORMAL]: 'M1,0 L0,1' }, + '╲': { [Style.NORMAL]: 'M0,0 L1,1' }, + '╳': { [Style.NORMAL]: 'M1,0 L0,1 M0,0 L1,1' }, + + // Mixed weight + '┑': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${leftMiddleXAxis}` }, + '┒': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom}` }, + '┕': { [Style.NORMAL]: `${topYAxisFromTop}`, [Style.BOLD]: `${rightMiddleXAxis}` }, + '┖': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop}` }, + '┙': { [Style.NORMAL]: `${topYAxisFromTop}`, [Style.BOLD]: `${leftMiddleXAxis}` }, + '┚': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop}` }, + '┝': { [Style.NORMAL]: `${yAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, + '┞': { [Style.NORMAL]: `${bottomYAxisFromMiddle} ${rightMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop}` }, + '┟': { [Style.NORMAL]: `${topYAxisFromMiddle} ${rightMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom}` }, + '┠': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${yAxis}` }, + '┡': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${topYAxisFromMiddle} ${rightMiddleXAxis}` }, + '┢': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` }, + '┥': { [Style.NORMAL]: `${yAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, + '┦': { [Style.NORMAL]: `${bottomYAxisFromMiddle} ${leftMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop}` }, + '┧': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` }, + '┨': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${yAxis}` }, + '┩': { [Style.NORMAL]: `${bottomYAxisFromMiddle}`, [Style.BOLD]: `${topYAxisFromMiddle} ${leftMiddleXAxis}` }, + '┪': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` }, + '┭': { [Style.NORMAL]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, + '┮': { [Style.NORMAL]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, + '┯': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${leftMiddleXAxis} ${rightMiddleXAxis}` }, + '┰': { [Style.NORMAL]: `${xAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom}` }, + '┱': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` }, + '┲': { [Style.NORMAL]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, + '┵': { [Style.NORMAL]: `${topYAxisFromMiddle} ${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, + '┶': { [Style.NORMAL]: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, + '┷': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${leftMiddleXAxis} ${rightMiddleXAxis}` }, + '┸': { [Style.NORMAL]: `${xAxis}`, [Style.BOLD]: `${topYAxisFromMiddle}` }, + '┹': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromMiddle} ${leftMiddleXAxis}` }, + '┺': { [Style.NORMAL]: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, + '┽': { [Style.NORMAL]: `${yAxis} ${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, + '┾': { [Style.NORMAL]: `${yAxis} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, + '┿': { [Style.NORMAL]: `${yAxis}`, [Style.BOLD]: `${leftMiddleXAxis} ${rightMiddleXAxis}` }, + '╀': { [Style.NORMAL]: `${xAxis}`, [Style.BOLD]: `${yAxis}` }, + '╁': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${yAxis} ${leftMiddleXAxis}` }, + '╂': { [Style.NORMAL]: `${yAxis} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, + '╃': { [Style.NORMAL]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop} ${leftMiddleXAxis}` }, + '╄': { [Style.NORMAL]: `${topYAxisFromTop} ${leftMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` }, + '╅': { [Style.NORMAL]: `${topYAxisFromTop} ${rightMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` }, + '╆': { [Style.NORMAL]: `${topYAxisFromTop} ${leftMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` }, + '╇': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${leftMiddleXAxis} ${topYAxisFromTop} ${rightMiddleXAxis}` }, + '╈': { [Style.NORMAL]: `${topYAxisFromTop}`, [Style.BOLD]: `${leftMiddleXAxis} ${bottomYAxisFromBottom} ${rightMiddleXAxis}` }, + '╉': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis} ${yAxis}` }, + '╊': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis} ${yAxis}` }, + '╼': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, + '╽': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${bottomYAxisFromBottom}` }, + '╾': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, + '╿': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${topYAxisFromMiddle}` }, + + // Dashed + '╌': { [Style.NORMAL]: `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` }, + '╍': { [Style.BOLD]: `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` }, + '┄': { [Style.NORMAL]: `` }, + '┅': { [Style.BOLD]: `` }, + '┈': { [Style.NORMAL]: `` }, + '┉': { [Style.BOLD]: `` }, + '╎': { [Style.NORMAL]: `${MOVE}${CENTER.TOP} ${TO}${'.5,.45'} ${MOVE}${'.5,.55'} ${TO}${CENTER.BOTTOM}` }, + '╏': { [Style.BOLD]: `${MOVE}${CENTER.TOP} ${TO}${'.5,.45'} ${MOVE}${'.5,.55'} ${TO}${CENTER.BOTTOM}` }, + '┆': { [Style.NORMAL]: `` }, + '┇': { [Style.BOLD]: `` }, + '┊': { [Style.NORMAL]: `` }, + '┋': { [Style.BOLD]: `` } }; const chars: { [index: string]: string } = { @@ -630,17 +451,30 @@ const chars: { [index: string]: string } = { // // '╳': `${MOVE}${} ${TO}${} ${TO}${}`, }; +// Give more specific name export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { - const match: { [fontWeight: number]: string } = map[c]; + const match: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } = map[c]; if (!match) { return; } for (const [fontWeight, instructions] of Object.entries(match)) { ctx.beginPath(); ctx.lineWidth = window.devicePixelRatio * Number.parseInt(fontWeight); - for (const instruction of instructions.split(' ')) { + let actualInstructions: string; + if (typeof instructions === 'function') { + const xp = .15; + const yp = .15 / cellHeight * cellWidth; + actualInstructions = instructions(xp, yp); + } else { + actualInstructions = instructions; + } + for (const instruction of actualInstructions.split(' ')) { const type = instruction[0]; const f = instructionMap[type]; + if (!f) { + console.error(`Could not find drawing instructions for "${type}"`); + continue; + } const coords: string[] = instruction.substring(1).split(','); if (!coords[0] || !coords[1]) { continue; @@ -670,8 +504,7 @@ function clamp(value: number, max: number, min: number = 0): number { const instructionMap: { [index: string]: any } = { 'M': (ctx: CanvasRenderingContext2D, x: number, y: number) => { - ctx.moveTo(x, y); - }, + ctx.moveTo(x, y); }, 'L': (ctx: CanvasRenderingContext2D, x: number, y: number) => { ctx.lineTo(x, y); } From 7549f0e92410f78007cdf29cd73c504eaec29c47 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 13 Aug 2021 15:09:04 -0700 Subject: [PATCH 303/377] Clean up --- demo/client.ts | 4 ++-- src/browser/renderer/BoxAndBlockCharacters.ts | 21 +++---------------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/demo/client.ts b/demo/client.ts index d7c0f840..cc467908 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -261,8 +261,8 @@ function runFakeTerminal(): void { term.write('└─┴─┘ ┗━┻━┛ ╚═╩═╝ └┴┘└┴┘└┺┛┗┹┘ └┴┘└┶┛┗┻┛┗┵┘\n\r'); term.write('\n\r'); term.write('Other:\n\r'); - term.write('╭─╮ ╲ ╱ ╷╻╎╏┆┇┊┋ ╺╾╴ ╌╌ ┄┄ ┈┈\n\r'); - term.write('│ │ ╳ ╽╿╎╏┆┇┊┋ ╶╼╸ ╍╍ ┅┅ ┉┉\n\r'); + term.write('╭─╮ ╲ ╱ ╷╻╎╏┆┇┊┋ ╺╾╴ ╌╌╌ ┄┄┄ ┈┈┈\n\r'); + term.write('│ │ ╳ ╽╿╎╏┆┇┊┋ ╶╼╸ ╍╍╍ ┅┅┅ ┉┉┉\n\r'); term.write('╰─╯ ╱ ╲ ╹╵╎╏┆┇┊┋\n\r'); term.write('\n\r'); term.write('All box drawing characters:\n\r'); diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index c220c9aa..9d99c285 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -243,22 +243,6 @@ const topYAxisFromMiddle = `${MOVE}${CENTER.TOP} ${TO}${CENTER.MIDDLE}`; const rightMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${RIGHT.MIDDLE}`; const leftMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${LEFT.MIDDLE}`; -const topXLine = `${MOVE}${'0,.45'} ${TO}${'1,.45'}`; -const bottomXLine = `${MOVE}${'0,.55'} ${TO}${'1,.55'}`; -const leftYLine = `${MOVE}${'.35,0'} ${TO}${'.35,1'}`; -const rightYLine = `${MOVE}${'.65,0'} ${TO}${'.65,1'}`; - -const leftTopXLine = `${MOVE}${'0,.45'} ${TO}${'.5,.45'}`; -const rightTopXLine = `${MOVE}${'.5,.45'} ${TO}${'1,.45'}`; - -const leftBottomXLine = `${MOVE}${'0,.55'} ${TO}${'.5,.55'}`; -const rightBottomXLine = `${MOVE}${'.5,.55'} ${TO}${'1,.55'}`; - -const bottomLeftYLine = `${MOVE}${'.35,.5'} ${TO}${'.35,1'}`; -const topLeftYLine = `${MOVE}${'.35,0'} ${TO}${'.35,.5'}`; - -const bottomRightYLine = `${MOVE}${'.65,.5'} ${TO}${'.65,1'}`; -const topRightYLine = `${MOVE}${'.65,0'} ${TO}${'.65,.5'}`; const enum Shapes { /** │ */ TOP_TO_BOTTOM = 'M.5,0 L.5,1', @@ -412,9 +396,10 @@ const map: { [character: string]: { [fontWeight: number]: string | ((xp: number, '╿': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${topYAxisFromMiddle}` }, // Dashed - '╌': { [Style.NORMAL]: `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` }, + // TODO: Spacing dashes evenly, use 1/2 padding on each edge so the line is continuous + '╌': { [Style.NORMAL]: `` }, // `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` }, '╍': { [Style.BOLD]: `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` }, - '┄': { [Style.NORMAL]: `` }, + '┄': { [Style.NORMAL]: `M.04,.5 L.96,.5` }, '┅': { [Style.BOLD]: `` }, '┈': { [Style.NORMAL]: `` }, '┉': { [Style.BOLD]: `` }, From 7344d62e81d3b4afaa628fc1cdd1cfbf01cc9f42 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Mon, 16 Aug 2021 09:39:44 -0700 Subject: [PATCH 304/377] clean up --- src/browser/renderer/BaseRenderLayer.ts | 4 +- src/browser/renderer/BoxAndBlockCharacters.ts | 59 +++++++------------ 2 files changed, 22 insertions(+), 41 deletions(-) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 31773f64..7b85d75e 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -17,7 +17,7 @@ import { IBufferService, IOptionsService } from 'common/services/Services'; import { throwIfFalsy } from 'browser/renderer/RendererUtils'; import { channels, color, rgba } from 'browser/Color'; import { removeElementFromParent } from 'browser/Dom'; -import { boxDrawingBoxes, boxDrawingLineSegments, draw } from 'browser/renderer/BoxAndBlockCharacters'; +import { boxDrawingBoxes, boxDrawingLineSegments, drawBoxChar } from 'browser/renderer/BoxAndBlockCharacters'; export abstract class BaseRenderLayer implements IRenderLayer { private _canvas: HTMLCanvasElement; @@ -422,7 +422,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { // increase # of pixels when font size incremented by 10 // this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); // yOffset - verticalCenter - draw(this._ctx, char, xOffset, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); + drawBoxChar(this._ctx, char, xOffset, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); return true; } diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 9d99c285..cdb8f259 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -264,6 +264,13 @@ const enum Shapes { /** ┬ */ T_BOTTOM = 'M0,.5 L1,.5 M.5,.5 L.5,1', /** ┼ */ CROSS = 'M0,.5 L1,.5 M.5,0 L.5,1', + + /** ╌ */ TWO_DASHES_HORIZONTAL = 'M.1,.5 L.45,.5 M.55,.5 L.9,.5', + /** ┄ */ THREE_DASHES_HORIZONTAL = 'M.052,.5 L.316,.5 M.0.421,.5 L.6315,.5 M.684,.5 L.947,.5', + /** ┉ */ FOUR_DASHES_HORIZONTAL = 'M.0588,.5 L.235,.5 M.294,.5 L.4705,.5 M.529,.5 L.7058,.5 M.765,.5 L.947,.5', + /** ╌ */ TWO_DASHES_VERTICAL = 'M.5,0 T.5,.45 M.5,.55 T.5,1', + /** ┄ */ THREE_DASHES_VERTICAL = 'M.5,.052 L.5,.316 M.5,.0.368 L.5.632 M.5,.684 L.5,.947', + /** ┉ */ FOUR_DASHES_VERTICAL = 'M.5,.0588 L.5,.235 M.5,.294 L.5,.4705 29 L.5,.7058 M.5,.765 L.5,.947', } const enum Style { @@ -397,47 +404,21 @@ const map: { [character: string]: { [fontWeight: number]: string | ((xp: number, // Dashed // TODO: Spacing dashes evenly, use 1/2 padding on each edge so the line is continuous - '╌': { [Style.NORMAL]: `` }, // `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` }, - '╍': { [Style.BOLD]: `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` }, - '┄': { [Style.NORMAL]: `M.04,.5 L.96,.5` }, - '┅': { [Style.BOLD]: `` }, - '┈': { [Style.NORMAL]: `` }, - '┉': { [Style.BOLD]: `` }, - '╎': { [Style.NORMAL]: `${MOVE}${CENTER.TOP} ${TO}${'.5,.45'} ${MOVE}${'.5,.55'} ${TO}${CENTER.BOTTOM}` }, - '╏': { [Style.BOLD]: `${MOVE}${CENTER.TOP} ${TO}${'.5,.45'} ${MOVE}${'.5,.55'} ${TO}${CENTER.BOTTOM}` }, - '┆': { [Style.NORMAL]: `` }, - '┇': { [Style.BOLD]: `` }, - '┊': { [Style.NORMAL]: `` }, - '┋': { [Style.BOLD]: `` } + '╌': { [Style.NORMAL]: Shapes.TWO_DASHES_HORIZONTAL }, + '╍': { [Style.BOLD]: Shapes.TWO_DASHES_HORIZONTAL }, + '┄': { [Style.NORMAL]: Shapes.THREE_DASHES_HORIZONTAL }, + '┅': { [Style.BOLD]: Shapes.THREE_DASHES_HORIZONTAL }, + '┈': { [Style.NORMAL]: Shapes.FOUR_DASHES_HORIZONTAL }, + '┉': { [Style.BOLD]: Shapes.FOUR_DASHES_HORIZONTAL }, + '╎': { [Style.NORMAL]: Shapes.TWO_DASHES_VERTICAL }, + '╏': { [Style.BOLD]: Shapes.TWO_DASHES_VERTICAL }, + '┆': { [Style.NORMAL]: Shapes.THREE_DASHES_VERTICAL }, + '┇': { [Style.BOLD]: Shapes.THREE_DASHES_VERTICAL }, + '┊': { [Style.NORMAL]: Shapes.FOUR_DASHES_VERTICAL }, + '┋': { [Style.BOLD]: Shapes.FOUR_DASHES_VERTICAL } }; -const chars: { [index: string]: string } = { -// // '╞': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╟': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╠': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╡': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╢': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╣': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╤': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╥': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╦': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╧': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╨': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╩': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╪': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╫': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╬': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╭': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╮': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╯': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╰': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╱': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╲': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╳': `${MOVE}${} ${TO}${} ${TO}${}`, -}; - -// Give more specific name -export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { +export function drawBoxChar(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { const match: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } = map[c]; if (!match) { return; From 62aa91a34dbfb8363fe4415b8658e58523e960e1 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Mon, 16 Aug 2021 09:51:20 -0700 Subject: [PATCH 305/377] clean up --- src/browser/renderer/BaseRenderLayer.ts | 15 +- src/browser/renderer/BoxAndBlockCharacters.ts | 165 ++---------------- 2 files changed, 13 insertions(+), 167 deletions(-) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 7b85d75e..44b23840 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -17,7 +17,7 @@ import { IBufferService, IOptionsService } from 'common/services/Services'; import { throwIfFalsy } from 'browser/renderer/RendererUtils'; import { channels, color, rgba } from 'browser/Color'; import { removeElementFromParent } from 'browser/Dom'; -import { boxDrawingBoxes, boxDrawingLineSegments, drawBoxChar } from 'browser/renderer/BoxAndBlockCharacters'; +import { boxCharacters, boxDrawingBoxes, drawBoxChar } from 'browser/renderer/BoxAndBlockCharacters'; export abstract class BaseRenderLayer implements IRenderLayer { private _canvas: HTMLCanvasElement; @@ -408,21 +408,12 @@ export abstract class BaseRenderLayer implements IRenderLayer { return true; } - const lineSegments = boxDrawingLineSegments[char]; + const lineSegments = boxCharacters[char]; if (!lineSegments) { return false; } - const xOffset = x * this._scaledCellWidth; - const verticalCenter = Math.round(this._scaledCellHeight / 2); - - const yOffset = y * this._scaledCellHeight + this._scaledCharTop + verticalCenter; - // const scale = window.devicePixelRatio; this._ctx.strokeStyle = this._ctx.fillStyle; - - // increase # of pixels when font size incremented by 10 - // this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); - // yOffset - verticalCenter - drawBoxChar(this._ctx, char, xOffset, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); + drawBoxChar(this._ctx, char, x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); return true; } diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index cdb8f259..23e76963 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -1,125 +1,3 @@ -export const boxDrawingLineSegments: { [index: string]: any } = { - '─': [{ x1: 0, y1: 3, x2: 6, y2: 3 }], - '━': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }], - '│': [{ x1: 3, y1: 0, x2: 3, y2: 6 }], - '┃': [{ x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], - '┌': [{ x1: 6, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], - '┍': [{ x1: 6, y1: 2, x2: 3, y2: 2 }, { x1: 3, y1: 2, x2: 3, y2: 6 }, { x1: 6, y1: 4, x2: 3, y2: 4 }], - '┎': [{ x1: 6, y1: 3, x2: 2, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], - '┏': [{ x1: 6, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 6 }, { x1: 6, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 6 }], - '┐': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], - '┑': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 3, y1: 2, x2: 3, y2: 6 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], - '┒': [{ x1: 0, y1: 3, x2: 4, y2: 3 }, { x1: 4, y1: 3, x2: 4, y2: 6 }, { x1: 2, y1: 3, x2: 2, y2: 6 }], - '┓': [{ x1: 0, y1: 2, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 4, y2: 6 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }], - '└': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], - '┕': [{ x1: 3, y1: 0, x2: 3, y2: 4 }, { x1: 3, y1: 4, x2: 6, y2: 4 }, { x1: 3, y1: 2, x2: 6, y2: 2 }], - '┖': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 2, y1: 3, x2: 6, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }], - '┗': [{ x1: 2, y1: 0, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 6, y2: 4 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }], - '┘': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 0 }], - '┙': [{ x1: 0, y1: 4, x2: 3, y2: 4 }, { x1: 3, y1: 4, x2: 3, y2: 0 }, { x1: 0, y1: 2, x2: 3, y2: 2 }], - '┚': [{ x1: 0, y1: 3, x2: 4, y2: 3 }, { x1: 4, y1: 3, x2: 4, y2: 0 }, { x1: 2, y1: 3, x2: 2, y2: 0 }], - '┛': [{ x1: 0, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 0 }, { x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }], - '├': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], - '┝': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], - '┞': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }, { x1: 4, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], - '┟': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], - '┠': [{ x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }, { x1: 4, y1: 3, x2: 6, y2: 3 }], - '┡': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 2, y1: 3, x2: 6, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], - '┢': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 2, y1: 6, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], - '┣': [{ x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 6, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 6 }], - '┤': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 3, x2: 3, y2: 3 }], - '┥': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], - '┦': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }, { x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], - '┧': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 0, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], - '┨': [{ x1: 0, y1: 3, x2: 2, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], - '┩': [{ x1: 2, y1: 0, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 0, y2: 2 }, { x1: 4, y1: 0, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 0, y2: 4 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], - '┪': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 3, y1: 2, x2: 3, y2: 6 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 3, y1: 0, x2: 3, y2: 3 }], - '┫': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], - '┬': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], - '┭': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }, { x1: 3, y1: 6, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], - '┮': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], - '┯': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 3, y1: 4, x2: 3, y2: 6 }], - '┰': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], - '┱': [{ x1: 0, y1: 2, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 4, y2: 6 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], - '┲': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 2, y1: 6, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], - '┳': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], - '┴': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 0, x2: 3, y2: 3 }], - '┵': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }, { x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], - '┶': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 0 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], - '┷': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 3, y1: 0, x2: 3, y2: 3 }], - '┸': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }], - '┹': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 0, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 0 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], - '┺': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 6, y2: 4 }, { x1: 3, y1: 0, x2: 3, y2: 2 }, { x1: 3, y1: 2, x2: 6, y2: 2 }], - '┻': [{ x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }], - '┼': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 0, x2: 3, y2: 6 }], - '┽': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 3, y1: 3, x2: 6, y2: 3 }, { x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], - '┾': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], - '┿': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }], - '╀': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }, { x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }], - '╁': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], - '╂': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], - '╃': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 0, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 0 }, { x1: 3, y1: 6, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], - '╄': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }, { x1: 2, y1: 0, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 6, y2: 4 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }], - '╅': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }, { x1: 0, y1: 2, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 4, y2: 6 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }], - '╆': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 0 }, { x1: 2, y1: 6, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], - '╇': [{ x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], - '╈': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], - '╉': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], - '╊': [{ x1: 0, y1: 3, x2: 2, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], - '╋': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], - '╌': [{ x1: 0, y1: 3, x2: 2, y2: 3 }, { x1: 4, y1: 3, x2: 6, y2: 3 }], - '╍': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], - '╎': [{ x1: 3, y1: 0, x2: 3, y2: 2 }, { x1: 3, y1: 4, x2: 3, y2: 6 }], - '╏': [{ x1: 2, y1: 0, x2: 2, y2: 2 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], - '═': [{ x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 6, y2: 5 }], - '║': [{ x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }], - '╒': [{ x1: 6, y1: 1, x2: 3, y2: 1 }, { x1: 3, y1: 1, x2: 3, y2: 6 }, { x1: 6, y1: 5, x2: 3, y2: 5 }], - '╓': [{ x1: 6, y1: 3, x2: 1, y2: 3 }, { x1: 1, y1: 3, x2: 1, y2: 6 }, { x1: 5, y1: 3, x2: 5, y2: 6 }], - '╔': [{ x1: 6, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 6 }, { x1: 6, y1: 5, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 5, y2: 6 }], - '╕': [{ x1: 0, y1: 1, x2: 3, y2: 1 }, { x1: 3, y1: 1, x2: 3, y2: 6 }, { x1: 0, y1: 5, x2: 3, y2: 5 }], - '╖': [{ x1: 0, y1: 3, x2: 5, y2: 3 }, { x1: 5, y1: 3, x2: 5, y2: 6 }, { x1: 1, y1: 3, x2: 1, y2: 6 }], - '╗': [{ x1: 0, y1: 1, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 5, y2: 6 }, { x1: 0, y1: 5, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 1, y2: 6 }], - '╘': [{ x1: 3, y1: 0, x2: 3, y2: 5 }, { x1: 3, y1: 5, x2: 6, y2: 5 }, { x1: 3, y1: 1, x2: 6, y2: 1 }], - '╙': [{ x1: 1, y1: 0, x2: 1, y2: 3 }, { x1: 1, y1: 3, x2: 6, y2: 3 }, { x1: 5, y1: 0, x2: 5, y2: 3 }], - '╚': [{ x1: 1, y1: 0, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 6, y2: 5 }, { x1: 5, y1: 0, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 6, y2: 1 }], - '╛': [{ x1: 0, y1: 1, x2: 3, y2: 1 }, { x1: 0, y1: 5, x2: 3, y2: 5 }, { x1: 3, y1: 5, x2: 3, y2: 0 }], - '╜': [{ x1: 0, y1: 3, x2: 5, y2: 3 }, { x1: 5, y1: 3, x2: 5, y2: 0 }, { x1: 1, y1: 3, x2: 1, y2: 0 }], - '╝': [{ x1: 0, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 0 }, { x1: 0, y1: 5, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 5, y2: 0 }], - '╞': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 3, y1: 1, x2: 6, y2: 1 }, { x1: 3, y1: 5, x2: 6, y2: 5 }], - '╟': [{ x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }, { x1: 5, y1: 3, x2: 6, y2: 3 }], - '╠': [{ x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 6, y2: 1 }, { x1: 5, y1: 6, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 6, y2: 5 }], - '╡': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 1, x2: 3, y2: 1 }, { x1: 0, y1: 5, x2: 3, y2: 5 }], - '╢': [{ x1: 0, y1: 3, x2: 1, y2: 3 }, { x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }], - '╣': [{ x1: 0, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 0 }, { x1: 0, y1: 5, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }], - '╤': [{ x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 6, y2: 5 }, { x1: 3, y1: 5, x2: 3, y2: 6 }], - '╥': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 1, y1: 3, x2: 1, y2: 6 }, { x1: 5, y1: 3, x2: 5, y2: 6 }], - '╦': [{ x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 1, y2: 6 }, { x1: 5, y1: 6, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 6, y2: 5 }], - '╧': [{ x1: 0, y1: 5, x2: 6, y2: 5 }, { x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 3, y1: 0, x2: 3, y2: 1 }], - '╨': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 1, y1: 0, x2: 1, y2: 3 }, { x1: 5, y1: 0, x2: 5, y2: 3 }], - '╩': [{ x1: 0, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 0 }, { x1: 5, y1: 0, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 6, y2: 5 }], - '╪': [{ x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 6, y2: 5 }, { x1: 3, y1: 0, x2: 3, y2: 6 }], - '╫': [{ x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }, { x1: 0, y1: 3, x2: 6, y2: 3 }], - '╬': [{ x1: 0, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 0 }, { x1: 5, y1: 0, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 6, y2: 1 }, { x1: 6, y1: 5, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 5, y2: 6 }, { x1: 1, y1: 6, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 0, y2: 5 }], - '╭': [{ x1: 6, y1: 3, x2: 3, y2: 6, cx1: 3, cy1: 3, cx2: 3, cy2: 3 }], - '╮': [{ x1: 0, y1: 3, x2: 3, y2: 6, cx1: 3, cy1: 3, cx2: 3, cy2: 3 }], - '╯': [{ x1: 0, y1: 3, x2: 3, y2: 0, cx1: 3, cy1: 3, cx2: 3, cy2: 3 }], - '╰': [{ x1: 3, y1: 0, x2: 6, y2: 3, cx1: 3, cy1: 3, cx2: 3, cy2: 3 }], - '╱': [{ x1: 0, y1: 6, x2: 6, y2: 0 }], - '╲': [{ x1: 0, y1: 0, x2: 6, y2: 6 }], - '╳': [{ x1: 0, y1: 6, x2: 6, y2: 0 }, { x1: 0, y1: 0, x2: 6, y2: 6 }], - '╴': [{ x1: 0, y1: 3, x2: 3, y2: 3 }], - '╵': [{ x1: 3, y1: 0, x2: 3, y2: 3 }], - '╶': [{ x1: 3, y1: 3, x2: 6, y2: 3 }], - '╷': [{ x1: 3, y1: 3, x2: 3, y2: 6 }], - '╸': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], - '╹': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }], - '╺': [{ x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], - '╻': [{ x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], - '╼': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], - '╽': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], - '╾': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], - '╿': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }] -}; export const boxDrawingBoxes: { [index: string]: any } = { '▀': [{ x: 0, y: 0, w: 8, h: 4 }], @@ -212,37 +90,14 @@ export const boxDrawingBoxes: { [index: string]: any } = { '\u{1FB97}': [{ x: 0, y: 2, w: 8, h: 2 }, { x: 0, y: 6, w: 8, h: 2 }] }; -export const enum CENTER { - BOTTOM ='.5,1', - TOP = '.5,0', - MIDDLE = '.5,.5' -} - -export const enum LEFT { - BOTTOM = '0,1', - TOP = '0,0', - MIDDLE = '0,.5' -} - -export const enum RIGHT { - BOTTOM = '1,1', - TOP = '1,0', - MIDDLE = '1,.5' -} - -const MOVE = 'M'; -const TO = 'L'; -const THICK = '!'; - -const yAxis = `${MOVE}${CENTER.TOP} ${TO}${CENTER.BOTTOM}`; -const xAxis = `${MOVE}${LEFT.MIDDLE} ${TO}${RIGHT.MIDDLE}`; -const bottomYAxisFromBottom = `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}`; -const bottomYAxisFromMiddle = `${MOVE}${CENTER.MIDDLE} ${TO}${CENTER.BOTTOM}`; -const topYAxisFromTop = `${MOVE}${CENTER.TOP} ${TO}${CENTER.MIDDLE}`; -const topYAxisFromMiddle = `${MOVE}${CENTER.TOP} ${TO}${CENTER.MIDDLE}`; -const rightMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${RIGHT.MIDDLE}`; -const leftMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${LEFT.MIDDLE}`; - +const yAxis = `M.5,0 L.5,1`; +const xAxis = `M0,.5 L1,.5`; +const bottomYAxisFromBottom = `M.5,1 L.5,.5`; +const bottomYAxisFromMiddle = `M.5,.5 L.5,1`; +const topYAxisFromTop = `M.5,0 L.5,.5`; +const topYAxisFromMiddle = `M.5,0 L.5,.5`; +const rightMiddleXAxis = `M.5,.5 L1,.5`; +const leftMiddleXAxis = `M.5,.5 L0,.5`; const enum Shapes { /** │ */ TOP_TO_BOTTOM = 'M.5,0 L.5,1', @@ -279,7 +134,7 @@ const enum Style { } // TODO: Tweak normal and bold weights -const map: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } } = { +export const boxCharacters: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } } = { // Uniform normal and bold '─': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT }, '━': { [Style.BOLD]: Shapes.LEFT_TO_RIGHT }, @@ -419,7 +274,7 @@ const map: { [character: string]: { [fontWeight: number]: string | ((xp: number, }; export function drawBoxChar(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { - const match: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } = map[c]; + const match: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } = boxCharacters[c]; if (!match) { return; } From 012468785b13ab9035dff84ed1f74424eed24bd4 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 16 Aug 2021 12:23:34 -0700 Subject: [PATCH 306/377] Clean up serialize addon --- .../src/SerializeAddon.ts | 93 +++++----- .../test/SerializeAddon.api.ts | 164 +++++++++--------- .../typings/xterm-addon-serialize.d.ts | 14 +- 3 files changed, 134 insertions(+), 137 deletions(-) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index 0caaaa03..5cd834b8 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -13,7 +13,10 @@ function constrain(value: number, low: number, high: number): number { // TODO: Refine this template class later abstract class BaseSerializeHandler { - constructor(private _buffer: IBuffer) { } + constructor( + protected readonly _buffer: IBuffer + ) { + } public serialize(startRow: number, endRow: number): string { // we need two of them to flip between old and new cell @@ -71,8 +74,6 @@ function equalFlags(cell1: IBufferCell, cell2: IBufferCell): boolean { && cell1.isDim() === cell2.isDim(); } - - class StringSerializeHandler extends BaseSerializeHandler { private _rowIndex: number = 0; private _allRows: string[] = new Array(); @@ -83,7 +84,7 @@ class StringSerializeHandler extends BaseSerializeHandler { // we can see a full colored cell and a null cell that only have background the same style // but the information isn't preserved by null cell itself // so wee need to record it when required. - private _cursorStyle: IBufferCell = this._buffer1.getNullCell(); + private _cursorStyle: IBufferCell = this._buffer.getNullCell(); // where exact the cursor styles comes from // because we can't copy the cell directly @@ -92,7 +93,7 @@ class StringSerializeHandler extends BaseSerializeHandler { private _cursorStyleCol: number = 0; // this is a null cell for reference for checking whether background is empty or not - private _backgroundCell: IBufferCell = this._buffer1.getNullCell(); + private _backgroundCell: IBufferCell = this._buffer.getNullCell(); private _firstRow: number = 0; private _lastCursorRow: number = 0; @@ -100,8 +101,11 @@ class StringSerializeHandler extends BaseSerializeHandler { private _lastContentCursorRow: number = 0; private _lastContentCursorCol: number = 0; - constructor(private _buffer1: IBuffer, private _terminal: Terminal) { - super(_buffer1); + constructor( + buffer: IBuffer, + private readonly _terminal: Terminal + ) { + super(buffer); } protected _beforeSerialize(rows: number, start: number, end: number): void { @@ -111,14 +115,14 @@ class StringSerializeHandler extends BaseSerializeHandler { this._firstRow = start; } - private _thisRowLastChar: IBufferCell = this._buffer1.getNullCell(); - private _thisRowLastSecondChar: IBufferCell = this._buffer1.getNullCell(); - private _nextRowFirstChar: IBufferCell = this._buffer1.getNullCell(); + private _thisRowLastChar: IBufferCell = this._buffer.getNullCell(); + private _thisRowLastSecondChar: IBufferCell = this._buffer.getNullCell(); + private _nextRowFirstChar: IBufferCell = this._buffer.getNullCell(); protected _rowEnd(row: number, isLastRow: boolean): void { // if there is colorful empty cell at line end, whe must pad it back, or the the color block will missing if (this._nullCellCount > 0 && !equalBg(this._cursorStyle, this._backgroundCell)) { // use clear right to set background. - this._currentRow += `\x1b[${this._nullCellCount}X`; + this._currentRow += `\u001b[${this._nullCellCount}X`; } let rowSeparator = ''; @@ -127,13 +131,13 @@ class StringSerializeHandler extends BaseSerializeHandler { if (!isLastRow) { // Enable BCE if (row - this._firstRow >= this._terminal.rows) { - this._buffer1.getLine(this._cursorStyleRow)?.getCell(this._cursorStyleCol, this._backgroundCell); + this._buffer.getLine(this._cursorStyleRow)?.getCell(this._cursorStyleCol, this._backgroundCell); } // Fetch current line - const currentLine = this._buffer1.getLine(row)!; + const currentLine = this._buffer.getLine(row)!; // Fetch next line - const nextLine = this._buffer1.getLine(row + 1)!; + const nextLine = this._buffer.getLine(row + 1)!; if (!nextLine.isWrapped) { // just insert the line break @@ -187,15 +191,15 @@ class StringSerializeHandler extends BaseSerializeHandler { // insert enough character to force the wrap rowSeparator = '-'.repeat(this._nullCellCount + 1); // move back and erase next line head - rowSeparator += '\x1b[1D\x1b[1X'; + rowSeparator += '\u001b[1D\u001b[1X'; if (this._nullCellCount > 0) { // do these because we filled the last several null slot, which we shouldn't - rowSeparator += '\x1b[A'; - rowSeparator += `\x1b[${currentLine.length - this._nullCellCount}C`; - rowSeparator += `\x1b[${this._nullCellCount}X`; - rowSeparator += `\x1b[${currentLine.length - this._nullCellCount}D`; - rowSeparator += '\x1b[B'; + rowSeparator += '\u001b[A'; + rowSeparator += `\u001b[${currentLine.length - this._nullCellCount}C`; + rowSeparator += `\u001b[${this._nullCellCount}X`; + rowSeparator += `\u001b[${currentLine.length - this._nullCellCount}D`; + rowSeparator += '\u001b[B'; } // This is content and need the be serialized even it is invisible. @@ -285,20 +289,20 @@ class StringSerializeHandler extends BaseSerializeHandler { if (this._nullCellCount > 0) { // use clear right to set background. if (!equalBg(this._cursorStyle, this._backgroundCell)) { - this._currentRow += `\x1b[${this._nullCellCount}X`; + this._currentRow += `\u001b[${this._nullCellCount}X`; } // use move right to move cursor. - this._currentRow += `\x1b[${this._nullCellCount}C`; + this._currentRow += `\u001b[${this._nullCellCount}C`; this._nullCellCount = 0; } this._lastContentCursorRow = this._lastCursorRow = row; this._lastContentCursorCol = this._lastCursorCol = col; - this._currentRow += `\x1b[${sgrSeq.join(';')}m`; + this._currentRow += `\u001b[${sgrSeq.join(';')}m`; // update the last cursor style - const line = this._buffer1.getLine(row); + const line = this._buffer.getLine(row); if (line !== undefined) { line.getCell(col, this._cursorStyle); this._cursorStyleRow = row; @@ -317,10 +321,10 @@ class StringSerializeHandler extends BaseSerializeHandler { // because style change is handled by previous stage // use move right when background is empty, use clear right when there is background. if (equalBg(this._cursorStyle, this._backgroundCell)) { - this._currentRow += `\x1b[${this._nullCellCount}C`; + this._currentRow += `\u001b[${this._nullCellCount}C`; } else { - this._currentRow += `\x1b[${this._nullCellCount}X`; - this._currentRow += `\x1b[${this._nullCellCount}C`; + this._currentRow += `\u001b[${this._nullCellCount}X`; + this._currentRow += `\u001b[${this._nullCellCount}C`; } this._nullCellCount = 0; } @@ -338,7 +342,7 @@ class StringSerializeHandler extends BaseSerializeHandler { // the fixup is only required for data without scrollback // because it will always be placed at last line otherwise - if (this._buffer1.length - this._firstRow <= this._terminal.rows) { + if (this._buffer.length - this._firstRow <= this._terminal.rows) { rowEnd = this._lastContentCursorRow + 1 - this._firstRow; this._lastCursorCol = this._lastContentCursorCol; this._lastCursorRow = this._lastContentCursorRow; @@ -354,8 +358,8 @@ class StringSerializeHandler extends BaseSerializeHandler { } // restore the cursor - const realCursorRow = this._buffer1.baseY + this._buffer1.cursorY; - const realCursorCol = this._buffer1.cursorX; + const realCursorRow = this._buffer.baseY + this._buffer.cursorY; + const realCursorCol = this._buffer.cursorX; const cursorMoved = (realCursorRow !== this._lastCursorRow || realCursorCol !== this._lastCursorCol); @@ -379,7 +383,6 @@ class StringSerializeHandler extends BaseSerializeHandler { moveRight(realCursorCol - this._lastCursorCol); } - return content; } } @@ -393,14 +396,11 @@ export class SerializeAddon implements ITerminalAddon { this._terminal = terminal; } - private _getString(buffer: IBuffer, scrollback?: number): string { + private _serializeBuffer(terminal: Terminal, buffer: IBuffer, scrollback?: number): string { const maxRows = buffer.length; - const handler = new StringSerializeHandler(buffer, this._terminal!); - - const correctRows = (scrollback === undefined) ? maxRows : constrain(scrollback + this!._terminal!.rows, 0, maxRows); - const result = handler.serialize(maxRows - correctRows, maxRows); - - return result; + const handler = new StringSerializeHandler(buffer, terminal); + const correctRows = (scrollback === undefined) ? maxRows : constrain(scrollback + terminal.rows, 0, maxRows); + return handler.serialize(maxRows - correctRows, maxRows); } public serialize(scrollback?: number): string { @@ -409,17 +409,16 @@ export class SerializeAddon implements ITerminalAddon { throw new Error('Cannot use addon until it has been loaded'); } - if (this._terminal.buffer.active.type === 'normal') { - return this._getString(this._terminal.buffer.active, scrollback); + // Normal buffer + let content = this._serializeBuffer(this._terminal, this._terminal.buffer.normal, scrollback); + + // Alternate buffer + if (this._terminal.buffer.active.type === 'alternate') { + const alternativeScreenContent = this._serializeBuffer(this._terminal, this._terminal.buffer.alternate, undefined); + content += `\u001b[?1049h\u001b[H${alternativeScreenContent}`; } - const normalScreenContent = this._getString(this._terminal.buffer.normal, scrollback); - // alt screen don't have scrollback - const alternativeScreenContent = this._getString(this._terminal.buffer.alternate, undefined); - - return normalScreenContent - + '\u001b[?1049h\u001b[H' - + alternativeScreenContent; + return content; } public dispose(): void { } diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index c46b3815..c8b7302f 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -89,8 +89,6 @@ describe('SerializeAddon', () => { }); it('empty content', async function(): Promise { - const rows = 10; - const cols = 10; assert.equal(await page.evaluate(`serializeAddon.serialize();`), ''); }); @@ -177,17 +175,17 @@ describe('SerializeAddon', () => { const cols = 10; const line = '+'.repeat(cols); const lines: string[] = [ - mkSGR(FG_P16_GREEN) + line, // Workaround: If we clear all flags a the end, serialize will use \x1b[0m to clear instead of the sepcific disable sequence - mkSGR(INVERSE) + line, - mkSGR(BOLD) + line, - mkSGR(UNDERLINED) + line, - mkSGR(BLINK) + line, - mkSGR(INVISIBLE) + line, - mkSGR(NO_INVERSE) + line, - mkSGR(NO_BOLD) + line, - mkSGR(NO_UNDERLINED) + line, - mkSGR(NO_BLINK) + line, - mkSGR(NO_INVISIBLE) + line + sgr(FG_P16_GREEN) + line, // Workaround: If we clear all flags a the end, serialize will use \x1b[0m to clear instead of the sepcific disable sequence + sgr(INVERSE) + line, + sgr(BOLD) + line, + sgr(UNDERLINED) + line, + sgr(BLINK) + line, + sgr(INVISIBLE) + line, + sgr(NO_INVERSE) + line, + sgr(NO_BOLD) + line, + sgr(NO_UNDERLINED) + line, + sgr(NO_BLINK) + line, + sgr(NO_INVISIBLE) + line ]; const rows = lines.length; await writeSync(page, lines.join('\\r\\n')); @@ -209,16 +207,16 @@ describe('SerializeAddon', () => { const cols = 10; const line = '+'.repeat(cols); const lines: string[] = [ - mkSGR(FG_P16_RED) + line, // fg Red, - mkSGR(UNDERLINED) + line, // fg Red, Underlined - mkSGR(FG_P16_GREEN) + line, // fg Green, Underlined - mkSGR(INVERSE) + line, // fg Green, Underlined, Inverse - mkSGR(NO_INVERSE) + line, // fg Green, Underlined - mkSGR(INVERSE) + line, // fg Green, Underlined, Inverse - mkSGR(BG_P16_YELLOW) + line, // fg Green, bg Yellow, Underlined, Inverse - mkSGR(FG_RESET) + line, // bg Yellow, Underlined, Inverse - mkSGR(BG_RESET) + line, // Underlined, Inverse - mkSGR(NORMAL) + line // Back to normal + sgr(FG_P16_RED) + line, // fg Red, + sgr(UNDERLINED) + line, // fg Red, Underlined + sgr(FG_P16_GREEN) + line, // fg Green, Underlined + sgr(INVERSE) + line, // fg Green, Underlined, Inverse + sgr(NO_INVERSE) + line, // fg Green, Underlined + sgr(INVERSE) + line, // fg Green, Underlined, Inverse + sgr(BG_P16_YELLOW) + line, // fg Green, bg Yellow, Underlined, Inverse + sgr(FG_RESET) + line, // bg Yellow, Underlined, Inverse + sgr(BG_RESET) + line, // Underlined, Inverse + sgr(NORMAL) + line // Back to normal ]; await writeSync(page, lines.join('\\r\\n')); assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n')); @@ -228,19 +226,19 @@ describe('SerializeAddon', () => { const cols = 10; const line = '+'.repeat(cols); const lines: string[] = [ - mkSGR(FG_P16_RED) + line, // fg Red - mkSGR(FG_P16_GREEN, BG_P16_YELLOW) + line, // fg Green, bg Yellow - mkSGR(UNDERLINED, ITALIC) + line, // fg Green, bg Yellow, Underlined, Italic - mkSGR(NO_UNDERLINED, NO_ITALIC) + line, // fg Green, bg Yellow - mkSGR(FG_RESET, ITALIC) + line, // bg Yellow, Italic - mkSGR(BG_RESET) + line, // Italic - mkSGR(NORMAL) + line, // Back to normal - mkSGR(FG_P16_RED) + line, // fg Red - mkSGR(FG_P16_GREEN, BG_P16_YELLOW) + line, // fg Green, bg Yellow - mkSGR(UNDERLINED, ITALIC) + line, // fg Green, bg Yellow, Underlined, Italic - mkSGR(NO_UNDERLINED, NO_ITALIC) + line, // fg Green, bg Yellow - mkSGR(FG_RESET, ITALIC) + line, // bg Yellow, Italic - mkSGR(BG_RESET) + line // Italic + sgr(FG_P16_RED) + line, // fg Red + sgr(FG_P16_GREEN, BG_P16_YELLOW) + line, // fg Green, bg Yellow + sgr(UNDERLINED, ITALIC) + line, // fg Green, bg Yellow, Underlined, Italic + sgr(NO_UNDERLINED, NO_ITALIC) + line, // fg Green, bg Yellow + sgr(FG_RESET, ITALIC) + line, // bg Yellow, Italic + sgr(BG_RESET) + line, // Italic + sgr(NORMAL) + line, // Back to normal + sgr(FG_P16_RED) + line, // fg Red + sgr(FG_P16_GREEN, BG_P16_YELLOW) + line, // fg Green, bg Yellow + sgr(UNDERLINED, ITALIC) + line, // fg Green, bg Yellow, Underlined, Italic + sgr(NO_UNDERLINED, NO_ITALIC) + line, // fg Green, bg Yellow + sgr(FG_RESET, ITALIC) + line, // bg Yellow, Italic + sgr(BG_RESET) + line // Italic ]; await writeSync(page, lines.join('\\r\\n')); assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n')); @@ -250,16 +248,16 @@ describe('SerializeAddon', () => { const cols = 10; const line = '+'.repeat(cols); const lines: string[] = [ - mkSGR(FG_P256_RED) + line, // fg Red 256, - mkSGR(UNDERLINED) + line, // fg Red 256, Underlined - mkSGR(FG_P256_GREEN) + line, // fg Green 256, Underlined - mkSGR(INVERSE) + line, // fg Green 256, Underlined, Inverse - mkSGR(NO_INVERSE) + line, // fg Green 256, Underlined - mkSGR(INVERSE) + line, // fg Green 256, Underlined, Inverse - mkSGR(BG_P256_YELLOW) + line, // fg Green 256, bg Yellow 256, Underlined, Inverse - mkSGR(FG_RESET) + line, // bg Yellow 256, Underlined, Inverse - mkSGR(BG_RESET) + line, // Underlined, Inverse - mkSGR(NORMAL) + line // Back to normal + sgr(FG_P256_RED) + line, // fg Red 256, + sgr(UNDERLINED) + line, // fg Red 256, Underlined + sgr(FG_P256_GREEN) + line, // fg Green 256, Underlined + sgr(INVERSE) + line, // fg Green 256, Underlined, Inverse + sgr(NO_INVERSE) + line, // fg Green 256, Underlined + sgr(INVERSE) + line, // fg Green 256, Underlined, Inverse + sgr(BG_P256_YELLOW) + line, // fg Green 256, bg Yellow 256, Underlined, Inverse + sgr(FG_RESET) + line, // bg Yellow 256, Underlined, Inverse + sgr(BG_RESET) + line, // Underlined, Inverse + sgr(NORMAL) + line // Back to normal ]; await writeSync(page, lines.join('\\r\\n')); assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n')); @@ -269,19 +267,19 @@ describe('SerializeAddon', () => { const cols = 10; const line = '+'.repeat(cols); const lines: string[] = [ - mkSGR(FG_P256_RED) + line, // fg Red 256 - mkSGR(FG_P256_GREEN, BG_P256_YELLOW) + line, // fg Green 256, bg Yellow 256 - mkSGR(UNDERLINED, ITALIC) + line, // fg Green 256, bg Yellow 256, Underlined, Italic - mkSGR(NO_UNDERLINED, NO_ITALIC) + line, // fg Green 256, bg Yellow 256 - mkSGR(FG_RESET, ITALIC) + line, // bg Yellow 256, Italic - mkSGR(BG_RESET) + line, // Italic - mkSGR(NORMAL) + line, // Back to normal - mkSGR(FG_P256_RED) + line, // fg Red 256 - mkSGR(FG_P256_GREEN, BG_P256_YELLOW) + line, // fg Green 256, bg Yellow 256 - mkSGR(UNDERLINED, ITALIC) + line, // fg Green 256, bg Yellow 256, Underlined, Italic - mkSGR(NO_UNDERLINED, NO_ITALIC) + line, // fg Green 256, bg Yellow 256 - mkSGR(FG_RESET, ITALIC) + line, // bg Yellow 256, Italic - mkSGR(BG_RESET) + line // Italic + sgr(FG_P256_RED) + line, // fg Red 256 + sgr(FG_P256_GREEN, BG_P256_YELLOW) + line, // fg Green 256, bg Yellow 256 + sgr(UNDERLINED, ITALIC) + line, // fg Green 256, bg Yellow 256, Underlined, Italic + sgr(NO_UNDERLINED, NO_ITALIC) + line, // fg Green 256, bg Yellow 256 + sgr(FG_RESET, ITALIC) + line, // bg Yellow 256, Italic + sgr(BG_RESET) + line, // Italic + sgr(NORMAL) + line, // Back to normal + sgr(FG_P256_RED) + line, // fg Red 256 + sgr(FG_P256_GREEN, BG_P256_YELLOW) + line, // fg Green 256, bg Yellow 256 + sgr(UNDERLINED, ITALIC) + line, // fg Green 256, bg Yellow 256, Underlined, Italic + sgr(NO_UNDERLINED, NO_ITALIC) + line, // fg Green 256, bg Yellow 256 + sgr(FG_RESET, ITALIC) + line, // bg Yellow 256, Italic + sgr(BG_RESET) + line // Italic ]; await writeSync(page, lines.join('\\r\\n')); assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n')); @@ -291,16 +289,16 @@ describe('SerializeAddon', () => { const cols = 10; const line = '+'.repeat(cols); const lines: string[] = [ - mkSGR(FG_RGB_RED) + line, // fg Red RGB, - mkSGR(UNDERLINED) + line, // fg Red RGB, Underlined - mkSGR(FG_RGB_GREEN) + line, // fg Green RGB, Underlined - mkSGR(INVERSE) + line, // fg Green RGB, Underlined, Inverse - mkSGR(NO_INVERSE) + line, // fg Green RGB, Underlined - mkSGR(INVERSE) + line, // fg Green RGB, Underlined, Inverse - mkSGR(BG_RGB_YELLOW) + line, // fg Green RGB, bg Yellow RGB, Underlined, Inverse - mkSGR(FG_RESET) + line, // bg Yellow RGB, Underlined, Inverse - mkSGR(BG_RESET) + line, // Underlined, Inverse - mkSGR(NORMAL) + line // Back to normal + sgr(FG_RGB_RED) + line, // fg Red RGB, + sgr(UNDERLINED) + line, // fg Red RGB, Underlined + sgr(FG_RGB_GREEN) + line, // fg Green RGB, Underlined + sgr(INVERSE) + line, // fg Green RGB, Underlined, Inverse + sgr(NO_INVERSE) + line, // fg Green RGB, Underlined + sgr(INVERSE) + line, // fg Green RGB, Underlined, Inverse + sgr(BG_RGB_YELLOW) + line, // fg Green RGB, bg Yellow RGB, Underlined, Inverse + sgr(FG_RESET) + line, // bg Yellow RGB, Underlined, Inverse + sgr(BG_RESET) + line, // Underlined, Inverse + sgr(NORMAL) + line // Back to normal ]; await writeSync(page, lines.join('\\r\\n')); assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n')); @@ -310,19 +308,19 @@ describe('SerializeAddon', () => { const cols = 10; const line = '+'.repeat(cols); const lines: string[] = [ - mkSGR(FG_RGB_RED) + line, // fg Red RGB - mkSGR(FG_RGB_GREEN, BG_RGB_YELLOW) + line, // fg Green RGB, bg Yellow RGB - mkSGR(UNDERLINED, ITALIC) + line, // fg Green RGB, bg Yellow RGB, Underlined, Italic - mkSGR(NO_UNDERLINED, NO_ITALIC) + line, // fg Green RGB, bg Yellow RGB - mkSGR(FG_RESET, ITALIC) + line, // bg Yellow RGB, Italic - mkSGR(BG_RESET) + line, // Italic - mkSGR(NORMAL) + line, // Back to normal - mkSGR(FG_RGB_RED) + line, // fg Red RGB - mkSGR(FG_RGB_GREEN, BG_RGB_YELLOW) + line, // fg Green RGB, bg Yellow RGB - mkSGR(UNDERLINED, ITALIC) + line, // fg Green RGB, bg Yellow RGB, Underlined, Italic - mkSGR(NO_UNDERLINED, NO_ITALIC) + line, // fg Green RGB, bg Yellow RGB - mkSGR(FG_RESET, ITALIC) + line, // bg Yellow RGB, Italic - mkSGR(BG_RESET) + line // Italic + sgr(FG_RGB_RED) + line, // fg Red RGB + sgr(FG_RGB_GREEN, BG_RGB_YELLOW) + line, // fg Green RGB, bg Yellow RGB + sgr(UNDERLINED, ITALIC) + line, // fg Green RGB, bg Yellow RGB, Underlined, Italic + sgr(NO_UNDERLINED, NO_ITALIC) + line, // fg Green RGB, bg Yellow RGB + sgr(FG_RESET, ITALIC) + line, // bg Yellow RGB, Italic + sgr(BG_RESET) + line, // Italic + sgr(NORMAL) + line, // Back to normal + sgr(FG_RGB_RED) + line, // fg Red RGB + sgr(FG_RGB_GREEN, BG_RGB_YELLOW) + line, // fg Green RGB, bg Yellow RGB + sgr(UNDERLINED, ITALIC) + line, // fg Green RGB, bg Yellow RGB, Underlined, Italic + sgr(NO_UNDERLINED, NO_ITALIC) + line, // fg Green RGB, bg Yellow RGB + sgr(FG_RESET, ITALIC) + line, // bg Yellow RGB, Italic + sgr(BG_RESET) + line // Italic ]; await writeSync(page, lines.join('\\r\\n')); assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n')); @@ -503,7 +501,7 @@ function digitsString(length: number, from: number = 0, sgr: string = ''): strin return s; } -function mkSGR(...seq: string[]): string { +function sgr(...seq: string[]): string { return `\x1b[${seq.join(';')}m`; } diff --git a/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts b/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts index 58be9a97..b55ee303 100644 --- a/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts +++ b/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts @@ -3,7 +3,6 @@ * @license MIT */ - import { Terminal, ITerminalAddon } from 'xterm'; declare module 'xterm-addon-serialize' { @@ -21,12 +20,13 @@ declare module 'xterm-addon-serialize' { public activate(terminal: Terminal): void; /** - * Serializes terminal rows into a string that can be written back to the terminal - * to restore the state. The cursor will also be positioned to the correct cell. - * When restoring a terminal it is best to do before `Terminal.open` is called - * to avoid wasting CPU cycles rendering incomplete frames. - * @param scrollback The number of rows in scrollback buffer to serialize, starting from the bottom of the - * scrollback buffer. This defaults to the all available rows in the scrollback buffer. + * Serializes terminal rows into a string that can be written back to the terminal to restore + * the state. The cursor will also be positioned to the correct cell. When restoring a terminal + * it is best to do before `Terminal.open` is called to avoid wasting CPU cycles rendering + * incomplete frames. + * @param scrollback The number of rows in scrollback buffer to serialize, starting from the + * bottom of the scrollback buffer. This defaults to the all available rows in the scrollback + * buffer. */ public serialize(scrollback?: number): string; From 6affe68ca3504921f5e8c1d67a4c697b26c784cf Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 16 Aug 2021 14:44:39 -0700 Subject: [PATCH 307/377] Expose modes api Part of #3417 --- src/browser/Terminal.ts | 46 +++++++++++++++--------------- src/browser/TestUtils.test.ts | 4 ++- src/browser/public/Terminal.ts | 23 ++++++++++++++- src/common/CoreTerminal.ts | 22 +++++++------- src/common/Types.d.ts | 4 ++- typings/xterm.d.ts | 52 ++++++++++++++++++++++++++++++++++ 6 files changed, 114 insertions(+), 37 deletions(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 004f2314..cc6498bd 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -267,8 +267,8 @@ export class Terminal extends CoreTerminal implements ITerminal { * Binds the desired focus behavior on a given terminal object. */ private _onTextAreaFocus(ev: KeyboardEvent): void { - if (this._coreService.decPrivateModes.sendFocus) { - this._coreService.triggerDataEvent(C0.ESC + '[I'); + if (this.coreService.decPrivateModes.sendFocus) { + this.coreService.triggerDataEvent(C0.ESC + '[I'); } this.updateCursorStyle(ev); this.element!.classList.add('focus'); @@ -292,8 +292,8 @@ export class Terminal extends CoreTerminal implements ITerminal { // screen readers reading it out. this.textarea!.value = ''; this.refresh(this.buffer.y, this.buffer.y); - if (this._coreService.decPrivateModes.sendFocus) { - this._coreService.triggerDataEvent(C0.ESC + '[O'); + if (this.coreService.decPrivateModes.sendFocus) { + this.coreService.triggerDataEvent(C0.ESC + '[O'); } this.element!.classList.remove('focus'); this._onBlur.fire(); @@ -340,7 +340,7 @@ export class Terminal extends CoreTerminal implements ITerminal { } copyHandler(event, this._selectionService!); })); - const pasteHandlerWrapper = (event: ClipboardEvent): void => handlePasteEvent(event, this.textarea!, this._coreService); + const pasteHandlerWrapper = (event: ClipboardEvent): void => handlePasteEvent(event, this.textarea!, this.coreService); this.register(addDisposableDomListener(this.textarea!, 'paste', pasteHandlerWrapper)); this.register(addDisposableDomListener(this.element!, 'paste', pasteHandlerWrapper)); @@ -526,7 +526,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this.register(addDisposableDomListener(this.element, 'mousedown', (e: MouseEvent) => this._selectionService!.onMouseDown(e))); // apply mouse event classes set by escape codes before terminal was attached - if (this._coreMouseService.areMouseEventsActive) { + if (this.coreMouseService.areMouseEventsActive) { this._selectionService.disable(); this.element.classList.add('enable-mouse-events'); } else { @@ -644,7 +644,7 @@ export class Terminal extends CoreTerminal implements ITerminal { return false; } - return self._coreMouseService.triggerMouseEvent({ + return self.coreMouseService.triggerMouseEvent({ col: pos.x - 33, // FIXME: why -33 here? row: pos.y - 33, button: but, @@ -699,11 +699,11 @@ export class Terminal extends CoreTerminal implements ITerminal { } } }; - this.register(this._coreMouseService.onProtocolChange(events => { + this.register(this.coreMouseService.onProtocolChange(events => { // apply global changes on events if (events) { if (this.optionsService.options.logLevel === 'debug') { - this._logService.debug('Binding to mouse events:', this._coreMouseService.explainEvents(events)); + this._logService.debug('Binding to mouse events:', this.coreMouseService.explainEvents(events)); } this.element!.classList.add('enable-mouse-events'); this._selectionService!.disable(); @@ -746,7 +746,7 @@ export class Terminal extends CoreTerminal implements ITerminal { } })); // force initial onProtocolChange so we dont miss early mouse requests - this._coreMouseService.activeProtocol = this._coreMouseService.activeProtocol; + this.coreMouseService.activeProtocol = this.coreMouseService.activeProtocol; /** * "Always on" event listeners. @@ -758,7 +758,7 @@ export class Terminal extends CoreTerminal implements ITerminal { // Don't send the mouse button to the pty if mouse events are disabled or // if the selection manager is having selection forced (ie. a modifier is // held). - if (!this._coreMouseService.areMouseEventsActive || this._selectionService!.shouldForceSelection(ev)) { + if (!this.coreMouseService.areMouseEventsActive || this._selectionService!.shouldForceSelection(ev)) { return; } @@ -791,12 +791,12 @@ export class Terminal extends CoreTerminal implements ITerminal { } // Construct and send sequences - const sequence = C0.ESC + (this._coreService.decPrivateModes.applicationCursorKeys ? 'O' : '[') + (ev.deltaY < 0 ? 'A' : 'B'); + const sequence = C0.ESC + (this.coreService.decPrivateModes.applicationCursorKeys ? 'O' : '[') + (ev.deltaY < 0 ? 'A' : 'B'); let data = ''; for (let i = 0; i < Math.abs(amount); i++) { data += sequence; } - this._coreService.triggerDataEvent(data, true); + this.coreService.triggerDataEvent(data, true); } return; } @@ -812,13 +812,13 @@ export class Terminal extends CoreTerminal implements ITerminal { }, { passive: false })); this.register(addDisposableDomListener(el, 'touchstart', (ev: TouchEvent) => { - if (this._coreMouseService.areMouseEventsActive) return; + if (this.coreMouseService.areMouseEventsActive) return; this.viewport!.onTouchStart(ev); return this.cancel(ev); }, { passive: true })); this.register(addDisposableDomListener(el, 'touchmove', (ev: TouchEvent) => { - if (this._coreMouseService.areMouseEventsActive) return; + if (this.coreMouseService.areMouseEventsActive) return; if (!this.viewport!.onTouchMove(ev)) { return this.cancel(ev); } @@ -860,8 +860,8 @@ export class Terminal extends CoreTerminal implements ITerminal { * Display the cursor element */ private _showCursor(): void { - if (!this._coreService.isCursorInitialized) { - this._coreService.isCursorInitialized = true; + if (!this.coreService.isCursorInitialized) { + this.coreService.isCursorInitialized = true; this.refresh(this.buffer.y, this.buffer.y); } } @@ -872,7 +872,7 @@ export class Terminal extends CoreTerminal implements ITerminal { } public paste(data: string): void { - paste(data, this.textarea!, this._coreService); + paste(data, this.textarea!, this.coreService); } /** @@ -1025,7 +1025,7 @@ export class Terminal extends CoreTerminal implements ITerminal { return false; } - const result = evaluateKeyboardEvent(event, this._coreService.decPrivateModes.applicationCursorKeys, this.browser.isMac, this.options.macOptionIsMeta); + const result = evaluateKeyboardEvent(event, this.coreService.decPrivateModes.applicationCursorKeys, this.browser.isMac, this.options.macOptionIsMeta); this.updateCursorStyle(event); @@ -1061,7 +1061,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this._onKey.fire({ key: result.key, domEvent: event }); this._showCursor(); - this._coreService.triggerDataEvent(result.key, true); + this.coreService.triggerDataEvent(result.key, true); // Cancel events when not in screen reader mode so events don't get bubbled up and handled by // other listeners. When screen reader mode is enabled, this could cause issues if the event @@ -1138,7 +1138,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this._onKey.fire({ key, domEvent: ev }); this._showCursor(); - this._coreService.triggerDataEvent(key, true); + this.coreService.triggerDataEvent(key, true); return true; } @@ -1247,12 +1247,12 @@ export class Terminal extends CoreTerminal implements ITerminal { case WindowsOptionsReportType.GET_WIN_SIZE_PIXELS: const canvasWidth = this._renderService.dimensions.scaledCanvasWidth.toFixed(0); const canvasHeight = this._renderService.dimensions.scaledCanvasHeight.toFixed(0); - this._coreService.triggerDataEvent(`${C0.ESC}[4;${canvasHeight};${canvasWidth}t`); + this.coreService.triggerDataEvent(`${C0.ESC}[4;${canvasHeight};${canvasWidth}t`); break; case WindowsOptionsReportType.GET_CELL_SIZE_PIXELS: const cellWidth = this._renderService.dimensions.scaledCellWidth.toFixed(0); const cellHeight = this._renderService.dimensions.scaledCellHeight.toFixed(0); - this._coreService.triggerDataEvent(`${C0.ESC}[6;${cellHeight};${cellWidth}t`); + this.coreService.triggerDataEvent(`${C0.ESC}[6;${cellHeight};${cellWidth}t`); break; } } diff --git a/src/browser/TestUtils.test.ts b/src/browser/TestUtils.test.ts index 9d5373c8..daa6843c 100644 --- a/src/browser/TestUtils.test.ts +++ b/src/browser/TestUtils.test.ts @@ -13,7 +13,7 @@ import { IBufferLine, ICellData, IAttributeData, ICircularList, XtermListener, I import { Buffer } from 'common/buffer/Buffer'; import * as Browser from 'common/Platform'; import { Terminal } from 'browser/Terminal'; -import { IUnicodeService, IOptionsService } from 'common/services/Services'; +import { IUnicodeService, IOptionsService, ICoreService, ICoreMouseService } from 'common/services/Services'; import { IFunctionIdentifier, IParams } from 'common/parser/Types'; import { AttributeData } from 'common/buffer/AttributeData'; @@ -43,6 +43,8 @@ export class MockTerminal implements ITerminal { public onRender!: IEvent<{ start: number, end: number }>; public onResize!: IEvent<{ cols: number, rows: number }>; public markers!: IMarker[]; + public coreMouseService!: ICoreMouseService; + public coreService!: ICoreService; public optionsService!: IOptionsService; public unicodeService!: IUnicodeService; public addMarker(cursorYOffset: number): IMarker { diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index 6af9db71..a76b1a22 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBufferNamespace as IBufferNamespaceApi, IParser, ILinkProvider, IUnicodeHandling, FontWeight } from 'xterm'; +import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBufferNamespace as IBufferNamespaceApi, IParser, ILinkProvider, IUnicodeHandling, FontWeight, IModes } from 'xterm'; import { ITerminal } from 'browser/Types'; import { Terminal as TerminalCore } from 'browser/Terminal'; import * as Strings from 'browser/LocalizableStrings'; @@ -68,6 +68,27 @@ export class Terminal implements ITerminalApi { this._checkProposedApi(); return this._core.markers; } + public get modes(): IModes { + const m = this._core.coreService.decPrivateModes; + let mouseTrackingMode: 'none' | 'x10' | 'vt200' | 'drag' | 'any' = 'none'; + switch (this._core.coreMouseService.activeProtocol) { + case 'X10': mouseTrackingMode = 'x10'; break; + case 'VT200': mouseTrackingMode = 'vt200'; break; + case 'DRAG': mouseTrackingMode = 'drag'; break; + case 'ANY': mouseTrackingMode = 'any'; break; + } + return { + applicationCursorKeysMode: m.applicationCursorKeys, + applicationKeypadMode: m.applicationKeypad, + bracketedPasteMode: m.bracketedPasteMode, + insertMode: this._core.coreService.modes.insertMode, + mouseTrackingMode: mouseTrackingMode, + originMode: m.origin, + reverseWraparoundMode: m.reverseWraparound, + sendFocusMode: m.sendFocus, + wraparoundMode: m.wraparound + }; + } public blur(): void { this._core.blur(); } diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index e61a8e16..96a4b53d 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -47,11 +47,11 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { protected readonly _instantiationService: IInstantiationService; protected readonly _bufferService: IBufferService; protected readonly _logService: ILogService; - protected readonly _coreService: ICoreService; protected readonly _charsetService: ICharsetService; - protected readonly _coreMouseService: ICoreMouseService; protected readonly _dirtyRowService: IDirtyRowService; + public readonly coreMouseService: ICoreMouseService; + public readonly coreService: ICoreService; public readonly unicodeService: IUnicodeService; public readonly optionsService: IOptionsService; @@ -100,10 +100,10 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this._instantiationService.setService(IBufferService, this._bufferService); this._logService = this._instantiationService.createInstance(LogService); this._instantiationService.setService(ILogService, this._logService); - this._coreService = this.register(this._instantiationService.createInstance(CoreService, () => this.scrollToBottom())); - this._instantiationService.setService(ICoreService, this._coreService); - this._coreMouseService = this._instantiationService.createInstance(CoreMouseService); - this._instantiationService.setService(ICoreMouseService, this._coreMouseService); + this.coreService = this.register(this._instantiationService.createInstance(CoreService, () => this.scrollToBottom())); + this._instantiationService.setService(ICoreService, this.coreService); + this.coreMouseService = this._instantiationService.createInstance(CoreMouseService); + this._instantiationService.setService(ICoreMouseService, this.coreMouseService); this._dirtyRowService = this._instantiationService.createInstance(DirtyRowService); this._instantiationService.setService(IDirtyRowService, this._dirtyRowService); this.unicodeService = this._instantiationService.createInstance(UnicodeService); @@ -112,14 +112,14 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this._instantiationService.setService(ICharsetService, this._charsetService); // Register input handler and handle/forward events - this._inputHandler = new InputHandler(this._bufferService, this._charsetService, this._coreService, this._dirtyRowService, this._logService, this.optionsService, this._coreMouseService, this.unicodeService); + this._inputHandler = new InputHandler(this._bufferService, this._charsetService, this.coreService, this._dirtyRowService, this._logService, this.optionsService, this.coreMouseService, this.unicodeService); this.register(forwardEvent(this._inputHandler.onLineFeed, this._onLineFeed)); this.register(this._inputHandler); // Setup listeners this.register(forwardEvent(this._bufferService.onResize, this._onResize)); - this.register(forwardEvent(this._coreService.onData, this._onData)); - this.register(forwardEvent(this._coreService.onBinary, this._onBinary)); + this.register(forwardEvent(this.coreService.onData, this._onData)); + this.register(forwardEvent(this.coreService.onBinary, this._onBinary)); this.register(this.optionsService.onOptionChange(key => this._updateOptions(key))); this.register(this._bufferService.onScroll(event => { this._onScroll.fire({ position: this._bufferService.buffer.ydisp, source: ScrollSource.TERMINAL }); @@ -250,8 +250,8 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this._inputHandler.reset(); this._bufferService.reset(); this._charsetService.reset(); - this._coreService.reset(); - this._coreMouseService.reset(); + this.coreService.reset(); + this.coreMouseService.reset(); } protected _updateOptions(key: string): void { diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index 36f75dd0..78e2e62d 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -7,10 +7,12 @@ import { IFunctionIdentifier, ITerminalOptions as IPublicTerminalOptions } from import { IEvent, IEventEmitter } from 'common/EventEmitter'; import { IDeleteEvent, IInsertEvent } from 'common/CircularList'; import { IParams } from 'common/parser/Types'; -import { IOptionsService, IUnicodeService } from 'common/services/Services'; +import { ICoreMouseService, ICoreService, IOptionsService, IUnicodeService } from 'common/services/Services'; import { IBufferSet } from 'common/buffer/Types'; export interface ICoreTerminal { + coreMouseService: ICoreMouseService; + coreService: ICoreService; optionsService: IOptionsService; unicodeService: IUnicodeService; buffers: IBufferSet; diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 035748fc..210e354d 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -622,6 +622,11 @@ declare module 'xterm' { */ readonly unicode: IUnicodeHandling; + /** + * Gets the terminal modes as set by SM/DECSET. + */ + readonly modes: IModes; + /** * Natural language strings that can be localized. */ @@ -1622,4 +1627,51 @@ declare module 'xterm' { */ activeVersion: string; } + + /** + * Terminal modes as set by SM/DECSET. + */ + export interface IModes { + /** + * Application Cursor Keys (DECCKM): `CSI ? 1 h` + */ + readonly applicationCursorKeysMode: boolean; + /** + * Application Keypad Mode (DECNKM): `CSI ? 6 6 h` + */ + readonly applicationKeypadMode: boolean; + /** + * Bracketed Paste Mode: `CSI ? 2 0 0 4 h` + */ + readonly bracketedPasteMode: boolean; + /** + * Insert Mode (IRM): `CSI 4 h` + */ + readonly insertMode: boolean; + /** + * Mouse Tracking, this can be one of the following: + * - none: This is the default value and can be reset with DECRST + * - x10: Send Mouse X & Y on button press `CSI ? 9 h` + * - vt200: Send Mouse X & Y on button press and release `CSI ? 1 0 0 0 h` + * - drag: Use Cell Motion Mouse Tracking `CSI ? 1 0 0 2 h` + * - any: Use All Motion Mouse Tracking `CSI ? 1 0 0 3 h` + */ + readonly mouseTrackingMode: 'none' | 'x10' | 'vt200' | 'drag' | 'any'; + /** + * Origin Mode (DECOM): `CSI ? 6 h` + */ + readonly originMode: boolean; + /** + * Reverse-wraparound Mode: `CSI ? 4 5 h` + */ + readonly reverseWraparoundMode: boolean; + /** + * Send FocusIn/FocusOut events: `CSI ? 1 0 0 3 h` + */ + readonly sendFocusMode: boolean; + /** + * Auto-Wrap Mode (DECAWM): `CSI ? 7 h` + */ + readonly wraparoundMode: boolean + } } From 8c25d57c260f275e3eb1c7e1890a647668d1a7a8 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 16 Aug 2021 15:01:30 -0700 Subject: [PATCH 308/377] xterm-headless modes api, tests for headless --- src/headless/public/Terminal.test.ts | 82 + src/headless/public/Terminal.ts | 23 +- typings/xterm-headless.d.ts | 2388 +++++++++++++------------- typings/xterm.d.ts | 2 +- 4 files changed, 1325 insertions(+), 1170 deletions(-) diff --git a/src/headless/public/Terminal.test.ts b/src/headless/public/Terminal.test.ts index 15e1efba..4247aae9 100644 --- a/src/headless/public/Terminal.test.ts +++ b/src/headless/public/Terminal.test.ts @@ -367,6 +367,88 @@ describe('Headless API Tests', function(): void { }); }); + describe('modes', () => { + it('defaults', () => { + deepStrictEqual(term.modes, { + applicationCursorKeysMode: false, + applicationKeypadMode: false, + bracketedPasteMode: false, + insertMode: false, + mouseTrackingMode: 'none', + originMode: false, + reverseWraparoundMode: false, + sendFocusMode: false, + wraparoundMode: true + }); + }); + it('applicationCursorKeysMode', async () => { + await writeSync('\x1b[?1h'); + strictEqual(term.modes.applicationCursorKeysMode, true); + await writeSync('\x1b[?1l'); + strictEqual(term.modes.applicationCursorKeysMode, false); + }); + it('applicationKeypadMode', async () => { + await writeSync('\x1b[?66h'); + strictEqual(term.modes.applicationKeypadMode, true); + await writeSync('\x1b[?66l'); + strictEqual(term.modes.applicationKeypadMode, false); + }); + it('bracketedPasteMode', async () => { + await writeSync('\x1b[?2004h'); + strictEqual(term.modes.bracketedPasteMode, true); + await writeSync('\x1b[?2004l'); + strictEqual(term.modes.bracketedPasteMode, false); + }); + it('insertMode', async () => { + await writeSync('\x1b[4h'); + strictEqual(term.modes.insertMode, true); + await writeSync('\x1b[4l'); + strictEqual(term.modes.insertMode, false); + }); + it('mouseTrackingMode', async () => { + await writeSync('\x1b[?9h'); + strictEqual(term.modes.mouseTrackingMode, 'x10'); + await writeSync('\x1b[?9l'); + strictEqual(term.modes.mouseTrackingMode, 'none'); + await writeSync('\x1b[?1000h'); + strictEqual(term.modes.mouseTrackingMode, 'vt200'); + await writeSync('\x1b[?1000l'); + strictEqual(term.modes.mouseTrackingMode, 'none'); + await writeSync('\x1b[?1002h'); + strictEqual(term.modes.mouseTrackingMode, 'drag'); + await writeSync('\x1b[?1002l'); + strictEqual(term.modes.mouseTrackingMode, 'none'); + await writeSync('\x1b[?1003h'); + strictEqual(term.modes.mouseTrackingMode, 'any'); + await writeSync('\x1b[?1003l'); + strictEqual(term.modes.mouseTrackingMode, 'none'); + }); + it('originMode', async () => { + await writeSync('\x1b[?6h'); + strictEqual(term.modes.originMode, true); + await writeSync('\x1b[?6l'); + strictEqual(term.modes.originMode, false); + }); + it('reverseWraparoundMode', async () => { + await writeSync('\x1b[?45h'); + strictEqual(term.modes.reverseWraparoundMode, true); + await writeSync('\x1b[?45l'); + strictEqual(term.modes.reverseWraparoundMode, false); + }); + it('sendFocusMode', async () => { + await writeSync('\x1b[?1004h'); + strictEqual(term.modes.sendFocusMode, true); + await writeSync('\x1b[?1004l'); + strictEqual(term.modes.sendFocusMode, false); + }); + it('wraparoundMode', async () => { + await writeSync('\x1b[?7h'); + strictEqual(term.modes.wraparoundMode, true); + await writeSync('\x1b[?7l'); + strictEqual(term.modes.wraparoundMode, false); + }); + }); + it('dispose', async () => { term.dispose(); strictEqual((term as any)._core._isDisposed, true); diff --git a/src/headless/public/Terminal.ts b/src/headless/public/Terminal.ts index a1de7fdb..29e83581 100644 --- a/src/headless/public/Terminal.ts +++ b/src/headless/public/Terminal.ts @@ -7,7 +7,7 @@ import { IEvent } from 'common/EventEmitter'; import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi'; import { ParserApi } from 'common/public/ParserApi'; import { UnicodeApi } from 'common/public/UnicodeApi'; -import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalAddon, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-headless'; +import { IBufferNamespace as IBufferNamespaceApi, IMarker, IModes, IParser, ITerminalAddon, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-headless'; import { Terminal as TerminalCore } from 'headless/Terminal'; import { AddonManager } from 'common/public/AddonManager'; @@ -61,6 +61,27 @@ export class Terminal implements ITerminalApi { this._checkProposedApi(); return this._core.markers; } + public get modes(): IModes { + const m = this._core.coreService.decPrivateModes; + let mouseTrackingMode: 'none' | 'x10' | 'vt200' | 'drag' | 'any' = 'none'; + switch (this._core.coreMouseService.activeProtocol) { + case 'X10': mouseTrackingMode = 'x10'; break; + case 'VT200': mouseTrackingMode = 'vt200'; break; + case 'DRAG': mouseTrackingMode = 'drag'; break; + case 'ANY': mouseTrackingMode = 'any'; break; + } + return { + applicationCursorKeysMode: m.applicationCursorKeys, + applicationKeypadMode: m.applicationKeypad, + bracketedPasteMode: m.bracketedPasteMode, + insertMode: this._core.coreService.modes.insertMode, + mouseTrackingMode: mouseTrackingMode, + originMode: m.origin, + reverseWraparoundMode: m.reverseWraparound, + sendFocusMode: m.sendFocus, + wraparoundMode: m.wraparound + }; + } public resize(columns: number, rows: number): void { this._verifyIntegers(columns, rows); this._core.resize(columns, rows); diff --git a/typings/xterm-headless.d.ts b/typings/xterm-headless.d.ts index 03e7567a..b6e1505b 100644 --- a/typings/xterm-headless.d.ts +++ b/typings/xterm-headless.d.ts @@ -8,1246 +8,1298 @@ */ declare module 'xterm-headless' { + /** + * A string representing log level. + */ + export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off'; + + /** + * An object containing start up options for the terminal. + */ + export interface ITerminalOptions { /** - * A string representing log level. + * Whether to allow the use of proposed API. When false, any usage of APIs + * marked as experimental/proposed will throw an error. This defaults to + * true currently, but will change to false in v5.0. */ - export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off'; + allowProposedApi?: boolean; /** - * An object containing start up options for the terminal. + * Whether background should support non-opaque color. It must be set before + * executing the `Terminal.open()` method and can't be changed later without + * executing it again. Note that enabling this can negatively impact + * performance. */ - export interface ITerminalOptions { - /** - * Whether to allow the use of proposed API. When false, any usage of APIs - * marked as experimental/proposed will throw an error. This defaults to - * true currently, but will change to false in v5.0. - */ - allowProposedApi?: boolean; - - /** - * Whether background should support non-opaque color. It must be set before - * executing the `Terminal.open()` method and can't be changed later without - * executing it again. Note that enabling this can negatively impact - * performance. - */ - allowTransparency?: boolean; - - /** - * If enabled, alt + click will move the prompt cursor to position - * underneath the mouse. The default is true. - */ - altClickMovesCursor?: boolean; - - /** - * A data uri of the sound to use for the bell when `bellStyle = 'sound'`. - */ - bellSound?: string; - - /** - * The type of the bell notification the terminal will use. - */ - bellStyle?: 'none' | 'sound'; - - /** - * When enabled the cursor will be set to the beginning of the next line - * with every new line. This is equivalent to sending '\r\n' for each '\n'. - * Normally the termios settings of the underlying PTY deals with the - * translation of '\n' to '\r\n' and this setting should not be used. If you - * deal with data from a non-PTY related source, this settings might be - * useful. - */ - convertEol?: boolean; - - /** - * The number of columns in the terminal. - */ - cols?: number; - - /** - * Whether the cursor blinks. - */ - cursorBlink?: boolean; - - /** - * The style of the cursor. - */ - cursorStyle?: 'block' | 'underline' | 'bar'; - - /** - * The width of the cursor in CSS pixels when `cursorStyle` is set to 'bar'. - */ - cursorWidth?: number; - - /** - * Whether input should be disabled. - */ - disableStdin?: boolean; - - /** - * Whether to draw bold text in bright colors. The default is true. - */ - drawBoldTextInBrightColors?: boolean; - - /** - * The modifier key hold to multiply scroll speed. - */ - fastScrollModifier?: 'alt' | 'ctrl' | 'shift' | undefined; - - /** - * The spacing in whole pixels between characters. - */ - letterSpacing?: number; - - /** - * The line height used to render text. - */ - lineHeight?: number; - - /** - * The duration in milliseconds before link tooltip events fire when - * hovering on a link. - * @deprecated This will be removed when the link matcher API is removed. - */ - linkTooltipHoverDuration?: number; - - /** - * What log level to use, this will log for all levels below and including - * what is set: - * - * 1. debug - * 2. info (default) - * 3. warn - * 4. error - * 5. off - */ - logLevel?: LogLevel; - - /** - * Whether to treat option as the meta key. - */ - macOptionIsMeta?: boolean; - - /** - * Whether holding a modifier key will force normal selection behavior, - * regardless of whether the terminal is in mouse events mode. This will - * also prevent mouse events from being emitted by the terminal. For - * example, this allows you to use xterm.js' regular selection inside tmux - * with mouse mode enabled. - */ - macOptionClickForcesSelection?: boolean; - - /** - * The minimum contrast ratio for text in the terminal, setting this will - * change the foreground color dynamically depending on whether the contrast - * ratio is met. Example values: - * - * - 1: The default, do nothing. - * - 4.5: Minimum for WCAG AA compliance. - * - 7: Minimum for WCAG AAA compliance. - * - 21: White on black or black on white. - */ - minimumContrastRatio?: number; - - /** - * Whether to select the word under the cursor on right click, this is - * standard behavior in a lot of macOS applications. - */ - rightClickSelectsWord?: boolean; - - /** - * The number of rows in the terminal. - */ - rows?: number; - - /** - * Whether screen reader support is enabled. When on this will expose - * supporting elements in the DOM to support NVDA on Windows and VoiceOver - * on macOS. - */ - screenReaderMode?: boolean; - - /** - * The amount of scrollback in the terminal. Scrollback is the amount of - * rows that are retained when lines are scrolled beyond the initial - * viewport. - */ - scrollback?: number; - - /** - * The scrolling speed multiplier used for adjusting normal scrolling speed. - */ - scrollSensitivity?: number; - - /** - * The size of tab stops in the terminal. - */ - tabStopWidth?: number; - - /** - * The color theme of the terminal. - */ - theme?: ITheme; - - /** - * Whether "Windows mode" is enabled. Because Windows backends winpty and - * conpty operate by doing line wrapping on their side, xterm.js does not - * have access to wrapped lines. When Windows mode is enabled the following - * changes will be in effect: - * - * - Reflow is disabled. - * - Lines are assumed to be wrapped if the last character of the line is - * not whitespace. - */ - windowsMode?: boolean; - - /** - * A string containing all characters that are considered word separated by the - * double click to select work logic. - */ - wordSeparator?: string; - - /** - * Enable various window manipulation and report features. - * All features are disabled by default for security reasons. - */ - windowOptions?: IWindowOptions; - } + allowTransparency?: boolean; /** - * Contains colors to theme the terminal with. + * If enabled, alt + click will move the prompt cursor to position + * underneath the mouse. The default is true. */ - export interface ITheme { - /** The default foreground color */ - foreground?: string; - /** The default background color */ - background?: string; - /** The cursor color */ - cursor?: string; - /** The accent color of the cursor (fg color for a block cursor) */ - cursorAccent?: string; - /** The selection background color (can be transparent) */ - selection?: string; - /** ANSI black (eg. `\x1b[30m`) */ - black?: string; - /** ANSI red (eg. `\x1b[31m`) */ - red?: string; - /** ANSI green (eg. `\x1b[32m`) */ - green?: string; - /** ANSI yellow (eg. `\x1b[33m`) */ - yellow?: string; - /** ANSI blue (eg. `\x1b[34m`) */ - blue?: string; - /** ANSI magenta (eg. `\x1b[35m`) */ - magenta?: string; - /** ANSI cyan (eg. `\x1b[36m`) */ - cyan?: string; - /** ANSI white (eg. `\x1b[37m`) */ - white?: string; - /** ANSI bright black (eg. `\x1b[1;30m`) */ - brightBlack?: string; - /** ANSI bright red (eg. `\x1b[1;31m`) */ - brightRed?: string; - /** ANSI bright green (eg. `\x1b[1;32m`) */ - brightGreen?: string; - /** ANSI bright yellow (eg. `\x1b[1;33m`) */ - brightYellow?: string; - /** ANSI bright blue (eg. `\x1b[1;34m`) */ - brightBlue?: string; - /** ANSI bright magenta (eg. `\x1b[1;35m`) */ - brightMagenta?: string; - /** ANSI bright cyan (eg. `\x1b[1;36m`) */ - brightCyan?: string; - /** ANSI bright white (eg. `\x1b[1;37m`) */ - brightWhite?: string; - } + altClickMovesCursor?: boolean; /** - * An object that can be disposed via a dispose function. + * A data uri of the sound to use for the bell when `bellStyle = 'sound'`. */ - export interface IDisposable { - dispose(): void; - } + bellSound?: string; /** - * An event that can be listened to. + * The type of the bell notification the terminal will use. + */ + bellStyle?: 'none' | 'sound'; + + /** + * When enabled the cursor will be set to the beginning of the next line + * with every new line. This is equivalent to sending '\r\n' for each '\n'. + * Normally the termios settings of the underlying PTY deals with the + * translation of '\n' to '\r\n' and this setting should not be used. If you + * deal with data from a non-PTY related source, this settings might be + * useful. + */ + convertEol?: boolean; + + /** + * The number of columns in the terminal. + */ + cols?: number; + + /** + * Whether the cursor blinks. + */ + cursorBlink?: boolean; + + /** + * The style of the cursor. + */ + cursorStyle?: 'block' | 'underline' | 'bar'; + + /** + * The width of the cursor in CSS pixels when `cursorStyle` is set to 'bar'. + */ + cursorWidth?: number; + + /** + * Whether input should be disabled. + */ + disableStdin?: boolean; + + /** + * Whether to draw bold text in bright colors. The default is true. + */ + drawBoldTextInBrightColors?: boolean; + + /** + * The modifier key hold to multiply scroll speed. + */ + fastScrollModifier?: 'alt' | 'ctrl' | 'shift' | undefined; + + /** + * The spacing in whole pixels between characters. + */ + letterSpacing?: number; + + /** + * The line height used to render text. + */ + lineHeight?: number; + + /** + * The duration in milliseconds before link tooltip events fire when + * hovering on a link. + * @deprecated This will be removed when the link matcher API is removed. + */ + linkTooltipHoverDuration?: number; + + /** + * What log level to use, this will log for all levels below and including + * what is set: + * + * 1. debug + * 2. info (default) + * 3. warn + * 4. error + * 5. off + */ + logLevel?: LogLevel; + + /** + * Whether to treat option as the meta key. + */ + macOptionIsMeta?: boolean; + + /** + * Whether holding a modifier key will force normal selection behavior, + * regardless of whether the terminal is in mouse events mode. This will + * also prevent mouse events from being emitted by the terminal. For + * example, this allows you to use xterm.js' regular selection inside tmux + * with mouse mode enabled. + */ + macOptionClickForcesSelection?: boolean; + + /** + * The minimum contrast ratio for text in the terminal, setting this will + * change the foreground color dynamically depending on whether the contrast + * ratio is met. Example values: + * + * - 1: The default, do nothing. + * - 4.5: Minimum for WCAG AA compliance. + * - 7: Minimum for WCAG AAA compliance. + * - 21: White on black or black on white. + */ + minimumContrastRatio?: number; + + /** + * Whether to select the word under the cursor on right click, this is + * standard behavior in a lot of macOS applications. + */ + rightClickSelectsWord?: boolean; + + /** + * The number of rows in the terminal. + */ + rows?: number; + + /** + * Whether screen reader support is enabled. When on this will expose + * supporting elements in the DOM to support NVDA on Windows and VoiceOver + * on macOS. + */ + screenReaderMode?: boolean; + + /** + * The amount of scrollback in the terminal. Scrollback is the amount of + * rows that are retained when lines are scrolled beyond the initial + * viewport. + */ + scrollback?: number; + + /** + * The scrolling speed multiplier used for adjusting normal scrolling speed. + */ + scrollSensitivity?: number; + + /** + * The size of tab stops in the terminal. + */ + tabStopWidth?: number; + + /** + * The color theme of the terminal. + */ + theme?: ITheme; + + /** + * Whether "Windows mode" is enabled. Because Windows backends winpty and + * conpty operate by doing line wrapping on their side, xterm.js does not + * have access to wrapped lines. When Windows mode is enabled the following + * changes will be in effect: + * + * - Reflow is disabled. + * - Lines are assumed to be wrapped if the last character of the line is + * not whitespace. + */ + windowsMode?: boolean; + + /** + * A string containing all characters that are considered word separated by the + * double click to select work logic. + */ + wordSeparator?: string; + + /** + * Enable various window manipulation and report features. + * All features are disabled by default for security reasons. + */ + windowOptions?: IWindowOptions; + } + + /** + * Contains colors to theme the terminal with. + */ + export interface ITheme { + /** The default foreground color */ + foreground?: string; + /** The default background color */ + background?: string; + /** The cursor color */ + cursor?: string; + /** The accent color of the cursor (fg color for a block cursor) */ + cursorAccent?: string; + /** The selection background color (can be transparent) */ + selection?: string; + /** ANSI black (eg. `\x1b[30m`) */ + black?: string; + /** ANSI red (eg. `\x1b[31m`) */ + red?: string; + /** ANSI green (eg. `\x1b[32m`) */ + green?: string; + /** ANSI yellow (eg. `\x1b[33m`) */ + yellow?: string; + /** ANSI blue (eg. `\x1b[34m`) */ + blue?: string; + /** ANSI magenta (eg. `\x1b[35m`) */ + magenta?: string; + /** ANSI cyan (eg. `\x1b[36m`) */ + cyan?: string; + /** ANSI white (eg. `\x1b[37m`) */ + white?: string; + /** ANSI bright black (eg. `\x1b[1;30m`) */ + brightBlack?: string; + /** ANSI bright red (eg. `\x1b[1;31m`) */ + brightRed?: string; + /** ANSI bright green (eg. `\x1b[1;32m`) */ + brightGreen?: string; + /** ANSI bright yellow (eg. `\x1b[1;33m`) */ + brightYellow?: string; + /** ANSI bright blue (eg. `\x1b[1;34m`) */ + brightBlue?: string; + /** ANSI bright magenta (eg. `\x1b[1;35m`) */ + brightMagenta?: string; + /** ANSI bright cyan (eg. `\x1b[1;36m`) */ + brightCyan?: string; + /** ANSI bright white (eg. `\x1b[1;37m`) */ + brightWhite?: string; + } + + /** + * An object that can be disposed via a dispose function. + */ + export interface IDisposable { + dispose(): void; + } + + /** + * An event that can be listened to. + * @returns an `IDisposable` to stop listening. + */ + export interface IEvent { + (listener: (arg1: T, arg2: U) => any): IDisposable; + } + + /** + * Represents a specific line in the terminal that is tracked when scrollback + * is trimmed and lines are added or removed. This is a single line that may + * be part of a larger wrapped line. + */ + export interface IMarker extends IDisposable { + /** + * A unique identifier for this marker. + */ + readonly id: number; + + /** + * Whether this marker is disposed. + */ + readonly isDisposed: boolean; + + /** + * The actual line index in the buffer at this point in time. This is set to + * -1 if the marker has been disposed. + */ + readonly line: number; + + /** + * Event listener to get notified when the marker gets disposed. Automatic disposal + * might happen for a marker, that got invalidated by scrolling out or removal of + * a line from the buffer. + */ + onDispose: IEvent; + } + + /** + * The set of localizable strings. + */ + export interface ILocalizableStrings { + /** + * The aria label for the underlying input textarea for the terminal. + */ + promptLabel: string; + + /** + * Announcement for when line reading is suppressed due to too many lines + * being printed to the terminal when `screenReaderMode` is enabled. + */ + tooMuchOutput: string; + } + + /** + * Enable various window manipulation and report features (CSI Ps ; Ps ; Ps t). + * + * Most settings have no default implementation, as they heavily rely on + * the embedding environment. + * + * To implement a feature, create a custom CSI hook like this: + * ```ts + * term.parser.addCsiHandler({final: 't'}, params => { + * const ps = params[0]; + * switch (ps) { + * case XY: + * ... // your implementation for option XY + * return true; // signal Ps=XY was handled + * } + * return false; // any Ps that was not handled + * }); + * ``` + * + * Note on security: + * Most features are meant to deal with some information of the host machine + * where the terminal runs on. This is seen as a security risk possibly leaking + * sensitive data of the host to the program in the terminal. Therefore all options + * (even those without a default implementation) are guarded by the boolean flag + * and disabled by default. + */ + export interface IWindowOptions { + /** + * Ps=1 De-iconify window. + * No default implementation. + */ + restoreWin?: boolean; + /** + * Ps=2 Iconify window. + * No default implementation. + */ + minimizeWin?: boolean; + /** + * Ps=3 ; x ; y + * Move window to [x, y]. + * No default implementation. + */ + setWinPosition?: boolean; + /** + * Ps = 4 ; height ; width + * Resize the window to given `height` and `width` in pixels. + * Omitted parameters should reuse the current height or width. + * Zero parameters should use the display's height or width. + * No default implementation. + */ + setWinSizePixels?: boolean; + /** + * Ps=5 Raise the window to the front of the stacking order. + * No default implementation. + */ + raiseWin?: boolean; + /** + * Ps=6 Lower the xterm window to the bottom of the stacking order. + * No default implementation. + */ + lowerWin?: boolean; + /** Ps=7 Refresh the window. */ + refreshWin?: boolean; + /** + * Ps = 8 ; height ; width + * Resize the text area to given height and width in characters. + * Omitted parameters should reuse the current height or width. + * Zero parameters use the display's height or width. + * No default implementation. + */ + setWinSizeChars?: boolean; + /** + * Ps=9 ; 0 Restore maximized window. + * Ps=9 ; 1 Maximize window (i.e., resize to screen size). + * Ps=9 ; 2 Maximize window vertically. + * Ps=9 ; 3 Maximize window horizontally. + * No default implementation. + */ + maximizeWin?: boolean; + /** + * Ps=10 ; 0 Undo full-screen mode. + * Ps=10 ; 1 Change to full-screen. + * Ps=10 ; 2 Toggle full-screen. + * No default implementation. + */ + fullscreenWin?: boolean; + /** Ps=11 Report xterm window state. + * If the xterm window is non-iconified, it returns "CSI 1 t". + * If the xterm window is iconified, it returns "CSI 2 t". + * No default implementation. + */ + getWinState?: boolean; + /** + * Ps=13 Report xterm window position. Result is "CSI 3 ; x ; y t". + * Ps=13 ; 2 Report xterm text-area position. Result is "CSI 3 ; x ; y t". + * No default implementation. + */ + getWinPosition?: boolean; + /** + * Ps=14 Report xterm text area size in pixels. Result is "CSI 4 ; height ; width t". + * Ps=14 ; 2 Report xterm window size in pixels. Result is "CSI 4 ; height ; width t". + * Has a default implementation. + */ + getWinSizePixels?: boolean; + /** + * Ps=15 Report size of the screen in pixels. Result is "CSI 5 ; height ; width t". + * No default implementation. + */ + getScreenSizePixels?: boolean; + /** + * Ps=16 Report xterm character cell size in pixels. Result is "CSI 6 ; height ; width t". + * Has a default implementation. + */ + getCellSizePixels?: boolean; + /** + * Ps=18 Report the size of the text area in characters. Result is "CSI 8 ; height ; width t". + * Has a default implementation. + */ + getWinSizeChars?: boolean; + /** + * Ps=19 Report the size of the screen in characters. Result is "CSI 9 ; height ; width t". + * No default implementation. + */ + getScreenSizeChars?: boolean; + /** + * Ps=20 Report xterm window's icon label. Result is "OSC L label ST". + * No default implementation. + */ + getIconTitle?: boolean; + /** + * Ps=21 Report xterm window's title. Result is "OSC l label ST". + * No default implementation. + */ + getWinTitle?: boolean; + /** + * Ps=22 ; 0 Save xterm icon and window title on stack. + * Ps=22 ; 1 Save xterm icon title on stack. + * Ps=22 ; 2 Save xterm window title on stack. + * All variants have a default implementation. + */ + pushTitle?: boolean; + /** + * Ps=23 ; 0 Restore xterm icon and window title from stack. + * Ps=23 ; 1 Restore xterm icon title from stack. + * Ps=23 ; 2 Restore xterm window title from stack. + * All variants have a default implementation. + */ + popTitle?: boolean; + /** + * Ps>=24 Resize to Ps lines (DECSLPP). + * DECSLPP is not implemented. This settings is also used to + * enable / disable DECCOLM (earlier variant of DECSLPP). + */ + setWinLines?: boolean; + } + + /** + * The class that represents an xterm.js terminal. + */ + export class Terminal implements IDisposable { + /** + * The number of rows in the terminal's viewport. Use + * `ITerminalOptions.rows` to set this in the constructor and + * `Terminal.resize` for when the terminal exists. + */ + readonly rows: number; + + /** + * The number of columns in the terminal's viewport. Use + * `ITerminalOptions.cols` to set this in the constructor and + * `Terminal.resize` for when the terminal exists. + */ + readonly cols: number; + + /** + * (EXPERIMENTAL) The terminal's current buffer, this might be either the + * normal buffer or the alt buffer depending on what's running in the + * terminal. + */ + readonly buffer: IBufferNamespace; + + /** + * (EXPERIMENTAL) Get all markers registered against the buffer. If the alt + * buffer is active this will always return []. + */ + readonly markers: ReadonlyArray; + + /** + * (EXPERIMENTAL) Get the parser interface to register + * custom escape sequence handlers. + */ + readonly parser: IParser; + + /** + * (EXPERIMENTAL) Get the Unicode handling interface + * to register and switch Unicode version. + */ + readonly unicode: IUnicodeHandling; + + /** + * Gets the terminal modes as set by SM/DECSET. + */ + readonly modes: IModes; + + /** + * Natural language strings that can be localized. + */ + static strings: ILocalizableStrings; + + /** + * Creates a new `Terminal` object. + * + * @param options An object containing a set of options. + */ + constructor(options?: ITerminalOptions); + + /** + * Adds an event listener for when the bell is triggered. * @returns an `IDisposable` to stop listening. */ - export interface IEvent { - (listener: (arg1: T, arg2: U) => any): IDisposable; - } + onBell: IEvent; /** - * Represents a specific line in the terminal that is tracked when scrollback - * is trimmed and lines are added or removed. This is a single line that may - * be part of a larger wrapped line. + * Adds an event listener for when a binary event fires. This is used to + * enable non UTF-8 conformant binary messages to be sent to the backend. + * Currently this is only used for a certain type of mouse reports that + * happen to be not UTF-8 compatible. + * The event value is a JS string, pass it to the underlying pty as + * binary data, e.g. `pty.write(Buffer.from(data, 'binary'))`. + * @returns an `IDisposable` to stop listening. */ - export interface IMarker extends IDisposable { - /** - * A unique identifier for this marker. - */ - readonly id: number; - - /** - * Whether this marker is disposed. - */ - readonly isDisposed: boolean; - - /** - * The actual line index in the buffer at this point in time. This is set to - * -1 if the marker has been disposed. - */ - readonly line: number; - - /** - * Event listener to get notified when the marker gets disposed. Automatic disposal - * might happen for a marker, that got invalidated by scrolling out or removal of - * a line from the buffer. - */ - onDispose: IEvent; - } + onBinary: IEvent; /** - * The set of localizable strings. + * Adds an event listener for the cursor moves. + * @returns an `IDisposable` to stop listening. */ - export interface ILocalizableStrings { - /** - * The aria label for the underlying input textarea for the terminal. - */ - promptLabel: string; - - /** - * Announcement for when line reading is suppressed due to too many lines - * being printed to the terminal when `screenReaderMode` is enabled. - */ - tooMuchOutput: string; - } + onCursorMove: IEvent; /** - * Enable various window manipulation and report features (CSI Ps ; Ps ; Ps t). - * - * Most settings have no default implementation, as they heavily rely on - * the embedding environment. - * - * To implement a feature, create a custom CSI hook like this: - * ```ts - * term.parser.addCsiHandler({final: 't'}, params => { - * const ps = params[0]; - * switch (ps) { - * case XY: - * ... // your implementation for option XY - * return true; // signal Ps=XY was handled - * } - * return false; // any Ps that was not handled - * }); - * ``` - * - * Note on security: - * Most features are meant to deal with some information of the host machine - * where the terminal runs on. This is seen as a security risk possibly leaking - * sensitive data of the host to the program in the terminal. Therefore all options - * (even those without a default implementation) are guarded by the boolean flag - * and disabled by default. + * Adds an event listener for when a data event fires. This happens for + * example when the user types or pastes into the terminal. The event value + * is whatever `string` results, in a typical setup, this should be passed + * on to the backing pty. + * @returns an `IDisposable` to stop listening. */ - export interface IWindowOptions { - /** - * Ps=1 De-iconify window. - * No default implementation. - */ - restoreWin?: boolean; - /** - * Ps=2 Iconify window. - * No default implementation. - */ - minimizeWin?: boolean; - /** - * Ps=3 ; x ; y - * Move window to [x, y]. - * No default implementation. - */ - setWinPosition?: boolean; - /** - * Ps = 4 ; height ; width - * Resize the window to given `height` and `width` in pixels. - * Omitted parameters should reuse the current height or width. - * Zero parameters should use the display's height or width. - * No default implementation. - */ - setWinSizePixels?: boolean; - /** - * Ps=5 Raise the window to the front of the stacking order. - * No default implementation. - */ - raiseWin?: boolean; - /** - * Ps=6 Lower the xterm window to the bottom of the stacking order. - * No default implementation. - */ - lowerWin?: boolean; - /** Ps=7 Refresh the window. */ - refreshWin?: boolean; - /** - * Ps = 8 ; height ; width - * Resize the text area to given height and width in characters. - * Omitted parameters should reuse the current height or width. - * Zero parameters use the display's height or width. - * No default implementation. - */ - setWinSizeChars?: boolean; - /** - * Ps=9 ; 0 Restore maximized window. - * Ps=9 ; 1 Maximize window (i.e., resize to screen size). - * Ps=9 ; 2 Maximize window vertically. - * Ps=9 ; 3 Maximize window horizontally. - * No default implementation. - */ - maximizeWin?: boolean; - /** - * Ps=10 ; 0 Undo full-screen mode. - * Ps=10 ; 1 Change to full-screen. - * Ps=10 ; 2 Toggle full-screen. - * No default implementation. - */ - fullscreenWin?: boolean; - /** Ps=11 Report xterm window state. - * If the xterm window is non-iconified, it returns "CSI 1 t". - * If the xterm window is iconified, it returns "CSI 2 t". - * No default implementation. - */ - getWinState?: boolean; - /** - * Ps=13 Report xterm window position. Result is "CSI 3 ; x ; y t". - * Ps=13 ; 2 Report xterm text-area position. Result is "CSI 3 ; x ; y t". - * No default implementation. - */ - getWinPosition?: boolean; - /** - * Ps=14 Report xterm text area size in pixels. Result is "CSI 4 ; height ; width t". - * Ps=14 ; 2 Report xterm window size in pixels. Result is "CSI 4 ; height ; width t". - * Has a default implementation. - */ - getWinSizePixels?: boolean; - /** - * Ps=15 Report size of the screen in pixels. Result is "CSI 5 ; height ; width t". - * No default implementation. - */ - getScreenSizePixels?: boolean; - /** - * Ps=16 Report xterm character cell size in pixels. Result is "CSI 6 ; height ; width t". - * Has a default implementation. - */ - getCellSizePixels?: boolean; - /** - * Ps=18 Report the size of the text area in characters. Result is "CSI 8 ; height ; width t". - * Has a default implementation. - */ - getWinSizeChars?: boolean; - /** - * Ps=19 Report the size of the screen in characters. Result is "CSI 9 ; height ; width t". - * No default implementation. - */ - getScreenSizeChars?: boolean; - /** - * Ps=20 Report xterm window's icon label. Result is "OSC L label ST". - * No default implementation. - */ - getIconTitle?: boolean; - /** - * Ps=21 Report xterm window's title. Result is "OSC l label ST". - * No default implementation. - */ - getWinTitle?: boolean; - /** - * Ps=22 ; 0 Save xterm icon and window title on stack. - * Ps=22 ; 1 Save xterm icon title on stack. - * Ps=22 ; 2 Save xterm window title on stack. - * All variants have a default implementation. - */ - pushTitle?: boolean; - /** - * Ps=23 ; 0 Restore xterm icon and window title from stack. - * Ps=23 ; 1 Restore xterm icon title from stack. - * Ps=23 ; 2 Restore xterm window title from stack. - * All variants have a default implementation. - */ - popTitle?: boolean; - /** - * Ps>=24 Resize to Ps lines (DECSLPP). - * DECSLPP is not implemented. This settings is also used to - * enable / disable DECCOLM (earlier variant of DECSLPP). - */ - setWinLines?: boolean; - } + onData: IEvent; /** - * The class that represents an xterm.js terminal. + * Adds an event listener for when a line feed is added. + * @returns an `IDisposable` to stop listening. */ - export class Terminal implements IDisposable { - /** - * The number of rows in the terminal's viewport. Use - * `ITerminalOptions.rows` to set this in the constructor and - * `Terminal.resize` for when the terminal exists. - */ - readonly rows: number; + onLineFeed: IEvent; - /** - * The number of columns in the terminal's viewport. Use - * `ITerminalOptions.cols` to set this in the constructor and - * `Terminal.resize` for when the terminal exists. - */ - readonly cols: number; + /** + * Adds an event listener for when the terminal is resized. The event value + * contains the new size. + * @returns an `IDisposable` to stop listening. + */ + onResize: IEvent<{ cols: number, rows: number }>; - /** - * (EXPERIMENTAL) The terminal's current buffer, this might be either the - * normal buffer or the alt buffer depending on what's running in the - * terminal. - */ - readonly buffer: IBufferNamespace; + /** + * Adds an event listener for when a scroll occurs. The event value is the + * new position of the viewport. + * @returns an `IDisposable` to stop listening. + */ + onScroll: IEvent; - /** - * (EXPERIMENTAL) Get all markers registered against the buffer. If the alt - * buffer is active this will always return []. - */ - readonly markers: ReadonlyArray; + /** + * Adds an event listener for when an OSC 0 or OSC 2 title change occurs. + * The event value is the new title. + * @returns an `IDisposable` to stop listening. + */ + onTitleChange: IEvent; - /** - * (EXPERIMENTAL) Get the parser interface to register - * custom escape sequence handlers. - */ - readonly parser: IParser; + /** + * Resizes the terminal. It's best practice to debounce calls to resize, + * this will help ensure that the pty can respond to the resize event + * before another one occurs. + * @param x The number of columns to resize to. + * @param y The number of rows to resize to. + */ + resize(columns: number, rows: number): void; - /** - * (EXPERIMENTAL) Get the Unicode handling interface - * to register and switch Unicode version. - */ - readonly unicode: IUnicodeHandling; + /** + * (EXPERIMENTAL) Adds a marker to the normal buffer and returns it. If the + * alt buffer is active, undefined is returned. + * @param cursorYOffset The y position offset of the marker from the cursor. + * @returns The new marker or undefined. + */ + registerMarker(cursorYOffset: number): IMarker | undefined; - /** - * Natural language strings that can be localized. - */ - static strings: ILocalizableStrings; + /** + * @deprecated use `registerMarker` instead. + */ + addMarker(cursorYOffset: number): IMarker | undefined; - /** - * Creates a new `Terminal` object. - * - * @param options An object containing a set of options. - */ - constructor(options?: ITerminalOptions); - - /** - * Adds an event listener for when the bell is triggered. - * @returns an `IDisposable` to stop listening. - */ - onBell: IEvent; - - /** - * Adds an event listener for when a binary event fires. This is used to - * enable non UTF-8 conformant binary messages to be sent to the backend. - * Currently this is only used for a certain type of mouse reports that - * happen to be not UTF-8 compatible. - * The event value is a JS string, pass it to the underlying pty as - * binary data, e.g. `pty.write(Buffer.from(data, 'binary'))`. - * @returns an `IDisposable` to stop listening. - */ - onBinary: IEvent; - - /** - * Adds an event listener for the cursor moves. - * @returns an `IDisposable` to stop listening. - */ - onCursorMove: IEvent; - - /** - * Adds an event listener for when a data event fires. This happens for - * example when the user types or pastes into the terminal. The event value - * is whatever `string` results, in a typical setup, this should be passed - * on to the backing pty. - * @returns an `IDisposable` to stop listening. - */ - onData: IEvent; - - /** - * Adds an event listener for when a line feed is added. - * @returns an `IDisposable` to stop listening. - */ - onLineFeed: IEvent; - - /** - * Adds an event listener for when the terminal is resized. The event value - * contains the new size. - * @returns an `IDisposable` to stop listening. - */ - onResize: IEvent<{ cols: number, rows: number }>; - - /** - * Adds an event listener for when a scroll occurs. The event value is the - * new position of the viewport. - * @returns an `IDisposable` to stop listening. - */ - onScroll: IEvent; - - /** - * Adds an event listener for when an OSC 0 or OSC 2 title change occurs. - * The event value is the new title. - * @returns an `IDisposable` to stop listening. - */ - onTitleChange: IEvent; - - /** - * Resizes the terminal. It's best practice to debounce calls to resize, - * this will help ensure that the pty can respond to the resize event - * before another one occurs. - * @param x The number of columns to resize to. - * @param y The number of rows to resize to. - */ - resize(columns: number, rows: number): void; - - /** - * (EXPERIMENTAL) Adds a marker to the normal buffer and returns it. If the - * alt buffer is active, undefined is returned. - * @param cursorYOffset The y position offset of the marker from the cursor. - * @returns The new marker or undefined. - */ - registerMarker(cursorYOffset: number): IMarker | undefined; - - /** - * @deprecated use `registerMarker` instead. - */ - addMarker(cursorYOffset: number): IMarker | undefined; - - /* - * Disposes of the terminal, detaching it from the DOM and removing any - * active listeners. - */ - dispose(): void; - - /** - * Scroll the display of the terminal - * @param amount The number of lines to scroll down (negative scroll up). - */ - scrollLines(amount: number): void; - - /** - * Scroll the display of the terminal by a number of pages. - * @param pageCount The number of pages to scroll (negative scrolls up). - */ - scrollPages(pageCount: number): void; - - /** - * Scrolls the display of the terminal to the top. - */ - scrollToTop(): void; - - /** - * Scrolls the display of the terminal to the bottom. - */ - scrollToBottom(): void; - - /** - * Scrolls to a line within the buffer. - * @param line The 0-based line index to scroll to. - */ - scrollToLine(line: number): void; - - /** - * Clear the entire buffer, making the prompt line the new first line. - */ - clear(): void; - - /** - * Write data to the terminal. - * @param data The data to write to the terminal. This can either be raw - * bytes given as Uint8Array from the pty or a string. Raw bytes will always - * be treated as UTF-8 encoded, string data as UTF-16. - * @param callback Optional callback that fires when the data was processed - * by the parser. - */ - write(data: string | Uint8Array, callback?: () => void): void; - - /** - * Writes data to the terminal, followed by a break line character (\n). - * @param data The data to write to the terminal. This can either be raw - * bytes given as Uint8Array from the pty or a string. Raw bytes will always - * be treated as UTF-8 encoded, string data as UTF-16. - * @param callback Optional callback that fires when the data was processed - * by the parser. - */ - writeln(data: string | Uint8Array, callback?: () => void): void; - - /** - * Write UTF8 data to the terminal. - * @param data The data to write to the terminal. - * @param callback Optional callback when data was processed. - * @deprecated use `write` instead - */ - writeUtf8(data: Uint8Array, callback?: () => void): void; - - /** - * Retrieves an option's value from the terminal. - * @param key The option key. - */ - getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string; - /** - * Retrieves an option's value from the terminal. - * @param key The option key. - */ - getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell' | 'windowsMode'): boolean; - /** - * Retrieves an option's value from the terminal. - * @param key The option key. - */ - getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; - /** - * Retrieves an option's value from the terminal. - * @param key The option key. - */ - getOption(key: string): any; - - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'fontFamily' | 'termName' | 'bellSound' | 'wordSeparator', value: string): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. + /* + * Disposes of the terminal, detaching it from the DOM and removing any + * active listeners. */ - setOption(key: 'fontWeight' | 'fontWeightBold', value: null | 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'logLevel', value: LogLevel): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'bellStyle', value: null | 'none' | 'visual' | 'sound' | 'both'): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'cursorStyle', value: null | 'block' | 'underline' | 'bar'): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'popOnBell' | 'rightClickSelectsWord' | 'visualBell' | 'windowsMode', value: boolean): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'theme', value: ITheme): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'cols' | 'rows', value: number): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: string, value: any): void; - - /** - * Perform a full reset (RIS, aka '\x1bc'). - */ - reset(): void; - - /** - * Loads an addon into this instance of xterm.js. - * @param addon The addon to load. - */ - loadAddon(addon: ITerminalAddon): void; - } + dispose(): void; /** - * An addon that can provide additional functionality to the terminal. + * Scroll the display of the terminal + * @param amount The number of lines to scroll down (negative scroll up). */ - export interface ITerminalAddon extends IDisposable { - /** - * This is called when the addon is activated. - */ - activate(terminal: Terminal): void; - } + scrollLines(amount: number): void; /** - * An object representing a selection within the terminal. + * Scroll the display of the terminal by a number of pages. + * @param pageCount The number of pages to scroll (negative scrolls up). */ - interface ISelectionPosition { - /** - * The start column of the selection. - */ - startColumn: number; - - /** - * The start row of the selection. - */ - startRow: number; - - /** - * The end column of the selection. - */ - endColumn: number; - - /** - * The end row of the selection. - */ - endRow: number; - } + scrollPages(pageCount: number): void; /** - * An object representing a range within the viewport of the terminal. + * Scrolls the display of the terminal to the top. */ - export interface IViewportRange { - /** - * The start of the range. - */ - start: IViewportRangePosition; - - /** - * The end of the range. - */ - end: IViewportRangePosition; - } + scrollToTop(): void; /** - * An object representing a cell position within the viewport of the terminal. + * Scrolls the display of the terminal to the bottom. */ - interface IViewportRangePosition { - /** - * The x position of the cell. This is a 0-based index that refers to the - * space in between columns, not the column itself. Index 0 refers to the - * left side of the viewport, index `Terminal.cols` refers to the right side - * of the viewport. This can be thought of as how a cursor is positioned in - * a text editor. - */ - x: number; - - /** - * The y position of the cell. This is a 0-based index that refers to a - * specific row. - */ - y: number; - } + scrollToBottom(): void; /** - * A range within a buffer. + * Scrolls to a line within the buffer. + * @param line The 0-based line index to scroll to. */ - interface IBufferRange { - /** - * The start position of the range. - */ - start: IBufferCellPosition; - - /** - * The end position of the range. - */ - end: IBufferCellPosition; - } + scrollToLine(line: number): void; /** - * A position within a buffer. + * Clear the entire buffer, making the prompt line the new first line. */ - interface IBufferCellPosition { - /** - * The x position within the buffer. - */ - x: number; - - /** - * The y position within the buffer. - */ - y: number; - } + clear(): void; /** - * Represents a terminal buffer. + * Write data to the terminal. + * @param data The data to write to the terminal. This can either be raw + * bytes given as Uint8Array from the pty or a string. Raw bytes will always + * be treated as UTF-8 encoded, string data as UTF-16. + * @param callback Optional callback that fires when the data was processed + * by the parser. */ - interface IBuffer { - /** - * The type of the buffer. - */ - readonly type: 'normal' | 'alternate'; - - /** - * The y position of the cursor. This ranges between `0` (when the - * cursor is at baseY) and `Terminal.rows - 1` (when the cursor is on the - * last row). - */ - readonly cursorY: number; - - /** - * The x position of the cursor. This ranges between `0` (left side) and - * `Terminal.cols` (after last cell of the row). - */ - readonly cursorX: number; - - /** - * The line within the buffer where the top of the viewport is. - */ - readonly viewportY: number; - - /** - * The line within the buffer where the top of the bottom page is (when - * fully scrolled down). - */ - readonly baseY: number; - - /** - * The amount of lines in the buffer. - */ - readonly length: number; - - /** - * Gets a line from the buffer, or undefined if the line index does not - * exist. - * - * Note that the result of this function should be used immediately after - * calling as when the terminal updates it could lead to unexpected - * behavior. - * - * @param y The line index to get. - */ - getLine(y: number): IBufferLine | undefined; - - /** - * Creates an empty cell object suitable as a cell reference in - * `line.getCell(x, cell)`. Use this to avoid costly recreation of - * cell objects when dealing with tons of cells. - */ - getNullCell(): IBufferCell; - } + write(data: string | Uint8Array, callback?: () => void): void; /** - * Represents the terminal's set of buffers. + * Writes data to the terminal, followed by a break line character (\n). + * @param data The data to write to the terminal. This can either be raw + * bytes given as Uint8Array from the pty or a string. Raw bytes will always + * be treated as UTF-8 encoded, string data as UTF-16. + * @param callback Optional callback that fires when the data was processed + * by the parser. */ - interface IBufferNamespace { - /** - * The active buffer, this will either be the normal or alternate buffers. - */ - readonly active: IBuffer; - - /** - * The normal buffer. - */ - readonly normal: IBuffer; - - /** - * The alternate buffer, this becomes the active buffer when an application - * enters this mode via DECSET (`CSI ? 4 7 h`) - */ - readonly alternate: IBuffer; - - /** - * Adds an event listener for when the active buffer changes. - * @returns an `IDisposable` to stop listening. - */ - onBufferChange: IEvent; - } + writeln(data: string | Uint8Array, callback?: () => void): void; /** - * Represents a line in the terminal's buffer. + * Write UTF8 data to the terminal. + * @param data The data to write to the terminal. + * @param callback Optional callback when data was processed. + * @deprecated use `write` instead */ - interface IBufferLine { - /** - * Whether the line is wrapped from the previous line. - */ - readonly isWrapped: boolean; - - /** - * The length of the line, all call to getCell beyond the length will result - * in `undefined`. - */ - readonly length: number; - - /** - * Gets a cell from the line, or undefined if the line index does not exist. - * - * Note that the result of this function should be used immediately after - * calling as when the terminal updates it could lead to unexpected - * behavior. - * - * @param x The character index to get. - * @param cell Optional cell object to load data into for performance - * reasons. This is mainly useful when every cell in the buffer is being - * looped over to avoid creating new objects for every cell. - */ - getCell(x: number, cell?: IBufferCell): IBufferCell | undefined; - - /** - * Gets the line as a string. Note that this is gets only the string for the - * line, not taking isWrapped into account. - * - * @param trimRight Whether to trim any whitespace at the right of the line. - * @param startColumn The column to start from (inclusive). - * @param endColumn The column to end at (exclusive). - */ - translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string; - } + writeUtf8(data: Uint8Array, callback?: () => void): void; /** - * Represents a single cell in the terminal's buffer. + * Retrieves an option's value from the terminal. + * @param key The option key. */ - interface IBufferCell { - /** - * The width of the character. Some examples: - * - * - `1` for most cells. - * - `2` for wide character like CJK glyphs. - * - `0` for cells immediately following cells with a width of `2`. - */ - getWidth(): number; - - /** - * The character(s) within the cell. Examples of what this can contain: - * - * - A normal width character - * - A wide character (eg. CJK) - * - An emoji - */ - getChars(): string; - - /** - * Gets the UTF32 codepoint of single characters, if content is a combined - * string it returns the codepoint of the last character in the string. - */ - getCode(): number; - - /** - * Gets the number representation of the foreground color mode, this can be - * used to perform quick comparisons of 2 cells to see if they're the same. - * Use `isFgRGB`, `isFgPalette` and `isFgDefault` to check what color mode - * a cell is. - */ - getFgColorMode(): number; - - /** - * Gets the number representation of the background color mode, this can be - * used to perform quick comparisons of 2 cells to see if they're the same. - * Use `isBgRGB`, `isBgPalette` and `isBgDefault` to check what color mode - * a cell is. - */ - getBgColorMode(): number; - - /** - * Gets a cell's foreground color number, this differs depending on what the - * color mode of the cell is: - * - * - Default: This should be 0, representing the default foreground color - * (CSI 39 m). - * - Palette: This is a number from 0 to 255 of ANSI colors (CSI 3(0-7) m, - * CSI 9(0-7) m, CSI 38 ; 5 ; 0-255 m). - * - RGB: A hex value representing a 'true color': 0xRRGGBB. - * (CSI 3 8 ; 2 ; Pi ; Pr ; Pg ; Pb) - */ - getFgColor(): number; - - /** - * Gets a cell's background color number, this differs depending on what the - * color mode of the cell is: - * - * - Default: This should be 0, representing the default background color - * (CSI 49 m). - * - Palette: This is a number from 0 to 255 of ANSI colors - * (CSI 4(0-7) m, CSI 10(0-7) m, CSI 48 ; 5 ; 0-255 m). - * - RGB: A hex value representing a 'true color': 0xRRGGBB - * (CSI 4 8 ; 2 ; Pi ; Pr ; Pg ; Pb) - */ - getBgColor(): number; - - /** Whether the cell has the bold attribute (CSI 1 m). */ - isBold(): number; - /** Whether the cell has the inverse attribute (CSI 3 m). */ - isItalic(): number; - /** Whether the cell has the inverse attribute (CSI 2 m). */ - isDim(): number; - /** Whether the cell has the underline attribute (CSI 4 m). */ - isUnderline(): number; - /** Whether the cell has the inverse attribute (CSI 5 m). */ - isBlink(): number; - /** Whether the cell has the inverse attribute (CSI 7 m). */ - isInverse(): number; - /** Whether the cell has the inverse attribute (CSI 8 m). */ - isInvisible(): number; - - /** Whether the cell is using the RGB foreground color mode. */ - isFgRGB(): boolean; - /** Whether the cell is using the RGB background color mode. */ - isBgRGB(): boolean; - /** Whether the cell is using the palette foreground color mode. */ - isFgPalette(): boolean; - /** Whether the cell is using the palette background color mode. */ - isBgPalette(): boolean; - /** Whether the cell is using the default foreground color mode. */ - isFgDefault(): boolean; - /** Whether the cell is using the default background color mode. */ - isBgDefault(): boolean; - - /** Whether the cell has the default attribute (no color or style). */ - isAttributeDefault(): boolean; - } + getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string; + /** + * Retrieves an option's value from the terminal. + * @param key The option key. + */ + getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell' | 'windowsMode'): boolean; + /** + * Retrieves an option's value from the terminal. + * @param key The option key. + */ + getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; + /** + * Retrieves an option's value from the terminal. + * @param key The option key. + */ + getOption(key: string): any; /** - * Data type to register a CSI, DCS or ESC callback in the parser - * in the form: - * ESC I..I F - * CSI Prefix P..P I..I F - * DCS Prefix P..P I..I F data_bytes ST - * - * with these rules/restrictions: - * - prefix can only be used with CSI and DCS - * - only one leading prefix byte is recognized by the parser - * before any other parameter bytes (P..P) - * - intermediate bytes are recognized up to 2 - * - * For custom sequences make sure to read ECMA-48 and the resources at - * vt100.net to not clash with existing sequences or reserved address space. - * General recommendations: - * - use private address space (see ECMA-48) - * - use max one intermediate byte (technically not limited by the spec, - * in practice there are no sequences with more than one intermediate byte, - * thus parsers might get confused with more intermediates) - * - test against other common emulators to check whether they escape/ignore - * the sequence correctly - * - * Notes: OSC command registration is handled differently (see addOscHandler) - * APC, PM or SOS is currently not supported. + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. */ - export interface IFunctionIdentifier { - /** - * Optional prefix byte, must be in range \x3c .. \x3f. - * Usable in CSI and DCS. - */ - prefix?: string; - /** - * Optional intermediate bytes, must be in range \x20 .. \x2f. - * Usable in CSI, DCS and ESC. - */ - intermediates?: string; - /** - * Final byte, must be in range \x40 .. \x7e for CSI and DCS, - * \x30 .. \x7e for ESC. - */ - final: string; - } + setOption(key: 'fontFamily' | 'termName' | 'bellSound' | 'wordSeparator', value: string): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'fontWeight' | 'fontWeightBold', value: null | 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'logLevel', value: LogLevel): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'bellStyle', value: null | 'none' | 'visual' | 'sound' | 'both'): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'cursorStyle', value: null | 'block' | 'underline' | 'bar'): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'popOnBell' | 'rightClickSelectsWord' | 'visualBell' | 'windowsMode', value: boolean): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'theme', value: ITheme): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'cols' | 'rows', value: number): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: string, value: any): void; /** - * Allows hooking into the parser for custom handling of escape sequences. + * Perform a full reset (RIS, aka '\x1bc'). */ - export interface IParser { - /** - * Adds a handler for CSI escape sequences. - * @param id Specifies the function identifier under which the callback - * gets registered, e.g. {final: 'm'} for SGR. - * @param callback The function to handle the sequence. The callback is - * called with the numerical params. If the sequence has subparams the - * array will contain subarrays with their numercial values. - * Return true if the sequence was handled; false if we should try - * a previous handler (set by addCsiHandler or setCsiHandler). - * The most recently added handler is tried first. - * @return An IDisposable you can call to remove this handler. - */ - registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable; - - /** - * Adds a handler for DCS escape sequences. - * @param id Specifies the function identifier under which the callback - * gets registered, e.g. {intermediates: '$' final: 'q'} for DECRQSS. - * @param callback The function to handle the sequence. Note that the - * function will only be called once if the sequence finished sucessfully. - * There is currently no way to intercept smaller data chunks, data chunks - * will be stored up until the sequence is finished. Since DCS sequences - * are not limited by the amount of data this might impose a problem for - * big payloads. Currently xterm.js limits DCS payload to 10 MB - * which should give enough room for most use cases. - * The function gets the payload and numerical parameters as arguments. - * Return true if the sequence was handled; false if we should try - * a previous handler (set by addDcsHandler or setDcsHandler). - * The most recently added handler is tried first. - * @return An IDisposable you can call to remove this handler. - */ - registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable; - - /** - * Adds a handler for ESC escape sequences. - * @param id Specifies the function identifier under which the callback - * gets registered, e.g. {intermediates: '%' final: 'G'} for - * default charset selection. - * @param callback The function to handle the sequence. - * Return true if the sequence was handled; false if we should try - * a previous handler (set by addEscHandler or setEscHandler). - * The most recently added handler is tried first. - * @return An IDisposable you can call to remove this handler. - */ - registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable; - - /** - * Adds a handler for OSC escape sequences. - * @param ident The number (first parameter) of the sequence. - * @param callback The function to handle the sequence. Note that the - * function will only be called once if the sequence finished sucessfully. - * There is currently no way to intercept smaller data chunks, data chunks - * will be stored up until the sequence is finished. Since OSC sequences - * are not limited by the amount of data this might impose a problem for - * big payloads. Currently xterm.js limits OSC payload to 10 MB - * which should give enough room for most use cases. - * The callback is called with OSC data string. - * Return true if the sequence was handled; false if we should try - * a previous handler (set by addOscHandler or setOscHandler). - * The most recently added handler is tried first. - * @return An IDisposable you can call to remove this handler. - */ - registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable; - } + reset(): void; /** - * (EXPERIMENTAL) Unicode version provider. - * Used to register custom Unicode versions with `Terminal.unicode.register`. + * Loads an addon into this instance of xterm.js. + * @param addon The addon to load. */ - export interface IUnicodeVersionProvider { - /** - * String indicating the Unicode version provided. - */ - readonly version: string; - - /** - * Unicode version dependent wcwidth implementation. - */ - wcwidth(codepoint: number): 0 | 1 | 2; - } - - /** - * (EXPERIMENTAL) Unicode handling interface. - */ - export interface IUnicodeHandling { - /** - * Register a custom Unicode version provider. - */ - register(provider: IUnicodeVersionProvider): void; - - /** - * Registered Unicode versions. - */ - readonly versions: ReadonlyArray; - - /** - * Getter/setter for active Unicode version. - */ - activeVersion: string; - } + loadAddon(addon: ITerminalAddon): void; } + + /** + * An addon that can provide additional functionality to the terminal. + */ + export interface ITerminalAddon extends IDisposable { + /** + * This is called when the addon is activated. + */ + activate(terminal: Terminal): void; + } + + /** + * An object representing a selection within the terminal. + */ + interface ISelectionPosition { + /** + * The start column of the selection. + */ + startColumn: number; + + /** + * The start row of the selection. + */ + startRow: number; + + /** + * The end column of the selection. + */ + endColumn: number; + + /** + * The end row of the selection. + */ + endRow: number; + } + + /** + * An object representing a range within the viewport of the terminal. + */ + export interface IViewportRange { + /** + * The start of the range. + */ + start: IViewportRangePosition; + + /** + * The end of the range. + */ + end: IViewportRangePosition; + } + + /** + * An object representing a cell position within the viewport of the terminal. + */ + interface IViewportRangePosition { + /** + * The x position of the cell. This is a 0-based index that refers to the + * space in between columns, not the column itself. Index 0 refers to the + * left side of the viewport, index `Terminal.cols` refers to the right side + * of the viewport. This can be thought of as how a cursor is positioned in + * a text editor. + */ + x: number; + + /** + * The y position of the cell. This is a 0-based index that refers to a + * specific row. + */ + y: number; + } + + /** + * A range within a buffer. + */ + interface IBufferRange { + /** + * The start position of the range. + */ + start: IBufferCellPosition; + + /** + * The end position of the range. + */ + end: IBufferCellPosition; + } + + /** + * A position within a buffer. + */ + interface IBufferCellPosition { + /** + * The x position within the buffer. + */ + x: number; + + /** + * The y position within the buffer. + */ + y: number; + } + + /** + * Represents a terminal buffer. + */ + interface IBuffer { + /** + * The type of the buffer. + */ + readonly type: 'normal' | 'alternate'; + + /** + * The y position of the cursor. This ranges between `0` (when the + * cursor is at baseY) and `Terminal.rows - 1` (when the cursor is on the + * last row). + */ + readonly cursorY: number; + + /** + * The x position of the cursor. This ranges between `0` (left side) and + * `Terminal.cols` (after last cell of the row). + */ + readonly cursorX: number; + + /** + * The line within the buffer where the top of the viewport is. + */ + readonly viewportY: number; + + /** + * The line within the buffer where the top of the bottom page is (when + * fully scrolled down). + */ + readonly baseY: number; + + /** + * The amount of lines in the buffer. + */ + readonly length: number; + + /** + * Gets a line from the buffer, or undefined if the line index does not + * exist. + * + * Note that the result of this function should be used immediately after + * calling as when the terminal updates it could lead to unexpected + * behavior. + * + * @param y The line index to get. + */ + getLine(y: number): IBufferLine | undefined; + + /** + * Creates an empty cell object suitable as a cell reference in + * `line.getCell(x, cell)`. Use this to avoid costly recreation of + * cell objects when dealing with tons of cells. + */ + getNullCell(): IBufferCell; + } + + /** + * Represents the terminal's set of buffers. + */ + interface IBufferNamespace { + /** + * The active buffer, this will either be the normal or alternate buffers. + */ + readonly active: IBuffer; + + /** + * The normal buffer. + */ + readonly normal: IBuffer; + + /** + * The alternate buffer, this becomes the active buffer when an application + * enters this mode via DECSET (`CSI ? 4 7 h`) + */ + readonly alternate: IBuffer; + + /** + * Adds an event listener for when the active buffer changes. + * @returns an `IDisposable` to stop listening. + */ + onBufferChange: IEvent; + } + + /** + * Represents a line in the terminal's buffer. + */ + interface IBufferLine { + /** + * Whether the line is wrapped from the previous line. + */ + readonly isWrapped: boolean; + + /** + * The length of the line, all call to getCell beyond the length will result + * in `undefined`. + */ + readonly length: number; + + /** + * Gets a cell from the line, or undefined if the line index does not exist. + * + * Note that the result of this function should be used immediately after + * calling as when the terminal updates it could lead to unexpected + * behavior. + * + * @param x The character index to get. + * @param cell Optional cell object to load data into for performance + * reasons. This is mainly useful when every cell in the buffer is being + * looped over to avoid creating new objects for every cell. + */ + getCell(x: number, cell?: IBufferCell): IBufferCell | undefined; + + /** + * Gets the line as a string. Note that this is gets only the string for the + * line, not taking isWrapped into account. + * + * @param trimRight Whether to trim any whitespace at the right of the line. + * @param startColumn The column to start from (inclusive). + * @param endColumn The column to end at (exclusive). + */ + translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string; + } + + /** + * Represents a single cell in the terminal's buffer. + */ + interface IBufferCell { + /** + * The width of the character. Some examples: + * + * - `1` for most cells. + * - `2` for wide character like CJK glyphs. + * - `0` for cells immediately following cells with a width of `2`. + */ + getWidth(): number; + + /** + * The character(s) within the cell. Examples of what this can contain: + * + * - A normal width character + * - A wide character (eg. CJK) + * - An emoji + */ + getChars(): string; + + /** + * Gets the UTF32 codepoint of single characters, if content is a combined + * string it returns the codepoint of the last character in the string. + */ + getCode(): number; + + /** + * Gets the number representation of the foreground color mode, this can be + * used to perform quick comparisons of 2 cells to see if they're the same. + * Use `isFgRGB`, `isFgPalette` and `isFgDefault` to check what color mode + * a cell is. + */ + getFgColorMode(): number; + + /** + * Gets the number representation of the background color mode, this can be + * used to perform quick comparisons of 2 cells to see if they're the same. + * Use `isBgRGB`, `isBgPalette` and `isBgDefault` to check what color mode + * a cell is. + */ + getBgColorMode(): number; + + /** + * Gets a cell's foreground color number, this differs depending on what the + * color mode of the cell is: + * + * - Default: This should be 0, representing the default foreground color + * (CSI 39 m). + * - Palette: This is a number from 0 to 255 of ANSI colors (CSI 3(0-7) m, + * CSI 9(0-7) m, CSI 38 ; 5 ; 0-255 m). + * - RGB: A hex value representing a 'true color': 0xRRGGBB. + * (CSI 3 8 ; 2 ; Pi ; Pr ; Pg ; Pb) + */ + getFgColor(): number; + + /** + * Gets a cell's background color number, this differs depending on what the + * color mode of the cell is: + * + * - Default: This should be 0, representing the default background color + * (CSI 49 m). + * - Palette: This is a number from 0 to 255 of ANSI colors + * (CSI 4(0-7) m, CSI 10(0-7) m, CSI 48 ; 5 ; 0-255 m). + * - RGB: A hex value representing a 'true color': 0xRRGGBB + * (CSI 4 8 ; 2 ; Pi ; Pr ; Pg ; Pb) + */ + getBgColor(): number; + + /** Whether the cell has the bold attribute (CSI 1 m). */ + isBold(): number; + /** Whether the cell has the inverse attribute (CSI 3 m). */ + isItalic(): number; + /** Whether the cell has the inverse attribute (CSI 2 m). */ + isDim(): number; + /** Whether the cell has the underline attribute (CSI 4 m). */ + isUnderline(): number; + /** Whether the cell has the inverse attribute (CSI 5 m). */ + isBlink(): number; + /** Whether the cell has the inverse attribute (CSI 7 m). */ + isInverse(): number; + /** Whether the cell has the inverse attribute (CSI 8 m). */ + isInvisible(): number; + + /** Whether the cell is using the RGB foreground color mode. */ + isFgRGB(): boolean; + /** Whether the cell is using the RGB background color mode. */ + isBgRGB(): boolean; + /** Whether the cell is using the palette foreground color mode. */ + isFgPalette(): boolean; + /** Whether the cell is using the palette background color mode. */ + isBgPalette(): boolean; + /** Whether the cell is using the default foreground color mode. */ + isFgDefault(): boolean; + /** Whether the cell is using the default background color mode. */ + isBgDefault(): boolean; + + /** Whether the cell has the default attribute (no color or style). */ + isAttributeDefault(): boolean; + } + + /** + * Data type to register a CSI, DCS or ESC callback in the parser + * in the form: + * ESC I..I F + * CSI Prefix P..P I..I F + * DCS Prefix P..P I..I F data_bytes ST + * + * with these rules/restrictions: + * - prefix can only be used with CSI and DCS + * - only one leading prefix byte is recognized by the parser + * before any other parameter bytes (P..P) + * - intermediate bytes are recognized up to 2 + * + * For custom sequences make sure to read ECMA-48 and the resources at + * vt100.net to not clash with existing sequences or reserved address space. + * General recommendations: + * - use private address space (see ECMA-48) + * - use max one intermediate byte (technically not limited by the spec, + * in practice there are no sequences with more than one intermediate byte, + * thus parsers might get confused with more intermediates) + * - test against other common emulators to check whether they escape/ignore + * the sequence correctly + * + * Notes: OSC command registration is handled differently (see addOscHandler) + * APC, PM or SOS is currently not supported. + */ + export interface IFunctionIdentifier { + /** + * Optional prefix byte, must be in range \x3c .. \x3f. + * Usable in CSI and DCS. + */ + prefix?: string; + /** + * Optional intermediate bytes, must be in range \x20 .. \x2f. + * Usable in CSI, DCS and ESC. + */ + intermediates?: string; + /** + * Final byte, must be in range \x40 .. \x7e for CSI and DCS, + * \x30 .. \x7e for ESC. + */ + final: string; + } + + /** + * Allows hooking into the parser for custom handling of escape sequences. + */ + export interface IParser { + /** + * Adds a handler for CSI escape sequences. + * @param id Specifies the function identifier under which the callback + * gets registered, e.g. {final: 'm'} for SGR. + * @param callback The function to handle the sequence. The callback is + * called with the numerical params. If the sequence has subparams the + * array will contain subarrays with their numercial values. + * Return true if the sequence was handled; false if we should try + * a previous handler (set by addCsiHandler or setCsiHandler). + * The most recently added handler is tried first. + * @return An IDisposable you can call to remove this handler. + */ + registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable; + + /** + * Adds a handler for DCS escape sequences. + * @param id Specifies the function identifier under which the callback + * gets registered, e.g. {intermediates: '$' final: 'q'} for DECRQSS. + * @param callback The function to handle the sequence. Note that the + * function will only be called once if the sequence finished sucessfully. + * There is currently no way to intercept smaller data chunks, data chunks + * will be stored up until the sequence is finished. Since DCS sequences + * are not limited by the amount of data this might impose a problem for + * big payloads. Currently xterm.js limits DCS payload to 10 MB + * which should give enough room for most use cases. + * The function gets the payload and numerical parameters as arguments. + * Return true if the sequence was handled; false if we should try + * a previous handler (set by addDcsHandler or setDcsHandler). + * The most recently added handler is tried first. + * @return An IDisposable you can call to remove this handler. + */ + registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable; + + /** + * Adds a handler for ESC escape sequences. + * @param id Specifies the function identifier under which the callback + * gets registered, e.g. {intermediates: '%' final: 'G'} for + * default charset selection. + * @param callback The function to handle the sequence. + * Return true if the sequence was handled; false if we should try + * a previous handler (set by addEscHandler or setEscHandler). + * The most recently added handler is tried first. + * @return An IDisposable you can call to remove this handler. + */ + registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable; + + /** + * Adds a handler for OSC escape sequences. + * @param ident The number (first parameter) of the sequence. + * @param callback The function to handle the sequence. Note that the + * function will only be called once if the sequence finished sucessfully. + * There is currently no way to intercept smaller data chunks, data chunks + * will be stored up until the sequence is finished. Since OSC sequences + * are not limited by the amount of data this might impose a problem for + * big payloads. Currently xterm.js limits OSC payload to 10 MB + * which should give enough room for most use cases. + * The callback is called with OSC data string. + * Return true if the sequence was handled; false if we should try + * a previous handler (set by addOscHandler or setOscHandler). + * The most recently added handler is tried first. + * @return An IDisposable you can call to remove this handler. + */ + registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable; + } + + /** + * (EXPERIMENTAL) Unicode version provider. + * Used to register custom Unicode versions with `Terminal.unicode.register`. + */ + export interface IUnicodeVersionProvider { + /** + * String indicating the Unicode version provided. + */ + readonly version: string; + + /** + * Unicode version dependent wcwidth implementation. + */ + wcwidth(codepoint: number): 0 | 1 | 2; + } + + /** + * (EXPERIMENTAL) Unicode handling interface. + */ + export interface IUnicodeHandling { + /** + * Register a custom Unicode version provider. + */ + register(provider: IUnicodeVersionProvider): void; + + /** + * Registered Unicode versions. + */ + readonly versions: ReadonlyArray; + + /** + * Getter/setter for active Unicode version. + */ + activeVersion: string; + } + + /** + * Terminal modes as set by SM/DECSET. + */ + export interface IModes { + /** + * Application Cursor Keys (DECCKM): `CSI ? 1 h` + */ + readonly applicationCursorKeysMode: boolean; + /** + * Application Keypad Mode (DECNKM): `CSI ? 6 6 h` + */ + readonly applicationKeypadMode: boolean; + /** + * Bracketed Paste Mode: `CSI ? 2 0 0 4 h` + */ + readonly bracketedPasteMode: boolean; + /** + * Insert Mode (IRM): `CSI 4 h` + */ + readonly insertMode: boolean; + /** + * Mouse Tracking, this can be one of the following: + * - none: This is the default value and can be reset with DECRST + * - x10: Send Mouse X & Y on button press `CSI ? 9 h` + * - vt200: Send Mouse X & Y on button press and release `CSI ? 1 0 0 0 h` + * - drag: Use Cell Motion Mouse Tracking `CSI ? 1 0 0 2 h` + * - any: Use All Motion Mouse Tracking `CSI ? 1 0 0 3 h` + */ + readonly mouseTrackingMode: 'none' | 'x10' | 'vt200' | 'drag' | 'any'; + /** + * Origin Mode (DECOM): `CSI ? 6 h` + */ + readonly originMode: boolean; + /** + * Reverse-wraparound Mode: `CSI ? 4 5 h` + */ + readonly reverseWraparoundMode: boolean; + /** + * Send FocusIn/FocusOut events: `CSI ? 1 0 0 4 h` + */ + readonly sendFocusMode: boolean; + /** + * Auto-Wrap Mode (DECAWM): `CSI ? 7 h` + */ + readonly wraparoundMode: boolean + } +} diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 210e354d..3828b415 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -1666,7 +1666,7 @@ declare module 'xterm' { */ readonly reverseWraparoundMode: boolean; /** - * Send FocusIn/FocusOut events: `CSI ? 1 0 0 3 h` + * Send FocusIn/FocusOut events: `CSI ? 1 0 0 4 h` */ readonly sendFocusMode: boolean; /** From bef865e1967637b0c07486b23cfc82ded14e27a2 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 16 Aug 2021 15:06:29 -0700 Subject: [PATCH 309/377] Add xterm api tests --- test/api/Terminal.api.ts | 92 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/test/api/Terminal.api.ts b/test/api/Terminal.api.ts index 75399b73..1599f3a2 100644 --- a/test/api/Terminal.api.ts +++ b/test/api/Terminal.api.ts @@ -562,6 +562,98 @@ describe('API Integration Tests', function(): void { }); }); + describe('modes', () => { + it('defaults', async () => { + await openTerminal(page); + assert.deepStrictEqual(await page.evaluate(`window.term.modes`), { + applicationCursorKeysMode: false, + applicationKeypadMode: false, + bracketedPasteMode: false, + insertMode: false, + mouseTrackingMode: 'none', + originMode: false, + reverseWraparoundMode: false, + sendFocusMode: false, + wraparoundMode: true + }); + }); + it('applicationCursorKeysMode', async () => { + await openTerminal(page); + await writeSync(page, '\\x1b[?1h'); + assert.strictEqual(await page.evaluate(`window.term.modes.applicationCursorKeysMode`), true); + await writeSync(page, '\\x1b[?1l'); + assert.strictEqual(await page.evaluate(`window.term.modes.applicationCursorKeysMode`), false); + }); + it('applicationKeypadMode', async () => { + await openTerminal(page); + await writeSync(page, '\\x1b[?66h'); + assert.strictEqual(await page.evaluate(`window.term.modes.applicationKeypadMode`), true); + await writeSync(page, '\\x1b[?66l'); + assert.strictEqual(await page.evaluate(`window.term.modes.applicationKeypadMode`), false); + }); + it('bracketedPasteMode', async () => { + await openTerminal(page); + await writeSync(page, '\\x1b[?2004h'); + assert.strictEqual(await page.evaluate(`window.term.modes.bracketedPasteMode`), true); + await writeSync(page, '\\x1b[?2004l'); + assert.strictEqual(await page.evaluate(`window.term.modes.bracketedPasteMode`), false); + }); + it('insertMode', async () => { + await openTerminal(page); + await writeSync(page, '\\x1b[4h'); + assert.strictEqual(await page.evaluate(`window.term.modes.insertMode`), true); + await writeSync(page, '\\x1b[4l'); + assert.strictEqual(await page.evaluate(`window.term.modes.insertMode`), false); + }); + it('mouseTrackingMode', async () => { + await openTerminal(page); + await writeSync(page, '\\x1b[?9h'); + assert.strictEqual(await page.evaluate(`window.term.modes.mouseTrackingMode`), 'x10'); + await writeSync(page, '\\x1b[?9l'); + assert.strictEqual(await page.evaluate(`window.term.modes.mouseTrackingMode`), 'none'); + await writeSync(page, '\\x1b[?1000h'); + assert.strictEqual(await page.evaluate(`window.term.modes.mouseTrackingMode`), 'vt200'); + await writeSync(page, '\\x1b[?1000l'); + assert.strictEqual(await page.evaluate(`window.term.modes.mouseTrackingMode`), 'none'); + await writeSync(page, '\\x1b[?1002h'); + assert.strictEqual(await page.evaluate(`window.term.modes.mouseTrackingMode`), 'drag'); + await writeSync(page, '\\x1b[?1002l'); + assert.strictEqual(await page.evaluate(`window.term.modes.mouseTrackingMode`), 'none'); + await writeSync(page, '\\x1b[?1003h'); + assert.strictEqual(await page.evaluate(`window.term.modes.mouseTrackingMode`), 'any'); + await writeSync(page, '\\x1b[?1003l'); + assert.strictEqual(await page.evaluate(`window.term.modes.mouseTrackingMode`), 'none'); + }); + it('originMode', async () => { + await openTerminal(page); + await writeSync(page, '\\x1b[?6h'); + assert.strictEqual(await page.evaluate(`window.term.modes.originMode`), true); + await writeSync(page, '\\x1b[?6l'); + assert.strictEqual(await page.evaluate(`window.term.modes.originMode`), false); + }); + it('reverseWraparoundMode', async () => { + await openTerminal(page); + await writeSync(page, '\\x1b[?45h'); + assert.strictEqual(await page.evaluate(`window.term.modes.reverseWraparoundMode`), true); + await writeSync(page, '\\x1b[?45l'); + assert.strictEqual(await page.evaluate(`window.term.modes.reverseWraparoundMode`), false); + }); + it('sendFocusMode', async () => { + await openTerminal(page); + await writeSync(page, '\\x1b[?1004h'); + assert.strictEqual(await page.evaluate(`window.term.modes.sendFocusMode`), true); + await writeSync(page, '\\x1b[?1004l'); + assert.strictEqual(await page.evaluate(`window.term.modes.sendFocusMode`), false); + }); + it('wraparoundMode', async () => { + await openTerminal(page); + await writeSync(page, '\\x1b[?7h'); + assert.strictEqual(await page.evaluate(`window.term.modes.wraparoundMode`), true); + await writeSync(page, '\\x1b[?7l'); + assert.strictEqual(await page.evaluate(`window.term.modes.wraparoundMode`), false); + }); + }); + it('dispose', async () => { await page.evaluate(` window.term = new Terminal(); From 6c834aecb4bc1e08e9710cf6cf54c90c23a69f1d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 16 Aug 2021 15:31:34 -0700 Subject: [PATCH 310/377] Serialize modes Fixes #3417 --- .../src/SerializeAddon.ts | 32 ++++++++++++ .../test/SerializeAddon.api.ts | 52 +++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index 5cd834b8..72780765 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -403,6 +403,35 @@ export class SerializeAddon implements ITerminalAddon { return handler.serialize(maxRows - correctRows, maxRows); } + private _serializeModes(terminal: Terminal): string { + let content = ''; + const modes = terminal.modes; + + // Default: false + if (modes.applicationCursorKeysMode) content += '\x1b[?1h'; + if (modes.applicationKeypadMode) content += '\x1b[?66h'; + if (modes.bracketedPasteMode) content += '\x1b[?2004h'; + if (modes.insertMode) content += '\x1b[4h'; + if (modes.originMode) content += '\x1b[?6h'; + if (modes.reverseWraparoundMode) content += '\x1b[?45h'; + if (modes.sendFocusMode) content += '\x1b[?1004h'; + + // Default: true + if (modes.wraparoundMode === false) content += '\x1b[?7l'; + + // Default: 'none' + if (modes.mouseTrackingMode !== 'none') { + switch (modes.mouseTrackingMode) { + case 'x10': content += '\x1b[?9h'; break; + case 'vt200': content += '\x1b[?1000h'; break; + case 'drag': content += '\x1b[?1002h'; break; + case 'any': content += '\x1b[?1003h'; break; + } + } + + return content; + } + public serialize(scrollback?: number): string { // TODO: Add combinedData support if (!this._terminal) { @@ -418,6 +447,9 @@ export class SerializeAddon implements ITerminalAddon { content += `\u001b[?1049h\u001b[H${alternativeScreenContent}`; } + // Modes + content += this._serializeModes(this._terminal); + return content; } diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index c8b7302f..87f77f59 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -30,6 +30,12 @@ const testNormalScreenEqual = async (page: any, str: string): Promise => { assert.equal(JSON.stringify(originalBuffer), JSON.stringify(newBuffer)); }; +async function testSerializeEquals(writeContent: string, expectedSerialized: string): Promise { + await writeRawSync(page, writeContent); + const result = await page.evaluate(`serializeAddon.serialize();`) as string; + assert.strictEqual(result, expectedSerialized); +} + describe('SerializeAddon', () => { before(async function(): Promise { const browserType = getBrowserType(); @@ -479,6 +485,52 @@ describe('SerializeAddon', () => { await testNormalScreenEqual(page, lines.join('')); }); + + describe('handle modes', () => { + it('applicationCursorKeysMode', async () => { + await testSerializeEquals('test\u001b[?1h', 'test\u001b[?1h'); + await testSerializeEquals('\u001b[?1l', 'test'); + }); + it('applicationKeypadMode', async () => { + await testSerializeEquals('test\u001b[?66h', 'test\u001b[?66h'); + await testSerializeEquals('\u001b[?66l', 'test'); + }); + it('bracketedPasteMode', async () => { + await testSerializeEquals('test\u001b[?2004h', 'test\u001b[?2004h'); + await testSerializeEquals('\u001b[?2004l', 'test'); + }); + it('insertMode', async () => { + await testSerializeEquals('test\u001b[4h', 'test\u001b[4h'); + await testSerializeEquals('\u001b[4l', 'test'); + }); + it('mouseTrackingMode', async () => { + await testSerializeEquals('test\u001b[?9h', 'test\u001b[?9h'); + await testSerializeEquals('\u001b[?9l', 'test'); + await testSerializeEquals('\u001b[?1000h', 'test\u001b[?1000h'); + await testSerializeEquals('\u001b[?1000l', 'test'); + await testSerializeEquals('\u001b[?1002h', 'test\u001b[?1002h'); + await testSerializeEquals('\u001b[?1002l', 'test'); + await testSerializeEquals('\u001b[?1003h', 'test\u001b[?1003h'); + await testSerializeEquals('\u001b[?1003l', 'test'); + }); + it('originMode', async () => { + // origin mode moves cursor to (0,0) + await testSerializeEquals('test\u001b[?6h', 'test\u001b[4D\u001b[?6h'); + await testSerializeEquals('\u001b[?6l', 'test\u001b[4D'); + }); + it('reverseWraparoundMode', async () => { + await testSerializeEquals('test\u001b[?45h', 'test\u001b[?45h'); + await testSerializeEquals('\u001b[?45l', 'test'); + }); + it('sendFocusMode', async () => { + await testSerializeEquals('test\u001b[?1004h', 'test\u001b[?1004h'); + await testSerializeEquals('\u001b[?1004l', 'test'); + }); + it('wraparoundMode', async () => { + await testSerializeEquals('test\u001b[?7l', 'test\u001b[?7l'); + await testSerializeEquals('\u001b[?7h', 'test'); + }); + }); }); function newArray(initial: T | ((index: number) => T), count: number): T[] { From c1b4f4edb15f9b9a55dabf373156417dfcea8cd8 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 04:41:44 -0700 Subject: [PATCH 311/377] Fix webgl access of core service --- addons/xterm-addon-webgl/src/WebglRenderer.ts | 2 +- .../xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index 9b75d1de..29e97d6d 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -60,7 +60,7 @@ export class WebglRenderer extends Disposable implements IRenderer { this._renderLayers = [ new LinkRenderLayer(this._core.screenElement!, 2, this._colors, this._core), - new CursorRenderLayer(this._core.screenElement!, 3, this._colors, this._onRequestRedraw) + new CursorRenderLayer(this._core.screenElement!, 3, this._colors, this._core, this._onRequestRedraw) ]; this.dimensions = { scaledCharWidth: 0, diff --git a/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts b/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts index 880896e0..912c23c9 100644 --- a/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts +++ b/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts @@ -7,7 +7,7 @@ import { Terminal } from 'xterm'; import { BaseRenderLayer } from './BaseRenderLayer'; import { ICellData } from 'common/Types'; import { CellData } from 'common/buffer/CellData'; -import { IColorSet } from 'browser/Types'; +import { IColorSet, ITerminal } from 'browser/Types'; import { IRenderDimensions, IRequestRedrawEvent } from 'browser/renderer/Types'; import { IEventEmitter } from 'common/EventEmitter'; @@ -34,6 +34,7 @@ export class CursorRenderLayer extends BaseRenderLayer { container: HTMLElement, zIndex: number, colors: IColorSet, + private readonly _terminal: ITerminal, private _onRequestRefreshRowsEvent: IEventEmitter ) { super(container, 'cursor', zIndex, true, colors); @@ -120,7 +121,7 @@ export class CursorRenderLayer extends BaseRenderLayer { private _render(terminal: Terminal, triggeredByAnimationFrame: boolean): void { // Don't draw the cursor if it's hidden // TODO: Need to expose API for this - if (!(terminal as any)._core._coreService.isCursorInitialized || (terminal as any)._core._coreService.isCursorHidden) { + if (!this._terminal.coreService.isCursorInitialized || this._terminal.coreService.isCursorHidden) { this._clearCursor(); return; } From 280ce85b748cabd299fb2e1f848063979ba78ece Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 04:50:29 -0700 Subject: [PATCH 312/377] Remove role=document from terminal element Part of microsoft/vscode#98918 --- src/browser/Terminal.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 004f2314..8072d6cb 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -408,7 +408,6 @@ export class Terminal extends CoreTerminal implements ITerminal { this.element.classList.add('terminal'); this.element.classList.add('xterm'); this.element.setAttribute('tabindex', '0'); - this.element.setAttribute('role', 'document'); parent.appendChild(this.element); // Performance: Use a document fragment to build the terminal From 7c0a28eb59304f919f02ef8bd94efd2b172f0f25 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 04:54:44 -0700 Subject: [PATCH 313/377] Call out xterm-headless in main readme Fixes #3412 --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 479c8113..720e703c 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,10 @@ We also partially support *Internet Explorer 11*, meaning xterm.js should work f Xterm.js works seamlessly in [Electron](https://electronjs.org/) apps and may even work on earlier versions of the browsers. These are the versions we strive to keep working. +### Node.js Support + +We also publish [`xterm-headless`](https://www.npmjs.com/package/xterm-headless) which is a stripped down version of xterm.js that runs in Node.js. An example use case for this is to keep track of a terminal's state where the process is running and using the serialize addon so it can get all state restored upon reconnection. + ## API The full API for xterm.js is contained within the [TypeScript declaration file](https://github.com/xtermjs/xterm.js/blob/master/typings/xterm.d.ts), use the branch/tag picker in GitHub (`w`) to navigate to the correct version of the API. From 7a2621f6abbb58d80e77d213182374bbc4b3199a Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 05:48:52 -0700 Subject: [PATCH 314/377] Make serialize and unicode11 compatible with node Fixes #3410 Fixes #3411 --- addons/xterm-addon-serialize/src/SerializeAddon.ts | 1 + addons/xterm-addon-serialize/webpack.config.js | 3 ++- addons/xterm-addon-unicode11/src/Unicode11Addon.ts | 1 + addons/xterm-addon-unicode11/webpack.config.js | 3 ++- headless/package.json | 9 --------- 5 files changed, 6 insertions(+), 11 deletions(-) delete mode 100644 headless/package.json diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index 0caaaa03..0cf474e6 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -7,6 +7,7 @@ import { Terminal, ITerminalAddon, IBuffer, IBufferCell } from 'xterm'; + function constrain(value: number, low: number, high: number): number { return Math.max(low, Math.min(value, high)); } diff --git a/addons/xterm-addon-serialize/webpack.config.js b/addons/xterm-addon-serialize/webpack.config.js index 4cabbad9..7c0ccd01 100644 --- a/addons/xterm-addon-serialize/webpack.config.js +++ b/addons/xterm-addon-serialize/webpack.config.js @@ -25,7 +25,8 @@ module.exports = { filename: mainFile, path: path.resolve('./lib'), library: addonName, - libraryTarget: 'umd' + libraryTarget: 'umd', + globalObject: 'this' }, mode: 'production' }; diff --git a/addons/xterm-addon-unicode11/src/Unicode11Addon.ts b/addons/xterm-addon-unicode11/src/Unicode11Addon.ts index cb8c9c56..d4ddf77e 100644 --- a/addons/xterm-addon-unicode11/src/Unicode11Addon.ts +++ b/addons/xterm-addon-unicode11/src/Unicode11Addon.ts @@ -8,6 +8,7 @@ import { Terminal, ITerminalAddon } from 'xterm'; import { UnicodeV11 } from './UnicodeV11'; + export class Unicode11Addon implements ITerminalAddon { public activate(terminal: Terminal): void { terminal.unicode.register(new UnicodeV11()); diff --git a/addons/xterm-addon-unicode11/webpack.config.js b/addons/xterm-addon-unicode11/webpack.config.js index 66a83a2f..10c0adc3 100644 --- a/addons/xterm-addon-unicode11/webpack.config.js +++ b/addons/xterm-addon-unicode11/webpack.config.js @@ -32,7 +32,8 @@ module.exports = { filename: mainFile, path: path.resolve('./lib'), library: addonName, - libraryTarget: 'umd' + libraryTarget: 'umd', + globalObject: 'this' }, mode: 'production' }; diff --git a/headless/package.json b/headless/package.json deleted file mode 100644 index d53761e7..00000000 --- a/headless/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "xterm-headless", - "description": "A headless terminal component that runs in Node.js", - "version": "4.13.0-alpha3", - "main": "lib-headless/xterm-headless.js", - "types": "typings/xterm-headless.d.ts", - "repository": "https://github.com/xtermjs/xterm.js", - "license": "MIT" -} \ No newline at end of file From 2b3c7639824468067f05009f60a091b5f047b4f6 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 07:42:47 -0700 Subject: [PATCH 315/377] Clean up mixed weight characters --- src/browser/renderer/BoxAndBlockCharacters.ts | 122 ++++++++---------- 1 file changed, 54 insertions(+), 68 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 23e76963..7882d03e 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -90,15 +90,6 @@ export const boxDrawingBoxes: { [index: string]: any } = { '\u{1FB97}': [{ x: 0, y: 2, w: 8, h: 2 }, { x: 0, y: 6, w: 8, h: 2 }] }; -const yAxis = `M.5,0 L.5,1`; -const xAxis = `M0,.5 L1,.5`; -const bottomYAxisFromBottom = `M.5,1 L.5,.5`; -const bottomYAxisFromMiddle = `M.5,.5 L.5,1`; -const topYAxisFromTop = `M.5,0 L.5,.5`; -const topYAxisFromMiddle = `M.5,0 L.5,.5`; -const rightMiddleXAxis = `M.5,.5 L1,.5`; -const leftMiddleXAxis = `M.5,.5 L0,.5`; - const enum Shapes { /** │ */ TOP_TO_BOTTOM = 'M.5,0 L.5,1', /** ─ */ LEFT_TO_RIGHT = 'M0,.5 L1,.5', @@ -108,8 +99,8 @@ const enum Shapes { /** ┐ */ LEFT_TO_BOTTOM = 'M0,.5 L.5,.5 L.5,1', /** ┌ */ RIGHT_TO_BOTTOM = 'M0.5,1 L.5,.5 L1,.5', - /** ╵ */ MIDDLE_TO_TOP = 'M.5,.5 L0,.5', - /** ╴ */ MIDDLE_TO_LEFT = 'M.5,.5 L.5,0', + /** ╵ */ MIDDLE_TO_TOP = 'M.5,.5 L.5,0', + /** ╴ */ MIDDLE_TO_LEFT = 'M.5,.5 L0,.5', /** ╶ */ MIDDLE_TO_RIGHT = 'M.5,.5 L1,.5', /** ╷ */ MIDDLE_TO_BOTTOM = 'M.5,.5 L.5,1', @@ -167,10 +158,6 @@ export const boxCharacters: { [character: string]: { [fontWeight: number]: strin '╷': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM }, '╻': { [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, - // Mixed normal/bold - '┍': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, - '┎': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, - // Double border '═': { [Style.NORMAL]: (xp, yp) => `M0,${.5 - yp} L1,${.5 - yp} M0,${.5 + yp} L1,${.5 + yp}` }, '║': { [Style.NORMAL]: (xp, yp) => `M${.5 - xp},0 L${.5 - xp},1 M${.5 + xp},0 L${.5 + xp},1` }, @@ -208,54 +195,56 @@ export const boxCharacters: { [character: string]: { [fontWeight: number]: strin '╳': { [Style.NORMAL]: 'M1,0 L0,1 M0,0 L1,1' }, // Mixed weight - '┑': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${leftMiddleXAxis}` }, - '┒': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom}` }, - '┕': { [Style.NORMAL]: `${topYAxisFromTop}`, [Style.BOLD]: `${rightMiddleXAxis}` }, - '┖': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop}` }, - '┙': { [Style.NORMAL]: `${topYAxisFromTop}`, [Style.BOLD]: `${leftMiddleXAxis}` }, - '┚': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop}` }, - '┝': { [Style.NORMAL]: `${yAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, - '┞': { [Style.NORMAL]: `${bottomYAxisFromMiddle} ${rightMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop}` }, - '┟': { [Style.NORMAL]: `${topYAxisFromMiddle} ${rightMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom}` }, - '┠': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${yAxis}` }, - '┡': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${topYAxisFromMiddle} ${rightMiddleXAxis}` }, - '┢': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` }, - '┥': { [Style.NORMAL]: `${yAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, - '┦': { [Style.NORMAL]: `${bottomYAxisFromMiddle} ${leftMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop}` }, - '┧': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` }, - '┨': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${yAxis}` }, - '┩': { [Style.NORMAL]: `${bottomYAxisFromMiddle}`, [Style.BOLD]: `${topYAxisFromMiddle} ${leftMiddleXAxis}` }, - '┪': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` }, - '┭': { [Style.NORMAL]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, - '┮': { [Style.NORMAL]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, - '┯': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${leftMiddleXAxis} ${rightMiddleXAxis}` }, - '┰': { [Style.NORMAL]: `${xAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom}` }, - '┱': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` }, - '┲': { [Style.NORMAL]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, - '┵': { [Style.NORMAL]: `${topYAxisFromMiddle} ${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, - '┶': { [Style.NORMAL]: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, - '┷': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${leftMiddleXAxis} ${rightMiddleXAxis}` }, - '┸': { [Style.NORMAL]: `${xAxis}`, [Style.BOLD]: `${topYAxisFromMiddle}` }, - '┹': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromMiddle} ${leftMiddleXAxis}` }, - '┺': { [Style.NORMAL]: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, - '┽': { [Style.NORMAL]: `${yAxis} ${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, - '┾': { [Style.NORMAL]: `${yAxis} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, - '┿': { [Style.NORMAL]: `${yAxis}`, [Style.BOLD]: `${leftMiddleXAxis} ${rightMiddleXAxis}` }, - '╀': { [Style.NORMAL]: `${xAxis}`, [Style.BOLD]: `${yAxis}` }, - '╁': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${yAxis} ${leftMiddleXAxis}` }, - '╂': { [Style.NORMAL]: `${yAxis} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, - '╃': { [Style.NORMAL]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop} ${leftMiddleXAxis}` }, - '╄': { [Style.NORMAL]: `${topYAxisFromTop} ${leftMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` }, - '╅': { [Style.NORMAL]: `${topYAxisFromTop} ${rightMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` }, - '╆': { [Style.NORMAL]: `${topYAxisFromTop} ${leftMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` }, - '╇': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${leftMiddleXAxis} ${topYAxisFromTop} ${rightMiddleXAxis}` }, - '╈': { [Style.NORMAL]: `${topYAxisFromTop}`, [Style.BOLD]: `${leftMiddleXAxis} ${bottomYAxisFromBottom} ${rightMiddleXAxis}` }, - '╉': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis} ${yAxis}` }, - '╊': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis} ${yAxis}` }, - '╼': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, - '╽': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${bottomYAxisFromBottom}` }, - '╾': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, - '╿': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${topYAxisFromMiddle}` }, + '╼': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, + '╽': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, + '╾': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT }, + '╿': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_TOP }, + '┍': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, + '┎': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, + '┑': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT }, + '┒': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, + '┕': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, + '┖': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_TOP }, + '┙': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT }, + '┚': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: Shapes.MIDDLE_TO_TOP }, + '┝': { [Style.NORMAL]: Shapes.TOP_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, + '┞': { [Style.NORMAL]: Shapes.RIGHT_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_TOP }, + '┟': { [Style.NORMAL]: Shapes.TOP_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, + '┠': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.TOP_TO_BOTTOM }, + '┡': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.TOP_TO_RIGHT }, + '┢': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: Shapes.RIGHT_TO_BOTTOM }, + '┥': { [Style.NORMAL]: Shapes.TOP_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT }, + '┦': { [Style.NORMAL]: Shapes.LEFT_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_TOP }, + '┧': { [Style.NORMAL]: Shapes.TOP_TO_LEFT, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, + '┨': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: Shapes.TOP_TO_BOTTOM }, + '┩': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.TOP_TO_LEFT }, + '┪': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: Shapes.LEFT_TO_BOTTOM }, + '┭': { [Style.NORMAL]: Shapes.RIGHT_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT }, + '┮': { [Style.NORMAL]: Shapes.LEFT_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, + '┯': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.LEFT_TO_RIGHT }, + '┰': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, + '┱': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.LEFT_TO_BOTTOM }, + '┲': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: Shapes.RIGHT_TO_BOTTOM }, + '┵': { [Style.NORMAL]: Shapes.TOP_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT }, + '┶': { [Style.NORMAL]: Shapes.TOP_TO_LEFT, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, + '┷': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: Shapes.LEFT_TO_RIGHT }, + '┸': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_TOP }, + '┹': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.TOP_TO_LEFT }, + '┺': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: Shapes.TOP_TO_RIGHT }, + '┽': { [Style.NORMAL]: `${Shapes.TOP_TO_BOTTOM} ${Shapes.MIDDLE_TO_RIGHT}`, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT }, + '┾': { [Style.NORMAL]: `${Shapes.TOP_TO_BOTTOM} ${Shapes.MIDDLE_TO_LEFT}`, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, + '┿': { [Style.NORMAL]: Shapes.TOP_TO_BOTTOM, [Style.BOLD]: Shapes.LEFT_TO_RIGHT }, + '╀': { [Style.NORMAL]: `${Shapes.LEFT_TO_RIGHT} ${Shapes.MIDDLE_TO_BOTTOM}`, [Style.BOLD]: Shapes.TOP_TO_BOTTOM }, + '╁': { [Style.NORMAL]: `${Shapes.MIDDLE_TO_TOP} ${Shapes.LEFT_TO_RIGHT}`, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, + '╂': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT, [Style.BOLD]: Shapes.TOP_TO_BOTTOM }, + '╃': { [Style.NORMAL]: Shapes.RIGHT_TO_BOTTOM, [Style.BOLD]: Shapes.TOP_TO_LEFT }, + '╄': { [Style.NORMAL]: Shapes.LEFT_TO_BOTTOM, [Style.BOLD]: Shapes.TOP_TO_RIGHT }, + '╅': { [Style.NORMAL]: Shapes.TOP_TO_RIGHT, [Style.BOLD]: Shapes.LEFT_TO_BOTTOM }, + '╆': { [Style.NORMAL]: Shapes.TOP_TO_LEFT, [Style.BOLD]: Shapes.RIGHT_TO_BOTTOM }, + '╇': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: `${Shapes.MIDDLE_TO_TOP} ${Shapes.LEFT_TO_RIGHT}` }, + '╈': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: `${Shapes.LEFT_TO_RIGHT} ${Shapes.MIDDLE_TO_BOTTOM}` }, + '╉': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: `${Shapes.TOP_TO_BOTTOM} ${Shapes.MIDDLE_TO_LEFT}` }, + '╊': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: `${Shapes.TOP_TO_BOTTOM} ${Shapes.MIDDLE_TO_RIGHT}` }, // Dashed // TODO: Spacing dashes evenly, use 1/2 padding on each edge so the line is continuous @@ -324,9 +313,6 @@ function clamp(value: number, max: number, min: number = 0): number { } const instructionMap: { [index: string]: any } = { - 'M': (ctx: CanvasRenderingContext2D, x: number, y: number) => { - ctx.moveTo(x, y); }, - 'L': (ctx: CanvasRenderingContext2D, x: number, y: number) => { - ctx.lineTo(x, y); - } + 'M': (ctx: CanvasRenderingContext2D, x: number, y: number) => ctx.moveTo(x, y), + 'L': (ctx: CanvasRenderingContext2D, x: number, y: number) => ctx.lineTo(x, y) }; From f43ae16a47d6062face1de48504d08f061a40797 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 07:57:32 -0700 Subject: [PATCH 316/377] Implement curved lines --- src/browser/renderer/BoxAndBlockCharacters.ts | 71 ++++++++++++------- 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 7882d03e..42608295 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -248,18 +248,24 @@ export const boxCharacters: { [character: string]: { [fontWeight: number]: strin // Dashed // TODO: Spacing dashes evenly, use 1/2 padding on each edge so the line is continuous - '╌': { [Style.NORMAL]: Shapes.TWO_DASHES_HORIZONTAL }, - '╍': { [Style.BOLD]: Shapes.TWO_DASHES_HORIZONTAL }, - '┄': { [Style.NORMAL]: Shapes.THREE_DASHES_HORIZONTAL }, - '┅': { [Style.BOLD]: Shapes.THREE_DASHES_HORIZONTAL }, - '┈': { [Style.NORMAL]: Shapes.FOUR_DASHES_HORIZONTAL }, - '┉': { [Style.BOLD]: Shapes.FOUR_DASHES_HORIZONTAL }, + '╌': { [Style.NORMAL]: Shapes.TWO_DASHES_HORIZONTAL }, + '╍': { [Style.BOLD]: Shapes.TWO_DASHES_HORIZONTAL }, + '┄': { [Style.NORMAL]: Shapes.THREE_DASHES_HORIZONTAL }, + '┅': { [Style.BOLD]: Shapes.THREE_DASHES_HORIZONTAL }, + '┈': { [Style.NORMAL]: Shapes.FOUR_DASHES_HORIZONTAL }, + '┉': { [Style.BOLD]: Shapes.FOUR_DASHES_HORIZONTAL }, '╎': { [Style.NORMAL]: Shapes.TWO_DASHES_VERTICAL }, '╏': { [Style.BOLD]: Shapes.TWO_DASHES_VERTICAL }, '┆': { [Style.NORMAL]: Shapes.THREE_DASHES_VERTICAL }, - '┇': { [Style.BOLD]: Shapes.THREE_DASHES_VERTICAL }, + '┇': { [Style.BOLD]: Shapes.THREE_DASHES_VERTICAL }, '┊': { [Style.NORMAL]: Shapes.FOUR_DASHES_VERTICAL }, - '┋': { [Style.BOLD]: Shapes.FOUR_DASHES_VERTICAL } + '┋': { [Style.BOLD]: Shapes.FOUR_DASHES_VERTICAL }, + + // Curved + '╭': { [Style.NORMAL]: 'C.5,1,.5,.5,1,.5' }, + '╮': { [Style.NORMAL]: 'C.5,1,.5,.5,0,.5' }, + '╯': { [Style.NORMAL]: 'C.5,0,.5,.5,0,.5' }, + '╰': { [Style.NORMAL]: 'C.5,0,.5,.5,1,.5' } }; export function drawBoxChar(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { @@ -285,23 +291,11 @@ export function drawBoxChar(ctx: CanvasRenderingContext2D, c: string, xOffset: n console.error(`Could not find drawing instructions for "${type}"`); continue; } - const coords: string[] = instruction.substring(1).split(','); - if (!coords[0] || !coords[1]) { + const args: string[] = instruction.substring(1).split(','); + if (!args[0] || !args[1]) { continue; } - let x = Number.parseFloat(coords[0].toString()) || Number.parseInt(coords[0].toString()); - let y = Number.parseFloat(coords[1].toString()) || Number.parseInt(coords[1].toString()); - - x *= cellWidth; - y *= cellHeight; - - if (y !== 0) { - y = clamp(Math.round(y + .5) - .5, cellHeight, 0); - } - if (x !== 0) { - x = clamp(Math.round(x + .5) - .5, cellWidth, 0); - } - f(ctx, xOffset + x, yOffset + y); + f(ctx, translateArgs(args, cellWidth, cellHeight, xOffset, yOffset)); } ctx.stroke(); ctx.closePath(); @@ -313,6 +307,33 @@ function clamp(value: number, max: number, min: number = 0): number { } const instructionMap: { [index: string]: any } = { - 'M': (ctx: CanvasRenderingContext2D, x: number, y: number) => ctx.moveTo(x, y), - 'L': (ctx: CanvasRenderingContext2D, x: number, y: number) => ctx.lineTo(x, y) + 'C': (ctx: CanvasRenderingContext2D, args: number[]) => ctx.bezierCurveTo(args[0], args[1], args[2], args[3], args[4], args[5]), + 'L': (ctx: CanvasRenderingContext2D, args: number[]) => ctx.lineTo(args[0], args[1]), + 'M': (ctx: CanvasRenderingContext2D, args: number[]) => ctx.moveTo(args[0], args[1]) }; + +function translateArgs(args: string[], cellWidth: number, cellHeight: number, xOffset: number, yOffset: number): number[] { + const result = args.map(e => parseFloat(e) || parseInt(e)); + + if (result.length < 2) { + throw new Error('Too few arguments for instruction'); + } + + for (let x = 0; x < result.length; x += 2) { + result[x] *= cellWidth; + if (result[x] !== 0) { + result[x] = clamp(Math.round(result[x] + 0.5) - 0.5, cellWidth, 0); + } + result[x] += xOffset; + } + + for (let y = 1; y < result.length; y += 2) { + result[y] *= cellHeight; + if (result[y] !== 0) { + result[y] = clamp(Math.round(result[y] + 0.5) - 0.5, cellHeight, 0); + } + result[y] += yOffset; + } + + return result; +} From fd25ee0127c4b88421723ab212af0313c20fef4b Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 08:02:19 -0700 Subject: [PATCH 317/377] Add some doc comments --- src/browser/renderer/BoxAndBlockCharacters.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 42608295..48645d03 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -125,6 +125,7 @@ const enum Style { } // TODO: Tweak normal and bold weights +// This contains the definitions of all box drawing characters as SVG paths (ie. the svg d attribute) export const boxCharacters: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } } = { // Uniform normal and bold '─': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT }, @@ -320,18 +321,26 @@ function translateArgs(args: string[], cellWidth: number, cellHeight: number, xO } for (let x = 0; x < result.length; x += 2) { + // Translate from 0-1 to 0-cellWidth result[x] *= cellWidth; + // Ensure coordinate doesn't escape cell bounds and round to the nearest 0.5 to ensure a crisp + // line at 100% devicePixelRatio if (result[x] !== 0) { result[x] = clamp(Math.round(result[x] + 0.5) - 0.5, cellWidth, 0); } + // Apply the cell's offset (ie. x*cellWidth) result[x] += xOffset; } for (let y = 1; y < result.length; y += 2) { + // Translate from 0-1 to 0-cellHeight result[y] *= cellHeight; + // Ensure coordinate doesn't escape cell bounds and round to the nearest 0.5 to ensure a crisp + // line at 100% devicePixelRatio if (result[y] !== 0) { result[y] = clamp(Math.round(result[y] + 0.5) - 0.5, cellHeight, 0); } + // Apply the cell's offset (ie. x*cellHeight) result[y] += yOffset; } From 9269e91c49de1c70b4fcb46d915fab862782d49e Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 08:04:17 -0700 Subject: [PATCH 318/377] Make bold triple normal weight so 1 dpr = 3px bold --- src/browser/renderer/BoxAndBlockCharacters.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 48645d03..af239191 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -121,10 +121,9 @@ const enum Shapes { const enum Style { NORMAL = 1, - BOLD = 2 + BOLD = 3 } -// TODO: Tweak normal and bold weights // This contains the definitions of all box drawing characters as SVG paths (ie. the svg d attribute) export const boxCharacters: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } } = { // Uniform normal and bold From bcfbbb481c5608aabd1079957e56f27b9b73b89c Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 08:14:46 -0700 Subject: [PATCH 319/377] Correct horizontal dash and a mixed weight char --- src/browser/renderer/BoxAndBlockCharacters.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index af239191..030c06e8 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -111,12 +111,12 @@ const enum Shapes { /** ┼ */ CROSS = 'M0,.5 L1,.5 M.5,0 L.5,1', - /** ╌ */ TWO_DASHES_HORIZONTAL = 'M.1,.5 L.45,.5 M.55,.5 L.9,.5', + /** ╌ */ TWO_DASHES_HORIZONTAL = 'M.1,.5 L.4,.5 M.6,.5 L.9,.5', /** ┄ */ THREE_DASHES_HORIZONTAL = 'M.052,.5 L.316,.5 M.0.421,.5 L.6315,.5 M.684,.5 L.947,.5', /** ┉ */ FOUR_DASHES_HORIZONTAL = 'M.0588,.5 L.235,.5 M.294,.5 L.4705,.5 M.529,.5 L.7058,.5 M.765,.5 L.947,.5', - /** ╌ */ TWO_DASHES_VERTICAL = 'M.5,0 T.5,.45 M.5,.55 T.5,1', - /** ┄ */ THREE_DASHES_VERTICAL = 'M.5,.052 L.5,.316 M.5,.0.368 L.5.632 M.5,.684 L.5,.947', - /** ┉ */ FOUR_DASHES_VERTICAL = 'M.5,.0588 L.5,.235 M.5,.294 L.5,.4705 29 L.5,.7058 M.5,.765 L.5,.947', + /** ╎ */ TWO_DASHES_VERTICAL = 'M.5,.1 T.5,.4 M.5,.6 T.5,.9', + /** ┆ */ THREE_DASHES_VERTICAL = 'M.5,.052 L.5,.316 M.5,.0.368 L.5.632 M.5,.684 L.5,.947', + /** ┊ */ FOUR_DASHES_VERTICAL = 'M.5,.0588 L.5,.235 M.5,.294 L.5,.4705 29 L.5,.7058 M.5,.765 L.5,.947', } const enum Style { @@ -234,7 +234,7 @@ export const boxCharacters: { [character: string]: { [fontWeight: number]: strin '┽': { [Style.NORMAL]: `${Shapes.TOP_TO_BOTTOM} ${Shapes.MIDDLE_TO_RIGHT}`, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT }, '┾': { [Style.NORMAL]: `${Shapes.TOP_TO_BOTTOM} ${Shapes.MIDDLE_TO_LEFT}`, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, '┿': { [Style.NORMAL]: Shapes.TOP_TO_BOTTOM, [Style.BOLD]: Shapes.LEFT_TO_RIGHT }, - '╀': { [Style.NORMAL]: `${Shapes.LEFT_TO_RIGHT} ${Shapes.MIDDLE_TO_BOTTOM}`, [Style.BOLD]: Shapes.TOP_TO_BOTTOM }, + '╀': { [Style.NORMAL]: `${Shapes.LEFT_TO_RIGHT} ${Shapes.MIDDLE_TO_BOTTOM}`, [Style.BOLD]: Shapes.MIDDLE_TO_TOP }, '╁': { [Style.NORMAL]: `${Shapes.MIDDLE_TO_TOP} ${Shapes.LEFT_TO_RIGHT}`, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, '╂': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT, [Style.BOLD]: Shapes.TOP_TO_BOTTOM }, '╃': { [Style.NORMAL]: Shapes.RIGHT_TO_BOTTOM, [Style.BOLD]: Shapes.TOP_TO_LEFT }, From ca88476934de016346e2bc57336d7e512631b81a Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 08:48:23 -0700 Subject: [PATCH 320/377] Improve spacing of dash characters --- src/browser/renderer/BoxAndBlockCharacters.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 030c06e8..ac37c761 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -111,12 +111,12 @@ const enum Shapes { /** ┼ */ CROSS = 'M0,.5 L1,.5 M.5,0 L.5,1', - /** ╌ */ TWO_DASHES_HORIZONTAL = 'M.1,.5 L.4,.5 M.6,.5 L.9,.5', - /** ┄ */ THREE_DASHES_HORIZONTAL = 'M.052,.5 L.316,.5 M.0.421,.5 L.6315,.5 M.684,.5 L.947,.5', - /** ┉ */ FOUR_DASHES_HORIZONTAL = 'M.0588,.5 L.235,.5 M.294,.5 L.4705,.5 M.529,.5 L.7058,.5 M.765,.5 L.947,.5', - /** ╎ */ TWO_DASHES_VERTICAL = 'M.5,.1 T.5,.4 M.5,.6 T.5,.9', - /** ┆ */ THREE_DASHES_VERTICAL = 'M.5,.052 L.5,.316 M.5,.0.368 L.5.632 M.5,.684 L.5,.947', - /** ┊ */ FOUR_DASHES_VERTICAL = 'M.5,.0588 L.5,.235 M.5,.294 L.5,.4705 29 L.5,.7058 M.5,.765 L.5,.947', + /** ╌ */ TWO_DASHES_HORIZONTAL = 'M.1,.5 L.4,.5 M.6,.5 L.9,.5', // .2 empty, .3 filled + /** ┄ */ THREE_DASHES_HORIZONTAL = 'M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5', // .1333 empty, .2 filled + /** ┉ */ FOUR_DASHES_HORIZONTAL = 'M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5', // .1 empty, .15 filled + /** ╎ */ TWO_DASHES_VERTICAL = 'M.5,.1 L.5,.4 M.5,.6 L.5,.9', + /** ┆ */ THREE_DASHES_VERTICAL = 'M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333', + /** ┊ */ FOUR_DASHES_VERTICAL = 'M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95', } const enum Style { @@ -171,7 +171,7 @@ export const boxCharacters: { [character: string]: { [fontWeight: number]: strin '╙': { [Style.NORMAL]: (xp, yp) => `M1,.5 L${.5 - xp},.5 L${.5 - xp},0 M${.5 + xp},.5 L${.5 + xp},0` }, '╚': { [Style.NORMAL]: (xp, yp) => `M1,${.5 - yp} L${.5 + xp},${.5 - yp} L${.5 + xp},0 M1,${.5 + yp} L${.5 - xp},${.5 + yp} L${.5 - xp},0` }, '╛': { [Style.NORMAL]: (xp, yp) => `M0,${.5 + yp} L.5,${.5 + yp} L.5,0 M0,${.5 - yp} L.5,${.5 - yp}` }, - '╜': { [Style.NORMAL]: (xp, yp) => `M0,.5 L${.5 + xp},.5 L${.5 + xp},0 M${.5 - xp},.5 L${.5 - xp},0 ` }, + '╜': { [Style.NORMAL]: (xp, yp) => `M0,.5 L${.5 + xp},.5 L${.5 + xp},0 M${.5 - xp},.5 L${.5 - xp},0` }, '╝': { [Style.NORMAL]: (xp, yp) => `M0,${.5 - yp} L${.5 - xp},${.5 - yp} L${.5 - xp},0 M0,${.5 + yp} L${.5 + xp},${.5 + yp} L${.5 + xp},0` }, '╞': { [Style.NORMAL]: (xp, yp) => `${Shapes.TOP_TO_BOTTOM} M.5,${.5 - yp} L1,${.5 - yp} M.5,${.5 + yp} L1,${.5 + yp}` }, '╟': { [Style.NORMAL]: (xp, yp) => `M${.5 - xp},0 L${.5 - xp},1 M${.5 + xp},0 L${.5 + xp},1 M${.5 + xp},.5 L1,.5` }, From f1849cafafe01df5f153aefc02f2eb8d03325148 Mon Sep 17 00:00:00 2001 From: Samuel Sampson Date: Tue, 17 Aug 2021 20:48:31 +0000 Subject: [PATCH 321/377] Introduce IRenderDebouncer interface, unifying RenderDebouncer and TimeBasedDebouncer types --- src/browser/AccessibilityManager.ts | 4 ++-- src/browser/RenderDebouncer.ts | 4 ++-- src/browser/TimeBasedDebouncer.ts | 4 ++-- src/browser/Types.d.ts | 4 ++++ src/browser/services/RenderService.ts | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/browser/AccessibilityManager.ts b/src/browser/AccessibilityManager.ts index 160aa3fc..1be3342d 100644 --- a/src/browser/AccessibilityManager.ts +++ b/src/browser/AccessibilityManager.ts @@ -4,7 +4,7 @@ */ import * as Strings from 'browser/LocalizableStrings'; -import { ITerminal } from 'browser/Types'; +import { ITerminal, IRenderDebouncer } from 'browser/Types'; import { IBuffer } from 'common/buffer/Types'; import { isMac } from 'common/Platform'; import { TimeBasedDebouncer } from 'browser/TimeBasedDebouncer'; @@ -28,7 +28,7 @@ export class AccessibilityManager extends Disposable { private _liveRegion: HTMLElement; private _liveRegionLineCount: number = 0; - private _renderRowsDebouncer: TimeBasedDebouncer; + private _renderRowsDebouncer: IRenderDebouncer; private _screenDprMonitor: ScreenDprMonitor; private _topBoundaryFocusListener: (e: FocusEvent) => void; diff --git a/src/browser/RenderDebouncer.ts b/src/browser/RenderDebouncer.ts index 2a06fdd6..02521070 100644 --- a/src/browser/RenderDebouncer.ts +++ b/src/browser/RenderDebouncer.ts @@ -3,12 +3,12 @@ * @license MIT */ -import { IDisposable } from 'common/Types'; +import { IRenderDebouncer } from 'browser/Types'; /** * Debounces calls to render terminal rows using animation frames. */ -export class RenderDebouncer implements IDisposable { +export class RenderDebouncer implements IRenderDebouncer { private _rowStart: number | undefined; private _rowEnd: number | undefined; private _rowCount: number | undefined; diff --git a/src/browser/TimeBasedDebouncer.ts b/src/browser/TimeBasedDebouncer.ts index 843787d5..e4aeb387 100644 --- a/src/browser/TimeBasedDebouncer.ts +++ b/src/browser/TimeBasedDebouncer.ts @@ -5,12 +5,12 @@ const RENDER_DEBOUNCE_THRESHOLD_MS = 1000; // 1 Second -import { IDisposable } from 'common/Types'; +import { IRenderDebouncer } from 'browser/Types'; /** * Debounces calls to update screen readers to update at most once per second. */ -export class TimeBasedDebouncer implements IDisposable { +export class TimeBasedDebouncer implements IRenderDebouncer { private _rowStart: number | undefined; private _rowEnd: number | undefined; private _rowCount: number | undefined; diff --git a/src/browser/Types.d.ts b/src/browser/Types.d.ts index c268c7bf..0d74b39f 100644 --- a/src/browser/Types.d.ts +++ b/src/browser/Types.d.ts @@ -309,3 +309,7 @@ export interface ICharacterJoiner { id: number; handler: CharacterJoinerHandler; } + +export interface IRenderDebouncer extends IDisposable { + refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void; +} diff --git a/src/browser/services/RenderService.ts b/src/browser/services/RenderService.ts index fc2eb435..332e71da 100644 --- a/src/browser/services/RenderService.ts +++ b/src/browser/services/RenderService.ts @@ -9,7 +9,7 @@ import { EventEmitter, IEvent } from 'common/EventEmitter'; import { Disposable } from 'common/Lifecycle'; import { ScreenDprMonitor } from 'browser/ScreenDprMonitor'; import { addDisposableDomListener } from 'browser/Lifecycle'; -import { IColorSet } from 'browser/Types'; +import { IColorSet, IRenderDebouncer } from 'browser/Types'; import { IOptionsService, IBufferService } from 'common/services/Services'; import { ICharSizeService, IRenderService } from 'browser/services/Services'; @@ -22,7 +22,7 @@ interface ISelectionState { export class RenderService extends Disposable implements IRenderService { public serviceBrand: undefined; - private _renderDebouncer: RenderDebouncer; + private _renderDebouncer: IRenderDebouncer; private _screenDprMonitor: ScreenDprMonitor; private _isPaused: boolean = false; From 9f24cf7e72a729946e606105b48f12dd953fad5a Mon Sep 17 00:00:00 2001 From: Samuel Sampson Date: Tue, 17 Aug 2021 21:28:58 +0000 Subject: [PATCH 322/377] Cancel queued refreshes in TimeBasedDebouncer on dispose --- src/browser/TimeBasedDebouncer.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/browser/TimeBasedDebouncer.ts b/src/browser/TimeBasedDebouncer.ts index e4aeb387..455621d7 100644 --- a/src/browser/TimeBasedDebouncer.ts +++ b/src/browser/TimeBasedDebouncer.ts @@ -20,12 +20,18 @@ export class TimeBasedDebouncer implements IRenderDebouncer { // Whether a trailing refresh should be triggered due to a refresh request that was throttled private _additionalRefreshRequested = false; + private _refreshTimeoutID: number | undefined; + constructor( private _renderCallback: (start: number, end: number) => void ) { } - public dispose(): void {} + public dispose(): void { + if (this._refreshTimeoutID) { + clearTimeout(this._refreshTimeoutID); + } + } public refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void { this._rowCount = rowCount; @@ -49,7 +55,7 @@ export class TimeBasedDebouncer implements IRenderDebouncer { const waitPeriodBeforeTrailingRefresh = RENDER_DEBOUNCE_THRESHOLD_MS - elapsed; this._additionalRefreshRequested = true; - setTimeout(() => { + this._refreshTimeoutID = window.setTimeout(() => { this._lastRefreshMs = Date.now(); this._innerRefresh(); this._additionalRefreshRequested = false; From ae58302dfaba3ffa2a8db74f88e728e8c875db2f Mon Sep 17 00:00:00 2001 From: Samuel Sampson Date: Tue, 17 Aug 2021 21:36:47 +0000 Subject: [PATCH 323/377] Allow render debounce interval to be configured at construction time in TimeBasedDebouncer --- src/browser/TimeBasedDebouncer.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/browser/TimeBasedDebouncer.ts b/src/browser/TimeBasedDebouncer.ts index 455621d7..584b33ce 100644 --- a/src/browser/TimeBasedDebouncer.ts +++ b/src/browser/TimeBasedDebouncer.ts @@ -8,7 +8,7 @@ const RENDER_DEBOUNCE_THRESHOLD_MS = 1000; // 1 Second import { IRenderDebouncer } from 'browser/Types'; /** - * Debounces calls to update screen readers to update at most once per second. + * Debounces calls to update screen readers to update at most once configurable interval of time. */ export class TimeBasedDebouncer implements IRenderDebouncer { private _rowStart: number | undefined; @@ -23,7 +23,8 @@ export class TimeBasedDebouncer implements IRenderDebouncer { private _refreshTimeoutID: number | undefined; constructor( - private _renderCallback: (start: number, end: number) => void + private _renderCallback: (start: number, end: number) => void, + private readonly debounceThresholdMS = RENDER_DEBOUNCE_THRESHOLD_MS ) { } @@ -45,14 +46,14 @@ export class TimeBasedDebouncer implements IRenderDebouncer { // Only refresh if the time since last refresh is above a threshold, otherwise wait for // enough time to pass before refreshing again. const refreshRequestTime: number = Date.now(); - if (refreshRequestTime - this._lastRefreshMs >= RENDER_DEBOUNCE_THRESHOLD_MS) { + if (refreshRequestTime - this._lastRefreshMs >= this.debounceThresholdMS) { // Enough time has lapsed since the last refresh; refresh immediately this._lastRefreshMs = refreshRequestTime; this._innerRefresh(); } else if (!this._additionalRefreshRequested) { // This is the first additional request throttled; set up trailing refresh const elapsed = refreshRequestTime - this._lastRefreshMs; - const waitPeriodBeforeTrailingRefresh = RENDER_DEBOUNCE_THRESHOLD_MS - elapsed; + const waitPeriodBeforeTrailingRefresh = this.debounceThresholdMS - elapsed; this._additionalRefreshRequested = true; this._refreshTimeoutID = window.setTimeout(() => { From e778df672acd8098c8bfd0adae5600420fc65fa3 Mon Sep 17 00:00:00 2001 From: Samuel Sampson Date: Tue, 17 Aug 2021 22:20:04 +0000 Subject: [PATCH 324/377] Don't clear timeouts in TimeBasedDebouncer if they've already been executed. --- src/browser/TimeBasedDebouncer.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/browser/TimeBasedDebouncer.ts b/src/browser/TimeBasedDebouncer.ts index 584b33ce..03e1a0c2 100644 --- a/src/browser/TimeBasedDebouncer.ts +++ b/src/browser/TimeBasedDebouncer.ts @@ -60,6 +60,7 @@ export class TimeBasedDebouncer implements IRenderDebouncer { this._lastRefreshMs = Date.now(); this._innerRefresh(); this._additionalRefreshRequested = false; + this._refreshTimeoutID = undefined; // No longer need to clear the timeout }, waitPeriodBeforeTrailingRefresh); } } From 42e0fcda29d2f202feb9b8ef6318eb1adb421d5a Mon Sep 17 00:00:00 2001 From: Samuel Sampson Date: Tue, 17 Aug 2021 22:26:14 +0000 Subject: [PATCH 325/377] Fix lint error due to private variable --- src/browser/TimeBasedDebouncer.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/browser/TimeBasedDebouncer.ts b/src/browser/TimeBasedDebouncer.ts index 03e1a0c2..707e25cb 100644 --- a/src/browser/TimeBasedDebouncer.ts +++ b/src/browser/TimeBasedDebouncer.ts @@ -24,7 +24,7 @@ export class TimeBasedDebouncer implements IRenderDebouncer { constructor( private _renderCallback: (start: number, end: number) => void, - private readonly debounceThresholdMS = RENDER_DEBOUNCE_THRESHOLD_MS + private readonly _debounceThresholdMS = RENDER_DEBOUNCE_THRESHOLD_MS ) { } @@ -46,14 +46,14 @@ export class TimeBasedDebouncer implements IRenderDebouncer { // Only refresh if the time since last refresh is above a threshold, otherwise wait for // enough time to pass before refreshing again. const refreshRequestTime: number = Date.now(); - if (refreshRequestTime - this._lastRefreshMs >= this.debounceThresholdMS) { + if (refreshRequestTime - this._lastRefreshMs >= this._debounceThresholdMS) { // Enough time has lapsed since the last refresh; refresh immediately this._lastRefreshMs = refreshRequestTime; this._innerRefresh(); } else if (!this._additionalRefreshRequested) { // This is the first additional request throttled; set up trailing refresh const elapsed = refreshRequestTime - this._lastRefreshMs; - const waitPeriodBeforeTrailingRefresh = this.debounceThresholdMS - elapsed; + const waitPeriodBeforeTrailingRefresh = this._debounceThresholdMS - elapsed; this._additionalRefreshRequested = true; this._refreshTimeoutID = window.setTimeout(() => { From 9fb1ce11fb2708b89ea32c4940cb953fd15e9fc8 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 18 Aug 2021 06:44:13 -0700 Subject: [PATCH 326/377] Add setting, clean up drawing, fix true color --- src/browser/renderer/BaseRenderLayer.ts | 55 +++++------- src/browser/renderer/BoxAndBlockCharacters.ts | 90 ++++++++++++++++--- src/common/services/OptionsService.ts | 1 + src/common/services/Services.ts | 1 + typings/xterm-headless.d.ts | 8 ++ typings/xterm.d.ts | 8 ++ 6 files changed, 118 insertions(+), 45 deletions(-) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 44b23840..e7116ed6 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -17,7 +17,7 @@ import { IBufferService, IOptionsService } from 'common/services/Services'; import { throwIfFalsy } from 'browser/renderer/RendererUtils'; import { channels, color, rgba } from 'browser/Color'; import { removeElementFromParent } from 'browser/Dom'; -import { boxCharacters, boxDrawingBoxes, drawBoxChar } from 'browser/renderer/BoxAndBlockCharacters'; +import { tryDrawCustomChar } from 'browser/renderer/BoxAndBlockCharacters'; export abstract class BaseRenderLayer implements IRenderLayer { private _canvas: HTMLCanvasElement; @@ -260,8 +260,15 @@ export abstract class BaseRenderLayer implements IRenderLayer { this._ctx.font = this._getFont(false, false); this._ctx.textBaseline = 'ideographic'; this._clipRow(y); - // TODO: fix - if (!this._drawBoxChar(cell, x, y)) { + + // Draw custom characters if applicable + let drawSuccess = false; + if (this._optionsService.options.customBlockAndBoxCharacters !== false) { + drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x, y, this._scaledCellWidth, this._scaledCellHeight, this._scaledCharLeft, this._scaledCharTop); + } + + // Draw the character + if (!drawSuccess) { this._ctx.fillText( cell.getChars(), x * this._scaledCellWidth + this._scaledCharLeft, @@ -377,46 +384,24 @@ export abstract class BaseRenderLayer implements IRenderLayer { if (cell.isDim()) { this._ctx.globalAlpha = DIM_OPACITY; } - if (!this._drawBoxChar(cell, x, y)) { - // Draw the character + + // Draw custom characters if applicable + let drawSuccess = false; + if (this._optionsService.options.customBlockAndBoxCharacters !== false) { + drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x, y, this._scaledCellWidth, this._scaledCellHeight, this._scaledCharLeft, this._scaledCharTop); + } + + // Draw the character + if (!drawSuccess) { this._ctx.fillText( cell.getChars(), x * this._scaledCellWidth + this._scaledCharLeft, y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight); } + this._ctx.restore(); } - private _drawBoxChar(cell: ICellData, x: number, y: number): boolean { - const char = cell.getChars(); - - const boxes = boxDrawingBoxes[char]; - if (boxes) { - this._ctx.strokeStyle = this._ctx.fillStyle; - const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; - const yOffset = y * this._scaledCellHeight + this._scaledCharTop; - for (let i = 0; i < boxes.length; i++) { - const box = boxes[i]; - const xEighth = this._scaledCellWidth / 8; - const yEighth = this._scaledCellHeight / 8; - this._ctx.fillRect( - xOffset, - yOffset, - box.w * xEighth, - box.h * yEighth); - } - return true; - } - - const lineSegments = boxCharacters[char]; - if (!lineSegments) { - return false; - } - this._ctx.strokeStyle = this._ctx.fillStyle; - drawBoxChar(this._ctx, char, x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); - return true; - } - /** * Clips a row to ensure no pixels will be drawn outside the cells in the row. diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index ac37c761..81cfaba8 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -1,5 +1,16 @@ +/** + * Copyright (c) 2021 The xterm.js authors. All rights reserved. + * @license MIT + */ -export const boxDrawingBoxes: { [index: string]: any } = { +interface IBlockVector { + x: number; + y: number; + w: number; + h: number; +} + +export const blockElementChars: { [index: string]: IBlockVector[] | undefined } = { '▀': [{ x: 0, y: 0, w: 8, h: 4 }], '█': [{ x: 0, y: 0, w: 8, h: 8 }], '▇': [{ x: 0, y: 1, w: 8, h: 7 }], @@ -125,7 +136,7 @@ const enum Style { } // This contains the definitions of all box drawing characters as SVG paths (ie. the svg d attribute) -export const boxCharacters: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } } = { +export const boxDrawingChars: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } | undefined } = { // Uniform normal and bold '─': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT }, '━': { [Style.BOLD]: Shapes.LEFT_TO_RIGHT }, @@ -247,7 +258,6 @@ export const boxCharacters: { [character: string]: { [fontWeight: number]: strin '╊': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: `${Shapes.TOP_TO_BOTTOM} ${Shapes.MIDDLE_TO_RIGHT}` }, // Dashed - // TODO: Spacing dashes evenly, use 1/2 padding on each edge so the line is continuous '╌': { [Style.NORMAL]: Shapes.TWO_DASHES_HORIZONTAL }, '╍': { [Style.BOLD]: Shapes.TWO_DASHES_HORIZONTAL }, '┄': { [Style.NORMAL]: Shapes.THREE_DASHES_HORIZONTAL }, @@ -268,18 +278,78 @@ export const boxCharacters: { [character: string]: { [fontWeight: number]: strin '╰': { [Style.NORMAL]: 'C.5,0,.5,.5,1,.5' } }; -export function drawBoxChar(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { - const match: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } = boxCharacters[c]; - if (!match) { - return; +/** + * Try drawing a custom block element or box drawing character, returning whether it was + * successfully drawn. + */ +export function tryDrawCustomChar( + ctx: CanvasRenderingContext2D, + c: string, + x: number, + y: number, + scaledCellWidth: number, + scaledCellHeight: number, + scaledCharLeft: number, + scaledCharTop: number +): boolean { + const blockElementInstruction = blockElementChars[c]; + if (blockElementInstruction) { + drawBlockElementChar(ctx, blockElementInstruction, x, y, scaledCellWidth, scaledCellHeight, scaledCharLeft, scaledCharTop); + return true; } - for (const [fontWeight, instructions] of Object.entries(match)) { + + const boxDrawingInstruction = boxDrawingChars[c]; + if (boxDrawingInstruction) { + drawBoxDrawingChar(ctx, boxDrawingInstruction, x, y, scaledCellWidth, scaledCellHeight); + return true; + } + + return false; +} + +function drawBlockElementChar( + ctx: CanvasRenderingContext2D, + instruction: IBlockVector[], + x: number, + y: number, + scaledCellWidth: number, + scaledCellHeight: number, + scaledCharLeft: number, + scaledCharTop: number +): void { + const xOffset = x * scaledCellWidth + scaledCharLeft; + const yOffset = y * scaledCellHeight + scaledCharTop; + for (let i = 0; i < instruction.length; i++) { + const box = instruction[i]; + const xEighth = scaledCellWidth / 8; + const yEighth = scaledCellHeight / 8; + ctx.fillRect( + xOffset, + yOffset, + box.w * xEighth, + box.h * yEighth + ); + } +} + +function drawBoxDrawingChar( + ctx: CanvasRenderingContext2D, + charDefinition: { [fontWeight: number]: string | ((xp: number, yp: number) => string) }, + x: number, + y: number, + scaledCellWidth: number, + scaledCellHeight: number +): void { + const xOffset = x * scaledCellWidth; + const yOffset = y * scaledCellHeight; + ctx.strokeStyle = ctx.fillStyle; + for (const [fontWeight, instructions] of Object.entries(charDefinition)) { ctx.beginPath(); ctx.lineWidth = window.devicePixelRatio * Number.parseInt(fontWeight); let actualInstructions: string; if (typeof instructions === 'function') { const xp = .15; - const yp = .15 / cellHeight * cellWidth; + const yp = .15 / scaledCellHeight * scaledCellWidth; actualInstructions = instructions(xp, yp); } else { actualInstructions = instructions; @@ -295,7 +365,7 @@ export function drawBoxChar(ctx: CanvasRenderingContext2D, c: string, xOffset: n if (!args[0] || !args[1]) { continue; } - f(ctx, translateArgs(args, cellWidth, cellHeight, xOffset, yOffset)); + f(ctx, translateArgs(args, scaledCellWidth, scaledCellHeight, xOffset, yOffset)); } ctx.stroke(); ctx.closePath(); diff --git a/src/common/services/OptionsService.ts b/src/common/services/OptionsService.ts index b7a1c58e..062166bc 100644 --- a/src/common/services/OptionsService.ts +++ b/src/common/services/OptionsService.ts @@ -21,6 +21,7 @@ export const DEFAULT_OPTIONS: ITerminalOptions = Object.freeze({ cursorBlink: false, cursorStyle: 'block', cursorWidth: 1, + customBlockAndBoxCharacters: true, bellSound: DEFAULT_BELL_SOUND, bellStyle: 'none', drawBoldTextInBrightColors: true, diff --git a/src/common/services/Services.ts b/src/common/services/Services.ts index ce297322..07615a41 100644 --- a/src/common/services/Services.ts +++ b/src/common/services/Services.ts @@ -244,6 +244,7 @@ export interface ITerminalOptions { cursorBlink: boolean; cursorStyle: 'block' | 'underline' | 'bar'; cursorWidth: number; + customBlockAndBoxCharacters: boolean; disableStdin: boolean; drawBoldTextInBrightColors: boolean; fastScrollModifier: 'alt' | 'ctrl' | 'shift' | undefined; diff --git a/typings/xterm-headless.d.ts b/typings/xterm-headless.d.ts index b6e1505b..dc886aa1 100644 --- a/typings/xterm-headless.d.ts +++ b/typings/xterm-headless.d.ts @@ -78,6 +78,14 @@ declare module 'xterm-headless' { */ cursorWidth?: number; + /** + * Whether to draw custom block element and box drawing characters instead of using the font. + * This should typically result in better rendering with continuous lines. Note that this + * doesn't work with the DOM renderer which renders all characters using the font. The default + * is true. + */ + customBlockAndBoxCharacters?: boolean; + /** * Whether input should be disabled. */ diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 3828b415..f6fbe709 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -90,6 +90,14 @@ declare module 'xterm' { */ cursorWidth?: number; + /** + * Whether to draw custom block element and box drawing characters instead of using the font. + * This should typically result in better rendering with continuous lines. Note that this + * doesn't work with the DOM renderer which renders all characters using the font. The default + * is true. + */ + customBlockAndBoxCharacters?: boolean; + /** * Whether input should be disabled. */ From 86a30dc689d20a776688404fdc88f3dc10145bdb Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 18 Aug 2021 06:45:40 -0700 Subject: [PATCH 327/377] Clean up usage of instruction/definition --- src/browser/renderer/BoxAndBlockCharacters.ts | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 81cfaba8..e4d549fb 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -10,7 +10,7 @@ interface IBlockVector { h: number; } -export const blockElementChars: { [index: string]: IBlockVector[] | undefined } = { +export const blockElementDefinitions: { [index: string]: IBlockVector[] | undefined } = { '▀': [{ x: 0, y: 0, w: 8, h: 4 }], '█': [{ x: 0, y: 0, w: 8, h: 8 }], '▇': [{ x: 0, y: 1, w: 8, h: 7 }], @@ -136,7 +136,7 @@ const enum Style { } // This contains the definitions of all box drawing characters as SVG paths (ie. the svg d attribute) -export const boxDrawingChars: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } | undefined } = { +export const boxDrawingDefinitions: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } | undefined } = { // Uniform normal and bold '─': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT }, '━': { [Style.BOLD]: Shapes.LEFT_TO_RIGHT }, @@ -292,15 +292,15 @@ export function tryDrawCustomChar( scaledCharLeft: number, scaledCharTop: number ): boolean { - const blockElementInstruction = blockElementChars[c]; - if (blockElementInstruction) { - drawBlockElementChar(ctx, blockElementInstruction, x, y, scaledCellWidth, scaledCellHeight, scaledCharLeft, scaledCharTop); + const blockElementDefinition = blockElementDefinitions[c]; + if (blockElementDefinition) { + drawBlockElementChar(ctx, blockElementDefinition, x, y, scaledCellWidth, scaledCellHeight, scaledCharLeft, scaledCharTop); return true; } - const boxDrawingInstruction = boxDrawingChars[c]; - if (boxDrawingInstruction) { - drawBoxDrawingChar(ctx, boxDrawingInstruction, x, y, scaledCellWidth, scaledCellHeight); + const boxDrawingDefinition = boxDrawingDefinitions[c]; + if (boxDrawingDefinition) { + drawBoxDrawingChar(ctx, boxDrawingDefinition, x, y, scaledCellWidth, scaledCellHeight); return true; } @@ -309,7 +309,7 @@ export function tryDrawCustomChar( function drawBlockElementChar( ctx: CanvasRenderingContext2D, - instruction: IBlockVector[], + charDefinition: IBlockVector[], x: number, y: number, scaledCellWidth: number, @@ -319,8 +319,8 @@ function drawBlockElementChar( ): void { const xOffset = x * scaledCellWidth + scaledCharLeft; const yOffset = y * scaledCellHeight + scaledCharTop; - for (let i = 0; i < instruction.length; i++) { - const box = instruction[i]; + for (let i = 0; i < charDefinition.length; i++) { + const box = charDefinition[i]; const xEighth = scaledCellWidth / 8; const yEighth = scaledCellHeight / 8; ctx.fillRect( From e5d66d63f5efedaedd152af9c6cd2fe1a7f8e1ae Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 18 Aug 2021 07:00:10 -0700 Subject: [PATCH 328/377] Fix offset of block elements --- src/browser/renderer/BoxAndBlockCharacters.ts | 53 +++++++++++++++++-- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index e4d549fb..fd897675 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -135,7 +135,10 @@ const enum Style { BOLD = 3 } -// This contains the definitions of all box drawing characters as SVG paths (ie. the svg d attribute) +/** + * This contains the definitions of all box drawing characters in the format of SVG paths (ie. the + * svg d attribute). + */ export const boxDrawingDefinitions: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } | undefined } = { // Uniform normal and bold '─': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT }, @@ -324,14 +327,54 @@ function drawBlockElementChar( const xEighth = scaledCellWidth / 8; const yEighth = scaledCellHeight / 8; ctx.fillRect( - xOffset, - yOffset, + xOffset + box.x * xEighth, + yOffset + box.y * yEighth, box.w * xEighth, box.h * yEighth ); } } +/** + * Draws the following box drawing characters by mapping a subset of SVG d attribute instructions to + * canvas draw calls. + * + * Box styles: ┎┰┒┍┯┑╓╥╖╒╤╕ ┏┳┓┌┲┓┌┬┐┏┱┐ + * ┌─┬─┐ ┏━┳━┓ ╔═╦═╗ ┠╂┨┝┿┥╟╫╢╞╪╡ ┡╇┩├╊┫┢╈┪┣╉┤ + * │ │ │ ┃ ┃ ┃ ║ ║ ║ ┖┸┚┕┷┙╙╨╜╘╧╛ └┴┘└┺┛┗┻┛┗┹┘ + * ├─┼─┤ ┣━╋━┫ ╠═╬═╣ ┏┱┐┌┲┓┌┬┐┌┬┐ ┏┳┓┌┮┓┌┬┐┏┭┐ + * │ │ │ ┃ ┃ ┃ ║ ║ ║ ┡╃┤├╄┩├╆┪┢╅┤ ┞╀┦├┾┫┟╁┧┣┽┤ + * └─┴─┘ ┗━┻━┛ ╚═╩═╝ └┴┘└┴┘└┺┛┗┹┘ └┴┘└┶┛┗┻┛┗┵┘ + * + * Other: + * ╭─╮ ╲ ╱ ╷╻╎╏┆┇┊┋ ╺╾╴ ╌╌╌ ┄┄┄ ┈┈┈ + * │ │ ╳ ╽╿╎╏┆┇┊┋ ╶╼╸ ╍╍╍ ┅┅┅ ┉┉┉ + * ╰─╯ ╱ ╲ ╹╵╎╏┆┇┊┋ + * + * All box drawing characters: + * ─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏ + * ┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟ + * ┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯ + * ┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿ + * ╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏ + * ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ + * ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯ + * ╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿ + * + * --- + * + * Box drawing alignment tests: █ + * ▉ + * ╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳ + * ║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳ + * ║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳ + * ╠╡ ╳ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳ + * ║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎ + * ║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏ + * ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█ + * + * Source: https://www.w3.org/2001/06/utf-8-test/UTF-8-demo.html + */ function drawBoxDrawingChar( ctx: CanvasRenderingContext2D, charDefinition: { [fontWeight: number]: string | ((xp: number, yp: number) => string) }, @@ -356,7 +399,7 @@ function drawBoxDrawingChar( } for (const instruction of actualInstructions.split(' ')) { const type = instruction[0]; - const f = instructionMap[type]; + const f = svgToCanvasInstructionMap[type]; if (!f) { console.error(`Could not find drawing instructions for "${type}"`); continue; @@ -376,7 +419,7 @@ function clamp(value: number, max: number, min: number = 0): number { return Math.max(Math.min(value, max), min); } -const instructionMap: { [index: string]: any } = { +const svgToCanvasInstructionMap: { [index: string]: any } = { 'C': (ctx: CanvasRenderingContext2D, args: number[]) => ctx.bezierCurveTo(args[0], args[1], args[2], args[3], args[4], args[5]), 'L': (ctx: CanvasRenderingContext2D, args: number[]) => ctx.lineTo(args[0], args[1]), 'M': (ctx: CanvasRenderingContext2D, args: number[]) => ctx.moveTo(args[0], args[1]) From 0aaa20f87338442036cb80d3a127362d37a00684 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 18 Aug 2021 07:31:35 -0700 Subject: [PATCH 329/377] Start of webgl integration --- addons/xterm-addon-webgl/src/WebglRenderer.ts | 2 +- .../src/atlas/CharAtlasCache.ts | 4 +++- .../src/atlas/CharAtlasUtils.ts | 5 +++- addons/xterm-addon-webgl/src/atlas/Types.d.ts | 3 +++ .../src/atlas/WebglCharAtlas.ts | 11 ++++++++- .../src/renderLayer/BaseRenderLayer.ts | 2 +- src/browser/Terminal.ts | 1 + src/browser/renderer/BaseRenderLayer.ts | 4 ++-- src/browser/renderer/BoxAndBlockCharacters.ts | 23 +++++++++---------- 9 files changed, 36 insertions(+), 19 deletions(-) diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index 29e97d6d..75b6230c 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -230,7 +230,7 @@ export class WebglRenderer extends Disposable implements IRenderer { return; } - const atlas = acquireCharAtlas(this._terminal, this._colors, this.dimensions.scaledCharWidth, this.dimensions.scaledCharHeight); + const atlas = acquireCharAtlas(this._terminal, this._colors, this.dimensions.scaledCellWidth, this.dimensions.scaledCellHeight, this.dimensions.scaledCharWidth, this.dimensions.scaledCharHeight); if (!('getRasterizedGlyph' in atlas)) { throw new Error('The webgl renderer only works with the webgl char atlas'); } diff --git a/addons/xterm-addon-webgl/src/atlas/CharAtlasCache.ts b/addons/xterm-addon-webgl/src/atlas/CharAtlasCache.ts index 5046006f..41114de0 100644 --- a/addons/xterm-addon-webgl/src/atlas/CharAtlasCache.ts +++ b/addons/xterm-addon-webgl/src/atlas/CharAtlasCache.ts @@ -28,10 +28,12 @@ const charAtlasCache: ICharAtlasCacheEntry[] = []; export function acquireCharAtlas( terminal: Terminal, colors: IColorSet, + scaledCellWidth: number, + scaledCellHeight: number, scaledCharWidth: number, scaledCharHeight: number ): WebglCharAtlas { - const newConfig = generateConfig(scaledCharWidth, scaledCharHeight, terminal, colors); + const newConfig = generateConfig(scaledCellWidth, scaledCellHeight, scaledCharWidth, scaledCharHeight, terminal, colors); // Check to see if the terminal already owns this config for (let i = 0; i < charAtlasCache.length; i++) { diff --git a/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts b/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts index 5496a500..e91c5fd1 100644 --- a/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts +++ b/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts @@ -13,7 +13,7 @@ const NULL_COLOR: IColor = { rgba: 0 }; -export function generateConfig(scaledCharWidth: number, scaledCharHeight: number, terminal: Terminal, colors: IColorSet): ICharAtlasConfig { +export function generateConfig(scaledCellWidth: number, scaledCellHeight: number, scaledCharWidth: number, scaledCharHeight: number, terminal: Terminal, colors: IColorSet): ICharAtlasConfig { // null out some fields that don't matter const clonedColors: IColorSet = { foreground: colors.foreground, @@ -28,7 +28,10 @@ export function generateConfig(scaledCharWidth: number, scaledCharHeight: number contrastCache: colors.contrastCache }; return { + customBlockAndBoxCharacters: terminal.getOption('customBlockAndBoxCharacters'), devicePixelRatio: window.devicePixelRatio, + scaledCellWidth, + scaledCellHeight, scaledCharWidth, scaledCharHeight, fontFamily: terminal.getOption('fontFamily'), diff --git a/addons/xterm-addon-webgl/src/atlas/Types.d.ts b/addons/xterm-addon-webgl/src/atlas/Types.d.ts index cd73393c..37384306 100644 --- a/addons/xterm-addon-webgl/src/atlas/Types.d.ts +++ b/addons/xterm-addon-webgl/src/atlas/Types.d.ts @@ -17,11 +17,14 @@ export interface IGlyphIdentifier { } export interface ICharAtlasConfig { + customBlockAndBoxCharacters: boolean; devicePixelRatio: number; fontSize: number; fontFamily: string; fontWeight: FontWeight; fontWeightBold: FontWeight; + scaledCellWidth: number; + scaledCellHeight: number; scaledCharWidth: number; scaledCharHeight: number; allowTransparency: boolean; diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 5f729e28..8fd43e1e 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -12,6 +12,7 @@ import { IColor } from 'browser/Types'; import { IDisposable } from 'xterm'; import { AttributeData } from 'common/buffer/AttributeData'; import { channels, rgba } from 'browser/Color'; +import { tryDrawCustomChar } from 'browser/renderer/BoxAndBlockCharacters'; // In practice we're probably never going to exhaust a texture this large. For debugging purposes, // however, it can be useful to set this to a really tiny value, to verify that LRU eviction works. @@ -390,8 +391,16 @@ export class WebglCharAtlas implements IDisposable { // For powerline glyphs left/top padding is excluded (https://github.com/microsoft/vscode/issues/120129) const padding = isPowerlineGlyph ? 0 : TMP_CANVAS_GLYPH_PADDING; + // Draw custom characters if applicable + let drawSuccess = false; + if (this._config.customBlockAndBoxCharacters !== false) { + drawSuccess = tryDrawCustomChar(this._tmpCtx, chars, TMP_CANVAS_GLYPH_PADDING, TMP_CANVAS_GLYPH_PADDING, this._config.scaledCellWidth, this._config.scaledCellHeight, this._config.scaledCharWidth, this._config.scaledCharHeight); + } + // Draw the character - this._tmpCtx.fillText(chars, padding, padding + this._config.scaledCharHeight); + if (!drawSuccess) { + this._tmpCtx.fillText(chars, padding, padding + this._config.scaledCharHeight); + } // Draw underline and strikethrough if (underline || strikethrough) { diff --git a/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts b/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts index cc210fd3..532836ee 100644 --- a/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts +++ b/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts @@ -92,7 +92,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { if (this._scaledCharWidth <= 0 && this._scaledCharHeight <= 0) { return; } - this._charAtlas = acquireCharAtlas(terminal, colorSet, this._scaledCharWidth, this._scaledCharHeight); + this._charAtlas = acquireCharAtlas(terminal, colorSet, this._scaledCellWidth, this._scaledCellHeight, this._scaledCharWidth, this._scaledCharHeight); this._charAtlas.warmUp(); } diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index e702e61e..3ab343da 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -224,6 +224,7 @@ export class Terminal extends CoreTerminal implements ITerminal { // The DOM renderer needs a row refresh to update the cursor styles this.refresh(this.buffer.y, this.buffer.y); break; + case 'customBlockAndBoxCharacters': case 'drawBoldTextInBrightColors': case 'letterSpacing': case 'lineHeight': diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index e7116ed6..afa12bb2 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -264,7 +264,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { // Draw custom characters if applicable let drawSuccess = false; if (this._optionsService.options.customBlockAndBoxCharacters !== false) { - drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x, y, this._scaledCellWidth, this._scaledCellHeight, this._scaledCharLeft, this._scaledCharTop); + drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight, this._scaledCharLeft, this._scaledCharTop); } // Draw the character @@ -388,7 +388,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { // Draw custom characters if applicable let drawSuccess = false; if (this._optionsService.options.customBlockAndBoxCharacters !== false) { - drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x, y, this._scaledCellWidth, this._scaledCellHeight, this._scaledCharLeft, this._scaledCharTop); + drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight, this._scaledCharLeft, this._scaledCharTop); } // Draw the character diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index fd897675..b38199ad 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -288,8 +288,8 @@ export const boxDrawingDefinitions: { [character: string]: { [fontWeight: number export function tryDrawCustomChar( ctx: CanvasRenderingContext2D, c: string, - x: number, - y: number, + xOffset: number, + yOffset: number, scaledCellWidth: number, scaledCellHeight: number, scaledCharLeft: number, @@ -297,13 +297,13 @@ export function tryDrawCustomChar( ): boolean { const blockElementDefinition = blockElementDefinitions[c]; if (blockElementDefinition) { - drawBlockElementChar(ctx, blockElementDefinition, x, y, scaledCellWidth, scaledCellHeight, scaledCharLeft, scaledCharTop); + drawBlockElementChar(ctx, blockElementDefinition, xOffset, yOffset, scaledCellWidth, scaledCellHeight, scaledCharLeft, scaledCharTop); return true; } const boxDrawingDefinition = boxDrawingDefinitions[c]; if (boxDrawingDefinition) { - drawBoxDrawingChar(ctx, boxDrawingDefinition, x, y, scaledCellWidth, scaledCellHeight); + drawBoxDrawingChar(ctx, boxDrawingDefinition, xOffset, yOffset, scaledCellWidth, scaledCellHeight); return true; } @@ -313,15 +313,16 @@ export function tryDrawCustomChar( function drawBlockElementChar( ctx: CanvasRenderingContext2D, charDefinition: IBlockVector[], - x: number, - y: number, + xOffset: number, + yOffset: number, scaledCellWidth: number, scaledCellHeight: number, scaledCharLeft: number, scaledCharTop: number ): void { - const xOffset = x * scaledCellWidth + scaledCharLeft; - const yOffset = y * scaledCellHeight + scaledCharTop; + // TODO: Scale to cell not char? + xOffset += scaledCharLeft; + yOffset += scaledCharTop; for (let i = 0; i < charDefinition.length; i++) { const box = charDefinition[i]; const xEighth = scaledCellWidth / 8; @@ -378,13 +379,11 @@ function drawBlockElementChar( function drawBoxDrawingChar( ctx: CanvasRenderingContext2D, charDefinition: { [fontWeight: number]: string | ((xp: number, yp: number) => string) }, - x: number, - y: number, + xOffset: number, + yOffset: number, scaledCellWidth: number, scaledCellHeight: number ): void { - const xOffset = x * scaledCellWidth; - const yOffset = y * scaledCellHeight; ctx.strokeStyle = ctx.fillStyle; for (const [fontWeight, instructions] of Object.entries(charDefinition)) { ctx.beginPath(); From fe7f28a7a0685f9ba83b5fe856bc241cb6207d32 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 18 Aug 2021 07:38:02 -0700 Subject: [PATCH 330/377] Fix block elements on webgl, scale block elements to cell --- .../xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 2 +- src/browser/renderer/BaseRenderLayer.ts | 4 ++-- src/browser/renderer/BoxAndBlockCharacters.ts | 13 +++---------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 8fd43e1e..3b40659e 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -394,7 +394,7 @@ export class WebglCharAtlas implements IDisposable { // Draw custom characters if applicable let drawSuccess = false; if (this._config.customBlockAndBoxCharacters !== false) { - drawSuccess = tryDrawCustomChar(this._tmpCtx, chars, TMP_CANVAS_GLYPH_PADDING, TMP_CANVAS_GLYPH_PADDING, this._config.scaledCellWidth, this._config.scaledCellHeight, this._config.scaledCharWidth, this._config.scaledCharHeight); + drawSuccess = tryDrawCustomChar(this._tmpCtx, chars, TMP_CANVAS_GLYPH_PADDING, TMP_CANVAS_GLYPH_PADDING, this._config.scaledCellWidth, this._config.scaledCellHeight); } // Draw the character diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index afa12bb2..b994a8df 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -264,7 +264,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { // Draw custom characters if applicable let drawSuccess = false; if (this._optionsService.options.customBlockAndBoxCharacters !== false) { - drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight, this._scaledCharLeft, this._scaledCharTop); + drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); } // Draw the character @@ -388,7 +388,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { // Draw custom characters if applicable let drawSuccess = false; if (this._optionsService.options.customBlockAndBoxCharacters !== false) { - drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight, this._scaledCharLeft, this._scaledCharTop); + drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); } // Draw the character diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index b38199ad..7d9a32bf 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -291,13 +291,11 @@ export function tryDrawCustomChar( xOffset: number, yOffset: number, scaledCellWidth: number, - scaledCellHeight: number, - scaledCharLeft: number, - scaledCharTop: number + scaledCellHeight: number ): boolean { const blockElementDefinition = blockElementDefinitions[c]; if (blockElementDefinition) { - drawBlockElementChar(ctx, blockElementDefinition, xOffset, yOffset, scaledCellWidth, scaledCellHeight, scaledCharLeft, scaledCharTop); + drawBlockElementChar(ctx, blockElementDefinition, xOffset, yOffset, scaledCellWidth, scaledCellHeight); return true; } @@ -316,13 +314,8 @@ function drawBlockElementChar( xOffset: number, yOffset: number, scaledCellWidth: number, - scaledCellHeight: number, - scaledCharLeft: number, - scaledCharTop: number + scaledCellHeight: number ): void { - // TODO: Scale to cell not char? - xOffset += scaledCharLeft; - yOffset += scaledCharTop; for (let i = 0; i < charDefinition.length; i++) { const box = charDefinition[i]; const xEighth = scaledCellWidth / 8; From da0928102b72e7c28d3513033b08524b76b48bb8 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 18 Aug 2021 08:19:23 -0700 Subject: [PATCH 331/377] Support shade char with patterns --- .../src/atlas/WebglCharAtlas.ts | 2 +- src/browser/renderer/BaseRenderLayer.ts | 2 +- ...xAndBlockCharacters.ts => CustomGlyphs.ts} | 88 +++++++++++++++++++ 3 files changed, 90 insertions(+), 2 deletions(-) rename src/browser/renderer/{BoxAndBlockCharacters.ts => CustomGlyphs.ts} (90%) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 3b40659e..e1f69555 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -12,7 +12,7 @@ import { IColor } from 'browser/Types'; import { IDisposable } from 'xterm'; import { AttributeData } from 'common/buffer/AttributeData'; import { channels, rgba } from 'browser/Color'; -import { tryDrawCustomChar } from 'browser/renderer/BoxAndBlockCharacters'; +import { tryDrawCustomChar } from 'browser/renderer/CustomGlyphs'; // In practice we're probably never going to exhaust a texture this large. For debugging purposes, // however, it can be useful to set this to a really tiny value, to verify that LRU eviction works. diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index b994a8df..117213eb 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -17,7 +17,7 @@ import { IBufferService, IOptionsService } from 'common/services/Services'; import { throwIfFalsy } from 'browser/renderer/RendererUtils'; import { channels, color, rgba } from 'browser/Color'; import { removeElementFromParent } from 'browser/Dom'; -import { tryDrawCustomChar } from 'browser/renderer/BoxAndBlockCharacters'; +import { tryDrawCustomChar } from 'browser/renderer/CustomGlyphs'; export abstract class BaseRenderLayer implements IRenderLayer { private _canvas: HTMLCanvasElement; diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/CustomGlyphs.ts similarity index 90% rename from src/browser/renderer/BoxAndBlockCharacters.ts rename to src/browser/renderer/CustomGlyphs.ts index 7d9a32bf..55dafc6b 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/CustomGlyphs.ts @@ -3,6 +3,8 @@ * @license MIT */ +import { throwIfFalsy } from 'browser/renderer/RendererUtils'; + interface IBlockVector { x: number; y: number; @@ -101,6 +103,33 @@ export const blockElementDefinitions: { [index: string]: IBlockVector[] | undefi '\u{1FB97}': [{ x: 0, y: 2, w: 8, h: 2 }, { x: 0, y: 6, w: 8, h: 2 }] }; +type PatternDefinition = number[][]; + +/** + * Defines the repeating pattern used by special characters, the pattern is made up of a 2d array of + * pixel values to be filled (1) or not filled (0). + */ +const patternCharacterDefinitions: { [key: string]: PatternDefinition | undefined } = { + '░': [ + [1, 0, 0, 0], + [0, 0, 0, 0], + [0, 0, 1, 0], + [0, 0, 0, 0] + ], + '▒': [ + [1, 0], + [0, 0], + [0, 1], + [0, 0] + ], + '▓': [ + [0, 1], + [1, 1], + [1, 0], + [1, 1] + ] +}; + const enum Shapes { /** │ */ TOP_TO_BOTTOM = 'M.5,0 L.5,1', /** ─ */ LEFT_TO_RIGHT = 'M0,.5 L1,.5', @@ -299,6 +328,13 @@ export function tryDrawCustomChar( return true; } + const patternDefinition = patternCharacterDefinitions[c]; + if (patternDefinition) { + console.log('draw pattern', c); + drawPatternChar(ctx, patternDefinition, xOffset, yOffset, scaledCellWidth, scaledCellHeight); + return true; + } + const boxDrawingDefinition = boxDrawingDefinitions[c]; if (boxDrawingDefinition) { drawBoxDrawingChar(ctx, boxDrawingDefinition, xOffset, yOffset, scaledCellWidth, scaledCellHeight); @@ -329,6 +365,58 @@ function drawBlockElementChar( } } +const cachedPatterns: Map> = new Map(); + +function drawPatternChar( + ctx: CanvasRenderingContext2D, + charDefinition: number[][], + xOffset: number, + yOffset: number, + scaledCellWidth: number, + scaledCellHeight: number +): void { + let patternSet = cachedPatterns.get(charDefinition); + if (!patternSet) { + patternSet = new Map(); + cachedPatterns.set(charDefinition, patternSet); + } + // TODO: Unsafe? + const fillStyle = ctx.fillStyle as string; + let pattern = patternSet.get(fillStyle); + if (!pattern) { + const width = charDefinition[0].length; + const height = charDefinition.length; + const tmpCanvas = document.createElement('canvas'); + tmpCanvas.width = width; + tmpCanvas.height = height; + const tmpCtx = throwIfFalsy(tmpCanvas.getContext('2d')); + const imageData = new ImageData(width, height); + // TODO: This is a little unsafe, fillStyle could be rgb/rgba format + const r = parseInt(fillStyle.substr(1, 2), 16); + const g = parseInt(fillStyle.substr(3, 2), 16); + const b = parseInt(fillStyle.substr(5, 2), 16); + const a = fillStyle.length > 7 && parseInt(fillStyle.substr(7, 2), 16) || undefined; + for (let y = 0; y < height; y++) { + for (let x = 0; x < width; x++) { + imageData.data[(y * width + x) * 4 ] = r; + imageData.data[(y * width + x) * 4 + 1] = g; + imageData.data[(y * width + x) * 4 + 2] = b; + imageData.data[(y * width + x) * 4 + 3] = charDefinition[y][x] * (a ?? 255); + } + } + console.log('put', imageData); + tmpCtx.putImageData(imageData, 0, 0); + // TODO: This will break for different colored patterns + // TODO: This could happen multiple times + pattern = throwIfFalsy(ctx.createPattern(tmpCanvas, null)); + patternSet.set(fillStyle, pattern); + } + + console.log('fill style', pattern); + ctx.fillStyle = pattern; + ctx.fillRect(xOffset, yOffset, scaledCellWidth, scaledCellHeight); +} + /** * Draws the following box drawing characters by mapping a subset of SVG d attribute instructions to * canvas draw calls. From 011026a8d15fac5546d10c2fbe033516b7a09492 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 18 Aug 2021 08:29:07 -0700 Subject: [PATCH 332/377] Get webgl glyphs scaling to cell size, invalidate on option change --- addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts | 5 +++++ addons/xterm-addon-webgl/src/atlas/Types.d.ts | 2 ++ addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 6 +++--- src/browser/renderer/CustomGlyphs.ts | 5 ----- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts b/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts index e91c5fd1..6a478338 100644 --- a/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts +++ b/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts @@ -30,6 +30,8 @@ export function generateConfig(scaledCellWidth: number, scaledCellHeight: number return { customBlockAndBoxCharacters: terminal.getOption('customBlockAndBoxCharacters'), devicePixelRatio: window.devicePixelRatio, + letterSpacing: terminal.getOption('letterSpacing'), + lineHeight: terminal.getOption('lineHeight'), scaledCellWidth, scaledCellHeight, scaledCharWidth, @@ -52,6 +54,9 @@ export function configEquals(a: ICharAtlasConfig, b: ICharAtlasConfig): boolean } } return a.devicePixelRatio === b.devicePixelRatio && + a.customBlockAndBoxCharacters === b.customBlockAndBoxCharacters && + a.lineHeight === b.lineHeight && + a.letterSpacing === b.letterSpacing && a.fontFamily === b.fontFamily && a.fontSize === b.fontSize && a.fontWeight === b.fontWeight && diff --git a/addons/xterm-addon-webgl/src/atlas/Types.d.ts b/addons/xterm-addon-webgl/src/atlas/Types.d.ts index 37384306..acbe3c71 100644 --- a/addons/xterm-addon-webgl/src/atlas/Types.d.ts +++ b/addons/xterm-addon-webgl/src/atlas/Types.d.ts @@ -19,6 +19,8 @@ export interface IGlyphIdentifier { export interface ICharAtlasConfig { customBlockAndBoxCharacters: boolean; devicePixelRatio: number; + letterSpacing: number; + lineHeight: number; fontSize: number; fontFamily: string; fontWeight: FontWeight; diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index e1f69555..6da70522 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -84,8 +84,8 @@ export class WebglCharAtlas implements IDisposable { this._cacheCtx = throwIfFalsy(this.cacheCanvas.getContext('2d', { alpha: true })); this._tmpCanvas = document.createElement('canvas'); - this._tmpCanvas.width = this._config.scaledCharWidth * 4 + TMP_CANVAS_GLYPH_PADDING * 2; - this._tmpCanvas.height = this._config.scaledCharHeight + TMP_CANVAS_GLYPH_PADDING * 2; + this._tmpCanvas.width = this._config.scaledCellWidth * 4 + TMP_CANVAS_GLYPH_PADDING * 2; + this._tmpCanvas.height = this._config.scaledCellHeight + TMP_CANVAS_GLYPH_PADDING * 2; this._tmpCtx = throwIfFalsy(this._tmpCanvas.getContext('2d', { alpha: this._config.allowTransparency })); } @@ -321,7 +321,7 @@ export class WebglCharAtlas implements IDisposable { // Allow 1 cell width per character, with a minimum of 2 (CJK), plus some padding. This is used // to draw the glyph to the canvas as well as to restrict the bounding box search to ensure // giant ligatures (eg. =====>) don't impact overall performance. - const allowedWidth = this._config.scaledCharWidth * Math.max(chars.length, 2) + TMP_CANVAS_GLYPH_PADDING * 2; + let allowedWidth = this._config.scaledCharWidth * Math.max(chars.length, 2) + TMP_CANVAS_GLYPH_PADDING * 2; if (this._tmpCanvas.width < allowedWidth) { this._tmpCanvas.width = allowedWidth; } diff --git a/src/browser/renderer/CustomGlyphs.ts b/src/browser/renderer/CustomGlyphs.ts index 55dafc6b..7457441b 100644 --- a/src/browser/renderer/CustomGlyphs.ts +++ b/src/browser/renderer/CustomGlyphs.ts @@ -404,15 +404,10 @@ function drawPatternChar( imageData.data[(y * width + x) * 4 + 3] = charDefinition[y][x] * (a ?? 255); } } - console.log('put', imageData); tmpCtx.putImageData(imageData, 0, 0); - // TODO: This will break for different colored patterns - // TODO: This could happen multiple times pattern = throwIfFalsy(ctx.createPattern(tmpCanvas, null)); patternSet.set(fillStyle, pattern); } - - console.log('fill style', pattern); ctx.fillStyle = pattern; ctx.fillRect(xOffset, yOffset, scaledCellWidth, scaledCellHeight); } From 54ce0172b416d8bfe53a8fc8e55fddd487488d51 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 18 Aug 2021 09:48:27 -0700 Subject: [PATCH 333/377] Add test custom glyph button to demo --- .../src/atlas/WebglCharAtlas.ts | 2 +- .../test/WebglRenderer.api.ts | 55 +++++++++- demo/client.ts | 100 +++++++++++------- demo/index.html | 1 + src/browser/renderer/CustomGlyphs.ts | 1 - 5 files changed, 118 insertions(+), 41 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 6da70522..557e23ef 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -321,7 +321,7 @@ export class WebglCharAtlas implements IDisposable { // Allow 1 cell width per character, with a minimum of 2 (CJK), plus some padding. This is used // to draw the glyph to the canvas as well as to restrict the bounding box search to ensure // giant ligatures (eg. =====>) don't impact overall performance. - let allowedWidth = this._config.scaledCharWidth * Math.max(chars.length, 2) + TMP_CANVAS_GLYPH_PADDING * 2; + const allowedWidth = this._config.scaledCharWidth * Math.max(chars.length, 2) + TMP_CANVAS_GLYPH_PADDING * 2; if (this._tmpCanvas.width < allowedWidth) { this._tmpCanvas.width = allowedWidth; } diff --git a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts index 1722e570..b666ceb4 100644 --- a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts +++ b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts @@ -6,7 +6,7 @@ import { ITerminalOptions } from '../../../src/common/Types'; import { ITheme } from 'xterm'; import { assert } from 'chai'; -import { openTerminal, pollFor, writeSync, getBrowserType } from '../../../out-test/api/TestUtils'; +import { openTerminal, pollFor, writeSync, getBrowserType, timeout } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -830,6 +830,45 @@ describe('WebGL Renderer Integration Tests', async () => { }); }); + describe.only('custom glyphs', () => { + if (areTestsEnabled) { + before(async () => setupBrowser()); + after(async () => browser.close()); + beforeEach(async () => page.evaluate(`window.term.reset()`)); + } + + itWebgl('should draw normal weight characters pixel perfect', async () => { + const theme: ITheme = { + background: '#000000', + foreground: '#ffffff' + }; + await page.evaluate(` + window.term.setOption('theme', ${JSON.stringify(theme)}); + window.term.setOption('fontSize', 12); + window.term.setOption('minimumContrastRatio', 1); + `); + await writeSync(page, + 'Box drawing alignment tests: █\\n\\r' + + ' ▉\\n\\r' + + ' ╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳\\n\\r' + + ' ║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳\\n\\r' + + ' ║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳\\n\\r' + + ' ╠╡ ╳ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳\\n\\r' + + ' ║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎\\n\\r' + + ' ║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏\\n\\r' + + ' ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█' + ); + // Validate before minimumContrastRatio is applied + await pollFor(page, () => getCellColor(1, 1), [0x2e, 0x34, 0x36, 255]); + const pixels = await getCellPixels(1, 1); + for (let y = 0; y < pixels.length / 20; y++) { + console.log(`pixels ${y}: ` + pixels.slice(y * 20, y * 20 + 20).join(', ')); + } + console.log('cellPixels', pixels.length); + await timeout(2000); + }); + }); + describe('selection', async () => { if (areTestsEnabled) { before(async () => setupBrowser()); @@ -890,6 +929,20 @@ async function getCellColor(col: number, row: number): Promise { return await page.evaluate(`Array.from(window.result)`); } +async function getCellPixels(col: number, row: number): Promise { + await page.evaluate(` + window.gl = window.term._core._renderService._renderer._gl; + window.result = new Uint8Array(window.d.scaledCellWidth * window.d.scaledCellHeight * 4); + window.d = window.term._core._renderService.dimensions; + window.gl.readPixels( + Math.floor(${col - 1} * window.d.scaledCellWidth), + Math.floor(window.gl.drawingBufferHeight - ${row} * window.d.scaledCellHeight), + window.d.scaledCellWidth, window.d.scaledCellHeight, window.gl.RGBA, window.gl.UNSIGNED_BYTE, window.result + ); + `); + return await page.evaluate(`Array.from(window.result)`); +} + async function setupBrowser(options: ITerminalOptions = { rendererType: 'dom' }): Promise { const browserType = getBrowserType(); browser = await browserType.launch({ diff --git a/demo/client.ts b/demo/client.ts index cc467908..de1faa37 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -147,6 +147,7 @@ if (document.location.pathname === '/test') { createTerminal(); document.getElementById('dispose').addEventListener('click', disposeRecreateButtonHandler); document.getElementById('serialize').addEventListener('click', serializeButtonHandler); + document.getElementById('custom-glyph').addEventListener('click', writeCustomGlyphHandler); } function createTerminal(): void { @@ -214,17 +215,16 @@ function createTerminal(): void { // Set terminal size again to set the specific dimensions on the demo updateTerminalSize(); - // fetch('/terminals?cols=' + term.cols + '&rows=' + term.rows, {method: 'POST'}).then((res) => { - // res.text().then((processId) => { - // pid = processId; - // socketURL += processId; - // socket = new WebSocket(socketURL); - // socket.onopen = runRealTerminal; - // socket.onclose = runFakeTerminal; - // socket.onerror = runFakeTerminal; - // }); - // }); - runFakeTerminal(); + fetch('/terminals?cols=' + term.cols + '&rows=' + term.rows, {method: 'POST'}).then((res) => { + res.text().then((processId) => { + pid = processId; + socketURL += processId; + socket = new WebSocket(socketURL); + socket.onopen = runRealTerminal; + socket.onclose = runFakeTerminal; + socket.onerror = runFakeTerminal; + }); + }); }, 0); } @@ -247,33 +247,11 @@ function runFakeTerminal(): void { term.write('\r\n$ '); }; - // term.writeln('Welcome to xterm.js'); - // term.writeln('This is a local terminal emulation, without a real terminal in the back-end.'); - // term.writeln('Type some keys and commands to play around.'); - // term.writeln(''); - // term.prompt(); - - term.write('Box styles: ┎┰┒┍┯┑╓╥╖╒╤╕ ┏┳┓┌┲┓┌┬┐┏┱┐\n\r'); - term.write('┌─┬─┐ ┏━┳━┓ ╔═╦═╗ ┠╂┨┝┿┥╟╫╢╞╪╡ ┡╇┩├╊┫┢╈┪┣╉┤\n\r'); - term.write('│ │ │ ┃ ┃ ┃ ║ ║ ║ ┖┸┚┕┷┙╙╨╜╘╧╛ └┴┘└┺┛┗┻┛┗┹┘\n\r'); - term.write('├─┼─┤ ┣━╋━┫ ╠═╬═╣ ┏┱┐┌┲┓┌┬┐┌┬┐ ┏┳┓┌┮┓┌┬┐┏┭┐\n\r'); - term.write('│ │ │ ┃ ┃ ┃ ║ ║ ║ ┡╃┤├╄┩├╆┪┢╅┤ ┞╀┦├┾┫┟╁┧┣┽┤\n\r'); - term.write('└─┴─┘ ┗━┻━┛ ╚═╩═╝ └┴┘└┴┘└┺┛┗┹┘ └┴┘└┶┛┗┻┛┗┵┘\n\r'); - term.write('\n\r'); - term.write('Other:\n\r'); - term.write('╭─╮ ╲ ╱ ╷╻╎╏┆┇┊┋ ╺╾╴ ╌╌╌ ┄┄┄ ┈┈┈\n\r'); - term.write('│ │ ╳ ╽╿╎╏┆┇┊┋ ╶╼╸ ╍╍╍ ┅┅┅ ┉┉┉\n\r'); - term.write('╰─╯ ╱ ╲ ╹╵╎╏┆┇┊┋\n\r'); - term.write('\n\r'); - term.write('All box drawing characters:\n\r'); - term.write('─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏\n\r'); - term.write('┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟\n\r'); - term.write('┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯\n\r'); - term.write('┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿\n\r'); - term.write('╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏\n\r'); - term.write('═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟\n\r'); - term.write('╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯\n\r'); - term.write('╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\n\r'); + term.writeln('Welcome to xterm.js'); + term.writeln('This is a local terminal emulation, without a real terminal in the back-end.'); + term.writeln('Type some keys and commands to play around.'); + term.writeln(''); + term.prompt(); term.onKey((e: { key: string, domEvent: KeyboardEvent }) => { const ev = e.domEvent; @@ -454,3 +432,49 @@ function serializeButtonHandler(): void { term.write(output); } } + + +function writeCustomGlyphHandler() { + term.write('\n\r'); + term.write('\n\r'); + term.write('Box styles: ┎┰┒┍┯┑╓╥╖╒╤╕ ┏┳┓┌┲┓┌┬┐┏┱┐\n\r'); + term.write('┌─┬─┐ ┏━┳━┓ ╔═╦═╗ ┠╂┨┝┿┥╟╫╢╞╪╡ ┡╇┩├╊┫┢╈┪┣╉┤\n\r'); + term.write('│ │ │ ┃ ┃ ┃ ║ ║ ║ ┖┸┚┕┷┙╙╨╜╘╧╛ └┴┘└┺┛┗┻┛┗┹┘\n\r'); + term.write('├─┼─┤ ┣━╋━┫ ╠═╬═╣ ┏┱┐┌┲┓┌┬┐┌┬┐ ┏┳┓┌┮┓┌┬┐┏┭┐\n\r'); + term.write('│ │ │ ┃ ┃ ┃ ║ ║ ║ ┡╃┤├╄┩├╆┪┢╅┤ ┞╀┦├┾┫┟╁┧┣┽┤\n\r'); + term.write('└─┴─┘ ┗━┻━┛ ╚═╩═╝ └┴┘└┴┘└┺┛┗┹┘ └┴┘└┶┛┗┻┛┗┵┘\n\r'); + term.write('\n\r'); + term.write('Other:\n\r'); + term.write('╭─╮ ╲ ╱ ╷╻╎╏┆┇┊┋ ╺╾╴ ╌╌╌ ┄┄┄ ┈┈┈\n\r'); + term.write('│ │ ╳ ╽╿╎╏┆┇┊┋ ╶╼╸ ╍╍╍ ┅┅┅ ┉┉┉\n\r'); + term.write('╰─╯ ╱ ╲ ╹╵╎╏┆┇┊┋\n\r'); + term.write('\n\r'); + term.write('All box drawing characters:\n\r'); + term.write('─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏\n\r'); + term.write('┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟\n\r'); + term.write('┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯\n\r'); + term.write('┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿\n\r'); + term.write('╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏\n\r'); + term.write('═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟\n\r'); + term.write('╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯\n\r'); + term.write('╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\n\r'); + term.write('Box drawing alignment tests:\x1b[31m █\n\r'); + term.write(' ▉\n\r'); + term.write(' ╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳\n\r'); + term.write(' ║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳\n\r'); + term.write(' ║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳\n\r'); + term.write(' ╠╡ ╳ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳\n\r'); + term.write(' ║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎\n\r'); + term.write(' ║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏\n\r'); + term.write(' ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█\n\r'); + term.write('Box drawing alignment tests:\x1b[32m █\n\r'); + term.write(' ▉\n\r'); + term.write(' ╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳\n\r'); + term.write(' ║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳\n\r'); + term.write(' ║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳\n\r'); + term.write(' ╠╡ ╳ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳\n\r'); + term.write(' ║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎\n\r'); + term.write(' ║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏\n\r'); + term.write(' ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█\n\r'); + window.scrollTo(0, 0); +} diff --git a/demo/index.html b/demo/index.html index ab5b2040..910397c3 100644 --- a/demo/index.html +++ b/demo/index.html @@ -50,6 +50,7 @@
+ diff --git a/src/browser/renderer/CustomGlyphs.ts b/src/browser/renderer/CustomGlyphs.ts index 7457441b..82e086c4 100644 --- a/src/browser/renderer/CustomGlyphs.ts +++ b/src/browser/renderer/CustomGlyphs.ts @@ -330,7 +330,6 @@ export function tryDrawCustomChar( const patternDefinition = patternCharacterDefinitions[c]; if (patternDefinition) { - console.log('draw pattern', c); drawPatternChar(ctx, patternDefinition, xOffset, yOffset, scaledCellWidth, scaledCellHeight); return true; } From 158dcb06bdcf68bcfafcec872861f1773fa8f848 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 19 Aug 2021 05:16:01 -0700 Subject: [PATCH 334/377] Remove custom glyph tests --- .../test/WebglRenderer.api.ts | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts index b666ceb4..48f9c3d0 100644 --- a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts +++ b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts @@ -830,45 +830,6 @@ describe('WebGL Renderer Integration Tests', async () => { }); }); - describe.only('custom glyphs', () => { - if (areTestsEnabled) { - before(async () => setupBrowser()); - after(async () => browser.close()); - beforeEach(async () => page.evaluate(`window.term.reset()`)); - } - - itWebgl('should draw normal weight characters pixel perfect', async () => { - const theme: ITheme = { - background: '#000000', - foreground: '#ffffff' - }; - await page.evaluate(` - window.term.setOption('theme', ${JSON.stringify(theme)}); - window.term.setOption('fontSize', 12); - window.term.setOption('minimumContrastRatio', 1); - `); - await writeSync(page, - 'Box drawing alignment tests: █\\n\\r' + - ' ▉\\n\\r' + - ' ╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳\\n\\r' + - ' ║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳\\n\\r' + - ' ║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳\\n\\r' + - ' ╠╡ ╳ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳\\n\\r' + - ' ║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎\\n\\r' + - ' ║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏\\n\\r' + - ' ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█' - ); - // Validate before minimumContrastRatio is applied - await pollFor(page, () => getCellColor(1, 1), [0x2e, 0x34, 0x36, 255]); - const pixels = await getCellPixels(1, 1); - for (let y = 0; y < pixels.length / 20; y++) { - console.log(`pixels ${y}: ` + pixels.slice(y * 20, y * 20 + 20).join(', ')); - } - console.log('cellPixels', pixels.length); - await timeout(2000); - }); - }); - describe('selection', async () => { if (areTestsEnabled) { before(async () => setupBrowser()); From 3be97841a3c91178b7a3e88425a0c32498150b41 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 19 Aug 2021 05:19:28 -0700 Subject: [PATCH 335/377] Rename setting customGlyphs --- addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts | 4 ++-- addons/xterm-addon-webgl/src/atlas/Types.d.ts | 2 +- addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 2 +- src/browser/Terminal.ts | 2 +- src/browser/renderer/BaseRenderLayer.ts | 4 ++-- src/common/services/OptionsService.ts | 2 +- src/common/services/Services.ts | 2 +- typings/xterm-headless.d.ts | 10 +++++----- typings/xterm.d.ts | 10 +++++----- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts b/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts index 6a478338..962eb7b3 100644 --- a/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts +++ b/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts @@ -28,7 +28,7 @@ export function generateConfig(scaledCellWidth: number, scaledCellHeight: number contrastCache: colors.contrastCache }; return { - customBlockAndBoxCharacters: terminal.getOption('customBlockAndBoxCharacters'), + customGlyphs: terminal.getOption('customGlyphs'), devicePixelRatio: window.devicePixelRatio, letterSpacing: terminal.getOption('letterSpacing'), lineHeight: terminal.getOption('lineHeight'), @@ -54,7 +54,7 @@ export function configEquals(a: ICharAtlasConfig, b: ICharAtlasConfig): boolean } } return a.devicePixelRatio === b.devicePixelRatio && - a.customBlockAndBoxCharacters === b.customBlockAndBoxCharacters && + a.customGlyphs === b.customGlyphs && a.lineHeight === b.lineHeight && a.letterSpacing === b.letterSpacing && a.fontFamily === b.fontFamily && diff --git a/addons/xterm-addon-webgl/src/atlas/Types.d.ts b/addons/xterm-addon-webgl/src/atlas/Types.d.ts index acbe3c71..8d2870cd 100644 --- a/addons/xterm-addon-webgl/src/atlas/Types.d.ts +++ b/addons/xterm-addon-webgl/src/atlas/Types.d.ts @@ -17,7 +17,7 @@ export interface IGlyphIdentifier { } export interface ICharAtlasConfig { - customBlockAndBoxCharacters: boolean; + customGlyphs: boolean; devicePixelRatio: number; letterSpacing: number; lineHeight: number; diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 557e23ef..4c45fce1 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -393,7 +393,7 @@ export class WebglCharAtlas implements IDisposable { // Draw custom characters if applicable let drawSuccess = false; - if (this._config.customBlockAndBoxCharacters !== false) { + if (this._config.customGlyphs !== false) { drawSuccess = tryDrawCustomChar(this._tmpCtx, chars, TMP_CANVAS_GLYPH_PADDING, TMP_CANVAS_GLYPH_PADDING, this._config.scaledCellWidth, this._config.scaledCellHeight); } diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 3ab343da..dde4a1b6 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -224,7 +224,7 @@ export class Terminal extends CoreTerminal implements ITerminal { // The DOM renderer needs a row refresh to update the cursor styles this.refresh(this.buffer.y, this.buffer.y); break; - case 'customBlockAndBoxCharacters': + case 'customGlyphs': case 'drawBoldTextInBrightColors': case 'letterSpacing': case 'lineHeight': diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 117213eb..448451d0 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -263,7 +263,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { // Draw custom characters if applicable let drawSuccess = false; - if (this._optionsService.options.customBlockAndBoxCharacters !== false) { + if (this._optionsService.options.customGlyphs !== false) { drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); } @@ -387,7 +387,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { // Draw custom characters if applicable let drawSuccess = false; - if (this._optionsService.options.customBlockAndBoxCharacters !== false) { + if (this._optionsService.options.customGlyphs !== false) { drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); } diff --git a/src/common/services/OptionsService.ts b/src/common/services/OptionsService.ts index 062166bc..5add8283 100644 --- a/src/common/services/OptionsService.ts +++ b/src/common/services/OptionsService.ts @@ -21,7 +21,7 @@ export const DEFAULT_OPTIONS: ITerminalOptions = Object.freeze({ cursorBlink: false, cursorStyle: 'block', cursorWidth: 1, - customBlockAndBoxCharacters: true, + customGlyphs: true, bellSound: DEFAULT_BELL_SOUND, bellStyle: 'none', drawBoldTextInBrightColors: true, diff --git a/src/common/services/Services.ts b/src/common/services/Services.ts index 07615a41..2190a0f8 100644 --- a/src/common/services/Services.ts +++ b/src/common/services/Services.ts @@ -244,7 +244,7 @@ export interface ITerminalOptions { cursorBlink: boolean; cursorStyle: 'block' | 'underline' | 'bar'; cursorWidth: number; - customBlockAndBoxCharacters: boolean; + customGlyphs: boolean; disableStdin: boolean; drawBoldTextInBrightColors: boolean; fastScrollModifier: 'alt' | 'ctrl' | 'shift' | undefined; diff --git a/typings/xterm-headless.d.ts b/typings/xterm-headless.d.ts index dc886aa1..13a32126 100644 --- a/typings/xterm-headless.d.ts +++ b/typings/xterm-headless.d.ts @@ -79,12 +79,12 @@ declare module 'xterm-headless' { cursorWidth?: number; /** - * Whether to draw custom block element and box drawing characters instead of using the font. - * This should typically result in better rendering with continuous lines. Note that this - * doesn't work with the DOM renderer which renders all characters using the font. The default - * is true. + * Whether to draw custom glyphs for block element and box drawing characters instead of using + * the font. This should typically result in better rendering with continuous lines, even when + * line height and letter spacing is used. Note that this doesn't work with the DOM renderer + * which renders all characters using the font. The default is true. */ - customBlockAndBoxCharacters?: boolean; + customGlyphs?: boolean; /** * Whether input should be disabled. diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index f6fbe709..ba2be988 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -91,12 +91,12 @@ declare module 'xterm' { cursorWidth?: number; /** - * Whether to draw custom block element and box drawing characters instead of using the font. - * This should typically result in better rendering with continuous lines. Note that this - * doesn't work with the DOM renderer which renders all characters using the font. The default - * is true. + * Whether to draw custom glyphs for block element and box drawing characters instead of using + * the font. This should typically result in better rendering with continuous lines, even when + * line height and letter spacing is used. Note that this doesn't work with the DOM renderer + * which renders all characters using the font. The default is true. */ - customBlockAndBoxCharacters?: boolean; + customGlyphs?: boolean; /** * Whether input should be disabled. From 24cbedb71528bc2d65b7c200af7ae1eac1fe85ab Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 19 Aug 2021 05:32:46 -0700 Subject: [PATCH 336/377] Fix custom glyphs when using transparency --- .../test/WebglRenderer.api.ts | 6 ++-- src/browser/renderer/CustomGlyphs.ts | 30 ++++++++++++++----- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts index 48f9c3d0..793929e9 100644 --- a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts +++ b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts @@ -3,11 +3,11 @@ * @license MIT */ -import { ITerminalOptions } from '../../../src/common/Types'; -import { ITheme } from 'xterm'; import { assert } from 'chai'; -import { openTerminal, pollFor, writeSync, getBrowserType, timeout } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; +import { ITheme } from 'xterm'; +import { getBrowserType, openTerminal, pollFor, writeSync } from '../../../out-test/api/TestUtils'; +import { ITerminalOptions } from '../../../src/common/Types'; const APP = 'http://127.0.0.1:3001/test'; diff --git a/src/browser/renderer/CustomGlyphs.ts b/src/browser/renderer/CustomGlyphs.ts index 82e086c4..a132877a 100644 --- a/src/browser/renderer/CustomGlyphs.ts +++ b/src/browser/renderer/CustomGlyphs.ts @@ -379,8 +379,10 @@ function drawPatternChar( patternSet = new Map(); cachedPatterns.set(charDefinition, patternSet); } - // TODO: Unsafe? - const fillStyle = ctx.fillStyle as string; + const fillStyle = ctx.fillStyle; + if (typeof fillStyle !== 'string') { + throw new Error(`Unexpected fillStyle type "${fillStyle}"`); + } let pattern = patternSet.get(fillStyle); if (!pattern) { const width = charDefinition[0].length; @@ -390,17 +392,29 @@ function drawPatternChar( tmpCanvas.height = height; const tmpCtx = throwIfFalsy(tmpCanvas.getContext('2d')); const imageData = new ImageData(width, height); - // TODO: This is a little unsafe, fillStyle could be rgb/rgba format - const r = parseInt(fillStyle.substr(1, 2), 16); - const g = parseInt(fillStyle.substr(3, 2), 16); - const b = parseInt(fillStyle.substr(5, 2), 16); - const a = fillStyle.length > 7 && parseInt(fillStyle.substr(7, 2), 16) || undefined; + + // Extract rgba from fillStyle + let r: number; + let g: number; + let b: number; + let a: number; + if (fillStyle.startsWith('#')) { + r = parseInt(fillStyle.substr(1, 2), 16); + g = parseInt(fillStyle.substr(3, 2), 16); + b = parseInt(fillStyle.substr(5, 2), 16); + a = fillStyle.length > 7 && parseInt(fillStyle.substr(7, 2), 16) || 1; + } else if (fillStyle.startsWith('rgba')) { + ([r, g, b, a] = fillStyle.substring(5, fillStyle.length - 1).split(',').map(e => parseFloat(e))); + } else { + throw new Error(`Unexpected fillStyle color format "${fillStyle}" when drawing pattern glyph`); + } + for (let y = 0; y < height; y++) { for (let x = 0; x < width; x++) { imageData.data[(y * width + x) * 4 ] = r; imageData.data[(y * width + x) * 4 + 1] = g; imageData.data[(y * width + x) * 4 + 2] = b; - imageData.data[(y * width + x) * 4 + 3] = charDefinition[y][x] * (a ?? 255); + imageData.data[(y * width + x) * 4 + 3] = charDefinition[y][x] * (a * 255); } } tmpCtx.putImageData(imageData, 0, 0); From 338d94daf9be0aed05e1d15b4d47dd6f6b090e43 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 19 Aug 2021 05:41:49 -0700 Subject: [PATCH 337/377] Fix webgl alignment issues No idea why this worked but it did --- addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 4c45fce1..340e83c9 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -394,7 +394,7 @@ export class WebglCharAtlas implements IDisposable { // Draw custom characters if applicable let drawSuccess = false; if (this._config.customGlyphs !== false) { - drawSuccess = tryDrawCustomChar(this._tmpCtx, chars, TMP_CANVAS_GLYPH_PADDING, TMP_CANVAS_GLYPH_PADDING, this._config.scaledCellWidth, this._config.scaledCellHeight); + drawSuccess = tryDrawCustomChar(this._tmpCtx, chars, padding, padding, this._config.scaledCellWidth, this._config.scaledCellHeight); } // Draw the character From 1a75416dbfe762f32aeeb2ee5faccafe80583841 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 19 Aug 2021 06:00:27 -0700 Subject: [PATCH 338/377] Add missing block elements (include all 0x2580-0x259F) --- src/browser/renderer/CustomGlyphs.ts | 61 +++++++++++++++++----------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/src/browser/renderer/CustomGlyphs.ts b/src/browser/renderer/CustomGlyphs.ts index a132877a..77562790 100644 --- a/src/browser/renderer/CustomGlyphs.ts +++ b/src/browser/renderer/CustomGlyphs.ts @@ -13,22 +13,40 @@ interface IBlockVector { } export const blockElementDefinitions: { [index: string]: IBlockVector[] | undefined } = { - '▀': [{ x: 0, y: 0, w: 8, h: 4 }], - '█': [{ x: 0, y: 0, w: 8, h: 8 }], - '▇': [{ x: 0, y: 1, w: 8, h: 7 }], - '▆': [{ x: 0, y: 2, w: 8, h: 6 }], - '▅': [{ x: 0, y: 3, w: 8, h: 5 }], - '▄': [{ x: 0, y: 4, w: 8, h: 4 }], - '▃': [{ x: 0, y: 5, w: 8, h: 3 }], - '▂': [{ x: 0, y: 6, w: 8, h: 2 }], - '▁': [{ x: 0, y: 7, w: 8, h: 1 }], - '▉': [{ x: 0, y: 0, w: 7, h: 8 }], - '▊': [{ x: 0, y: 0, w: 6, h: 8 }], - '▋': [{ x: 0, y: 0, w: 5, h: 8 }], - '▌': [{ x: 0, y: 0, w: 4, h: 8 }], - '▍': [{ x: 0, y: 0, w: 3, h: 8 }], - '▎': [{ x: 0, y: 0, w: 2, h: 8 }], - '▏': [{ x: 0, y: 0, w: 1, h: 8 }], + // Block elements (0x2580-0x2590) + '▀': [{ x: 0, y: 0, w: 8, h: 4 }], // UPPER HALF BLOCK + '▁': [{ x: 0, y: 7, w: 8, h: 1 }], // LOWER ONE EIGHTH BLOCK + '▂': [{ x: 0, y: 6, w: 8, h: 2 }], // LOWER ONE QUARTER BLOCK + '▃': [{ x: 0, y: 5, w: 8, h: 3 }], // LOWER THREE EIGHTHS BLOCK + '▄': [{ x: 0, y: 4, w: 8, h: 4 }], // LOWER HALF BLOCK + '▅': [{ x: 0, y: 3, w: 8, h: 5 }], // LOWER FIVE EIGHTHS BLOCK + '▆': [{ x: 0, y: 2, w: 8, h: 6 }], // LOWER THREE QUARTERS BLOCK + '▇': [{ x: 0, y: 1, w: 8, h: 7 }], // LOWER SEVEN EIGHTHS BLOCK + '█': [{ x: 0, y: 0, w: 8, h: 8 }], // FULL BLOCK + '▉': [{ x: 0, y: 0, w: 7, h: 8 }], // LEFT SEVEN EIGHTHS BLOCK + '▊': [{ x: 0, y: 0, w: 6, h: 8 }], // LEFT THREE QUARTERS BLOCK + '▋': [{ x: 0, y: 0, w: 5, h: 8 }], // LEFT FIVE EIGHTHS BLOCK + '▌': [{ x: 0, y: 0, w: 4, h: 8 }], // LEFT HALF BLOCK + '▍': [{ x: 0, y: 0, w: 3, h: 8 }], // LEFT THREE EIGHTHS BLOCK + '▎': [{ x: 0, y: 0, w: 2, h: 8 }], // LEFT ONE QUARTER BLOCK + '▏': [{ x: 0, y: 0, w: 1, h: 8 }], // LEFT ONE EIGHTH BLOCK + '▐': [{ x: 4, y: 0, w: 4, h: 8 }], // RIGHT HALF BLOCK + + // Block elements (0x2594-0x2595) + '▔': [{ x: 0, y: 0, w: 9, h: 1 }], // UPPER ONE EIGHTH BLOCK + '▕': [{ x: 7, y: 0, w: 1, h: 8 }], // RIGHT ONE EIGHTH BLOCK + + // Terminal graphic characters (0x2596-0x259F) + '▖': [{ x: 0, y: 4, w: 4, h: 4 }], // QUADRANT LOWER LEFT + '▗': [{ x: 4, y: 4, w: 4, h: 4 }], // QUADRANT LOWER RIGHT + '▘': [{ x: 0, y: 0, w: 4, h: 4 }], // QUADRANT UPPER LEFT + '▙': [{ x: 0, y: 0, w: 4, h: 8 }, { x: 0, y: 4, w: 8, h: 4 }], // QUADRANT UPPER LEFT AND LOWER LEFT AND LOWER RIGHT + '▚': [{ x: 0, y: 0, w: 4, h: 4 }, { x: 4, y: 4, w: 4, h: 4 }], // QUADRANT UPPER LEFT AND LOWER RIGHT + '▛': [{ x: 0, y: 0, w: 4, h: 8 }, { x: 0, y: 0, w: 4, h: 8 }], // QUADRANT UPPER LEFT AND UPPER RIGHT AND LOWER LEFT + '▜': [{ x: 0, y: 0, w: 8, h: 4 }, { x: 4, y: 0, w: 4, h: 8 }], // QUADRANT UPPER LEFT AND UPPER RIGHT AND LOWER RIGHT + '▝': [{ x: 4, y: 0, w: 4, h: 4 }], // QUADRANT UPPER RIGHT + '▞': [{ x: 4, y: 0, w: 4, h: 4 }, { x: 0, y: 4, w: 4, h: 4 }], // QUADRANT UPPER RIGHT AND LOWER LEFT + '▟': [{ x: 4, y: 0, w: 4, h: 8 }, { x: 0, y: 4, w: 8, h: 4 }], // QUADRANT UPPER RIGHT AND LOWER LEFT AND LOWER RIGHT // VERTICAL ONE EIGHTH BLOCK-2 through VERTICAL ONE EIGHTH BLOCK-7 '\u{1FB70}': [{ x: 1, y: 0, w: 1, h: 8 }], @@ -37,11 +55,7 @@ export const blockElementDefinitions: { [index: string]: IBlockVector[] | undefi '\u{1FB73}': [{ x: 4, y: 0, w: 1, h: 8 }], '\u{1FB74}': [{ x: 5, y: 0, w: 1, h: 8 }], '\u{1FB75}': [{ x: 6, y: 0, w: 1, h: 8 }], - // RIGHT ONE EIGHTH BLOCK - '▕': [{ x: 7, y: 0, w: 1, h: 8 }], - // UPPER ONE EIGHTH BLOCK - '▔': [{ x: 0, y: 0, w: 8, h: 1 }], // HORIZONTAL ONE EIGHTH BLOCK-2 through HORIZONTAL ONE EIGHTH BLOCK-7 '\u{1FB76}': [{ x: 0, y: 1, w: 8, h: 1 }], '\u{1FB77}': [{ x: 0, y: 2, w: 8, h: 1 }], @@ -110,19 +124,20 @@ type PatternDefinition = number[][]; * pixel values to be filled (1) or not filled (0). */ const patternCharacterDefinitions: { [key: string]: PatternDefinition | undefined } = { - '░': [ + // Shade characters (0x2591-0x2593) + '░': [ // LIGHT SHADE (25%) [1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, 0], [0, 0, 0, 0] ], - '▒': [ + '▒': [ // MEDIUM SHADE (50%) [1, 0], [0, 0], [0, 1], [0, 0] ], - '▓': [ + '▓': [ // DARK SHADE (75%) [0, 1], [1, 1], [1, 0], From 53dbcbafb2b7e39dc29631f892a5df09390ea131 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 19 Aug 2021 07:05:42 -0700 Subject: [PATCH 339/377] Ensure underscore is within cell bounds Fixes #3423 --- .../src/atlas/WebglCharAtlas.ts | 16 +++++++++++++ .../renderer/atlas/DynamicCharAtlas.ts | 24 +++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 340e83c9..33a819fb 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -402,6 +402,22 @@ export class WebglCharAtlas implements IDisposable { this._tmpCtx.fillText(chars, padding, padding + this._config.scaledCharHeight); } + // If this charcater is underscore and beyond the cell bounds, shift it up until it is visible, + // try for a maximum of 5 pixels. + if (chars === '_' && !this._config.allowTransparency) { + let isBeyondCellBounds = clearColor(this._tmpCtx.getImageData(padding, padding, this._config.scaledCellWidth, this._config.scaledCellHeight), backgroundColor); + if (isBeyondCellBounds) { + for (let offset = 1; offset <= 5; offset++) { + this._tmpCtx.clearRect(0, 0, this._tmpCanvas.width, this._tmpCanvas.height); + this._tmpCtx.fillText(chars, padding, padding + this._config.scaledCharHeight - offset); + isBeyondCellBounds = clearColor(this._tmpCtx.getImageData(padding, padding, this._config.scaledCellWidth, this._config.scaledCellHeight), backgroundColor); + if (!isBeyondCellBounds) { + break; + } + } + } + } + // Draw underline and strikethrough if (underline || strikethrough) { const lineWidth = Math.max(1, Math.floor(this._config.fontSize / 10)); diff --git a/src/browser/renderer/atlas/DynamicCharAtlas.ts b/src/browser/renderer/atlas/DynamicCharAtlas.ts index 883ebe78..a7237878 100644 --- a/src/browser/renderer/atlas/DynamicCharAtlas.ts +++ b/src/browser/renderer/atlas/DynamicCharAtlas.ts @@ -266,11 +266,10 @@ export class DynamicCharAtlas extends BaseCharAtlas { } // Draw the character this._tmpCtx.fillText(glyph.chars, 0, this._config.scaledCharHeight); - this._tmpCtx.restore(); // clear the background from the character to avoid issues with drawing over the previous // character if it extends past it's bounds - const imageData = this._tmpCtx.getImageData( + let imageData = this._tmpCtx.getImageData( 0, 0, this._config.scaledCharWidth, this._config.scaledCharHeight ); let isEmpty = false; @@ -278,6 +277,27 @@ export class DynamicCharAtlas extends BaseCharAtlas { isEmpty = clearColor(imageData, backgroundColor); } + // If this charcater is underscore and empty, shift it up until it is visible, try for a maximum + // of 5 pixels. + if (isEmpty && glyph.chars === '_' && !this._config.allowTransparency) { + for (let offset = 1; offset <= 5; offset++) { + // Draw the character + this._tmpCtx.fillText(glyph.chars, 0, this._config.scaledCharHeight - offset); + + // clear the background from the character to avoid issues with drawing over the previous + // character if it extends past it's bounds + imageData = this._tmpCtx.getImageData( + 0, 0, this._config.scaledCharWidth, this._config.scaledCharHeight + ); + isEmpty = clearColor(imageData, backgroundColor); + if (!isEmpty) { + break; + } + } + } + + this._tmpCtx.restore(); + // copy the data from imageData to _cacheCanvas const x = this._toCoordinateX(index); const y = this._toCoordinateY(index); From c1413ce58dcb92611eb28fb5c8109d8828e04f70 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Thu, 19 Aug 2021 18:24:49 -0700 Subject: [PATCH 340/377] fix #3427 --- addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 33a819fb..6128c836 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -459,7 +459,7 @@ export class WebglCharAtlas implements IDisposable { return NULL_RASTERIZED_GLYPH; } - const rasterizedGlyph = this._findGlyphBoundingBox(imageData, this._workBoundingBox, allowedWidth, isPowerlineGlyph); + const rasterizedGlyph = this._findGlyphBoundingBox(imageData, this._workBoundingBox, allowedWidth, isPowerlineGlyph, drawSuccess); const clippedImageData = this._clipImageData(imageData, this._workBoundingBox); // Check if there is enough room in the current row and go to next if needed @@ -492,7 +492,7 @@ export class WebglCharAtlas implements IDisposable { * @param imageData The image data to read. * @param boundingBox An IBoundingBox to put the clipped bounding box values. */ - private _findGlyphBoundingBox(imageData: ImageData, boundingBox: IBoundingBox, allowedWidth: number, restrictedGlyph: boolean): IRasterizedGlyph { + private _findGlyphBoundingBox(imageData: ImageData, boundingBox: IBoundingBox, allowedWidth: number, restrictedGlyph: boolean, customGlyph: boolean): IRasterizedGlyph { boundingBox.top = 0; const height = restrictedGlyph ? this._config.scaledCharHeight : this._tmpCanvas.height; const width = restrictedGlyph ? this._config.scaledCharWidth : allowedWidth; @@ -567,8 +567,8 @@ export class WebglCharAtlas implements IDisposable { y: (boundingBox.bottom - boundingBox.top + 1) / TEXTURE_HEIGHT }, offset: { - x: -boundingBox.left + (restrictedGlyph ? 0 : TMP_CANVAS_GLYPH_PADDING), - y: -boundingBox.top + (restrictedGlyph ? 0 : TMP_CANVAS_GLYPH_PADDING) + x: -boundingBox.left + (restrictedGlyph ? 0 : TMP_CANVAS_GLYPH_PADDING) + (customGlyph ? Math.floor(this._config.letterSpacing / 2) : 0), + y: -boundingBox.top + (restrictedGlyph ? 0 : TMP_CANVAS_GLYPH_PADDING) + (customGlyph ? this._config.lineHeight === 1 ? 0 : Math.round((this._config.scaledCellHeight - this._config.scaledCharHeight) / 2) : 0) } }; } From f0636ed083e0fb7bdfdd0ab09c080b71567675b1 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sun, 22 Aug 2021 17:15:00 +0200 Subject: [PATCH 341/377] input: handle dead keys --- src/browser/Terminal.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index dde4a1b6..2a81d928 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -94,6 +94,13 @@ export class Terminal extends CoreTerminal implements ITerminal { */ private _keyDownHandled: boolean = false; + /** + * Records whether there has been a keydown event for a dead key without a corresponding keydown + * event for the composed/alternative character. If we cancel the keydown event for the dead key, + * no events will be emitted for the final character. + */ + private _unprocessedDeadKey: boolean = false; + public linkifier: ILinkifier; public linkifier2: ILinkifier2; public viewport: IViewport | undefined; @@ -1025,6 +1032,10 @@ export class Terminal extends CoreTerminal implements ITerminal { return false; } + if (event.key === 'Dead') { + this._unprocessedDeadKey = true; + } + const result = evaluateKeyboardEvent(event, this.coreService.decPrivateModes.applicationCursorKeys, this.browser.isMac, this.options.macOptionIsMeta); this.updateCursorStyle(event); @@ -1052,6 +1063,11 @@ export class Terminal extends CoreTerminal implements ITerminal { return true; } + if (this._unprocessedDeadKey) { + this._unprocessedDeadKey = false; + return true; + } + // If ctrl+c or enter is being sent, clear out the textarea. This is done so that screen readers // will announce deleted characters. This will not work 100% of the time but it should cover // most scenarios. From b3cd4948ad46c5c504ff5039714a420fb84068d9 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sun, 22 Aug 2021 16:19:17 +0200 Subject: [PATCH 342/377] input: handle input from macOS and Windows emoji panels --- src/browser/Terminal.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index dde4a1b6..6d31345b 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -94,6 +94,13 @@ export class Terminal extends CoreTerminal implements ITerminal { */ private _keyDownHandled: boolean = false; + /** + * Records whether the keypress event has already been handled and triggered a data event, if so + * the input event should not trigger a data event but should still print to the textarea so + * screen readers will announce it. + */ + private _keyPressHandled: boolean = false; + public linkifier: ILinkifier; public linkifier2: ILinkifier2; public viewport: IViewport | undefined; @@ -383,6 +390,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this.register(addDisposableDomListener(this.textarea!, 'compositionstart', () => this._compositionHelper!.compositionstart())); this.register(addDisposableDomListener(this.textarea!, 'compositionupdate', (e: CompositionEvent) => this._compositionHelper!.compositionupdate(e))); this.register(addDisposableDomListener(this.textarea!, 'compositionend', () => this._compositionHelper!.compositionend())); + this.register(addDisposableDomListener(this.textarea!, 'input', (ev: InputEvent) => this._inputEvent(ev), true)); this.register(this.onRender(() => this._compositionHelper!.updateCompositionElements())); this.register(this.onRender(e => this._queueLinkification(e.start, e.end))); } @@ -1097,6 +1105,7 @@ export class Terminal extends CoreTerminal implements ITerminal { } this.updateCursorStyle(ev); + this._keyPressHandled = false; } /** @@ -1108,6 +1117,8 @@ export class Terminal extends CoreTerminal implements ITerminal { protected _keyPress(ev: KeyboardEvent): boolean { let key; + this._keyPressHandled = false; + if (this._keyDownHandled) { return false; } @@ -1140,9 +1151,33 @@ export class Terminal extends CoreTerminal implements ITerminal { this._showCursor(); this.coreService.triggerDataEvent(key, true); + this._keyPressHandled = true; + return true; } + /** + * Handle an input event. + * Key Resources: + * - https://developer.mozilla.org/en-US/docs/Web/API/InputEvent + * @param ev The input event to be handled. + */ + protected _inputEvent(ev: InputEvent): boolean { + if (ev.data && ev.inputType === 'insertText') { + if (this._keyPressHandled) { + return false; + } + + const text = ev.data; + this.coreService.triggerDataEvent(text, true); + + this.cancel(ev); + return true; + } + + return false; + } + /** * Ring the bell. * Note: We could do sweet things with webaudio here From 44be1f5d2a373eba9aceb88394f1fedc769a7518 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 23 Aug 2021 05:23:17 -0700 Subject: [PATCH 343/377] Add repository key to serialize package.json Not having this breaks some of vscode's tooling --- addons/xterm-addon-serialize/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/xterm-addon-serialize/package.json b/addons/xterm-addon-serialize/package.json index 770771c4..91ef26af 100644 --- a/addons/xterm-addon-serialize/package.json +++ b/addons/xterm-addon-serialize/package.json @@ -7,6 +7,7 @@ }, "main": "lib/xterm-addon-serialize.js", "types": "typings/xterm-addon-serialize.d.ts", + "repository": "https://github.com/xtermjs/xterm.js", "license": "MIT", "scripts": { "build": "../../node_modules/.bin/tsc -p .", From fa9126c4e6c19cfb9276cd1ecbbef06eac34cc78 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Wed, 25 Aug 2021 21:48:25 +0200 Subject: [PATCH 344/377] input: support AltGraph as a third level shift modifier --- src/browser/Terminal.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 2a81d928..fc725122 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -1090,10 +1090,11 @@ export class Terminal extends CoreTerminal implements ITerminal { this._keyDownHandled = true; } - private _isThirdLevelShift(browser: IBrowser, ev: IKeyboardEvent): boolean { + private _isThirdLevelShift(browser: IBrowser, ev: KeyboardEvent): boolean { const thirdLevelKey = (browser.isMac && !this.options.macOptionIsMeta && ev.altKey && !ev.ctrlKey && !ev.metaKey) || - (browser.isWindows && ev.altKey && ev.ctrlKey && !ev.metaKey); + (browser.isWindows && ev.altKey && ev.ctrlKey && !ev.metaKey) || + (browser.isWindows && ev.getModifierState('AltGraph')); if (ev.type === 'keypress') { return thirdLevelKey; From f2ef2b0b040c043ef786629f45cf5bfa0d012199 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sat, 28 Aug 2021 14:13:27 +0200 Subject: [PATCH 345/377] input: treat AltGraph as a dead key too --- src/browser/Terminal.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 2a81d928..b8d2091b 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -1032,7 +1032,7 @@ export class Terminal extends CoreTerminal implements ITerminal { return false; } - if (event.key === 'Dead') { + if (event.key === 'Dead' || event.key === 'AltGraph') { this._unprocessedDeadKey = true; } From 2be3fc82bacce610b786fe7d4cf8db47e2466077 Mon Sep 17 00:00:00 2001 From: Simran Narang Date: Mon, 30 Aug 2021 15:14:15 +0530 Subject: [PATCH 346/377] Terminal controls shifted to the right of the demo The terminals have been shifted using a fixed tab bar on the right side of the demo. --- demo/index.html | 99 +++++++++++++++++++++++++++++++------------------ demo/style.css | 49 ++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 36 deletions(-) diff --git a/demo/index.html b/demo/index.html index 910397c3..621a1883 100644 --- a/demo/index.html +++ b/demo/index.html @@ -15,42 +15,69 @@

xterm.js: A terminal for the web

-
-
-

Options

-

These options can be set in the Terminal constructor or by using the Terminal.setOption function.

-
-
-
-

Addons

-

Addons can be loaded and unloaded on a particular terminal to extend its functionality.

-
-

Addons Control

-

SearchAddon

-

- - - - - -

-

SerializeAddon

-

- - -

-

-
-
-

Style

-
- - +
+
+
+
+
+
+ + + +
+
+

Options

+

These options can be set in the Terminal constructor or by using the Terminal.setOption function.

+
+
+
+

Addons

+

Addons can be loaded and unloaded on a particular terminal to extend its functionality.

+
+

Addons Control

+

SearchAddon

+

+ + + + + +

+

SerializeAddon

+

+ + +

+

+
+
+

Style

+
+ + +
+
-
- - - - +
+ + + + + diff --git a/demo/style.css b/demo/style.css index 9c5fd0bd..29c4cbb1 100644 --- a/demo/style.css +++ b/demo/style.css @@ -41,3 +41,52 @@ pre { word-wrap: break-word; white-space: pre-wrap; } + + +#container { + display: flex; + height: 75vh; +} +#grid { + flex: 1; + /* max-height: 80vh; + overflow-y: auto; */ + width: 100%; +} +.tab { + overflow: hidden; + border: 1px solid #ccc; + background-color: #f1f1f1; +} + +/* Style the buttons inside the tab */ +.tab button { + background-color: inherit; + float: left; + border: none; + outline: none; + cursor: pointer; + padding: 14px 16px; + transition: 0.3s; + font-size: 17px; +} + +/* Change background color of buttons on hover */ +.tab button:hover { + background-color: #ddd; +} + +/* Create an active/current tablink class */ +.tab button.active { + background-color: #ccc; + } + +/* Style the tab content */ +.tabContent { + display: none; + padding: 6px 12px; + border: 1px solid #ccc; + border-top: none; + max-height: 67.7vh; + overflow-y: auto; +} From 640ea60945794aaadc17acc14bcc8f5673989b5d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 30 Aug 2021 10:48:12 -0700 Subject: [PATCH 347/377] Action feedback --- src/browser/Viewport.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index 77325ef9..9ce14daf 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -23,6 +23,7 @@ export class Viewport extends Disposable implements IViewport { private _lastRecordedBufferHeight: number = 0; private _lastTouchY: number = 0; private _lastScrollTop: number = 0; + private _lastHadScrollBar: boolean = false; // Stores a partial line amount when scrolling, this is used to keep track of how much of a line // is scrolled so we can "scroll" over partial lines and feel natural on touchpads. This is a @@ -47,6 +48,7 @@ export class Viewport extends Disposable implements IViewport { // Unfortunately the overlay scrollbar would be hidden underneath the screen element in that case, // therefore we account for a standard amount to make it visible this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH; + this._lastHadScrollBar = true; this.register(addDisposableDomListener(this._viewportElement, 'scroll', this._onScroll.bind(this))); // Perform this async to ensure the ICharSizeService is ready. @@ -93,14 +95,19 @@ export class Viewport extends Disposable implements IViewport { this._ignoreNextScrollEvent = true; this._viewportElement.scrollTop = scrollTop; } - if (this._optionsService.getOption('scrollback') === 0) { + + // Update scroll bar width + if (this._optionsService.options.scrollback === 0) { this.scrollBarWidth = 0; } else { this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH; } + this._lastHadScrollBar = this.scrollBarWidth > 0; + this._viewportElement.style.width = (this._renderService.dimensions.actualCellWidth * (this._bufferService.cols) + this.scrollBarWidth).toString() + 'px'; this._refreshAnimationFrame = null; } + /** * Updates dimensions and synchronizes the scroll area if necessary. */ @@ -136,9 +143,11 @@ export class Viewport extends Disposable implements IViewport { this._refresh(immediate); return; } - // This is for refreshing the viewport if scrollBarWidth has to be updated - this._refresh(immediate); - return; + + // If the scroll bar visibility changed + if (this._lastHadScrollBar !== (this._optionsService.options.scrollback > 0)) { + this._refresh(immediate); + } } /** From b19b3f0fb693518246268669b8533eada8ed337a Mon Sep 17 00:00:00 2001 From: Simran Narang Date: Tue, 31 Aug 2021 11:41:00 +0530 Subject: [PATCH 348/377] Implemented all the changes requested! All Suggested changes committed successfully! --- demo/index.html | 37 +++++++++++++++++++++++++++++-------- demo/style.css | 2 +- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/demo/index.html b/demo/index.html index 621a1883..20924b66 100644 --- a/demo/index.html +++ b/demo/index.html @@ -21,9 +21,10 @@
- - - + + + +

Options

@@ -36,7 +37,7 @@

Addons Control

SearchAddon

-

+

@@ -57,13 +58,32 @@

+
+

Test

+
+ + +
+
-
- - diff --git a/demo/style.css b/demo/style.css index 29c4cbb1..cebd08e0 100644 --- a/demo/style.css +++ b/demo/style.css @@ -87,6 +87,6 @@ pre { padding: 6px 12px; border: 1px solid #ccc; border-top: none; - max-height: 67.7vh; + max-height: 100vh; overflow-y: auto; } From 9e40614b5cc1d64998014507b206b15895d2eaf9 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 31 Aug 2021 12:50:54 +0200 Subject: [PATCH 349/377] feat(test): use common function to launch the browser --- addons/xterm-addon-attach/test/AttachAddon.api.ts | 7 ++----- addons/xterm-addon-fit/test/FitAddon.api.ts | 7 ++----- addons/xterm-addon-search/test/SearchAddon.api.ts | 7 ++----- .../test/SerializeAddon.api.ts | 7 ++----- .../test/Unicode11Addon.api.ts | 7 ++----- .../test/WebLinksAddon.api.ts | 7 ++----- addons/xterm-addon-webgl/test/WebglRenderer.api.ts | 7 ++----- bin/test_api.js | 6 ++++++ test/api/CharWidth.api.ts | 7 ++----- test/api/InputHandler.api.ts | 6 ++---- test/api/MouseTracking.api.ts | 6 ++---- test/api/Parser.api.ts | 7 ++----- test/api/Terminal.api.ts | 7 ++----- test/api/TestUtils.ts | 14 ++++++++++++++ 14 files changed, 44 insertions(+), 58 deletions(-) diff --git a/addons/xterm-addon-attach/test/AttachAddon.api.ts b/addons/xterm-addon-attach/test/AttachAddon.api.ts index ef26cfd2..8335cf0f 100644 --- a/addons/xterm-addon-attach/test/AttachAddon.api.ts +++ b/addons/xterm-addon-attach/test/AttachAddon.api.ts @@ -4,7 +4,7 @@ */ import WebSocket = require('ws'); -import { openTerminal, pollFor, getBrowserType } from '../../../out-test/api/TestUtils'; +import { openTerminal, pollFor, launchBrowser } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -16,10 +16,7 @@ const height = 600; describe('AttachAddon', () => { before(async function(): Promise { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.includes('--headless') - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); }); diff --git a/addons/xterm-addon-fit/test/FitAddon.api.ts b/addons/xterm-addon-fit/test/FitAddon.api.ts index 8859b5a6..987092ad 100644 --- a/addons/xterm-addon-fit/test/FitAddon.api.ts +++ b/addons/xterm-addon-fit/test/FitAddon.api.ts @@ -4,7 +4,7 @@ */ import { assert } from 'chai'; -import { openTerminal, getBrowserType } from '../../../out-test/api/TestUtils'; +import { openTerminal, launchBrowser } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -16,10 +16,7 @@ const height = 768; describe('FitAddon', () => { before(async function(): Promise { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.includes('--headless') - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); await page.goto(APP); diff --git a/addons/xterm-addon-search/test/SearchAddon.api.ts b/addons/xterm-addon-search/test/SearchAddon.api.ts index 3c94d416..8bdf61cf 100644 --- a/addons/xterm-addon-search/test/SearchAddon.api.ts +++ b/addons/xterm-addon-search/test/SearchAddon.api.ts @@ -6,7 +6,7 @@ import { assert } from 'chai'; import { readFile } from 'fs'; import { resolve } from 'path'; -import { openTerminal, writeSync, getBrowserType } from '../../../out-test/api/TestUtils'; +import { openTerminal, writeSync, launchBrowser } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -18,10 +18,7 @@ const height = 600; describe('Search Tests', function(): void { before(async function(): Promise { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.includes('--headless') - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); await page.goto(APP); diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index 87f77f59..bb66f37b 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -4,7 +4,7 @@ */ import { assert } from 'chai'; -import { openTerminal, writeSync, getBrowserType } from '../../../out-test/api/TestUtils'; +import { openTerminal, writeSync, launchBrowser } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -38,10 +38,7 @@ async function testSerializeEquals(writeContent: string, expectedSerialized: str describe('SerializeAddon', () => { before(async function(): Promise { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.includes('--headless') - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); await page.goto(APP); diff --git a/addons/xterm-addon-unicode11/test/Unicode11Addon.api.ts b/addons/xterm-addon-unicode11/test/Unicode11Addon.api.ts index ba536e90..4c695b00 100644 --- a/addons/xterm-addon-unicode11/test/Unicode11Addon.api.ts +++ b/addons/xterm-addon-unicode11/test/Unicode11Addon.api.ts @@ -4,7 +4,7 @@ */ import { assert } from 'chai'; -import { openTerminal, getBrowserType } from '../../../out-test/api/TestUtils'; +import { openTerminal, launchBrowser } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -16,10 +16,7 @@ const height = 600; describe('Unicode11Addon', () => { before(async function(): Promise { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.includes('--headless') - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); }); diff --git a/addons/xterm-addon-web-links/test/WebLinksAddon.api.ts b/addons/xterm-addon-web-links/test/WebLinksAddon.api.ts index 54650f1f..fe44dc31 100644 --- a/addons/xterm-addon-web-links/test/WebLinksAddon.api.ts +++ b/addons/xterm-addon-web-links/test/WebLinksAddon.api.ts @@ -4,7 +4,7 @@ */ import { assert } from 'chai'; -import { openTerminal, pollFor, writeSync, getBrowserType } from '../../../out-test/api/TestUtils'; +import { openTerminal, pollFor, writeSync, launchBrowser } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -16,10 +16,7 @@ const height = 600; describe('WebLinksAddon', () => { before(async function(): Promise { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.includes('--headless') - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); }); diff --git a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts index 793929e9..e6942d1c 100644 --- a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts +++ b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts @@ -6,7 +6,7 @@ import { assert } from 'chai'; import { Browser, Page } from 'playwright'; import { ITheme } from 'xterm'; -import { getBrowserType, openTerminal, pollFor, writeSync } from '../../../out-test/api/TestUtils'; +import { getBrowserType, launchBrowser, openTerminal, pollFor, writeSync } from '../../../out-test/api/TestUtils'; import { ITerminalOptions } from '../../../src/common/Types'; const APP = 'http://127.0.0.1:3001/test'; @@ -905,10 +905,7 @@ async function getCellPixels(col: number, row: number): Promise { } async function setupBrowser(options: ITerminalOptions = { rendererType: 'dom' }): Promise { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.includes('--headless') - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); await page.goto(APP); diff --git a/bin/test_api.js b/bin/test_api.js index 9fe4659a..f173b417 100644 --- a/bin/test_api.js +++ b/bin/test_api.js @@ -59,6 +59,12 @@ server.stdout.on('data', (data) => { `${script}.cmd` : script)); } + server.kill(); + process.exit(run.status); } }); + +server.stderr.on('data', (data) => { + console.error(data.toString()); +}); diff --git a/test/api/CharWidth.api.ts b/test/api/CharWidth.api.ts index d7cea109..83067149 100644 --- a/test/api/CharWidth.api.ts +++ b/test/api/CharWidth.api.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { pollFor, openTerminal, getBrowserType } from './TestUtils'; +import { pollFor, openTerminal, launchBrowser } from './TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -15,10 +15,7 @@ const height = 600; describe('CharWidth Integration Tests', function(): void { before(async function(): Promise { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.indexOf('--headless') !== -1 - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); await page.goto(APP); diff --git a/test/api/InputHandler.api.ts b/test/api/InputHandler.api.ts index a695abdc..54ee6957 100644 --- a/test/api/InputHandler.api.ts +++ b/test/api/InputHandler.api.ts @@ -4,7 +4,7 @@ */ import { assert } from 'chai'; -import { pollFor, openTerminal, getBrowserType } from './TestUtils'; +import { pollFor, openTerminal, getBrowserType, launchBrowser } from './TestUtils'; import { Browser, Page } from 'playwright'; import { IRenderDimensions } from 'browser/renderer/Types'; @@ -21,9 +21,7 @@ describe('InputHandler Integration Tests', function(): void { before(async function(): Promise { const browserType = getBrowserType(); isChromium = browserType.name() === 'chromium'; - browser = await browserType.launch({ - headless: process.argv.indexOf('--headless') !== -1 - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); await page.goto(APP); diff --git a/test/api/MouseTracking.api.ts b/test/api/MouseTracking.api.ts index 3df21a90..ebeb680f 100644 --- a/test/api/MouseTracking.api.ts +++ b/test/api/MouseTracking.api.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { pollFor, writeSync, openTerminal, getBrowserType } from './TestUtils'; +import { pollFor, writeSync, openTerminal, getBrowserType, launchBrowser } from './TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -211,9 +211,7 @@ describe('Mouse Tracking Tests', async () => { const itMouse = isChromium ? it : it.skip; before(async function(): Promise { - browser = await browserType.launch({ - headless: process.argv.indexOf('--headless') !== -1 - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); }); diff --git a/test/api/Parser.api.ts b/test/api/Parser.api.ts index 0ef57cf1..ada28adf 100644 --- a/test/api/Parser.api.ts +++ b/test/api/Parser.api.ts @@ -4,7 +4,7 @@ */ import { assert } from 'chai'; -import { writeSync, openTerminal, getBrowserType } from './TestUtils'; +import { writeSync, openTerminal, launchBrowser } from './TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -16,10 +16,7 @@ const height = 600; describe('Parser Integration Tests', function (): void { before(async function (): Promise { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.indexOf('--headless') !== -1 - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); await page.goto(APP); diff --git a/test/api/Terminal.api.ts b/test/api/Terminal.api.ts index 1599f3a2..00598e47 100644 --- a/test/api/Terminal.api.ts +++ b/test/api/Terminal.api.ts @@ -4,7 +4,7 @@ */ import { assert } from 'chai'; -import { pollFor, timeout, writeSync, openTerminal, getBrowserType } from './TestUtils'; +import { pollFor, timeout, writeSync, openTerminal, launchBrowser } from './TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -16,10 +16,7 @@ const height = 600; describe('API Integration Tests', function(): void { before(async () => { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.indexOf('--headless') !== -1 - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); }); diff --git a/test/api/TestUtils.ts b/test/api/TestUtils.ts index 2b1e8828..4fa98d43 100644 --- a/test/api/TestUtils.ts +++ b/test/api/TestUtils.ts @@ -67,3 +67,17 @@ export function getBrowserType(): playwright.BrowserType = { + headless: process.argv.includes('--headless'), + } + + const index = process.argv.indexOf('--executablePath'); + if(index > 0 && process.argv.length > index + 1 && typeof process.argv[index + 1] === 'string') { + options.executablePath = process.argv[index + 1]; + } + + return browserType.launch(options); +} From 50e8727111c0e8dcf88228d58e8ab92d11b7d106 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 31 Aug 2021 13:04:40 +0200 Subject: [PATCH 350/377] refactor(test): add command to run an unique test and support Mocha Explorer extension --- .mocharc.yml | 11 +++++++++++ .vscode/settings.json | 5 ++++- package.json | 2 ++ yarn.lock | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .mocharc.yml diff --git a/.mocharc.yml b/.mocharc.yml new file mode 100644 index 00000000..c19fe15a --- /dev/null +++ b/.mocharc.yml @@ -0,0 +1,11 @@ +require: + - source-map-support/register +spec: + - out/**/*.test.js + - addons/**/out/*.test.js +watch-files: + - out/**/*.js + - addons/**/out/*.js +reporter: spec +color: true +check-leaks: true diff --git a/.vscode/settings.json b/.vscode/settings.json index f07ca545..ecea784c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,7 @@ { "typescript.preferences.importModuleSpecifier": "non-relative", - "typescript.preferences.quoteStyle": "single" + "typescript.preferences.quoteStyle": "single", + "mochaExplorer.env": { + "NODE_PATH": "./out" + } } diff --git a/package.json b/package.json index 71a0f308..40de4017 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "test-api-webkit": "node ./bin/test_api.js --browser=webkit --timeout=20000", "test-unit": "node ./bin/test.js", "test-unit-coverage": "node ./bin/test.js --coverage", + "test:dev": "NODE_PATH='./out' mocha", "build": "tsc -b ./tsconfig.all.json", "prepare": "npm run setup", "setup": "npm run build", @@ -61,6 +62,7 @@ "nyc": "^15.1.0", "playwright": "^1.11.0", "source-map-loader": "^2.0.1", + "source-map-support": "^0.5.19", "ts-loader": "^9.1.2", "typescript": "^4.2.4", "utf8": "^3.0.0", diff --git a/yarn.lock b/yarn.lock index 571f8a90..0d8ac14f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3909,7 +3909,7 @@ source-map-loader@^2.0.1: iconv-lite "^0.6.2" source-map-js "^0.6.2" -source-map-support@~0.5.19: +source-map-support@^0.5.19, source-map-support@~0.5.19: version "0.5.19" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== From 8801926b1000c89bb1d50b4f1684e182140f0dd1 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 31 Aug 2021 15:40:35 +0200 Subject: [PATCH 351/377] fix: `test:dev` is running on Windows --- package.json | 3 ++- yarn.lock | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 40de4017..43fb640e 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "test-api-webkit": "node ./bin/test_api.js --browser=webkit --timeout=20000", "test-unit": "node ./bin/test.js", "test-unit-coverage": "node ./bin/test.js --coverage", - "test:dev": "NODE_PATH='./out' mocha", + "test:dev": "cross-env NODE_PATH='./out' mocha", "build": "tsc -b ./tsconfig.all.json", "prepare": "npm run setup", "setup": "npm run build", @@ -50,6 +50,7 @@ "@typescript-eslint/eslint-plugin": "^4.23.0", "@typescript-eslint/parser": "^4.23.0", "chai": "^4.3.4", + "cross-env": "^7.0.3", "deep-equal": "^2.0.5", "eslint": "^7.26.0", "express": "^4.17.1", diff --git a/yarn.lock b/yarn.lock index 0d8ac14f..cf92d8f7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1329,7 +1329,14 @@ core-util-is@1.0.2, core-util-is@~1.0.0: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= -cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: +cross-env@^7.0.3: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf" + integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw== + dependencies: + cross-spawn "^7.0.1" + +cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== From 7cda0017aa0f14d6e7ab8677e28f7a58ff2b89f5 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 31 Aug 2021 15:53:43 +0200 Subject: [PATCH 352/377] fix: make Mocha Explorer working on Windows --- .env.test | 1 + .vscode/settings.json | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) create mode 100644 .env.test diff --git a/.env.test b/.env.test new file mode 100644 index 00000000..78a9f930 --- /dev/null +++ b/.env.test @@ -0,0 +1 @@ +NODE_PATH=./out diff --git a/.vscode/settings.json b/.vscode/settings.json index ecea784c..7720b1ee 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,5 @@ { "typescript.preferences.importModuleSpecifier": "non-relative", "typescript.preferences.quoteStyle": "single", - "mochaExplorer.env": { - "NODE_PATH": "./out" - } + "mochaExplorer.envPath": ".env.test" } From 8edf0d5e1dcd0d68dc2ec815ffc22bc0350e0c72 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 31 Aug 2021 07:29:31 -0700 Subject: [PATCH 353/377] Improve checkbox and italics styling --- demo/index.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/demo/index.html b/demo/index.html index 20924b66..fc5ca175 100644 --- a/demo/index.html +++ b/demo/index.html @@ -37,19 +37,19 @@

Addons Control

SearchAddon

-

+

- - - -

+ + + +

SerializeAddon

-

+

-

+

Style

From f12b917930da17a5894965e0239cd140c871a2f3 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 31 Aug 2021 07:32:54 -0700 Subject: [PATCH 354/377] Make addons tab title consistent --- demo/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/index.html b/demo/index.html index fc5ca175..33389ae9 100644 --- a/demo/index.html +++ b/demo/index.html @@ -22,7 +22,7 @@
- +
From ac750596840ad3d43d788eb956ac48911abae623 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 31 Aug 2021 16:56:40 +0200 Subject: [PATCH 355/377] refactor: rename file to a better name --- .env.test => .mocha.env | 0 .vscode/settings.json | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename .env.test => .mocha.env (100%) diff --git a/.env.test b/.mocha.env similarity index 100% rename from .env.test rename to .mocha.env diff --git a/.vscode/settings.json b/.vscode/settings.json index 7720b1ee..9fa94d5f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { "typescript.preferences.importModuleSpecifier": "non-relative", "typescript.preferences.quoteStyle": "single", - "mochaExplorer.envPath": ".env.test" + "mochaExplorer.envPath": ".mocha.env" } From f41eea025ec68948ce1a92d1010ec2e3fce4c76f Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 31 Aug 2021 16:58:20 +0200 Subject: [PATCH 356/377] refactor: rename script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 43fb640e..29b6fd46 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "test-api-webkit": "node ./bin/test_api.js --browser=webkit --timeout=20000", "test-unit": "node ./bin/test.js", "test-unit-coverage": "node ./bin/test.js --coverage", - "test:dev": "cross-env NODE_PATH='./out' mocha", + "test-unit-dev": "cross-env NODE_PATH='./out' mocha", "build": "tsc -b ./tsconfig.all.json", "prepare": "npm run setup", "setup": "npm run build", From b3c0c2bd3c9e1c7c009129ebd43d47eca279f280 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 1 Sep 2021 05:45:00 -0700 Subject: [PATCH 357/377] Add loadtest button to demo --- demo/client.ts | 34 ++++++++++++++++++++++++++++++++++ demo/index.html | 1 + 2 files changed, 35 insertions(+) diff --git a/demo/client.ts b/demo/client.ts index 48b6d177..a02b155c 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -148,6 +148,7 @@ if (document.location.pathname === '/test') { document.getElementById('dispose').addEventListener('click', disposeRecreateButtonHandler); document.getElementById('serialize').addEventListener('click', serializeButtonHandler); document.getElementById('custom-glyph').addEventListener('click', writeCustomGlyphHandler); + document.getElementById('load-test').addEventListener('click', loadTest); } function createTerminal(): void { @@ -481,3 +482,36 @@ function writeCustomGlyphHandler() { term.write(' ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█\n\r'); window.scrollTo(0, 0); } + +function loadTest() { + const isWebglEnabled = !!addons.webgl.instance; + const testData = []; + let byteCount = 0; + for (let i = 0; i < 50; i++) { + const count = 1 + Math.floor(Math.random() * 79); + byteCount += count + 2; + const data = new Uint8Array(count + 2); + data[0] = 0x0A; // \n + for (let i = 1; i < count + 1; i++) { + data[i] = 0x61 + Math.floor(Math.random() * (0x7A - 0x61)); + } + // End each line with \r so the cursor remains constant, this is what ls/tree do and improves + // performance significantly due to the cursor DOM element not needing to change + data[data.length - 1] = 0x0D; // \r + testData.push(data); + } + const start = performance.now(); + for (let i = 0; i < 1024; i++) { + for (const d of testData) { + term.write(d); + } + } + // Wait for all data to be parsed before evaluating time + term.write('', () => { + const time = Math.round(performance.now() - start); + const mbs = ((byteCount / 1024) * (1 / (time / 1000))).toFixed(2); + term.write(`\n\r\nWrote ${byteCount}kB in ${time}ms (${mbs}MB/s) using the (${isWebglEnabled ? 'webgl' : 'canvas'} renderer)`); + // Send ^C to get a new prompt + term._core._onData.fire('\x03'); + }); +} diff --git a/demo/index.html b/demo/index.html index 33389ae9..9c86783b 100644 --- a/demo/index.html +++ b/demo/index.html @@ -63,6 +63,7 @@
+
From cece3db0cb01bfb403d468010b89fb3161fe0b5d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 1 Sep 2021 06:15:59 -0700 Subject: [PATCH 358/377] Cache a copy of the active buffer as a private prop This reduces GC from the const buffer workaround that avoids excessive getter access with far less getter access Part of #3450 --- src/common/InputHandler.ts | 435 ++++++++++++++++++------------------- 1 file changed, 206 insertions(+), 229 deletions(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index d4354e90..f2f0d0ce 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -20,6 +20,7 @@ import { AttributeData } from 'common/buffer/AttributeData'; import { ICoreService, IBufferService, IOptionsService, ILogService, IDirtyRowService, ICoreMouseService, ICharsetService, IUnicodeService, LogLevelEnum } from 'common/services/Services'; import { OscHandler } from 'common/parser/OscParser'; import { DcsHandler } from 'common/parser/DcsParser'; +import { IBuffer } from 'common/buffer/Types'; /** * Map collect to glevel. Used in `selectCharset`. @@ -234,6 +235,8 @@ export class InputHandler extends Disposable implements IInputHandler { private _curAttrData: IAttributeData = DEFAULT_ATTR_DATA.clone(); private _eraseAttrDataInternal: IAttributeData = DEFAULT_ATTR_DATA.clone(); + private _activeBuffer: IBuffer; + private _onRequestBell = new EventEmitter(); public get onRequestBell(): IEvent { return this._onRequestBell.event; } private _onRequestRefreshRows = new EventEmitter(); @@ -282,6 +285,10 @@ export class InputHandler extends Disposable implements IInputHandler { super(); this.register(this._parser); + // Track properties used in performance critical code manually to avoid using slow getters + this._activeBuffer = this._bufferService.buffer; + this.register(this._bufferService.buffers.onBufferActivate(e => this._activeBuffer = e.activeBuffer)); + /** * custom fallback handlers */ @@ -508,9 +515,8 @@ export class InputHandler extends Disposable implements IInputHandler { */ public parse(data: string | Uint8Array, promiseResult?: boolean): void | Promise { let result: void | Promise; - let buffer = this._bufferService.buffer; - let cursorStartX = buffer.x; - let cursorStartY = buffer.y; + let cursorStartX = this._activeBuffer.x; + let cursorStartY = this._activeBuffer.y; let start = 0; const wasPaused = this._parseStack.paused; @@ -569,8 +575,7 @@ export class InputHandler extends Disposable implements IInputHandler { } } - buffer = this._bufferService.buffer; - if (buffer.x !== cursorStartX || buffer.y !== cursorStartY) { + if (this._activeBuffer.x !== cursorStartX || this._activeBuffer.y !== cursorStartY) { this._onCursorMove.fire(); } @@ -581,20 +586,19 @@ export class InputHandler extends Disposable implements IInputHandler { public print(data: Uint32Array, start: number, end: number): void { let code: number; let chWidth: number; - const buffer = this._bufferService.buffer; const charset = this._charsetService.charset; const screenReaderMode = this._optionsService.options.screenReaderMode; const cols = this._bufferService.cols; const wraparoundMode = this._coreService.decPrivateModes.wraparound; const insertMode = this._coreService.modes.insertMode; const curAttr = this._curAttrData; - let bufferRow = buffer.lines.get(buffer.ybase + buffer.y)!; + let bufferRow = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y)!; - this._dirtyRowService.markDirty(buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); // handle wide chars: reset start_cell-1 if we would overwrite the second cell of a wide char - if (buffer.x && end - start > 0 && bufferRow.getWidth(buffer.x - 1) === 2) { - bufferRow.setCellFromCodePoint(buffer.x - 1, 0, 1, curAttr.fg, curAttr.bg, curAttr.extended); + if (this._activeBuffer.x && end - start > 0 && bufferRow.getWidth(this._activeBuffer.x - 1) === 2) { + bufferRow.setCellFromCodePoint(this._activeBuffer.x - 1, 0, 1, curAttr.fg, curAttr.bg, curAttr.extended); } for (let pos = start; pos < end; ++pos) { @@ -619,17 +623,17 @@ export class InputHandler extends Disposable implements IInputHandler { } // insert combining char at last cursor position - // buffer.x should never be 0 for a combining char + // this._activeBuffer.x should never be 0 for a combining char // since they always follow a cell consuming char - // therefore we can test for buffer.x to avoid overflow left - if (!chWidth && buffer.x) { - if (!bufferRow.getWidth(buffer.x - 1)) { + // therefore we can test for this._activeBuffer.x to avoid overflow left + if (!chWidth && this._activeBuffer.x) { + if (!bufferRow.getWidth(this._activeBuffer.x - 1)) { // found empty cell after fullwidth, need to go 2 cells back // it is save to step 2 cells back here // since an empty cell is only set by fullwidth chars - bufferRow.addCodepointToCell(buffer.x - 2, code); + bufferRow.addCodepointToCell(this._activeBuffer.x - 2, code); } else { - bufferRow.addCodepointToCell(buffer.x - 1, code); + bufferRow.addCodepointToCell(this._activeBuffer.x - 1, code); } continue; } @@ -637,31 +641,31 @@ export class InputHandler extends Disposable implements IInputHandler { // goto next line if ch would overflow // NOTE: To avoid costly width checks here, // the terminal does not allow a cols < 2. - if (buffer.x + chWidth - 1 >= cols) { + if (this._activeBuffer.x + chWidth - 1 >= cols) { // autowrap - DECAWM // automatically wraps to the beginning of the next line if (wraparoundMode) { // clear left over cells to the right - while (buffer.x < cols) { - bufferRow.setCellFromCodePoint(buffer.x++, 0, 1, curAttr.fg, curAttr.bg, curAttr.extended); + while (this._activeBuffer.x < cols) { + bufferRow.setCellFromCodePoint(this._activeBuffer.x++, 0, 1, curAttr.fg, curAttr.bg, curAttr.extended); } - buffer.x = 0; - buffer.y++; - if (buffer.y === buffer.scrollBottom + 1) { - buffer.y--; + this._activeBuffer.x = 0; + this._activeBuffer.y++; + if (this._activeBuffer.y === this._activeBuffer.scrollBottom + 1) { + this._activeBuffer.y--; this._bufferService.scroll(this._eraseAttrData(), true); } else { - if (buffer.y >= this._bufferService.rows) { - buffer.y = this._bufferService.rows - 1; + if (this._activeBuffer.y >= this._bufferService.rows) { + this._activeBuffer.y = this._bufferService.rows - 1; } // The line already exists (eg. the initial viewport), mark it as a // wrapped line - buffer.lines.get(buffer.ybase + buffer.y)!.isWrapped = true; + this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y)!.isWrapped = true; } // row changed, get it again - bufferRow = buffer.lines.get(buffer.ybase + buffer.y)!; + bufferRow = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y)!; } else { - buffer.x = cols - 1; + this._activeBuffer.x = cols - 1; if (chWidth === 2) { // FIXME: check for xterm behavior // What to do here? We got a wide char that does not fit into last cell @@ -673,7 +677,7 @@ export class InputHandler extends Disposable implements IInputHandler { // insert mode: move characters to right if (insertMode) { // right shift cells according to the width - bufferRow.insertCells(buffer.x, chWidth, buffer.getNullCell(curAttr), curAttr); + bufferRow.insertCells(this._activeBuffer.x, chWidth, this._activeBuffer.getNullCell(curAttr), curAttr); // test last cell - since the last cell has only room for // a halfwidth char any fullwidth shifted there is lost // and will be set to empty cell @@ -683,15 +687,15 @@ export class InputHandler extends Disposable implements IInputHandler { } // write current char to buffer and advance cursor - bufferRow.setCellFromCodePoint(buffer.x++, code, chWidth, curAttr.fg, curAttr.bg, curAttr.extended); + bufferRow.setCellFromCodePoint(this._activeBuffer.x++, code, chWidth, curAttr.fg, curAttr.bg, curAttr.extended); // fullwidth char - also set next cell to placeholder stub and advance cursor // for graphemes bigger than fullwidth we can simply loop to zero - // we already made sure above, that buffer.x + chWidth will not overflow right + // we already made sure above, that this._activeBuffer.x + chWidth will not overflow right if (chWidth > 0) { while (--chWidth) { // other than a regular empty cell a cell following a wide char has no width - bufferRow.setCellFromCodePoint(buffer.x++, 0, 0, curAttr.fg, curAttr.bg, curAttr.extended); + bufferRow.setCellFromCodePoint(this._activeBuffer.x++, 0, 0, curAttr.fg, curAttr.bg, curAttr.extended); } } } @@ -700,7 +704,7 @@ export class InputHandler extends Disposable implements IInputHandler { // - fullwidth + surrogates: reset // - combining: only base char gets carried on (bug in xterm?) if (end - start > 0) { - bufferRow.loadCell(buffer.x - 1, this._workCell); + bufferRow.loadCell(this._activeBuffer.x - 1, this._workCell); if (this._workCell.getWidth() === 2 || this._workCell.getCode() > 0xFFFF) { this._parser.precedingCodepoint = 0; } else if (this._workCell.isCombined()) { @@ -711,11 +715,11 @@ export class InputHandler extends Disposable implements IInputHandler { } // handle wide chars: reset cell to the right if it is second cell of a wide char - if (buffer.x < cols && end - start > 0 && bufferRow.getWidth(buffer.x) === 0 && !bufferRow.hasContent(buffer.x)) { - bufferRow.setCellFromCodePoint(buffer.x, 0, 1, curAttr.fg, curAttr.bg, curAttr.extended); + if (this._activeBuffer.x < cols && end - start > 0 && bufferRow.getWidth(this._activeBuffer.x) === 0 && !bufferRow.hasContent(this._activeBuffer.x)) { + bufferRow.setCellFromCodePoint(this._activeBuffer.x, 0, 1, curAttr.fg, curAttr.bg, curAttr.extended); } - this._dirtyRowService.markDirty(buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); } /** @@ -779,25 +783,22 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y C0 FF "Form Feed" "\f, \x0C" "Treated as LF." */ public lineFeed(): boolean { - // make buffer local for faster access - const buffer = this._bufferService.buffer; - - this._dirtyRowService.markDirty(buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); if (this._optionsService.options.convertEol) { - buffer.x = 0; + this._activeBuffer.x = 0; } - buffer.y++; - if (buffer.y === buffer.scrollBottom + 1) { - buffer.y--; + this._activeBuffer.y++; + if (this._activeBuffer.y === this._activeBuffer.scrollBottom + 1) { + this._activeBuffer.y--; this._bufferService.scroll(this._eraseAttrData()); - } else if (buffer.y >= this._bufferService.rows) { - buffer.y = this._bufferService.rows - 1; + } else if (this._activeBuffer.y >= this._bufferService.rows) { + this._activeBuffer.y = this._bufferService.rows - 1; } // If the end of the line is hit, prevent this action from wrapping around to the next line. - if (buffer.x >= this._bufferService.cols) { - buffer.x--; + if (this._activeBuffer.x >= this._bufferService.cols) { + this._activeBuffer.x--; } - this._dirtyRowService.markDirty(buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); this._onLineFeed.fire(); return true; @@ -810,7 +811,7 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y C0 CR "Carriage Return" "\r, \x0D" "Move the cursor to the beginning of the row." */ public carriageReturn(): boolean { - this._bufferService.buffer.x = 0; + this._activeBuffer.x = 0; return true; } @@ -826,13 +827,11 @@ export class InputHandler extends Disposable implements IInputHandler { * with the cursor, thus at the home position (top-leftmost cell) this has no effect. */ public backspace(): boolean { - const buffer = this._bufferService.buffer; - // reverse wrap-around is disabled if (!this._coreService.decPrivateModes.reverseWraparound) { this._restrictCursor(); - if (buffer.x > 0) { - buffer.x--; + if (this._activeBuffer.x > 0) { + this._activeBuffer.x--; } return true; } @@ -842,8 +841,8 @@ export class InputHandler extends Disposable implements IInputHandler { // to be at x=cols to be able to address the last cell of a row by BS this._restrictCursor(this._bufferService.cols); - if (buffer.x > 0) { - buffer.x--; + if (this._activeBuffer.x > 0) { + this._activeBuffer.x--; } else { /** * reverse wrap-around handling: @@ -853,21 +852,21 @@ export class InputHandler extends Disposable implements IInputHandler { * - cannot peek into scrollbuffer * - any cursor movement sequence keeps working as expected */ - if (buffer.x === 0 - && buffer.y > buffer.scrollTop - && buffer.y <= buffer.scrollBottom - && buffer.lines.get(buffer.ybase + buffer.y)?.isWrapped) + if (this._activeBuffer.x === 0 + && this._activeBuffer.y > this._activeBuffer.scrollTop + && this._activeBuffer.y <= this._activeBuffer.scrollBottom + && this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y)?.isWrapped) { - buffer.lines.get(buffer.ybase + buffer.y)!.isWrapped = false; - buffer.y--; - buffer.x = this._bufferService.cols - 1; + this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y)!.isWrapped = false; + this._activeBuffer.y--; + this._activeBuffer.x = this._bufferService.cols - 1; // find last taken cell - last cell can have 3 different states: // - hasContent(true) + hasWidth(1): narrow char - we are done // - hasWidth(0): second part of wide char - we are done // - hasContent(false) + hasWidth(1): empty cell due to early wrapping wide char, go one cell further back - const line = buffer.lines.get(buffer.ybase + buffer.y)!; - if (line.hasWidth(buffer.x) && !line.hasContent(buffer.x)) { - buffer.x--; + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y)!; + if (line.hasWidth(this._activeBuffer.x) && !line.hasContent(this._activeBuffer.x)) { + this._activeBuffer.x--; // We do this only once, since width=1 + hasContent=false currently happens only once before // early wrapping of a wide char. // This needs to be fixed once we support graphemes taking more than 2 cells. @@ -885,13 +884,13 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y C0 HT "Horizontal Tabulation" "\t, \x09" "Move the cursor to the next character tab stop." */ public tab(): boolean { - if (this._bufferService.buffer.x >= this._bufferService.cols) { + if (this._activeBuffer.x >= this._bufferService.cols) { return true; } - const originalX = this._bufferService.buffer.x; - this._bufferService.buffer.x = this._bufferService.buffer.nextStop(); + const originalX = this._activeBuffer.x; + this._activeBuffer.x = this._activeBuffer.nextStop(); if (this._optionsService.options.screenReaderMode) { - this._onA11yTab.fire(this._bufferService.buffer.x - originalX); + this._onA11yTab.fire(this._activeBuffer.x - originalX); } return true; } @@ -924,27 +923,27 @@ export class InputHandler extends Disposable implements IInputHandler { * Restrict cursor to viewport size / scroll margin (origin mode). */ private _restrictCursor(maxCol: number = this._bufferService.cols - 1): void { - this._bufferService.buffer.x = Math.min(maxCol, Math.max(0, this._bufferService.buffer.x)); - this._bufferService.buffer.y = this._coreService.decPrivateModes.origin - ? Math.min(this._bufferService.buffer.scrollBottom, Math.max(this._bufferService.buffer.scrollTop, this._bufferService.buffer.y)) - : Math.min(this._bufferService.rows - 1, Math.max(0, this._bufferService.buffer.y)); - this._dirtyRowService.markDirty(this._bufferService.buffer.y); + this._activeBuffer.x = Math.min(maxCol, Math.max(0, this._activeBuffer.x)); + this._activeBuffer.y = this._coreService.decPrivateModes.origin + ? Math.min(this._activeBuffer.scrollBottom, Math.max(this._activeBuffer.scrollTop, this._activeBuffer.y)) + : Math.min(this._bufferService.rows - 1, Math.max(0, this._activeBuffer.y)); + this._dirtyRowService.markDirty(this._activeBuffer.y); } /** * Set absolute cursor position. */ private _setCursor(x: number, y: number): void { - this._dirtyRowService.markDirty(this._bufferService.buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); if (this._coreService.decPrivateModes.origin) { - this._bufferService.buffer.x = x; - this._bufferService.buffer.y = this._bufferService.buffer.scrollTop + y; + this._activeBuffer.x = x; + this._activeBuffer.y = this._activeBuffer.scrollTop + y; } else { - this._bufferService.buffer.x = x; - this._bufferService.buffer.y = y; + this._activeBuffer.x = x; + this._activeBuffer.y = y; } this._restrictCursor(); - this._dirtyRowService.markDirty(this._bufferService.buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); } /** @@ -954,7 +953,7 @@ export class InputHandler extends Disposable implements IInputHandler { // for relative changes we have to make sure we are within 0 .. cols/rows - 1 // before calculating the new position this._restrictCursor(); - this._setCursor(this._bufferService.buffer.x + x, this._bufferService.buffer.y + y); + this._setCursor(this._activeBuffer.x + x, this._activeBuffer.y + y); } /** @@ -966,7 +965,7 @@ export class InputHandler extends Disposable implements IInputHandler { */ public cursorUp(params: IParams): boolean { // stop at scrollTop - const diffToTop = this._bufferService.buffer.y - this._bufferService.buffer.scrollTop; + const diffToTop = this._activeBuffer.y - this._activeBuffer.scrollTop; if (diffToTop >= 0) { this._moveCursor(0, -Math.min(diffToTop, params.params[0] || 1)); } else { @@ -984,7 +983,7 @@ export class InputHandler extends Disposable implements IInputHandler { */ public cursorDown(params: IParams): boolean { // stop at scrollBottom - const diffToBottom = this._bufferService.buffer.scrollBottom - this._bufferService.buffer.y; + const diffToBottom = this._activeBuffer.scrollBottom - this._activeBuffer.y; if (diffToBottom >= 0) { this._moveCursor(0, Math.min(diffToBottom, params.params[0] || 1)); } else { @@ -1025,7 +1024,7 @@ export class InputHandler extends Disposable implements IInputHandler { */ public cursorNextLine(params: IParams): boolean { this.cursorDown(params); - this._bufferService.buffer.x = 0; + this._activeBuffer.x = 0; return true; } @@ -1039,7 +1038,7 @@ export class InputHandler extends Disposable implements IInputHandler { */ public cursorPrecedingLine(params: IParams): boolean { this.cursorUp(params); - this._bufferService.buffer.x = 0; + this._activeBuffer.x = 0; return true; } @@ -1050,7 +1049,7 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y CSI CHA "Cursor Horizontal Absolute" "CSI Ps G" "Move cursor to `Ps`-th column of the active row (default=1)." */ public cursorCharAbsolute(params: IParams): boolean { - this._setCursor((params.params[0] || 1) - 1, this._bufferService.buffer.y); + this._setCursor((params.params[0] || 1) - 1, this._activeBuffer.y); return true; } @@ -1081,7 +1080,7 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y CSI HPA "Horizontal Position Absolute" "CSI Ps ` " "Same as CHA." */ public charPosAbsolute(params: IParams): boolean { - this._setCursor((params.params[0] || 1) - 1, this._bufferService.buffer.y); + this._setCursor((params.params[0] || 1) - 1, this._activeBuffer.y); return true; } @@ -1103,7 +1102,7 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y CSI VPA "Vertical Position Absolute" "CSI Ps d" "Move cursor to `Ps`-th row (default=1)." */ public linePosAbsolute(params: IParams): boolean { - this._setCursor(this._bufferService.buffer.x, (params.params[0] || 1) - 1); + this._setCursor(this._activeBuffer.x, (params.params[0] || 1) - 1); return true; } @@ -1146,9 +1145,9 @@ export class InputHandler extends Disposable implements IInputHandler { public tabClear(params: IParams): boolean { const param = params.params[0]; if (param === 0) { - delete this._bufferService.buffer.tabs[this._bufferService.buffer.x]; + delete this._activeBuffer.tabs[this._activeBuffer.x]; } else if (param === 3) { - this._bufferService.buffer.tabs = {}; + this._activeBuffer.tabs = {}; } return true; } @@ -1160,12 +1159,12 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y CSI CHT "Cursor Horizontal Tabulation" "CSI Ps I" "Move cursor `Ps` times tabs forward (default=1)." */ public cursorForwardTab(params: IParams): boolean { - if (this._bufferService.buffer.x >= this._bufferService.cols) { + if (this._activeBuffer.x >= this._bufferService.cols) { return true; } let param = params.params[0] || 1; while (param--) { - this._bufferService.buffer.x = this._bufferService.buffer.nextStop(); + this._activeBuffer.x = this._activeBuffer.nextStop(); } return true; } @@ -1176,16 +1175,13 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y CSI CBT "Cursor Backward Tabulation" "CSI Ps Z" "Move cursor `Ps` tabs backward (default=1)." */ public cursorBackwardTab(params: IParams): boolean { - if (this._bufferService.buffer.x >= this._bufferService.cols) { + if (this._activeBuffer.x >= this._bufferService.cols) { return true; } let param = params.params[0] || 1; - // make buffer local for faster access - const buffer = this._bufferService.buffer; - while (param--) { - buffer.x = buffer.prevStop(); + this._activeBuffer.x = this._activeBuffer.prevStop(); } return true; } @@ -1199,11 +1195,11 @@ export class InputHandler extends Disposable implements IInputHandler { * @param end end - 1 is last erased cell */ private _eraseInBufferLine(y: number, start: number, end: number, clearWrap: boolean = false): void { - const line = this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase + y)!; + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + y)!; line.replaceCells( start, end, - this._bufferService.buffer.getNullCell(this._eraseAttrData()), + this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData() ); if (clearWrap) { @@ -1217,8 +1213,8 @@ export class InputHandler extends Disposable implements IInputHandler { * @param y row index */ private _resetBufferLine(y: number): void { - const line = this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase + y)!; - line.fill(this._bufferService.buffer.getNullCell(this._eraseAttrData())); + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + y)!; + line.fill(this._activeBuffer.getNullCell(this._eraseAttrData())); line.isWrapped = false; } @@ -1251,22 +1247,22 @@ export class InputHandler extends Disposable implements IInputHandler { let j; switch (params.params[0]) { case 0: - j = this._bufferService.buffer.y; + j = this._activeBuffer.y; this._dirtyRowService.markDirty(j); - this._eraseInBufferLine(j++, this._bufferService.buffer.x, this._bufferService.cols, this._bufferService.buffer.x === 0); + this._eraseInBufferLine(j++, this._activeBuffer.x, this._bufferService.cols, this._activeBuffer.x === 0); for (; j < this._bufferService.rows; j++) { this._resetBufferLine(j); } this._dirtyRowService.markDirty(j); break; case 1: - j = this._bufferService.buffer.y; + j = this._activeBuffer.y; this._dirtyRowService.markDirty(j); // Deleted front part of line and everything before. This line will no longer be wrapped. - this._eraseInBufferLine(j, 0, this._bufferService.buffer.x + 1, true); - if (this._bufferService.buffer.x + 1 >= this._bufferService.cols) { + this._eraseInBufferLine(j, 0, this._activeBuffer.x + 1, true); + if (this._activeBuffer.x + 1 >= this._bufferService.cols) { // Deleted entire previous line. This next line can no longer be wrapped. - this._bufferService.buffer.lines.get(j + 1)!.isWrapped = false; + this._activeBuffer.lines.get(j + 1)!.isWrapped = false; } while (j--) { this._resetBufferLine(j); @@ -1283,11 +1279,11 @@ export class InputHandler extends Disposable implements IInputHandler { break; case 3: // Clear scrollback (everything not in viewport) - const scrollBackSize = this._bufferService.buffer.lines.length - this._bufferService.rows; + const scrollBackSize = this._activeBuffer.lines.length - this._bufferService.rows; if (scrollBackSize > 0) { - this._bufferService.buffer.lines.trimStart(scrollBackSize); - this._bufferService.buffer.ybase = Math.max(this._bufferService.buffer.ybase - scrollBackSize, 0); - this._bufferService.buffer.ydisp = Math.max(this._bufferService.buffer.ydisp - scrollBackSize, 0); + this._activeBuffer.lines.trimStart(scrollBackSize); + this._activeBuffer.ybase = Math.max(this._activeBuffer.ybase - scrollBackSize, 0); + this._activeBuffer.ydisp = Math.max(this._activeBuffer.ydisp - scrollBackSize, 0); // Force a scroll event to refresh viewport this._onScroll.fire(0); } @@ -1322,16 +1318,16 @@ export class InputHandler extends Disposable implements IInputHandler { this._restrictCursor(this._bufferService.cols); switch (params.params[0]) { case 0: - this._eraseInBufferLine(this._bufferService.buffer.y, this._bufferService.buffer.x, this._bufferService.cols); + this._eraseInBufferLine(this._activeBuffer.y, this._activeBuffer.x, this._bufferService.cols); break; case 1: - this._eraseInBufferLine(this._bufferService.buffer.y, 0, this._bufferService.buffer.x + 1); + this._eraseInBufferLine(this._activeBuffer.y, 0, this._activeBuffer.x + 1); break; case 2: - this._eraseInBufferLine(this._bufferService.buffer.y, 0, this._bufferService.cols); + this._eraseInBufferLine(this._activeBuffer.y, 0, this._bufferService.cols); break; } - this._dirtyRowService.markDirty(this._bufferService.buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); return true; } @@ -1348,26 +1344,23 @@ export class InputHandler extends Disposable implements IInputHandler { this._restrictCursor(); let param = params.params[0] || 1; - // make buffer local for faster access - const buffer = this._bufferService.buffer; - - if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) { + if (this._activeBuffer.y > this._activeBuffer.scrollBottom || this._activeBuffer.y < this._activeBuffer.scrollTop) { return true; } - const row: number = buffer.ybase + buffer.y; + const row: number = this._activeBuffer.ybase + this._activeBuffer.y; - const scrollBottomRowsOffset = this._bufferService.rows - 1 - buffer.scrollBottom; - const scrollBottomAbsolute = this._bufferService.rows - 1 + buffer.ybase - scrollBottomRowsOffset + 1; + const scrollBottomRowsOffset = this._bufferService.rows - 1 - this._activeBuffer.scrollBottom; + const scrollBottomAbsolute = this._bufferService.rows - 1 + this._activeBuffer.ybase - scrollBottomRowsOffset + 1; while (param--) { // test: echo -e '\e[44m\e[1L\e[0m' // blankLine(true) - xterm/linux behavior - buffer.lines.splice(scrollBottomAbsolute - 1, 1); - buffer.lines.splice(row, 0, buffer.getBlankLine(this._eraseAttrData())); + this._activeBuffer.lines.splice(scrollBottomAbsolute - 1, 1); + this._activeBuffer.lines.splice(row, 0, this._activeBuffer.getBlankLine(this._eraseAttrData())); } - this._dirtyRowService.markRangeDirty(buffer.y, buffer.scrollBottom); - buffer.x = 0; // see https://vt100.net/docs/vt220-rm/chapter4.html - vt220 only? + this._dirtyRowService.markRangeDirty(this._activeBuffer.y, this._activeBuffer.scrollBottom); + this._activeBuffer.x = 0; // see https://vt100.net/docs/vt220-rm/chapter4.html - vt220 only? return true; } @@ -1384,27 +1377,24 @@ export class InputHandler extends Disposable implements IInputHandler { this._restrictCursor(); let param = params.params[0] || 1; - // make buffer local for faster access - const buffer = this._bufferService.buffer; - - if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) { + if (this._activeBuffer.y > this._activeBuffer.scrollBottom || this._activeBuffer.y < this._activeBuffer.scrollTop) { return true; } - const row: number = buffer.ybase + buffer.y; + const row: number = this._activeBuffer.ybase + this._activeBuffer.y; let j: number; - j = this._bufferService.rows - 1 - buffer.scrollBottom; - j = this._bufferService.rows - 1 + buffer.ybase - j; + j = this._bufferService.rows - 1 - this._activeBuffer.scrollBottom; + j = this._bufferService.rows - 1 + this._activeBuffer.ybase - j; while (param--) { // test: echo -e '\e[44m\e[1M\e[0m' // blankLine(true) - xterm/linux behavior - buffer.lines.splice(row, 1); - buffer.lines.splice(j, 0, buffer.getBlankLine(this._eraseAttrData())); + this._activeBuffer.lines.splice(row, 1); + this._activeBuffer.lines.splice(j, 0, this._activeBuffer.getBlankLine(this._eraseAttrData())); } - this._dirtyRowService.markRangeDirty(buffer.y, buffer.scrollBottom); - buffer.x = 0; // see https://vt100.net/docs/vt220-rm/chapter4.html - vt220 only? + this._dirtyRowService.markRangeDirty(this._activeBuffer.y, this._activeBuffer.scrollBottom); + this._activeBuffer.x = 0; // see https://vt100.net/docs/vt220-rm/chapter4.html - vt220 only? return true; } @@ -1421,15 +1411,15 @@ export class InputHandler extends Disposable implements IInputHandler { */ public insertChars(params: IParams): boolean { this._restrictCursor(); - const line = this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase + this._bufferService.buffer.y); + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y); if (line) { line.insertCells( - this._bufferService.buffer.x, + this._activeBuffer.x, params.params[0] || 1, - this._bufferService.buffer.getNullCell(this._eraseAttrData()), + this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData() ); - this._dirtyRowService.markDirty(this._bufferService.buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); } return true; } @@ -1447,15 +1437,15 @@ export class InputHandler extends Disposable implements IInputHandler { */ public deleteChars(params: IParams): boolean { this._restrictCursor(); - const line = this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase + this._bufferService.buffer.y); + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y); if (line) { line.deleteCells( - this._bufferService.buffer.x, + this._activeBuffer.x, params.params[0] || 1, - this._bufferService.buffer.getNullCell(this._eraseAttrData()), + this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData() ); - this._dirtyRowService.markDirty(this._bufferService.buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); } return true; } @@ -1471,14 +1461,11 @@ export class InputHandler extends Disposable implements IInputHandler { public scrollUp(params: IParams): boolean { let param = params.params[0] || 1; - // make buffer local for faster access - const buffer = this._bufferService.buffer; - while (param--) { - buffer.lines.splice(buffer.ybase + buffer.scrollTop, 1); - buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 0, buffer.getBlankLine(this._eraseAttrData())); + this._activeBuffer.lines.splice(this._activeBuffer.ybase + this._activeBuffer.scrollTop, 1); + this._activeBuffer.lines.splice(this._activeBuffer.ybase + this._activeBuffer.scrollBottom, 0, this._activeBuffer.getBlankLine(this._eraseAttrData())); } - this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop, this._activeBuffer.scrollBottom); return true; } @@ -1490,14 +1477,11 @@ export class InputHandler extends Disposable implements IInputHandler { public scrollDown(params: IParams): boolean { let param = params.params[0] || 1; - // make buffer local for faster access - const buffer = this._bufferService.buffer; - while (param--) { - buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 1); - buffer.lines.splice(buffer.ybase + buffer.scrollTop, 0, buffer.getBlankLine(DEFAULT_ATTR_DATA)); + this._activeBuffer.lines.splice(this._activeBuffer.ybase + this._activeBuffer.scrollBottom, 1); + this._activeBuffer.lines.splice(this._activeBuffer.ybase + this._activeBuffer.scrollTop, 0, this._activeBuffer.getBlankLine(DEFAULT_ATTR_DATA)); } - this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop, this._activeBuffer.scrollBottom); return true; } @@ -1520,17 +1504,16 @@ export class InputHandler extends Disposable implements IInputHandler { * SL has no effect outside of the scroll margins. */ public scrollLeft(params: IParams): boolean { - const buffer = this._bufferService.buffer; - if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) { + if (this._activeBuffer.y > this._activeBuffer.scrollBottom || this._activeBuffer.y < this._activeBuffer.scrollTop) { return true; } const param = params.params[0] || 1; - for (let y = buffer.scrollTop; y <= buffer.scrollBottom; ++y) { - const line = buffer.lines.get(buffer.ybase + y)!; - line.deleteCells(0, param, buffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()); + for (let y = this._activeBuffer.scrollTop; y <= this._activeBuffer.scrollBottom; ++y) { + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + y)!; + line.deleteCells(0, param, this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()); line.isWrapped = false; } - this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop, this._activeBuffer.scrollBottom); return true; } @@ -1554,17 +1537,16 @@ export class InputHandler extends Disposable implements IInputHandler { * SL has no effect outside of the scroll margins. */ public scrollRight(params: IParams): boolean { - const buffer = this._bufferService.buffer; - if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) { + if (this._activeBuffer.y > this._activeBuffer.scrollBottom || this._activeBuffer.y < this._activeBuffer.scrollTop) { return true; } const param = params.params[0] || 1; - for (let y = buffer.scrollTop; y <= buffer.scrollBottom; ++y) { - const line = buffer.lines.get(buffer.ybase + y)!; - line.insertCells(0, param, buffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()); + for (let y = this._activeBuffer.scrollTop; y <= this._activeBuffer.scrollBottom; ++y) { + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + y)!; + line.insertCells(0, param, this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()); line.isWrapped = false; } - this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop, this._activeBuffer.scrollBottom); return true; } @@ -1578,17 +1560,16 @@ export class InputHandler extends Disposable implements IInputHandler { * DECIC has no effect outside the scrolling margins. */ public insertColumns(params: IParams): boolean { - const buffer = this._bufferService.buffer; - if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) { + if (this._activeBuffer.y > this._activeBuffer.scrollBottom || this._activeBuffer.y < this._activeBuffer.scrollTop) { return true; } const param = params.params[0] || 1; - for (let y = buffer.scrollTop; y <= buffer.scrollBottom; ++y) { - const line = this._bufferService.buffer.lines.get(buffer.ybase + y)!; - line.insertCells(buffer.x, param, buffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()); + for (let y = this._activeBuffer.scrollTop; y <= this._activeBuffer.scrollBottom; ++y) { + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + y)!; + line.insertCells(this._activeBuffer.x, param, this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()); line.isWrapped = false; } - this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop, this._activeBuffer.scrollBottom); return true; } @@ -1602,17 +1583,16 @@ export class InputHandler extends Disposable implements IInputHandler { * DECDC has no effect outside the scrolling margins. */ public deleteColumns(params: IParams): boolean { - const buffer = this._bufferService.buffer; - if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) { + if (this._activeBuffer.y > this._activeBuffer.scrollBottom || this._activeBuffer.y < this._activeBuffer.scrollTop) { return true; } const param = params.params[0] || 1; - for (let y = buffer.scrollTop; y <= buffer.scrollBottom; ++y) { - const line = buffer.lines.get(buffer.ybase + y)!; - line.deleteCells(buffer.x, param, buffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()); + for (let y = this._activeBuffer.scrollTop; y <= this._activeBuffer.scrollBottom; ++y) { + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + y)!; + line.deleteCells(this._activeBuffer.x, param, this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()); line.isWrapped = false; } - this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop, this._activeBuffer.scrollBottom); return true; } @@ -1626,15 +1606,15 @@ export class InputHandler extends Disposable implements IInputHandler { */ public eraseChars(params: IParams): boolean { this._restrictCursor(); - const line = this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase + this._bufferService.buffer.y); + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y); if (line) { line.replaceCells( - this._bufferService.buffer.x, - this._bufferService.buffer.x + (params.params[0] || 1), - this._bufferService.buffer.getNullCell(this._eraseAttrData()), + this._activeBuffer.x, + this._activeBuffer.x + (params.params[0] || 1), + this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData() ); - this._dirtyRowService.markDirty(this._bufferService.buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); } return true; } @@ -2570,8 +2550,8 @@ export class InputHandler extends Disposable implements IInputHandler { break; case 6: // cursor position - const y = this._bufferService.buffer.y + 1; - const x = this._bufferService.buffer.x + 1; + const y = this._activeBuffer.y + 1; + const x = this._activeBuffer.x + 1; this._coreService.triggerDataEvent(`${C0.ESC}[${y};${x}R`); break; } @@ -2585,8 +2565,8 @@ export class InputHandler extends Disposable implements IInputHandler { switch (params.params[0]) { case 6: // cursor position - const y = this._bufferService.buffer.y + 1; - const x = this._bufferService.buffer.x + 1; + const y = this._activeBuffer.y + 1; + const x = this._activeBuffer.x + 1; this._coreService.triggerDataEvent(`${C0.ESC}[?${y};${x}R`); break; case 15: @@ -2631,18 +2611,18 @@ export class InputHandler extends Disposable implements IInputHandler { public softReset(params: IParams): boolean { this._coreService.isCursorHidden = false; this._onRequestSyncScrollBar.fire(); - this._bufferService.buffer.scrollTop = 0; - this._bufferService.buffer.scrollBottom = this._bufferService.rows - 1; + this._activeBuffer.scrollTop = 0; + this._activeBuffer.scrollBottom = this._bufferService.rows - 1; this._curAttrData = DEFAULT_ATTR_DATA.clone(); this._coreService.reset(); this._charsetService.reset(); // reset DECSC data - this._bufferService.buffer.savedX = 0; - this._bufferService.buffer.savedY = this._bufferService.buffer.ybase; - this._bufferService.buffer.savedCurAttrData.fg = this._curAttrData.fg; - this._bufferService.buffer.savedCurAttrData.bg = this._curAttrData.bg; - this._bufferService.buffer.savedCharset = this._charsetService.charset; + this._activeBuffer.savedX = 0; + this._activeBuffer.savedY = this._activeBuffer.ybase; + this._activeBuffer.savedCurAttrData.fg = this._curAttrData.fg; + this._activeBuffer.savedCurAttrData.bg = this._curAttrData.bg; + this._activeBuffer.savedCharset = this._charsetService.charset; // reset DECOM this._coreService.decPrivateModes.origin = false; @@ -2705,8 +2685,8 @@ export class InputHandler extends Disposable implements IInputHandler { } if (bottom > top) { - this._bufferService.buffer.scrollTop = top - 1; - this._bufferService.buffer.scrollBottom = bottom - 1; + this._activeBuffer.scrollTop = top - 1; + this._activeBuffer.scrollBottom = bottom - 1; this._setCursor(0, 0); } return true; @@ -2801,11 +2781,11 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y ESC SC "Save Cursor" "ESC 7" "Save cursor position, charmap and text attributes." */ public saveCursor(params?: IParams): boolean { - this._bufferService.buffer.savedX = this._bufferService.buffer.x; - this._bufferService.buffer.savedY = this._bufferService.buffer.ybase + this._bufferService.buffer.y; - this._bufferService.buffer.savedCurAttrData.fg = this._curAttrData.fg; - this._bufferService.buffer.savedCurAttrData.bg = this._curAttrData.bg; - this._bufferService.buffer.savedCharset = this._charsetService.charset; + this._activeBuffer.savedX = this._activeBuffer.x; + this._activeBuffer.savedY = this._activeBuffer.ybase + this._activeBuffer.y; + this._activeBuffer.savedCurAttrData.fg = this._curAttrData.fg; + this._activeBuffer.savedCurAttrData.bg = this._curAttrData.bg; + this._activeBuffer.savedCharset = this._charsetService.charset; return true; } @@ -2819,13 +2799,13 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y ESC RC "Restore Cursor" "ESC 8" "Restore cursor position, charmap and text attributes." */ public restoreCursor(params?: IParams): boolean { - this._bufferService.buffer.x = this._bufferService.buffer.savedX || 0; - this._bufferService.buffer.y = Math.max(this._bufferService.buffer.savedY - this._bufferService.buffer.ybase, 0); - this._curAttrData.fg = this._bufferService.buffer.savedCurAttrData.fg; - this._curAttrData.bg = this._bufferService.buffer.savedCurAttrData.bg; + this._activeBuffer.x = this._activeBuffer.savedX || 0; + this._activeBuffer.y = Math.max(this._activeBuffer.savedY - this._activeBuffer.ybase, 0); + this._curAttrData.fg = this._activeBuffer.savedCurAttrData.fg; + this._curAttrData.bg = this._activeBuffer.savedCurAttrData.bg; this._charsetService.charset = (this as any)._savedCharset; - if (this._bufferService.buffer.savedCharset) { - this._charsetService.charset = this._bufferService.buffer.savedCharset; + if (this._activeBuffer.savedCharset) { + this._charsetService.charset = this._activeBuffer.savedCharset; } this._restrictCursor(); return true; @@ -2907,7 +2887,7 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y ESC NEL "Next Line" "ESC E" "Move the cursor to the beginning of the next row." */ public nextLine(): boolean { - this._bufferService.buffer.x = 0; + this._activeBuffer.x = 0; this.index(); return true; } @@ -2987,13 +2967,12 @@ export class InputHandler extends Disposable implements IInputHandler { */ public index(): boolean { this._restrictCursor(); - const buffer = this._bufferService.buffer; - this._bufferService.buffer.y++; - if (buffer.y === buffer.scrollBottom + 1) { - buffer.y--; + this._activeBuffer.y++; + if (this._activeBuffer.y === this._activeBuffer.scrollBottom + 1) { + this._activeBuffer.y--; this._bufferService.scroll(this._eraseAttrData()); - } else if (buffer.y >= this._bufferService.rows) { - buffer.y = this._bufferService.rows - 1; + } else if (this._activeBuffer.y >= this._bufferService.rows) { + this._activeBuffer.y = this._bufferService.rows - 1; } this._restrictCursor(); return true; @@ -3010,7 +2989,7 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y ESC HTS "Horizontal Tabulation Set" "ESC H" "Places a tab stop at the current cursor position." */ public tabSet(): boolean { - this._bufferService.buffer.tabs[this._bufferService.buffer.x] = true; + this._activeBuffer.tabs[this._activeBuffer.x] = true; return true; } @@ -3025,17 +3004,16 @@ export class InputHandler extends Disposable implements IInputHandler { */ public reverseIndex(): boolean { this._restrictCursor(); - const buffer = this._bufferService.buffer; - if (buffer.y === buffer.scrollTop) { + if (this._activeBuffer.y === this._activeBuffer.scrollTop) { // possibly move the code below to term.reverseScroll(); // test: echo -ne '\e[1;1H\e[44m\eM\e[0m' // blankLine(true) is xterm/linux behavior - const scrollRegionHeight = buffer.scrollBottom - buffer.scrollTop; - buffer.lines.shiftElements(buffer.ybase + buffer.y, scrollRegionHeight, 1); - buffer.lines.set(buffer.ybase + buffer.y, buffer.getBlankLine(this._eraseAttrData())); - this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + const scrollRegionHeight = this._activeBuffer.scrollBottom - this._activeBuffer.scrollTop; + this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase + this._activeBuffer.y, scrollRegionHeight, 1); + this._activeBuffer.lines.set(this._activeBuffer.ybase + this._activeBuffer.y, this._activeBuffer.getBlankLine(this._eraseAttrData())); + this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop, this._activeBuffer.scrollBottom); } else { - buffer.y--; + this._activeBuffer.y--; this._restrictCursor(); // quickfix to not run out of bounds } return true; @@ -3096,12 +3074,11 @@ export class InputHandler extends Disposable implements IInputHandler { cell.fg = this._curAttrData.fg; cell.bg = this._curAttrData.bg; - const buffer = this._bufferService.buffer; this._setCursor(0, 0); for (let yOffset = 0; yOffset < this._bufferService.rows; ++yOffset) { - const row = buffer.ybase + buffer.y + yOffset; - const line = buffer.lines.get(row); + const row = this._activeBuffer.ybase + this._activeBuffer.y + yOffset; + const line = this._activeBuffer.lines.get(row); if (line) { line.fill(cell); line.isWrapped = false; From aa046b73fb1bb269023aaabf3d2b4c93adf8b049 Mon Sep 17 00:00:00 2001 From: Simon Lamon Date: Wed, 1 Sep 2021 13:34:27 +0000 Subject: [PATCH 359/377] Handle undefined rows or cols better --- src/common/services/BufferService.ts | 4 ++-- src/common/services/OptionsService.test.ts | 14 ++++++++++++-- src/common/services/OptionsService.ts | 9 +++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/common/services/BufferService.ts b/src/common/services/BufferService.ts index 99594d22..c8c5f273 100644 --- a/src/common/services/BufferService.ts +++ b/src/common/services/BufferService.ts @@ -36,8 +36,8 @@ export class BufferService extends Disposable implements IBufferService { @IOptionsService private _optionsService: IOptionsService ) { super(); - this.cols = Math.max(_optionsService.options.cols, MINIMUM_COLS); - this.rows = Math.max(_optionsService.options.rows, MINIMUM_ROWS); + this.cols = Math.max(_optionsService.options.cols || 0, MINIMUM_COLS); + this.rows = Math.max(_optionsService.options.rows || 0, MINIMUM_ROWS); this.buffers = new BufferSet(_optionsService, this); } diff --git a/src/common/services/OptionsService.test.ts b/src/common/services/OptionsService.test.ts index c289b5be..e140b5b4 100644 --- a/src/common/services/OptionsService.test.ts +++ b/src/common/services/OptionsService.test.ts @@ -10,13 +10,23 @@ describe('OptionsService', () => { describe('constructor', () => { const originalError = console.error; beforeEach(() => { - console.error = () => {}; + console.error = () => { }; }); afterEach(() => { console.error = originalError; }); + it('uses default value if invalid constructor option values passed for cols/rows', () => { + const optionsService = new OptionsService({ cols: undefined, rows: undefined }); + assert.equal(optionsService.getOption('rows'), DEFAULT_OPTIONS.rows); + assert.equal(optionsService.getOption('cols'), DEFAULT_OPTIONS.cols); + }); + it('uses values from constructor option values if correctly passed', () => { + const optionsService = new OptionsService({ cols: 80, rows: 25 }); + assert.equal(optionsService.getOption('rows'), 25); + assert.equal(optionsService.getOption('cols'), 80); + }); it('uses default value if invalid constructor option value passed', () => { - assert.equal(new OptionsService({tabStopWidth: 0}).getOption('tabStopWidth'), DEFAULT_OPTIONS.tabStopWidth); + assert.equal(new OptionsService({ tabStopWidth: 0 }).getOption('tabStopWidth'), DEFAULT_OPTIONS.tabStopWidth); }); }); describe('setOption', () => { diff --git a/src/common/services/OptionsService.ts b/src/common/services/OptionsService.ts index 5add8283..d7ac1411 100644 --- a/src/common/services/OptionsService.ts +++ b/src/common/services/OptionsService.ts @@ -22,7 +22,7 @@ export const DEFAULT_OPTIONS: ITerminalOptions = Object.freeze({ cursorStyle: 'block', cursorWidth: 1, customGlyphs: true, - bellSound: DEFAULT_BELL_SOUND, + bellSound: DEFAULT_BELL_SOUND, bellStyle: 'none', drawBoldTextInBrightColors: true, fastScrollModifier: 'alt', @@ -128,7 +128,7 @@ export class OptionsService implements IOptionsService { break; case 'cursorWidth': value = Math.floor(value); - // Fall through for bounds check + // Fall through for bounds check case 'lineHeight': case 'tabStopWidth': if (value < 1) { @@ -149,6 +149,11 @@ export class OptionsService implements IOptionsService { if (value <= 0) { throw new Error(`${key} cannot be less than or equal to 0, value: ${value}`); } + case 'rows': + case 'cols': + if (!value && value !== 0) { + throw new Error(`${key} must be numeric, value: ${value}`); + } break; } return value; From ffef3dba002e91ecac6b0d6a888fac1076cc7279 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 1 Sep 2021 06:41:10 -0700 Subject: [PATCH 360/377] Avoid property use and float->number conversion --- src/browser/Viewport.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index 9ce14daf..fecad811 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -8,6 +8,8 @@ import { addDisposableDomListener } from 'browser/Lifecycle'; import { IColorSet, IViewport } from 'browser/Types'; import { ICharSizeService, IRenderService } from 'browser/services/Services'; import { IBufferService, IOptionsService } from 'common/services/Services'; +import { IBuffer } from 'common/buffer/Types'; +import { IRenderDimensions } from 'browser/renderer/Types'; const FALLBACK_SCROLL_BAR_WIDTH = 15; @@ -18,12 +20,15 @@ const FALLBACK_SCROLL_BAR_WIDTH = 15; export class Viewport extends Disposable implements IViewport { public scrollBarWidth: number = 0; private _currentRowHeight: number = 0; + private _currentScaledCellHeight: number = 0; private _lastRecordedBufferLength: number = 0; private _lastRecordedViewportHeight: number = 0; private _lastRecordedBufferHeight: number = 0; private _lastTouchY: number = 0; private _lastScrollTop: number = 0; private _lastHadScrollBar: boolean = false; + private _activeBuffer: IBuffer; + private _renderDimensions: IRenderDimensions; // Stores a partial line amount when scrolling, this is used to keep track of how much of a line // is scrolled so we can "scroll" over partial lines and feel natural on touchpads. This is a @@ -51,6 +56,12 @@ export class Viewport extends Disposable implements IViewport { this._lastHadScrollBar = true; this.register(addDisposableDomListener(this._viewportElement, 'scroll', this._onScroll.bind(this))); + // Track properties used in performance critical code manually to avoid using slow getters + this._activeBuffer = this._bufferService.buffer; + this.register(this._bufferService.buffers.onBufferActivate(e => this._activeBuffer = e.activeBuffer)); + this._renderDimensions = this._renderService.dimensions; + this.register(this._renderService.onDimensionsChange(e => this._renderDimensions = e)); + // Perform this async to ensure the ICharSizeService is ready. setTimeout(() => this.syncScrollArea(), 0); } @@ -79,6 +90,7 @@ export class Viewport extends Disposable implements IViewport { private _innerRefresh(): void { if (this._charSizeService.height > 0) { this._currentRowHeight = this._renderService.dimensions.scaledCellHeight / window.devicePixelRatio; + this._currentScaledCellHeight = this._renderService.dimensions.scaledCellHeight; this._lastRecordedViewportHeight = this._viewportElement.offsetHeight; const newBufferHeight = Math.round(this._currentRowHeight * this._lastRecordedBufferLength) + (this._lastRecordedViewportHeight - this._renderService.dimensions.canvasHeight); if (this._lastRecordedBufferHeight !== newBufferHeight) { @@ -126,8 +138,7 @@ export class Viewport extends Disposable implements IViewport { } // If the buffer position doesn't match last scroll top - const newScrollTop = this._bufferService.buffer.ydisp * this._currentRowHeight; - if (this._lastScrollTop !== newScrollTop) { + if (this._lastScrollTop !== this._activeBuffer.ydisp * this._currentRowHeight) { this._refresh(immediate); return; } @@ -139,7 +150,7 @@ export class Viewport extends Disposable implements IViewport { } // If row height changed - if (this._renderService.dimensions.scaledCellHeight / window.devicePixelRatio !== this._currentRowHeight) { + if (this._renderDimensions.scaledCellHeight !== this._currentScaledCellHeight) { this._refresh(immediate); return; } From 263c6d75bfccc34c0e926d44f9e79ab533b20bfd Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 1 Sep 2021 06:44:34 -0700 Subject: [PATCH 361/377] Avoid scrollTop call in hot code This seems to have been added in f6d5abf but it's not clear why, scroll APIs seem to work fine without it and using a DOM API here is causing slowness --- src/browser/Viewport.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index fecad811..3c9bea4c 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -143,12 +143,6 @@ export class Viewport extends Disposable implements IViewport { return; } - // If element's scroll top changed, this can happen when hiding the element - if (this._lastScrollTop !== this._viewportElement.scrollTop) { - this._refresh(immediate); - return; - } - // If row height changed if (this._renderDimensions.scaledCellHeight !== this._currentScaledCellHeight) { this._refresh(immediate); From 3c8f600c572f16b63008e9d1bb6f56bf13325fdd Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 1 Sep 2021 11:27:14 -0700 Subject: [PATCH 362/377] fix #3348 --- addons/xterm-addon-webgl/src/WebglRenderer.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index 75b6230c..a3b8ddef 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -108,7 +108,9 @@ export class WebglRenderer extends Disposable implements IRenderer { for (const l of this._renderLayers) { l.dispose(); } - this._core.screenElement!.removeChild(this._canvas); + if (this._canvas.parentNode) { + this._core.screenElement?.removeChild(this._canvas); + } super.dispose(); } From 199e477349f8c5be149b1c9b57d23624ab1b65d6 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 1 Sep 2021 13:45:49 -0700 Subject: [PATCH 363/377] 3 -> 1 line --- addons/xterm-addon-webgl/src/WebglRenderer.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index a3b8ddef..9d8bde79 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -108,9 +108,7 @@ export class WebglRenderer extends Disposable implements IRenderer { for (const l of this._renderLayers) { l.dispose(); } - if (this._canvas.parentNode) { - this._core.screenElement?.removeChild(this._canvas); - } + this._canvas.parentElement?.removeChild(this._canvas); super.dispose(); } From 453688a555b9589666c161b69e5167235d9c4b8a Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 2 Sep 2021 06:26:31 -0700 Subject: [PATCH 364/377] Split up unicode surrogates tests to avoid timeout Fixes #3441 --- src/browser/Terminal.test.ts | 144 +++++++++++++++++------------------ 1 file changed, 71 insertions(+), 73 deletions(-) diff --git a/src/browser/Terminal.test.ts b/src/browser/Terminal.test.ts index 84e6a87e..a102d93f 100644 --- a/src/browser/Terminal.test.ts +++ b/src/browser/Terminal.test.ts @@ -732,80 +732,78 @@ describe('Terminal', () => { }); describe('unicode - surrogates', () => { - it('2 characters per cell', async function (): Promise { - this.timeout(10000); // This is needed because istanbul patches code and slows it down - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - await term.writeP(high + String.fromCharCode(i)); - const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); - assert.equal(tchar.getChars(), high + String.fromCharCode(i)); - assert.equal(tchar.getChars().length, 2); - assert.equal(tchar.getWidth(), 1); - assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), ''); - term.reset(); - } - }); - it('2 characters at last cell', async () => { - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - term.buffer.x = term.cols - 1; - await term.writeP(high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars(), high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars().length, 2); - assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), ''); - term.reset(); - } - }); - it('2 characters per cell over line end with autowrap', async function (): Promise { - this.timeout(10000); - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - term.buffer.x = term.cols - 1; - - await term.writeP('a' + high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), 'a'); - assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars().length, 2); - assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), ''); - term.reset(); - } - }); - it('2 characters per cell over line end without autowrap', async function (): Promise { - this.timeout(10000); - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - term.buffer.x = term.cols - 1; - await term.writeP('\x1b[?7l'); // Disable wraparound mode - const width = wcwidth((0xD800 - 0xD800) * 0x400 + i - 0xDC00 + 0x10000); - if (width !== 1) { - continue; + for (let i = 0xDC00; i <= 0xDCF0; i += 0x10) { + const range = `0x${i.toString(16).toUpperCase()}-0x${(i + 0xF).toString(16).toUpperCase()}`; + it(`${range}: 2 characters per cell`, async function (): Promise { + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + for (let j = i; j <= i + 0xF; j++) { + await term.writeP(high + String.fromCharCode(j)); + const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); + assert.equal(tchar.getChars(), high + String.fromCharCode(j)); + assert.equal(tchar.getChars().length, 2); + assert.equal(tchar.getWidth(), 1); + assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), ''); + term.reset(); } - await term.writeP('a' + high + String.fromCharCode(i)); - // auto wraparound mode should cut off the rest of the line - assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars().length, 2); - assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), ''); - term.reset(); - } - }); - it('splitted surrogates', async function (): Promise { - this.timeout(10000); - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - await term.writeP(high + String.fromCharCode(i)); - const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); - assert.equal(tchar.getChars(), high + String.fromCharCode(i)); - assert.equal(tchar.getChars().length, 2); - assert.equal(tchar.getWidth(), 1); - assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), ''); - term.reset(); - } - }); + }); + it(`${range}: 2 characters at last cell`, async () => { + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + term.buffer.x = term.cols - 1; + for (let j = i; j <= i + 0xF; j++) { + await term.writeP(high + String.fromCharCode(j)); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars(), high + String.fromCharCode(j)); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars().length, 2); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), ''); + term.reset(); + } + }); + it(`${range}: 2 characters per cell over line end with autowrap`, async function (): Promise { + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + for (let j = i; j <= i + 0xF; j++) { + term.buffer.x = term.cols - 1; + await term.writeP('a' + high + String.fromCharCode(j)); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), 'a'); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), high + String.fromCharCode(j)); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars().length, 2); + assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), ''); + term.reset(); + } + }); + it(`${range}: 2 characters per cell over line end without autowrap`, async function (): Promise { + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + for (let j = i; j <= i + 0xF; j++) { + term.buffer.x = term.cols - 1; + await term.writeP('\x1b[?7l'); // Disable wraparound mode + const width = wcwidth((0xD800 - 0xD800) * 0x400 + j - 0xDC00 + 0x10000); + if (width !== 1) { + continue; + } + await term.writeP('a' + high + String.fromCharCode(j)); + // auto wraparound mode should cut off the rest of the line + assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), high + String.fromCharCode(j)); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars().length, 2); + assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), ''); + term.reset(); + } + }); + it(`${range}: splitted surrogates`, async function (): Promise { + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + for (let j = i; j <= i + 0xF; j++) { + await term.writeP(high + String.fromCharCode(j)); + const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); + assert.equal(tchar.getChars(), high + String.fromCharCode(j)); + assert.equal(tchar.getChars().length, 2); + assert.equal(tchar.getWidth(), 1); + assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), ''); + term.reset(); + } + }); + } }); describe('unicode - combining characters', () => { From 20460a2be19c72956d0519fa49658a437f54416c Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 2 Sep 2021 07:34:04 -0700 Subject: [PATCH 365/377] Fire buffer activate event on buffer service reset --- src/common/buffer/BufferSet.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/buffer/BufferSet.ts b/src/common/buffer/BufferSet.ts index b74c4eac..de220e8f 100644 --- a/src/common/buffer/BufferSet.ts +++ b/src/common/buffer/BufferSet.ts @@ -42,6 +42,10 @@ export class BufferSet extends Disposable implements IBufferSet { // See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer this._alt = new Buffer(false, this._optionsService, this._bufferService); this._activeBuffer = this._normal; + this._onBufferActivate.fire({ + activeBuffer: this._normal, + inactiveBuffer: this._alt + }); this.setupTabStops(); } From fa778257b9c7f1fb973e3bd63fa1fea01bc3fd14 Mon Sep 17 00:00:00 2001 From: Simon Lamon Date: Fri, 3 Sep 2021 04:40:29 +0000 Subject: [PATCH 366/377] Formatting --- src/common/services/OptionsService.test.ts | 4 ++-- src/common/services/OptionsService.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/services/OptionsService.test.ts b/src/common/services/OptionsService.test.ts index e140b5b4..8675b6b9 100644 --- a/src/common/services/OptionsService.test.ts +++ b/src/common/services/OptionsService.test.ts @@ -10,7 +10,7 @@ describe('OptionsService', () => { describe('constructor', () => { const originalError = console.error; beforeEach(() => { - console.error = () => { }; + console.error = () => {}; }); afterEach(() => { console.error = originalError; @@ -26,7 +26,7 @@ describe('OptionsService', () => { assert.equal(optionsService.getOption('cols'), 80); }); it('uses default value if invalid constructor option value passed', () => { - assert.equal(new OptionsService({ tabStopWidth: 0 }).getOption('tabStopWidth'), DEFAULT_OPTIONS.tabStopWidth); + assert.equal(new OptionsService({tabStopWidth: 0}).getOption('tabStopWidth'), DEFAULT_OPTIONS.tabStopWidth); }); }); describe('setOption', () => { diff --git a/src/common/services/OptionsService.ts b/src/common/services/OptionsService.ts index d7ac1411..e9dcaa6a 100644 --- a/src/common/services/OptionsService.ts +++ b/src/common/services/OptionsService.ts @@ -22,7 +22,7 @@ export const DEFAULT_OPTIONS: ITerminalOptions = Object.freeze({ cursorStyle: 'block', cursorWidth: 1, customGlyphs: true, - bellSound: DEFAULT_BELL_SOUND, + bellSound: DEFAULT_BELL_SOUND, bellStyle: 'none', drawBoldTextInBrightColors: true, fastScrollModifier: 'alt', @@ -128,7 +128,7 @@ export class OptionsService implements IOptionsService { break; case 'cursorWidth': value = Math.floor(value); - // Fall through for bounds check + // Fall through for bounds check case 'lineHeight': case 'tabStopWidth': if (value < 1) { From 3eeec144628a571aef2cb675b294e4070af5523c Mon Sep 17 00:00:00 2001 From: anirudh1713 Date: Sun, 5 Sep 2021 20:35:07 +0530 Subject: [PATCH 367/377] switch active unicode version in demo --- demo/client.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/demo/client.ts b/demo/client.ts index a02b155c..a5ac8bb5 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -377,6 +377,9 @@ function initAddons(term: TerminalType): void { if (!addon.canChange) { checkbox.disabled = true; } + if(name === 'unicode11' && checkbox.checked) { + term.unicode.activeVersion = '11'; + } addDomListener(checkbox, 'change', () => { if (checkbox.checked) { addon.instance = new addon.ctor(); @@ -385,10 +388,14 @@ function initAddons(term: TerminalType): void { setTimeout(() => { document.body.appendChild((addon.instance as WebglAddon).textureAtlas); }, 0); + } else if (name === 'unicode11') { + term.unicode.activeVersion = '11'; } } else { if (name === 'webgl') { document.body.removeChild((addon.instance as WebglAddon).textureAtlas); + } else if (name === 'unicode11') { + term.unicode.activeVersion = '6'; } addon.instance!.dispose(); addon.instance = undefined; From 3cb374076a2f408882303c4124bfedf0705f3062 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 9 Sep 2021 05:49:04 -0700 Subject: [PATCH 368/377] v4.14.0 --- addons/xterm-addon-search/package.json | 2 +- addons/xterm-addon-serialize/package.json | 2 +- addons/xterm-addon-unicode11/package.json | 2 +- addons/xterm-addon-webgl/package.json | 2 +- package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/xterm-addon-search/package.json b/addons/xterm-addon-search/package.json index 659bd834..08fe195f 100644 --- a/addons/xterm-addon-search/package.json +++ b/addons/xterm-addon-search/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-search", - "version": "0.8.0", + "version": "0.8.1", "author": { "name": "The xterm.js authors", "url": "https://xtermjs.org/" diff --git a/addons/xterm-addon-serialize/package.json b/addons/xterm-addon-serialize/package.json index 91ef26af..77a54dbf 100644 --- a/addons/xterm-addon-serialize/package.json +++ b/addons/xterm-addon-serialize/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-serialize", - "version": "0.5.0", + "version": "0.6.0", "author": { "name": "The xterm.js authors", "url": "https://xtermjs.org/" diff --git a/addons/xterm-addon-unicode11/package.json b/addons/xterm-addon-unicode11/package.json index 397bf2b9..9fc69416 100644 --- a/addons/xterm-addon-unicode11/package.json +++ b/addons/xterm-addon-unicode11/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-unicode11", - "version": "0.2.0", + "version": "0.3.0", "author": { "name": "The xterm.js authors", "url": "https://xtermjs.org/" diff --git a/addons/xterm-addon-webgl/package.json b/addons/xterm-addon-webgl/package.json index 421f6092..226f34ba 100644 --- a/addons/xterm-addon-webgl/package.json +++ b/addons/xterm-addon-webgl/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-webgl", - "version": "0.11.1", + "version": "0.11.2", "author": { "name": "The xterm.js authors", "url": "https://xtermjs.org/" diff --git a/package.json b/package.json index 29b6fd46..1b2bfb67 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "xterm", "description": "Full xterm terminal, in your browser", - "version": "4.13.0", + "version": "4.14.0", "main": "lib/xterm.js", "style": "css/xterm.css", "types": "typings/xterm.d.ts", From 662154123da91fdce991bf7b6a4f4c5f8c826eb4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 9 Sep 2021 13:24:07 +0000 Subject: [PATCH 369/377] Bump axios from 0.18.1 to 0.21.2 in /addons/xterm-addon-ligatures Bumps [axios](https://github.com/axios/axios) from 0.18.1 to 0.21.2. - [Release notes](https://github.com/axios/axios/releases) - [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md) - [Commits](https://github.com/axios/axios/compare/v0.18.1...v0.21.2) --- updated-dependencies: - dependency-name: axios dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- addons/xterm-addon-ligatures/package.json | 2 +- addons/xterm-addon-ligatures/yarn.lock | 33 +++++++---------------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/addons/xterm-addon-ligatures/package.json b/addons/xterm-addon-ligatures/package.json index ecbcc006..b1688772 100644 --- a/addons/xterm-addon-ligatures/package.json +++ b/addons/xterm-addon-ligatures/package.json @@ -36,7 +36,7 @@ }, "devDependencies": { "@types/sinon": "^5.0.1", - "axios": "^0.18.0", + "axios": "^0.21.2", "mkdirp": "0.5.5", "sinon": "6.3.5", "yauzl": "^2.10.0" diff --git a/addons/xterm-addon-ligatures/yarn.lock b/addons/xterm-addon-ligatures/yarn.lock index 2aac858b..f6ce913b 100644 --- a/addons/xterm-addon-ligatures/yarn.lock +++ b/addons/xterm-addon-ligatures/yarn.lock @@ -45,23 +45,17 @@ array-from@^2.1.1: resolved "https://registry.yarnpkg.com/array-from/-/array-from-2.1.1.tgz#cfe9d8c26628b9dc5aecc62a9f5d8f1f352c1195" integrity sha1-z+nYwmYoudxa7MYqn12PHzUsEZU= -axios@^0.18.0: - version "0.18.1" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.18.1.tgz#ff3f0de2e7b5d180e757ad98000f1081b87bcea3" +axios@^0.21.2: + version "0.21.2" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.2.tgz#21297d5084b2aeeb422f5d38e7be4fbb82239017" + integrity sha512-87otirqUw3e8CzHTMO+/9kh/FSgXt/eVDvipijwDtEuwbkySWZ9SBm6VEubmJ/kLKEoLQV/POhxXFb66bfekfg== dependencies: - follow-redirects "1.5.10" - is-buffer "^2.0.2" + follow-redirects "^1.14.0" buffer-crc32@~0.2.3: version "0.2.13" resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" -debug@=3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" - dependencies: - ms "2.0.0" - diff@^3.5.0: version "3.5.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" @@ -72,11 +66,10 @@ fd-slicer@~1.1.0: dependencies: pend "~1.2.0" -follow-redirects@1.5.10: - version "1.5.10" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a" - dependencies: - debug "=3.1.0" +follow-redirects@^1.14.0: + version "1.14.3" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.3.tgz#6ada78118d8d24caee595595accdc0ac6abd022e" + integrity sha512-3MkHxknWMUtb23apkgz/83fDoe+y+qr0TdgacGIA7bew+QLBo3vdgEN2xEsuXNivpFy4CyDhBBZnNZOtalmenw== font-finder@^1.0.3: version "1.0.4" @@ -110,10 +103,6 @@ has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" -is-buffer@^2.0.2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.3.tgz#4ecf3fcf749cbd1e472689e109ac66261a25e725" - isarray@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" @@ -163,10 +152,6 @@ mkdirp@0.5.5: dependencies: minimist "^1.2.5" -ms@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - nise@^1.4.5: version "1.5.3" resolved "https://registry.yarnpkg.com/nise/-/nise-1.5.3.tgz#9d2cfe37d44f57317766c6e9408a359c5d3ac1f7" From 5a65fd9c6ab244637b4c76199d4c1aeb7da6c8a3 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 10 Sep 2021 09:42:19 -0700 Subject: [PATCH 370/377] Disable emoji ime when screenReaderMode is on Fixes #3467 --- src/browser/Terminal.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index ebe755bc..d28be5bf 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -1180,7 +1180,9 @@ export class Terminal extends CoreTerminal implements ITerminal { * @param ev The input event to be handled. */ protected _inputEvent(ev: InputEvent): boolean { - if (ev.data && ev.inputType === 'insertText') { + // Only support emoji IMEs when screen reader mode is disabled as the event must bubble up to + // support reading out character input which can doubling up input characters + if (ev.data && ev.inputType === 'insertText' && !this.optionsService.options.screenReaderMode) { if (this._keyPressHandled) { return false; } From db6b3c4bcc4cf0934a71752e9c13ff2ade4174cd Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 10 Sep 2021 09:44:29 -0700 Subject: [PATCH 371/377] v4.14.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1b2bfb67..ad288f49 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "xterm", "description": "Full xterm terminal, in your browser", - "version": "4.14.0", + "version": "4.14.1", "main": "lib/xterm.js", "style": "css/xterm.css", "types": "typings/xterm.d.ts", From c186fbeafcc907bb2e6af80c4485a255b8c4e778 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 15 Sep 2021 05:04:11 -0700 Subject: [PATCH 372/377] Add exclude mode/alt buffer options to serialize addon Fixes #3472 --- .../src/SerializeAddon.ts | 23 +++++++++++---- .../test/SerializeAddon.api.ts | 4 +-- .../typings/xterm-addon-serialize.d.ts | 29 +++++++++++++++---- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index a54b4325..d692c818 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -433,26 +433,37 @@ export class SerializeAddon implements ITerminalAddon { return content; } - public serialize(scrollback?: number): string { + public serialize(options?: ISerializeOptions): string { // TODO: Add combinedData support if (!this._terminal) { throw new Error('Cannot use addon until it has been loaded'); } // Normal buffer - let content = this._serializeBuffer(this._terminal, this._terminal.buffer.normal, scrollback); + let content = this._serializeBuffer(this._terminal, this._terminal.buffer.normal, options?.scrollback); // Alternate buffer - if (this._terminal.buffer.active.type === 'alternate') { - const alternativeScreenContent = this._serializeBuffer(this._terminal, this._terminal.buffer.alternate, undefined); - content += `\u001b[?1049h\u001b[H${alternativeScreenContent}`; + if (!options?.excludeAltBuffer) { + if (this._terminal.buffer.active.type === 'alternate') { + const alternativeScreenContent = this._serializeBuffer(this._terminal, this._terminal.buffer.alternate, undefined); + content += `\u001b[?1049h\u001b[H${alternativeScreenContent}`; + } } // Modes - content += this._serializeModes(this._terminal); + if (!options?.excludeModes) { + content += this._serializeModes(this._terminal); + } return content; } public dispose(): void { } } + + +interface ISerializeOptions { + scrollback?: number; + excludeModes?: boolean; + excludeAltBuffer?: boolean; +} diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index bb66f37b..c8593b72 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -146,7 +146,7 @@ describe('SerializeAddon', () => { const cols = 10; const lines = newArray((index: number) => digitsString(cols, index), rows); await writeSync(page, lines.join('\\r\\n')); - assert.equal(await page.evaluate(`serializeAddon.serialize(${halfScrollback});`), lines.slice(halfScrollback, rows).join('\r\n')); + assert.equal(await page.evaluate(`serializeAddon.serialize({ scrollback: ${halfScrollback} });`), lines.slice(halfScrollback, rows).join('\r\n')); }); it('serialize 0 rows of scrollback', async function(): Promise { @@ -154,7 +154,7 @@ describe('SerializeAddon', () => { const cols = 10; const lines = newArray((index: number) => digitsString(cols, index), rows); await writeSync(page, lines.join('\\r\\n')); - assert.equal(await page.evaluate(`serializeAddon.serialize(0);`), lines.slice(rows - 10, rows).join('\r\n')); + assert.equal(await page.evaluate(`serializeAddon.serialize({ scrollback: 0 });`), lines.slice(rows - 10, rows).join('\r\n')); }); it('serialize all rows of content with color16', async function(): Promise { diff --git a/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts b/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts index b55ee303..a29dbb28 100644 --- a/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts +++ b/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts @@ -7,14 +7,14 @@ import { Terminal, ITerminalAddon } from 'xterm'; declare module 'xterm-addon-serialize' { /** - * An xterm.js addon that enables web links. + * An xterm.js addon that enables serialization of terminal contents. */ export class SerializeAddon implements ITerminalAddon { constructor(); /** - * Activates the addon + * Activates the addon. * @param terminal The terminal the addon is being loaded in. */ public activate(terminal: Terminal): void; @@ -24,15 +24,32 @@ declare module 'xterm-addon-serialize' { * the state. The cursor will also be positioned to the correct cell. When restoring a terminal * it is best to do before `Terminal.open` is called to avoid wasting CPU cycles rendering * incomplete frames. - * @param scrollback The number of rows in scrollback buffer to serialize, starting from the - * bottom of the scrollback buffer. This defaults to the all available rows in the scrollback - * buffer. + * @param options Custom options to allow control over what gets serialized. */ - public serialize(scrollback?: number): string; + public serialize(options?: ISerializeOptions): string; /** * Disposes the addon. */ public dispose(): void; } + + export interface ISerializeOptions { + /** + * The number of rows in the scrollback buffer to serialize, starting from the bottom of the + * scrollback buffer. When not specified, all available rows in the scrollback buffer will be + * serialized. + */ + scrollback?: number; + + /** + * Whether to exclude the terminal modes from the serialization. False by default. + */ + excludeModes?: boolean; + + /** + * Whether to exclude the alt buffer from the serialization. False by default. + */ + excludeAltBuffer?: boolean; + } } From 6493edcddf2b987afd927ad50a642b0abafb5b46 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 15 Sep 2021 05:40:46 -0700 Subject: [PATCH 373/377] Add new serialize option tests --- .../xterm-addon-serialize/test/SerializeAddon.api.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index c8593b72..5fc1bfaf 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -157,6 +157,18 @@ describe('SerializeAddon', () => { assert.equal(await page.evaluate(`serializeAddon.serialize({ scrollback: 0 });`), lines.slice(rows - 10, rows).join('\r\n')); }); + it('serialize exclude modes', async () => { + await writeSync(page, 'before\\x1b[?1hafter'); + assert.equal(await page.evaluate(`serializeAddon.serialize();`), 'beforeafter\x1b[?1h'); + assert.equal(await page.evaluate(`serializeAddon.serialize({ excludeModes: true });`), 'beforeafter'); + }); + + it('serialize exclude alt buffer', async () => { + await writeSync(page, 'normal\\x1b[?1049h\\x1b[Halt'); + assert.equal(await page.evaluate(`serializeAddon.serialize();`), 'normal\x1b[?1049h\x1b[Halt'); + assert.equal(await page.evaluate(`serializeAddon.serialize({ excludeAltBuffer: true });`), 'normal'); + }); + it('serialize all rows of content with color16', async function(): Promise { const cols = 10; const color16 = [ From 2e4e29ad73174757632be34fb0d0c11377e3e803 Mon Sep 17 00:00:00 2001 From: Simon Lamon Date: Wed, 22 Sep 2021 08:47:36 +0000 Subject: [PATCH 374/377] Support strikethrough in serialize addon --- addons/xterm-addon-serialize/src/SerializeAddon.ts | 6 ++++-- typings/xterm-headless.d.ts | 12 +++++++----- typings/xterm.d.ts | 10 ++++++---- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index a54b4325..41195a7e 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -72,7 +72,8 @@ function equalFlags(cell1: IBufferCell, cell2: IBufferCell): boolean { && cell1.isBlink() === cell2.isBlink() && cell1.isInvisible() === cell2.isInvisible() && cell1.isItalic() === cell2.isItalic() - && cell1.isDim() === cell2.isDim(); + && cell1.isDim() === cell2.isDim() + && cell1.isStrikethrough() === cell2.isStrikethrough(); } class StringSerializeHandler extends BaseSerializeHandler { @@ -160,7 +161,7 @@ class StringSerializeHandler extends BaseSerializeHandler { if ( // you must output character to cause overflow, control sequence can't do this nextRowFirstChar.getChars() && - isNextRowFirstCharDoubleWidth ? this._nullCellCount <= 1 : this._nullCellCount <= 0 + isNextRowFirstCharDoubleWidth ? this._nullCellCount <= 1 : this._nullCellCount <= 0 ) { if ( // the last character can't be null, @@ -259,6 +260,7 @@ class StringSerializeHandler extends BaseSerializeHandler { if (cell.isInvisible() !== oldCell.isInvisible()) { sgrSeq.push(cell.isInvisible() ? 8 : 28); } if (cell.isItalic() !== oldCell.isItalic()) { sgrSeq.push(cell.isItalic() ? 3 : 23); } if (cell.isDim() !== oldCell.isDim()) { sgrSeq.push(cell.isDim() ? 2 : 22); } + if (cell.isStrikethrough() !== oldCell.isStrikethrough()) { sgrSeq.push(cell.isStrikethrough() ? 9 : 29); } } } } diff --git a/typings/xterm-headless.d.ts b/typings/xterm-headless.d.ts index 13a32126..84b715e8 100644 --- a/typings/xterm-headless.d.ts +++ b/typings/xterm-headless.d.ts @@ -84,7 +84,7 @@ declare module 'xterm-headless' { * line height and letter spacing is used. Note that this doesn't work with the DOM renderer * which renders all characters using the font. The default is true. */ - customGlyphs?: boolean; + customGlyphs?: boolean; /** * Whether input should be disabled. @@ -1085,18 +1085,20 @@ declare module 'xterm-headless' { /** Whether the cell has the bold attribute (CSI 1 m). */ isBold(): number; - /** Whether the cell has the inverse attribute (CSI 3 m). */ + /** Whether the cell has the italic attribute (CSI 3 m). */ isItalic(): number; - /** Whether the cell has the inverse attribute (CSI 2 m). */ + /** Whether the cell has the dim attribute (CSI 2 m). */ isDim(): number; /** Whether the cell has the underline attribute (CSI 4 m). */ isUnderline(): number; - /** Whether the cell has the inverse attribute (CSI 5 m). */ + /** Whether the cell has the blink attribute (CSI 5 m). */ isBlink(): number; /** Whether the cell has the inverse attribute (CSI 7 m). */ isInverse(): number; - /** Whether the cell has the inverse attribute (CSI 8 m). */ + /** Whether the cell has the invisible attribute (CSI 8 m). */ isInvisible(): number; + /** Whether the cell has the strikethrough attribute (CSI 9 m). */ + isStrikethrough(): number; /** Whether the cell is using the RGB foreground color mode. */ isFgRGB(): boolean; diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index ba2be988..6cf34bf8 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -1444,18 +1444,20 @@ declare module 'xterm' { /** Whether the cell has the bold attribute (CSI 1 m). */ isBold(): number; - /** Whether the cell has the inverse attribute (CSI 3 m). */ + /** Whether the cell has the italic attribute (CSI 3 m). */ isItalic(): number; - /** Whether the cell has the inverse attribute (CSI 2 m). */ + /** Whether the cell has the dim attribute (CSI 2 m). */ isDim(): number; /** Whether the cell has the underline attribute (CSI 4 m). */ isUnderline(): number; - /** Whether the cell has the inverse attribute (CSI 5 m). */ + /** Whether the cell has the blink attribute (CSI 5 m). */ isBlink(): number; /** Whether the cell has the inverse attribute (CSI 7 m). */ isInverse(): number; - /** Whether the cell has the inverse attribute (CSI 8 m). */ + /** Whether the cell has the invisible attribute (CSI 8 m). */ isInvisible(): number; + /** Whether the cell has the strikethrough attribute (CSI 9 m). */ + isStrikethrough(): number; /** Whether the cell is using the RGB foreground color mode. */ isFgRGB(): boolean; From 3fe32c07246937729719e576ae5453f30b21edf6 Mon Sep 17 00:00:00 2001 From: Simon Lamon Date: Wed, 22 Sep 2021 09:38:37 +0000 Subject: [PATCH 375/377] Adjust test to include strikethrough test --- .../test/SerializeAddon.api.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index bb66f37b..97525226 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -184,11 +184,13 @@ describe('SerializeAddon', () => { sgr(UNDERLINED) + line, sgr(BLINK) + line, sgr(INVISIBLE) + line, + sgr(STRIKETHROUGH) + line, sgr(NO_INVERSE) + line, sgr(NO_BOLD) + line, sgr(NO_UNDERLINED) + line, sgr(NO_BLINK) + line, - sgr(NO_INVISIBLE) + line + sgr(NO_INVISIBLE) + line, + sgr(NO_STRIKETHROUGH) + line ]; const rows = lines.length; await writeSync(page, lines.join('\\r\\n')); @@ -579,20 +581,20 @@ const BG_RGB_GREEN = '48;2;0;255;0'; const BG_RGB_YELLOW = '48;2;255;255;0'; const BG_RESET = '49'; -const INVERSE = '7'; const BOLD = '1'; +const DIM = '2'; +const ITALIC = '3'; const UNDERLINED = '4'; const BLINK = '5'; +const INVERSE = '7'; const INVISIBLE = '8'; +const STRIKETHROUGH = '9'; -const NO_INVERSE = '27'; const NO_BOLD = '22'; +const NO_DIM = '22'; +const NO_ITALIC = '23'; const NO_UNDERLINED = '24'; const NO_BLINK = '25'; +const NO_INVERSE = '27'; const NO_INVISIBLE = '28'; - -const ITALIC = '3'; -const DIM = '2'; - -const NO_ITALIC = '23'; -const NO_DIM = '22'; +const NO_STRIKETHROUGH = '29'; From 189ff562242baa8cb9dea7c510b9377da9cd39a2 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 22 Sep 2021 06:38:47 -0700 Subject: [PATCH 376/377] Add API to clear canvas renderer texture atlas Fixes #3455 --- src/browser/Terminal.ts | 4 ++++ src/browser/TestUtils.test.ts | 6 ++++++ src/browser/Types.d.ts | 1 + src/browser/public/Terminal.ts | 3 +++ src/browser/renderer/BaseRenderLayer.ts | 4 ++++ src/browser/renderer/Renderer.ts | 6 ++++++ src/browser/renderer/Types.d.ts | 6 ++++++ src/browser/renderer/atlas/BaseCharAtlas.ts | 2 ++ src/browser/renderer/atlas/DynamicCharAtlas.ts | 10 ++++++++++ src/browser/services/RenderService.ts | 5 +++++ src/browser/services/Services.ts | 1 + typings/xterm.d.ts | 8 ++++++++ 12 files changed, 56 insertions(+) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index ebe755bc..4e6a2201 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -1290,6 +1290,10 @@ export class Terminal extends CoreTerminal implements ITerminal { this.viewport?.syncScrollArea(); } + public clearTextureAtlas(): void { + this._renderService?.clearTextureAtlas(); + } + private _reportWindowsOptions(type: WindowsOptionsReportType): void { if (!this._renderService) { return; diff --git a/src/browser/TestUtils.test.ts b/src/browser/TestUtils.test.ts index daa6843c..8fdf458e 100644 --- a/src/browser/TestUtils.test.ts +++ b/src/browser/TestUtils.test.ts @@ -195,6 +195,9 @@ export class MockTerminal implements ITerminal { public reset(): void { throw new Error('Method not implemented.'); } + public clearTextureAtlas(): void { + throw new Error('Method not implemented.'); + } public refresh(start: number, end: number): void { throw new Error('Method not implemented.'); } @@ -374,6 +377,9 @@ export class MockRenderService implements IRenderService { public refreshRows(start: number, end: number): void { throw new Error('Method not implemented.'); } + public clearTextureAtlas(): void { + throw new Error('Method not implemented.'); + } public resize(cols: number, rows: number): void { throw new Error('Method not implemented.'); } diff --git a/src/browser/Types.d.ts b/src/browser/Types.d.ts index 0d74b39f..bafeff77 100644 --- a/src/browser/Types.d.ts +++ b/src/browser/Types.d.ts @@ -79,6 +79,7 @@ export interface IPublicTerminal extends IDisposable { write(data: string | Uint8Array, callback?: () => void): void; paste(data: string): void; refresh(start: number, end: number): void; + clearTextureAtlas(): void; reset(): void; } diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index a76b1a22..26cf2728 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -222,6 +222,9 @@ export class Terminal implements ITerminalApi { public reset(): void { this._core.reset(); } + public clearTextureAtlas(): void { + this._core.clearTextureAtlas(); + } public loadAddon(addon: ITerminalAddon): void { return this._addonManager.loadAddon(this, addon); } diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 448451d0..68f83a75 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -138,6 +138,10 @@ export abstract class BaseRenderLayer implements IRenderLayer { public abstract reset(): void; + public clearTextureAtlas(): void { + this._charAtlas?.clear(); + } + /** * Fills 1+ cells completely. This uses the existing fillStyle on the context. * @param x The column to start at. diff --git a/src/browser/renderer/Renderer.ts b/src/browser/renderer/Renderer.ts index d5de40db..162a7ed3 100644 --- a/src/browser/renderer/Renderer.ts +++ b/src/browser/renderer/Renderer.ts @@ -149,6 +149,12 @@ export class Renderer extends Disposable implements IRenderer { } } + public clearTextureAtlas(): void { + for (const layer of this._renderLayers) { + layer.clearTextureAtlas(); + } + } + /** * Recalculates the character and canvas dimensions. */ diff --git a/src/browser/renderer/Types.d.ts b/src/browser/renderer/Types.d.ts index fc137bc8..6818a926 100644 --- a/src/browser/renderer/Types.d.ts +++ b/src/browser/renderer/Types.d.ts @@ -52,6 +52,7 @@ export interface IRenderer extends IDisposable { onOptionsChanged(): void; clear(): void; renderRows(start: number, end: number): void; + clearTextureAtlas?(): void; } export interface IRenderLayer extends IDisposable { @@ -100,4 +101,9 @@ export interface IRenderLayer extends IDisposable { * Clear the state of the render layer. */ reset(): void; + + /** + * Clears the texture atlas. + */ + clearTextureAtlas(): void; } diff --git a/src/browser/renderer/atlas/BaseCharAtlas.ts b/src/browser/renderer/atlas/BaseCharAtlas.ts index 4ebaaa47..83c30d2f 100644 --- a/src/browser/renderer/atlas/BaseCharAtlas.ts +++ b/src/browser/renderer/atlas/BaseCharAtlas.ts @@ -28,6 +28,8 @@ export abstract class BaseCharAtlas implements IDisposable { */ private _doWarmUp(): void { } + public clear(): void { } + /** * Called when we start drawing a new frame. * diff --git a/src/browser/renderer/atlas/DynamicCharAtlas.ts b/src/browser/renderer/atlas/DynamicCharAtlas.ts index a7237878..666324ad 100644 --- a/src/browser/renderer/atlas/DynamicCharAtlas.ts +++ b/src/browser/renderer/atlas/DynamicCharAtlas.ts @@ -119,6 +119,16 @@ export class DynamicCharAtlas extends BaseCharAtlas { this._drawToCacheCount = 0; } + public clear(): void { + if (this._cacheMap.size > 0) { + const capacity = this._width * this._height; + this._cacheMap = new LRUMap(capacity); + this._cacheMap.prealloc(capacity); + } + this._cacheCtx.clearRect(0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT); + this._tmpCtx.clearRect(0, 0, this._config.scaledCharWidth, this._config.scaledCharHeight); + } + public draw( ctx: CanvasRenderingContext2D, glyph: IGlyphIdentifier, diff --git a/src/browser/services/RenderService.ts b/src/browser/services/RenderService.ts index 332e71da..b8283e0e 100644 --- a/src/browser/services/RenderService.ts +++ b/src/browser/services/RenderService.ts @@ -168,6 +168,11 @@ export class RenderService extends Disposable implements IRenderService { } } + public clearTextureAtlas(): void { + this._renderer?.clearTextureAtlas?.(); + this._fullRefresh(); + } + public setColors(colors: IColorSet): void { this._renderer.setColors(colors); this._fullRefresh(); diff --git a/src/browser/services/Services.ts b/src/browser/services/Services.ts index 8c8a7bd9..4928fa28 100644 --- a/src/browser/services/Services.ts +++ b/src/browser/services/Services.ts @@ -53,6 +53,7 @@ export interface IRenderService extends IDisposable { dimensions: IRenderDimensions; refreshRows(start: number, end: number): void; + clearTextureAtlas(): void; resize(cols: number, rows: number): void; changeOptions(): void; setRenderer(renderer: IRenderer): void; diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index ba2be988..66d45f32 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -1056,6 +1056,14 @@ declare module 'xterm' { */ refresh(start: number, end: number): void; + /** + * Clears the texture atlas of the canvas renderer if it's active. Doing this will force a + * redraw of all glyphs which can workaround issues causing the texture to become corrupt, for + * example Chromium/Nvidia has an issue where the texture gets messed up when resuming the OS + * from sleep. + */ + clearTextureAtlas(): void; + /** * Perform a full reset (RIS, aka '\x1bc'). */ From 3a71b3f11e9781e0df834bafdf8c51a007b06920 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 22 Sep 2021 14:21:50 -0700 Subject: [PATCH 377/377] Add document role to accessibility tree root See microsoft/vscode#98918 --- src/browser/AccessibilityManager.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/browser/AccessibilityManager.ts b/src/browser/AccessibilityManager.ts index 1be3342d..80092202 100644 --- a/src/browser/AccessibilityManager.ts +++ b/src/browser/AccessibilityManager.ts @@ -53,6 +53,7 @@ export class AccessibilityManager extends Disposable { ) { super(); this._accessibilityTreeRoot = document.createElement('div'); + this._accessibilityTreeRoot.setAttribute('role', 'document'); this._accessibilityTreeRoot.classList.add('xterm-accessibility'); this._rowContainer = document.createElement('div');