提交 52e29e90 编写于 作者: D Daniel Imms

Update reaching into xterm.js internals to work after layering merge

上级 519b82b5
......@@ -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;
charMeasure?: { height: number, width: number };
renderer: {
_renderLayers: any[];
onIntersectionChange: any;
}
}
/**
* Emit an event on the terminal.
*/
emit(type: string, data: any): void;
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 };
}
}
......@@ -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
};
}
}
......
......@@ -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 = (<any>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 = (<any>this._xterm.buffer);
const buffer = (<any>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 = (<any>this._xterm.buffer);
const buffer = (<any>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') {
(<any>this._xterm).renderer.onIntersectionChange({ intersectionRatio: 1 });
this._xterm._core.renderer.onIntersectionChange({ intersectionRatio: 1 });
}
}
}
......
......@@ -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;
}
}
......
......@@ -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', () => {
(<any>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();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册