From 114adf703be6203fba2da696aeac439449241ac9 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 26 Dec 2017 04:01:20 -0800 Subject: [PATCH] Upgrade xterm.js --- package.json | 4 +- src/typings/xterm.d.ts | 52 +++++++++---------- .../electron-browser/terminalInstance.ts | 6 +-- .../electron-browser/windowsShellHelper.ts | 6 +-- yarn.lock | 4 +- 5 files changed, 34 insertions(+), 38 deletions(-) diff --git a/package.json b/package.json index 58405fbb67d..e33c50a1e24 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "vscode-debugprotocol": "1.25.0", "vscode-ripgrep": "^0.6.0-patch.0.5", "vscode-textmate": "^3.2.0", - "xterm": "Tyriar/xterm.js#vscode-release/1.19", + "xterm": "Tyriar/xterm.js#vscode-release/1.20", "yauzl": "2.8.0" }, "devDependencies": { @@ -129,4 +129,4 @@ "windows-mutex": "^0.2.0", "windows-process-tree": "0.1.6" } -} \ No newline at end of file +} diff --git a/src/typings/xterm.d.ts b/src/typings/xterm.d.ts index 0f26b76a5aa..76e37c5684e 100644 --- a/src/typings/xterm.d.ts +++ b/src/typings/xterm.d.ts @@ -11,7 +11,7 @@ declare module 'xterm' { /** * An object containing start up options for the terminal. */ - interface ITerminalOptions { + export interface ITerminalOptions { /** * A data uri of the sound to use for the bell (needs bellStyle = 'sound'). */ @@ -20,7 +20,7 @@ declare module 'xterm' { /** * The type of the bell notification the terminal will use. */ - bellStyle?: 'none' | 'visual' | 'sound' | 'both'; + bellStyle?: 'none' /*| 'visual'*/ | 'sound' /*| 'both'*/; /** * The number of columns in the terminal. @@ -57,6 +57,11 @@ declare module 'xterm' { */ fontFamily?: string; + /** + * The spacing in whole pixels between characters.. + */ + letterSpacing?: number; + /** * The line height used to render text. */ @@ -87,17 +92,17 @@ declare module 'xterm' { /** * Contains colors to theme the terminal with. */ - interface ITheme { + export interface ITheme { /** The default foreground color */ foreground?: string, /** The default background color */ background?: string, /** The cursor color */ cursor?: string, - /** The selection color (can be transparent) */ - selection?: string, /** The accent color of the cursor (used as the foreground color for a block cursor) */ cursorAccent?: string, + /** The selection color (can be transparent) */ + selection?: string, /** ANSI black (eg. `\x1b[30m`) */ black?: string, /** ANSI red (eg. `\x1b[31m`) */ @@ -135,7 +140,7 @@ declare module 'xterm' { /** * An object containing options for a link matcher. */ - interface ILinkMatcherOptions { + export interface ILinkMatcherOptions { /** * The index of the link from the regex.match(text) call. This defaults to 0 * (for regular expressions without capture groups). @@ -213,7 +218,7 @@ declare module 'xterm' { * @param type The type of the event. * @param listener The listener. */ - on(type: 'blur' | 'focus' | 'lineFeed', listener: () => void): void; + on(type: 'blur' | 'focus' | 'linefeed' | 'selection', listener: () => void): void; /** * Registers an event listener. * @param type The type of the event. @@ -237,13 +242,13 @@ declare module 'xterm' { * @param type The type of the event. * @param listener The listener. */ - on(type: 'refresh', listener: (data?: { start: number, end: number }) => void): void; + on(type: 'refresh', listener: (data?: {start: number, end: number}) => void): void; /** * Registers an event listener. * @param type The type of the event. * @param listener The listener. */ - on(type: 'resize', listener: (data?: { cols: number, rows: number }) => void): void; + on(type: 'resize', listener: (data?: {cols: number, rows: number}) => void): void; /** * Registers an event listener. * @param type The type of the event. @@ -268,7 +273,7 @@ declare module 'xterm' { * @param type The type of the event. * @param listener The listener. */ - off(type: 'blur' | 'focus' | 'lineFeed' | 'data' | 'key' | 'keypress' | 'keydown' | 'refresh' | 'resize' | 'scroll' | 'title' | string, listener: (...args: any[]) => void): void; + off(type: 'blur' | 'focus' | 'linefeed' | 'selection' | 'data' | 'key' | 'keypress' | 'keydown' | 'refresh' | 'resize' | 'scroll' | 'title' | string, listener: (...args: any[]) => void): void; /** * Resizes the terminal. @@ -285,7 +290,9 @@ declare module 'xterm' { /** * Opens the terminal within an element. - * @param parent The element to create the terminal within. + * @param parent The element to create the terminal within. This element + * must be visible (have dimensions) when `open` is called as several DOM- + * based measurements need to be performed when this function is called. */ open(parent: HTMLElement): void; @@ -412,12 +419,7 @@ declare module 'xterm' { * Retrieves an option's value from the terminal. * @param key The option key. */ - getOption(key: 'cols' | 'fontSize' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; - /** - * Retrieves an option's value from the terminal. - * @param key The option key. - */ - getOption(key: 'geometry'): [number, number]; + getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; /** * Retrieves an option's value from the terminal. * @param key The option key. @@ -464,13 +466,7 @@ declare module 'xterm' { * @param key The option key. * @param value The option value. */ - setOption(key: 'cols' | 'fontSize' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback', value: number): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'geometry', value: [number, number]): void; + setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; /** * Sets an option on the terminal. * @param key The option key. @@ -504,11 +500,11 @@ declare module 'xterm' { reset(): void /** - * Loads an addon, attaching it to the Terminal prototype and making it - * available to all newly created Terminals. - * @param addon The addon to load. + * Applies an addon to the Terminal prototype, making it available to all + * newly created Terminals. + * @param addon The addon to apply. */ - static loadAddon(addon: 'attach' | 'fit' | 'fullscreen' | 'search' | 'terminado' | 'winptyCompat'): void; + static applyAddon(addon: any): void; diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts index 2bf830a0f1b..f44e3cf3296 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts @@ -256,9 +256,9 @@ export class TerminalInstance implements ITerminalInstance { if (!Terminal) { Terminal = (await import('xterm')).Terminal; // Enable search functionality in xterm.js instance - Terminal.loadAddon('search'); + Terminal.applyAddon(require.__$__nodeRequire('xterm/lib/addons/search/search')); // Enable the winpty compatibility addon which will simulate wraparound mode - Terminal.loadAddon('winptyCompat'); + Terminal.applyAddon(require.__$__nodeRequire('xterm/lib/addons/winptyCompat/winptyCompat')); } const font = this._configHelper.getFont(true); this._xterm = new Terminal({ @@ -273,7 +273,7 @@ export class TerminalInstance implements ITerminalInstance { this._xterm.writeln(this._shellLaunchConfig.initialText); } this._xterm.winptyCompatInit(); - this._xterm.on('lineFeed', () => this._onLineFeed()); + this._xterm.on('linefeed', () => this._onLineFeed()); this._process.on('message', (message) => this._sendPtyDataToXterm(message)); this._xterm.on('data', (data) => { if (this._processId) { diff --git a/src/vs/workbench/parts/terminal/electron-browser/windowsShellHelper.ts b/src/vs/workbench/parts/terminal/electron-browser/windowsShellHelper.ts index da9a2b515ea..bad3cc6cbd8 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/windowsShellHelper.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/windowsShellHelper.ts @@ -42,12 +42,12 @@ export class WindowsShellHelper { }, 50); }); - // We want to fire a new check for the shell on a lineFeed, but only + // We want to fire a new check for the shell on a linefeed, but only // when parsing has finished which is indicated by the cursormove event. - // If this is done on every lineFeed, parsing ends up taking + // 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('linefeed', () => this._newLineFeed = true); this._xterm.on('cursormove', () => { if (this._newLineFeed) { this._onCheckShell.fire(); diff --git a/yarn.lock b/yarn.lock index f241642dc91..07dbc1b4d42 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5946,9 +5946,9 @@ xtend@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xtend/-/xtend-3.0.0.tgz#5cce7407baf642cba7becda568111c493f59665a" -xterm@Tyriar/xterm.js#vscode-release/1.19: +xterm@Tyriar/xterm.js#vscode-release/1.20: version "2.9.1" - resolved "https://codeload.github.com/Tyriar/xterm.js/tar.gz/d242c552cb5c88125ac257ccaebed7fe336d9266" + resolved "https://codeload.github.com/Tyriar/xterm.js/tar.gz/7892768df9a90731ad066ff4be4286ab55ca803d" y18n@^3.2.0: version "3.2.1" -- GitLab