diff --git a/src/vs/workbench/contrib/terminal/browser/terminalCommandTracker.ts b/src/vs/workbench/contrib/terminal/browser/terminalCommandTracker.ts index c7857624a7d1a9caff0298aec628b6ace672ce7c..2ff3af60b2e2a3822820dc78c2700cf9cb9029d2 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalCommandTracker.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalCommandTracker.ts @@ -30,7 +30,7 @@ export class TerminalCommandTracker implements ITerminalCommandTracker, IDisposa constructor( private _xterm: Terminal ) { - this._xterm.on('key', key => this._onKey(key)); + this._xterm.onKey(e => this._onKey(e.key)); } public dispose(): void { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index d235512c919385688b46c23a325a7209cb821efc..77d251bee3e69e89f70b787aa2e4207e30147d6e 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -371,7 +371,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._core.buffer.ydisp); + this._xterm._core._onScroll.fire(this._xterm._core.buffer.ydisp); } } @@ -421,12 +421,12 @@ export class TerminalInstance implements ITerminalInstance { if (this._shellLaunchConfig.initialText) { this._xterm.writeln(this._shellLaunchConfig.initialText); } - this._xterm.on('linefeed', () => this._onLineFeed()); - this._xterm.on('key', (key, ev) => this._onKey(key, ev)); + this._xterm.onLineFeed(() => this._onLineFeed()); + this._xterm.onKey(e => this._onKey(e.key, e.domEvent)); if (this._processManager) { this._processManager.onProcessData(data => this._onProcessData(data)); - this._xterm.on('data', data => this._processManager!.write(data)); + this._xterm.onData(data => this._processManager!.write(data)); // TODO: How does the cwd work on detached processes? this.processReady.then(async () => { this._linkHandler.processCwd = await this._processManager!.getInitialCwd(); @@ -445,11 +445,11 @@ export class TerminalInstance implements ITerminalInstance { } else if (this.shellLaunchConfig.isRendererOnly) { this._linkHandler = this._instantiationService.createInstance(TerminalLinkHandler, this._xterm, undefined, undefined); } - this._xterm.on('focus', () => this._onFocus.fire(this)); + this._xterm.textarea.addEventListener('focus', () => this._onFocus.fire(this)); // Register listener to trigger the onInput ext API if the terminal is a renderer only if (this._shellLaunchConfig.isRendererOnly) { - this._xterm.on('data', (data) => this._sendRendererInput(data)); + this._xterm.onData(data => this._sendRendererInput(data)); } this._commandTracker = new TerminalCommandTracker(this._xterm); @@ -858,7 +858,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._core.buffer.ydisp); + this._xterm._core._onScroll.fire(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 diff --git a/src/vs/workbench/contrib/terminal/node/windowsShellHelper.ts b/src/vs/workbench/contrib/terminal/node/windowsShellHelper.ts index d841d02369590415101785aeddaf8e846d84301f..1bc875456ddb9bf2424e796ba8f92b8a8ed6a542 100644 --- a/src/vs/workbench/contrib/terminal/node/windowsShellHelper.ts +++ b/src/vs/workbench/contrib/terminal/node/windowsShellHelper.ts @@ -61,15 +61,15 @@ export class WindowsShellHelper implements IWindowsShellHelper { // If this is done on every linefeed, parsing ends up taking // significantly longer due to resetting timers. Note that this is // private API. - this._xterm.on('linefeed', () => this._newLineFeed = true); - this._xterm.on('cursormove', () => { + this._xterm.onLineFeed(() => this._newLineFeed = true); + this._xterm.onCursorMove(() => { if (this._newLineFeed) { this._onCheckShell.fire(undefined); } }); // Fire a new check for the shell when any key is pressed. - this._xterm.on('keypress', () => this._onCheckShell.fire(undefined)); + this._xterm.onKey(() => this._onCheckShell.fire(undefined)); }); } diff --git a/src/vs/workbench/contrib/terminal/test/electron-browser/terminalCommandTracker.test.ts b/src/vs/workbench/contrib/terminal/test/electron-browser/terminalCommandTracker.test.ts index ec94ff8a518bcec580a84731953eada0d2c0d2e8..cd80a60ee1ace15429977bb6c71908593cf2df0f 100644 --- a/src/vs/workbench/contrib/terminal/test/electron-browser/terminalCommandTracker.test.ts +++ b/src/vs/workbench/contrib/terminal/test/electron-browser/terminalCommandTracker.test.ts @@ -46,13 +46,13 @@ suite('Workbench - TerminalCommandTracker', () => { test('should track commands when the prompt is of sufficient size', () => { assert.equal(xterm.markers.length, 0); syncWrite(xterm, '\x1b[3G'); // Move cursor to column 3 - xterm.emit('key', '\x0d'); + xterm._core._onKey.fire({ key: '\x0d' }); assert.equal(xterm.markers.length, 1); }); test('should not track commands when the prompt is too small', () => { assert.equal(xterm.markers.length, 0); syncWrite(xterm, '\x1b[2G'); // Move cursor to column 2 - xterm.emit('key', '\x0d'); + xterm._core._onKey.fire({ key: '\x0d' }); assert.equal(xterm.markers.length, 0); }); }); @@ -60,7 +60,7 @@ suite('Workbench - TerminalCommandTracker', () => { suite('Commands', () => { test('should scroll to the next and previous commands', () => { syncWrite(xterm, '\x1b[3G'); // Move cursor to column 3 - xterm.emit('key', '\x0d'); // Mark line #10 + xterm._core._onKey.fire({ key: '\x0d' }); // Mark line #10 assert.equal(xterm.markers[0].line, 9); for (let i = 0; i < 20; i++) { @@ -94,11 +94,11 @@ suite('Workbench - TerminalCommandTracker', () => { syncWrite(xterm, '\r0'); syncWrite(xterm, '\n\r1'); syncWrite(xterm, '\x1b[3G'); // Move cursor to column 3 - xterm.emit('key', '\x0d'); // Mark line + xterm._core._onKey.fire({ key: '\x0d' }); // Mark line assert.equal(xterm.markers[0].line, 10); syncWrite(xterm, '\n\r2'); syncWrite(xterm, '\x1b[3G'); // Move cursor to column 3 - xterm.emit('key', '\x0d'); // Mark line + xterm._core._onKey.fire({ key: '\x0d' }); // Mark line assert.equal(xterm.markers[1].line, 11); syncWrite(xterm, '\n\r3'); @@ -124,11 +124,11 @@ suite('Workbench - TerminalCommandTracker', () => { syncWrite(xterm, '\r0'); syncWrite(xterm, '\n\r1'); syncWrite(xterm, '\x1b[3G'); // Move cursor to column 3 - xterm.emit('key', '\x0d'); // Mark line + xterm._core._onKey.fire({ key: '\x0d' }); // Mark line assert.equal(xterm.markers[0].line, 10); syncWrite(xterm, '\n\r2'); syncWrite(xterm, '\x1b[3G'); // Move cursor to column 3 - xterm.emit('key', '\x0d'); // Mark line + xterm._core._onKey.fire({ key: '\x0d' }); // Mark line assert.equal(xterm.markers[1].line, 11); syncWrite(xterm, '\n\r3');