未验证 提交 1afae050 编写于 作者: D Daniel Imms 提交者: GitHub

Merge pull request #52463 from Microsoft/tyriar/xterm_update

Update xterm
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
"vscode-nsfw": "1.0.17", "vscode-nsfw": "1.0.17",
"vscode-ripgrep": "^1.0.1", "vscode-ripgrep": "^1.0.1",
"vscode-textmate": "^4.0.0-next.2", "vscode-textmate": "^4.0.0-next.2",
"vscode-xterm": "3.5.0-beta13", "vscode-xterm": "3.5.0-beta14",
"yauzl": "^2.9.1" "yauzl": "^2.9.1"
}, },
"devDependencies": { "devDependencies": {
......
...@@ -670,19 +670,38 @@ declare module 'vscode-xterm' { ...@@ -670,19 +670,38 @@ declare module 'vscode-xterm' {
// Modifications to official .d.ts below // Modifications to official .d.ts below
declare module 'vscode-xterm' { declare module 'vscode-xterm' {
interface Terminal { interface TerminalCore {
buffer: { buffer: {
y: number; y: number;
ybase: number; ybase: number;
ydisp: number; ydisp: number;
x: number; x: number;
lines: any[];
translateBufferLineToString(lineIndex: number, trimRight: boolean): string;
}; };
send(text: string): void;
/** /**
* Emit an event on the terminal. * Emit an event on the terminal.
*/ */
emit(type: string, data: any): void; emit(type: string, data: any): void;
charMeasure?: { height: number, width: number };
renderer: {
_renderLayers: any[];
onIntersectionChange: any;
};
}
interface Terminal {
_core: TerminalCore;
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 * Find the next instance of the term, then scroll to and select it. If it
* doesn't exist, do nothing. * doesn't exist, do nothing.
...@@ -698,9 +717,5 @@ declare module 'vscode-xterm' { ...@@ -698,9 +717,5 @@ declare module 'vscode-xterm' {
* @return Whether a result was found. * @return Whether a result was found.
*/ */
findPrevious(term: string): boolean; findPrevious(term: string): boolean;
webLinksInit(handler?: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions): void;
winptyCompatInit(): void;
charMeasure?: { height: number, width: number };
} }
} }
...@@ -13,6 +13,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti ...@@ -13,6 +13,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { getTopLeftOffset, getClientArea } from 'vs/base/browser/dom'; import { getTopLeftOffset, getClientArea } from 'vs/base/browser/dom';
import * as electron from 'electron'; import * as electron from 'electron';
import { IWindowService } from 'vs/platform/windows/common/windows'; import { IWindowService } from 'vs/platform/windows/common/windows';
import { Terminal } from 'vscode-xterm';
function serializeElement(element: Element, recursive: boolean): IElement { function serializeElement(element: Element, recursive: boolean): IElement {
const attributes = Object.create(null); const attributes = Object.create(null);
...@@ -172,7 +173,7 @@ class WindowDriver implements IWindowDriver { ...@@ -172,7 +173,7 @@ class WindowDriver implements IWindowDriver {
throw new Error('Terminal not found: ' + selector); throw new Error('Terminal not found: ' + selector);
} }
const xterm = (element as any).xterm; const xterm: Terminal = (element as any).xterm;
if (!xterm) { if (!xterm) {
throw new Error('Xterm not found: ' + selector); throw new Error('Xterm not found: ' + selector);
...@@ -180,8 +181,8 @@ class WindowDriver implements IWindowDriver { ...@@ -180,8 +181,8 @@ class WindowDriver implements IWindowDriver {
const lines: string[] = []; const lines: string[] = [];
for (let i = 0; i < xterm.buffer.lines.length; i++) { for (let i = 0; i < xterm._core.buffer.lines.length; i++) {
lines.push(xterm.buffer.translateBufferLineToString(i, true)); lines.push(xterm._core.buffer.translateBufferLineToString(i, true));
} }
return lines; return lines;
...@@ -194,13 +195,13 @@ class WindowDriver implements IWindowDriver { ...@@ -194,13 +195,13 @@ class WindowDriver implements IWindowDriver {
throw new Error('Element not found'); throw new Error('Element not found');
} }
const xterm = (element as any).xterm; const xterm: Terminal = (element as any).xterm;
if (!xterm) { if (!xterm) {
throw new Error('Xterm not found'); throw new Error('Xterm not found');
} }
xterm.send(text); xterm._core.send(text);
} }
async openDevTools(): TPromise<void> { async openDevTools(): TPromise<void> {
......
...@@ -137,14 +137,14 @@ export class TerminalConfigHelper implements ITerminalConfigHelper { ...@@ -137,14 +137,14 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
// Get the character dimensions from xterm if it's available // Get the character dimensions from xterm if it's available
if (xterm) { if (xterm) {
if (xterm.charMeasure && xterm.charMeasure.width && xterm.charMeasure.height) { if (xterm._core.charMeasure && xterm._core.charMeasure.width && xterm._core.charMeasure.height) {
return { return {
fontFamily, fontFamily,
fontSize, fontSize,
letterSpacing, letterSpacing,
lineHeight, lineHeight,
charHeight: xterm.charMeasure.height, charHeight: xterm._core.charMeasure.height,
charWidth: xterm.charMeasure.width charWidth: xterm._core.charMeasure.width
}; };
} }
} }
......
...@@ -232,7 +232,7 @@ export class TerminalInstance implements ITerminalInstance { ...@@ -232,7 +232,7 @@ export class TerminalInstance implements ITerminalInstance {
// it gets removed and then added back to the DOM (resetting scrollTop to 0). // it gets removed and then added back to the DOM (resetting scrollTop to 0).
// Upstream issue: https://github.com/sourcelair/xterm.js/issues/291 // Upstream issue: https://github.com/sourcelair/xterm.js/issues/291
if (this._xterm) { 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 { ...@@ -460,7 +460,7 @@ export class TerminalInstance implements ITerminalInstance {
private _measureRenderTime(): void { private _measureRenderTime(): void {
const frameTimes: number[] = []; const frameTimes: number[] = [];
const textRenderLayer = (<any>this._xterm).renderer._renderLayers[0]; const textRenderLayer = this._xterm._core.renderer._renderLayers[0];
const originalOnGridChanged = textRenderLayer.onGridChanged; const originalOnGridChanged = textRenderLayer.onGridChanged;
const evaluateCanvasRenderer = () => { const evaluateCanvasRenderer = () => {
...@@ -575,7 +575,7 @@ export class TerminalInstance implements ITerminalInstance { ...@@ -575,7 +575,7 @@ export class TerminalInstance implements ITerminalInstance {
this._xtermElement = null; this._xtermElement = null;
} }
if (this._xterm) { if (this._xterm) {
const buffer = (<any>this._xterm.buffer); const buffer = (<any>this._xterm._core.buffer);
this._sendLineData(buffer, buffer.ybase + buffer.y); this._sendLineData(buffer, buffer.ybase + buffer.y);
this._xterm.dispose(); this._xterm.dispose();
this._xterm = null; this._xterm = null;
...@@ -648,7 +648,7 @@ export class TerminalInstance implements ITerminalInstance { ...@@ -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 // 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 // background since scrollTop changes take no effect but the terminal's position does
// change since the number of visible rows decreases. // 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) { if (this._container && this._container.parentElement) {
// Force a layout when the instance becomes invisible. This is particularly important // 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 // for ensuring that terminals that are created in the background by an extension will
...@@ -848,7 +848,7 @@ export class TerminalInstance implements ITerminalInstance { ...@@ -848,7 +848,7 @@ export class TerminalInstance implements ITerminalInstance {
} }
private _onLineFeed(): void { private _onLineFeed(): void {
const buffer = (<any>this._xterm.buffer); const buffer = (<any>this._xterm._core.buffer);
const newLine = buffer.lines.get(buffer.ybase + buffer.y); const newLine = buffer.lines.get(buffer.ybase + buffer.y);
if (!newLine.isWrapped) { if (!newLine.isWrapped) {
this._sendLineData(buffer, buffer.ybase + buffer.y - 1); this._sendLineData(buffer, buffer.ybase + buffer.y - 1);
...@@ -974,7 +974,7 @@ export class TerminalInstance implements ITerminalInstance { ...@@ -974,7 +974,7 @@ export class TerminalInstance implements ITerminalInstance {
// on Winodws/Linux would fire an event saying that the terminal was not visible. // on Winodws/Linux would fire an event saying that the terminal was not visible.
// This should only force a refresh if one is needed. // This should only force a refresh if one is needed.
if (this._xterm.getOption('rendererType') === 'canvas') { if (this._xterm.getOption('rendererType') === 'canvas') {
(<any>this._xterm).renderer.onIntersectionChange({ intersectionRatio: 1 }); this._xterm._core.renderer.onIntersectionChange({ intersectionRatio: 1 });
} }
} }
} }
......
...@@ -49,7 +49,7 @@ export class TerminalCommandTracker implements ITerminalCommandTracker, IDisposa ...@@ -49,7 +49,7 @@ export class TerminalCommandTracker implements ITerminalCommandTracker, IDisposa
} }
private _onEnter(): void { private _onEnter(): void {
if (this._xterm.buffer.x >= MINIMUM_PROMPT_LENGTH) { if (this._xterm._core.buffer.x >= MINIMUM_PROMPT_LENGTH) {
this._xterm.addMarker(0); this._xterm.addMarker(0);
} }
} }
...@@ -176,7 +176,7 @@ export class TerminalCommandTracker implements ITerminalCommandTracker, IDisposa ...@@ -176,7 +176,7 @@ export class TerminalCommandTracker implements ITerminalCommandTracker, IDisposa
private _getLine(marker: IMarker | Boundary): number { private _getLine(marker: IMarker | Boundary): number {
// Use the _second last_ row as the last row is likely the prompt // Use the _second last_ row as the last row is likely the prompt
if (marker === Boundary.Bottom) { 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) { if (marker === Boundary.Top) {
...@@ -236,10 +236,10 @@ export class TerminalCommandTracker implements ITerminalCommandTracker, IDisposa ...@@ -236,10 +236,10 @@ export class TerminalCommandTracker implements ITerminalCommandTracker, IDisposa
if (this._currentMarker === Boundary.Bottom) { if (this._currentMarker === Boundary.Bottom) {
return 0; return 0;
} else if (this._currentMarker === Boundary.Top) { } 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 { } else {
let offset = this._getLine(this._currentMarker); 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; return offset;
} }
} }
......
...@@ -4,19 +4,23 @@ ...@@ -4,19 +4,23 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as assert from 'assert'; import * as assert from 'assert';
import { Terminal } from 'vscode-xterm'; import { Terminal, TerminalCore } from 'vscode-xterm';
import { TerminalCommandTracker } from 'vs/workbench/parts/terminal/node/terminalCommandTracker'; import { TerminalCommandTracker } from 'vs/workbench/parts/terminal/node/terminalCommandTracker';
import { isWindows } from 'vs/base/common/platform'; import { isWindows } from 'vs/base/common/platform';
interface TestTerminal extends Terminal { interface TestTerminalCore extends TerminalCore {
writeBuffer: string[]; writeBuffer: string[];
_innerWrite(): void; _innerWrite(): void;
} }
interface TestTerminal extends Terminal {
_core: TestTerminalCore;
}
function syncWrite(term: TestTerminal, data: string): void { function syncWrite(term: TestTerminal, data: string): void {
// Terminal.write is asynchronous // Terminal.write is asynchronous
term.writeBuffer.push(data); term._core.writeBuffer.push(data);
term._innerWrite(); term._core._innerWrite();
} }
const ROWS = 10; const ROWS = 10;
...@@ -62,24 +66,24 @@ suite('Workbench - TerminalCommandTracker', () => { ...@@ -62,24 +66,24 @@ suite('Workbench - TerminalCommandTracker', () => {
for (let i = 0; i < 20; i++) { for (let i = 0; i < 20; i++) {
syncWrite(xterm, `\r\n`); syncWrite(xterm, `\r\n`);
} }
assert.equal(xterm.buffer.ybase, 20); assert.equal(xterm._core.buffer.ybase, 20);
assert.equal(xterm.buffer.ydisp, 20); assert.equal(xterm._core.buffer.ydisp, 20);
// Scroll to marker // Scroll to marker
commandTracker.scrollToPreviousCommand(); commandTracker.scrollToPreviousCommand();
assert.equal(xterm.buffer.ydisp, 9); assert.equal(xterm._core.buffer.ydisp, 9);
// Scroll to top boundary // Scroll to top boundary
commandTracker.scrollToPreviousCommand(); commandTracker.scrollToPreviousCommand();
assert.equal(xterm.buffer.ydisp, 0); assert.equal(xterm._core.buffer.ydisp, 0);
// Scroll to marker // Scroll to marker
commandTracker.scrollToNextCommand(); commandTracker.scrollToNextCommand();
assert.equal(xterm.buffer.ydisp, 9); assert.equal(xterm._core.buffer.ydisp, 9);
// Scroll to bottom boundary // Scroll to bottom boundary
commandTracker.scrollToNextCommand(); commandTracker.scrollToNextCommand();
assert.equal(xterm.buffer.ydisp, 20); assert.equal(xterm._core.buffer.ydisp, 20);
}); });
test('should select to the next and previous commands', () => { test('should select to the next and previous commands', () => {
(<any>window).matchMedia = () => { (<any>window).matchMedia = () => {
...@@ -98,8 +102,8 @@ suite('Workbench - TerminalCommandTracker', () => { ...@@ -98,8 +102,8 @@ suite('Workbench - TerminalCommandTracker', () => {
assert.equal(xterm.markers[1].line, 11); assert.equal(xterm.markers[1].line, 11);
syncWrite(xterm, '\n\r3'); syncWrite(xterm, '\n\r3');
assert.equal(xterm.buffer.ybase, 3); assert.equal(xterm._core.buffer.ybase, 3);
assert.equal(xterm.buffer.ydisp, 3); assert.equal(xterm._core.buffer.ydisp, 3);
assert.equal(xterm.getSelection(), ''); assert.equal(xterm.getSelection(), '');
commandTracker.selectToPreviousCommand(); commandTracker.selectToPreviousCommand();
...@@ -128,8 +132,8 @@ suite('Workbench - TerminalCommandTracker', () => { ...@@ -128,8 +132,8 @@ suite('Workbench - TerminalCommandTracker', () => {
assert.equal(xterm.markers[1].line, 11); assert.equal(xterm.markers[1].line, 11);
syncWrite(xterm, '\n\r3'); syncWrite(xterm, '\n\r3');
assert.equal(xterm.buffer.ybase, 3); assert.equal(xterm._core.buffer.ybase, 3);
assert.equal(xterm.buffer.ydisp, 3); assert.equal(xterm._core.buffer.ydisp, 3);
assert.equal(xterm.getSelection(), ''); assert.equal(xterm.getSelection(), '');
commandTracker.selectToPreviousLine(); commandTracker.selectToPreviousLine();
......
...@@ -6253,9 +6253,9 @@ vscode-textmate@^4.0.0-next.2: ...@@ -6253,9 +6253,9 @@ vscode-textmate@^4.0.0-next.2:
fast-plist "^0.1.2" fast-plist "^0.1.2"
oniguruma "^7.0.0" oniguruma "^7.0.0"
vscode-xterm@3.5.0-beta13: vscode-xterm@3.5.0-beta14:
version "3.5.0-beta13" version "3.5.0-beta14"
resolved "https://registry.yarnpkg.com/vscode-xterm/-/vscode-xterm-3.5.0-beta13.tgz#8fc24f6d7509e6119d8ec0deb07070e1ed86ddbc" resolved "https://registry.yarnpkg.com/vscode-xterm/-/vscode-xterm-3.5.0-beta14.tgz#3d55256e68b822cb528e64c281a786d2ac9db369"
vso-node-api@^6.1.2-preview: vso-node-api@^6.1.2-preview:
version "6.1.2-preview" version "6.1.2-preview"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册