diff --git a/src/typings/vscode-xterm.d.ts b/src/typings/vscode-xterm.d.ts index 356aee471e3..8c3b106917b 100644 --- a/src/typings/vscode-xterm.d.ts +++ b/src/typings/vscode-xterm.d.ts @@ -671,17 +671,29 @@ declare module 'vscode-xterm' { // Modifications to official .d.ts below declare module 'vscode-xterm' { interface Terminal { - buffer: { - y: number; - ybase: number; - ydisp: number; - x: number; - }; + _core: { + buffer: { + y: number; + ybase: number; + ydisp: number; + x: number; + }; - /** - * Emit an event on the terminal. - */ - emit(type: string, data: any): void; + /** + * Emit an event on the terminal. + */ + emit(type: string, data: any): void; + + charMeasure?: { height: number, width: number }; + + renderer: { + _renderLayers: any[]; + onIntersectionChange: any; + } + } + + webLinksInit(handler?: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions): void; + winptyCompatInit(): void; /** * Find the next instance of the term, then scroll to and select it. If it @@ -698,9 +710,5 @@ declare module 'vscode-xterm' { * @return Whether a result was found. */ findPrevious(term: string): boolean; - - webLinksInit(handler?: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions): void; - winptyCompatInit(): void; - charMeasure?: { height: number, width: number }; } } diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts index 2d887bcd678..4d4f6645ad0 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts @@ -137,14 +137,14 @@ export class TerminalConfigHelper implements ITerminalConfigHelper { // Get the character dimensions from xterm if it's available if (xterm) { - if (xterm.charMeasure && xterm.charMeasure.width && xterm.charMeasure.height) { + if (xterm._core.charMeasure && xterm._core.charMeasure.width && xterm._core.charMeasure.height) { return { fontFamily, fontSize, letterSpacing, lineHeight, - charHeight: xterm.charMeasure.height, - charWidth: xterm.charMeasure.width + charHeight: xterm._core.charMeasure.height, + charWidth: xterm._core.charMeasure.width }; } } diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts index 7f7ebf03667..6203b5c5c97 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts @@ -232,7 +232,7 @@ export class TerminalInstance implements ITerminalInstance { // it gets removed and then added back to the DOM (resetting scrollTop to 0). // Upstream issue: https://github.com/sourcelair/xterm.js/issues/291 if (this._xterm) { - this._xterm.emit('scroll', this._xterm.buffer.ydisp); + this._xterm.emit('scroll', this._xterm._core.buffer.ydisp); } } @@ -460,7 +460,7 @@ export class TerminalInstance implements ITerminalInstance { private _measureRenderTime(): void { const frameTimes: number[] = []; - const textRenderLayer = (this._xterm).renderer._renderLayers[0]; + const textRenderLayer = this._xterm._core.renderer._renderLayers[0]; const originalOnGridChanged = textRenderLayer.onGridChanged; const evaluateCanvasRenderer = () => { @@ -575,7 +575,7 @@ export class TerminalInstance implements ITerminalInstance { this._xtermElement = null; } if (this._xterm) { - const buffer = (this._xterm.buffer); + const buffer = (this._xterm._core.buffer); this._sendLineData(buffer, buffer.ybase + buffer.y); this._xterm.dispose(); this._xterm = null; @@ -648,7 +648,7 @@ export class TerminalInstance implements ITerminalInstance { // necessary if the number of rows in the terminal has decreased while it was in the // background since scrollTop changes take no effect but the terminal's position does // change since the number of visible rows decreases. - this._xterm.emit('scroll', this._xterm.buffer.ydisp); + this._xterm.emit('scroll', this._xterm._core.buffer.ydisp); if (this._container && this._container.parentElement) { // Force a layout when the instance becomes invisible. This is particularly important // for ensuring that terminals that are created in the background by an extension will @@ -848,7 +848,7 @@ export class TerminalInstance implements ITerminalInstance { } private _onLineFeed(): void { - const buffer = (this._xterm.buffer); + const buffer = (this._xterm._core.buffer); const newLine = buffer.lines.get(buffer.ybase + buffer.y); if (!newLine.isWrapped) { this._sendLineData(buffer, buffer.ybase + buffer.y - 1); @@ -974,7 +974,7 @@ export class TerminalInstance implements ITerminalInstance { // on Winodws/Linux would fire an event saying that the terminal was not visible. // This should only force a refresh if one is needed. if (this._xterm.getOption('rendererType') === 'canvas') { - (this._xterm).renderer.onIntersectionChange({ intersectionRatio: 1 }); + this._xterm._core.renderer.onIntersectionChange({ intersectionRatio: 1 }); } } } diff --git a/src/vs/workbench/parts/terminal/node/terminalCommandTracker.ts b/src/vs/workbench/parts/terminal/node/terminalCommandTracker.ts index bdde9f6e0b9..6e8f0335b8b 100644 --- a/src/vs/workbench/parts/terminal/node/terminalCommandTracker.ts +++ b/src/vs/workbench/parts/terminal/node/terminalCommandTracker.ts @@ -49,7 +49,7 @@ export class TerminalCommandTracker implements ITerminalCommandTracker, IDisposa } private _onEnter(): void { - if (this._xterm.buffer.x >= MINIMUM_PROMPT_LENGTH) { + if (this._xterm._core.buffer.x >= MINIMUM_PROMPT_LENGTH) { this._xterm.addMarker(0); } } @@ -176,7 +176,7 @@ export class TerminalCommandTracker implements ITerminalCommandTracker, IDisposa private _getLine(marker: IMarker | Boundary): number { // Use the _second last_ row as the last row is likely the prompt if (marker === Boundary.Bottom) { - return this._xterm.buffer.ybase + this._xterm.rows - 1; + return this._xterm._core.buffer.ybase + this._xterm.rows - 1; } if (marker === Boundary.Top) { @@ -236,10 +236,10 @@ export class TerminalCommandTracker implements ITerminalCommandTracker, IDisposa if (this._currentMarker === Boundary.Bottom) { return 0; } else if (this._currentMarker === Boundary.Top) { - return 0 - (this._xterm.buffer.ybase + this._xterm.buffer.y); + return 0 - (this._xterm._core.buffer.ybase + this._xterm._core.buffer.y); } else { let offset = this._getLine(this._currentMarker); - offset -= this._xterm.buffer.ybase + this._xterm.buffer.y; + offset -= this._xterm._core.buffer.ybase + this._xterm._core.buffer.y; return offset; } } diff --git a/src/vs/workbench/parts/terminal/test/node/terminalCommandTracker.test.ts b/src/vs/workbench/parts/terminal/test/node/terminalCommandTracker.test.ts index 003f76b383b..abc4abc1d10 100644 --- a/src/vs/workbench/parts/terminal/test/node/terminalCommandTracker.test.ts +++ b/src/vs/workbench/parts/terminal/test/node/terminalCommandTracker.test.ts @@ -62,24 +62,24 @@ suite('Workbench - TerminalCommandTracker', () => { for (let i = 0; i < 20; i++) { syncWrite(xterm, `\r\n`); } - assert.equal(xterm.buffer.ybase, 20); - assert.equal(xterm.buffer.ydisp, 20); + assert.equal(xterm._core.buffer.ybase, 20); + assert.equal(xterm._core.buffer.ydisp, 20); // Scroll to marker commandTracker.scrollToPreviousCommand(); - assert.equal(xterm.buffer.ydisp, 9); + assert.equal(xterm._core.buffer.ydisp, 9); // Scroll to top boundary commandTracker.scrollToPreviousCommand(); - assert.equal(xterm.buffer.ydisp, 0); + assert.equal(xterm._core.buffer.ydisp, 0); // Scroll to marker commandTracker.scrollToNextCommand(); - assert.equal(xterm.buffer.ydisp, 9); + assert.equal(xterm._core.buffer.ydisp, 9); // Scroll to bottom boundary commandTracker.scrollToNextCommand(); - assert.equal(xterm.buffer.ydisp, 20); + assert.equal(xterm._core.buffer.ydisp, 20); }); test('should select to the next and previous commands', () => { (window).matchMedia = () => { @@ -98,8 +98,8 @@ suite('Workbench - TerminalCommandTracker', () => { assert.equal(xterm.markers[1].line, 11); syncWrite(xterm, '\n\r3'); - assert.equal(xterm.buffer.ybase, 3); - assert.equal(xterm.buffer.ydisp, 3); + assert.equal(xterm._core.buffer.ybase, 3); + assert.equal(xterm._core.buffer.ydisp, 3); assert.equal(xterm.getSelection(), ''); commandTracker.selectToPreviousCommand(); @@ -128,8 +128,8 @@ suite('Workbench - TerminalCommandTracker', () => { assert.equal(xterm.markers[1].line, 11); syncWrite(xterm, '\n\r3'); - assert.equal(xterm.buffer.ybase, 3); - assert.equal(xterm.buffer.ydisp, 3); + assert.equal(xterm._core.buffer.ybase, 3); + assert.equal(xterm._core.buffer.ydisp, 3); assert.equal(xterm.getSelection(), ''); commandTracker.selectToPreviousLine();