提交 76ddb455 编写于 作者: D Daniel Imms

Adopt xterm buffer API changes

上级 613261ce
......@@ -50,7 +50,7 @@ export class CommandTrackerAddon implements ICommandTracker, ITerminalAddon {
if (!this._terminal) {
return;
}
if (this._terminal.buffer.cursorX >= MINIMUM_PROMPT_LENGTH) {
if (this._terminal.buffer.active.cursorX >= MINIMUM_PROMPT_LENGTH) {
this._terminal.registerMarker(0);
}
}
......@@ -64,8 +64,8 @@ export class CommandTrackerAddon implements ICommandTracker, ITerminalAddon {
}
let markerIndex;
const currentLineY = Math.min(this._getLine(this._terminal, this._currentMarker), this._terminal.buffer.baseY);
const viewportY = this._terminal.buffer.viewportY;
const currentLineY = Math.min(this._getLine(this._terminal, this._currentMarker), this._terminal.buffer.active.baseY);
const viewportY = this._terminal.buffer.active.viewportY;
if (!retainSelection && currentLineY !== viewportY) {
// The user has scrolled, find the line based on the current scroll position. This only
// works when not retaining selection
......@@ -103,8 +103,8 @@ export class CommandTrackerAddon implements ICommandTracker, ITerminalAddon {
}
let markerIndex;
const currentLineY = Math.min(this._getLine(this._terminal, this._currentMarker), this._terminal.buffer.baseY);
const viewportY = this._terminal.buffer.viewportY;
const currentLineY = Math.min(this._getLine(this._terminal, this._currentMarker), this._terminal.buffer.active.baseY);
const viewportY = this._terminal.buffer.active.viewportY;
if (!retainSelection && currentLineY !== viewportY) {
// The user has scrolled, find the line based on the current scroll position. This only
// works when not retaining selection
......@@ -212,7 +212,7 @@ export class CommandTrackerAddon implements ICommandTracker, ITerminalAddon {
private _getLine(xterm: Terminal, marker: IMarker | Boundary): number {
// Use the _second last_ row as the last row is likely the prompt
if (marker === Boundary.Bottom) {
return xterm.buffer.baseY + xterm.rows - 1;
return xterm.buffer.active.baseY + xterm.rows - 1;
}
if (marker === Boundary.Top) {
......@@ -272,10 +272,10 @@ export class CommandTrackerAddon implements ICommandTracker, ITerminalAddon {
if (this._currentMarker === Boundary.Bottom) {
return 0;
} else if (this._currentMarker === Boundary.Top) {
return 0 - (xterm.buffer.baseY + xterm.buffer.cursorY);
return 0 - (xterm.buffer.active.baseY + xterm.buffer.active.cursorY);
} else {
let offset = this._getLine(xterm, this._currentMarker);
offset -= xterm.buffer.baseY + xterm.buffer.cursorY;
offset -= xterm.buffer.active.baseY + xterm.buffer.active.cursorY;
return offset;
}
}
......
......@@ -55,7 +55,7 @@ export class NavigationModeAddon implements INavigationMode, ITerminalAddon {
}
// Target is row before the cursor
const targetRow = Math.max(this._terminal.buffer.cursorY - 1, 0);
const targetRow = Math.max(this._terminal.buffer.active.cursorY - 1, 0);
// Check bounds
if (treeContainer.childElementCount < targetRow) {
......@@ -98,7 +98,7 @@ export class NavigationModeAddon implements INavigationMode, ITerminalAddon {
}
// Target is cursor row
const targetRow = this._terminal.buffer.cursorY;
const targetRow = this._terminal.buffer.active.cursorY;
// Check bounds
if (treeContainer.childElementCount < targetRow) {
......
......@@ -735,7 +735,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
}
if (this._xterm) {
const buffer = this._xterm.buffer;
this._sendLineData(buffer, buffer.baseY + buffer.cursorY);
this._sendLineData(buffer.active, buffer.active.baseY + buffer.active.cursorY);
this._xterm.dispose();
}
......@@ -813,7 +813,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
// change since the number of visible rows decreases.
// This can likely be removed after https://github.com/xtermjs/xterm.js/issues/291 is
// fixed upstream.
this._xtermCore._onScroll.fire(this._xterm.buffer.viewportY);
this._xtermCore._onScroll.fire(this._xterm.buffer.active.viewportY);
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
......@@ -1065,15 +1065,15 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
private _onLineFeed(): void {
const buffer = this._xterm!.buffer;
const newLine = buffer.getLine(buffer.baseY + buffer.cursorY);
const newLine = buffer.active.getLine(buffer.active.baseY + buffer.active.cursorY);
if (newLine && !newLine.isWrapped) {
this._sendLineData(buffer, buffer.baseY + buffer.cursorY - 1);
this._sendLineData(buffer.active, buffer.active.baseY + buffer.active.cursorY - 1);
}
}
private _onCursorMove(): void {
const buffer = this._xterm!.buffer;
this._sendLineData(buffer, buffer.baseY + buffer.cursorY);
this._sendLineData(buffer.active, buffer.active.baseY + buffer.active.cursorY);
}
private _onTitleChange(title: string): void {
......
......@@ -61,24 +61,24 @@ suite('Workbench - TerminalCommandTracker', () => {
for (let i = 0; i < 20; i++) {
await writePromise(xterm, `\r\n`);
}
assert.equal(xterm.buffer.baseY, 20);
assert.equal(xterm.buffer.viewportY, 20);
assert.equal(xterm.buffer.active.baseY, 20);
assert.equal(xterm.buffer.active.viewportY, 20);
// Scroll to marker
commandTracker.scrollToPreviousCommand();
assert.equal(xterm.buffer.viewportY, 9);
assert.equal(xterm.buffer.active.viewportY, 9);
// Scroll to top boundary
commandTracker.scrollToPreviousCommand();
assert.equal(xterm.buffer.viewportY, 0);
assert.equal(xterm.buffer.active.viewportY, 0);
// Scroll to marker
commandTracker.scrollToNextCommand();
assert.equal(xterm.buffer.viewportY, 9);
assert.equal(xterm.buffer.active.viewportY, 9);
// Scroll to bottom boundary
commandTracker.scrollToNextCommand();
assert.equal(xterm.buffer.viewportY, 20);
assert.equal(xterm.buffer.active.viewportY, 20);
});
test('should select to the next and previous commands', async () => {
(<any>window).matchMedia = () => {
......@@ -99,8 +99,8 @@ suite('Workbench - TerminalCommandTracker', () => {
assert.equal(xterm.markers[1].line, 11);
await writePromise(xterm, '\n\r3');
assert.equal(xterm.buffer.baseY, 3);
assert.equal(xterm.buffer.viewportY, 3);
assert.equal(xterm.buffer.active.baseY, 3);
assert.equal(xterm.buffer.active.viewportY, 3);
assert.equal(xterm.getSelection(), '');
commandTracker.selectToPreviousCommand();
......@@ -133,8 +133,8 @@ suite('Workbench - TerminalCommandTracker', () => {
assert.equal(xterm.markers[1].line, 11);
await writePromise(xterm, '\n\r3');
assert.equal(xterm.buffer.baseY, 3);
assert.equal(xterm.buffer.viewportY, 3);
assert.equal(xterm.buffer.active.baseY, 3);
assert.equal(xterm.buffer.active.viewportY, 3);
assert.equal(xterm.getSelection(), '');
commandTracker.selectToPreviousLine();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册