From 357b8e9d4413bc5c566a7d4b751bb381b8fe5db8 Mon Sep 17 00:00:00 2001 From: Alex Logan Date: Tue, 3 Mar 2020 11:21:23 +0000 Subject: [PATCH] bump version of xterm Signed-off-by: Alex Logan --- packages/terminal/package.json | 4 +++- .../browser/search/terminal-search-widget.tsx | 11 +++++---- .../src/browser/terminal-frontend-module.ts | 2 +- .../src/browser/terminal-linkmatcher.ts | 2 +- .../src/browser/terminal-theme-service.ts | 6 ++--- .../src/browser/terminal-widget-impl.ts | 23 +++++++++++-------- yarn.lock | 18 +++++++++++---- 7 files changed, 43 insertions(+), 23 deletions(-) diff --git a/packages/terminal/package.json b/packages/terminal/package.json index 8b39b6db2e0d0..51382367fd1eb 100644 --- a/packages/terminal/package.json +++ b/packages/terminal/package.json @@ -8,7 +8,9 @@ "@theia/filesystem": "^0.16.0", "@theia/process": "^0.16.0", "@theia/workspace": "^0.16.0", - "xterm": "3.13.0" + "xterm": "^4.4.0", + "xterm-addon-fit": "^0.3.0", + "xterm-addon-search": "^0.5.0" }, "publishConfig": { "access": "public" diff --git a/packages/terminal/src/browser/search/terminal-search-widget.tsx b/packages/terminal/src/browser/search/terminal-search-widget.tsx index ed5df66379305..f782d4c322bd3 100644 --- a/packages/terminal/src/browser/search/terminal-search-widget.tsx +++ b/packages/terminal/src/browser/search/terminal-search-widget.tsx @@ -19,8 +19,7 @@ import { ReactWidget } from '@theia/core/lib/browser/widgets/react-widget'; import * as React from 'react'; import '../../../src/browser/style/terminal-search.css'; import { Terminal } from 'xterm'; -import { findNext, findPrevious } from 'xterm/lib/addons/search/search'; -import { ISearchOptions } from 'xterm/lib/addons/search/Interfaces'; +import { SearchAddon, ISearchOptions } from 'xterm-addon-search'; import { Key } from '@theia/core/lib/browser'; export const TERMINAL_SEARCH_WIDGET_FACTORY_ID = 'terminal-search'; @@ -33,6 +32,7 @@ export class TerminalSearchWidget extends ReactWidget { private searchInput: HTMLInputElement | null; private searchBox: HTMLDivElement | null; private searchOptions: ISearchOptions = {}; + private searchAddon: SearchAddon; @inject(Terminal) protected terminal: Terminal; @@ -41,6 +41,9 @@ export class TerminalSearchWidget extends ReactWidget { protected init(): void { this.node.classList.add('theia-search-terminal-widget-parent'); + this.searchAddon = new SearchAddon(); + this.terminal.loadAddon(this.searchAddon); + this.hide(); this.update(); } @@ -128,11 +131,11 @@ export class TerminalSearchWidget extends ReactWidget { const searchText = this.searchInput.value; if (searchDirection === 'next') { - findNext(this.terminal, searchText, this.searchOptions); + this.searchAddon.findNext(searchText, this.searchOptions); } if (searchDirection === 'previous') { - findPrevious(this.terminal, searchText, this.searchOptions); + this.searchAddon.findPrevious(searchText, this.searchOptions); } } } diff --git a/packages/terminal/src/browser/terminal-frontend-module.ts b/packages/terminal/src/browser/terminal-frontend-module.ts index 1b996233865f7..06eecb6aeb327 100644 --- a/packages/terminal/src/browser/terminal-frontend-module.ts +++ b/packages/terminal/src/browser/terminal-frontend-module.ts @@ -15,7 +15,7 @@ ********************************************************************************/ import '../../src/browser/style/terminal.css'; -import 'xterm/lib/xterm.css'; +import 'xterm/css/xterm.css'; import { ContainerModule, Container } from 'inversify'; import { CommandContribution, MenuContribution } from '@theia/core/lib/common'; diff --git a/packages/terminal/src/browser/terminal-linkmatcher.ts b/packages/terminal/src/browser/terminal-linkmatcher.ts index 49b7172c3f85f..eafccb58dcc16 100644 --- a/packages/terminal/src/browser/terminal-linkmatcher.ts +++ b/packages/terminal/src/browser/terminal-linkmatcher.ts @@ -50,7 +50,7 @@ export abstract class AbstractCmdClickTerminalContribution implements TerminalCo terminalWidget.showHoverMessage(event.clientX, event.clientY, this.getHoverMessage()); } }, - leaveCallback: (event: MouseEvent, uri: string) => { + leaveCallback: () => { terminalWidget.hideHover(); }, validationCallback: async (uri: string, callBack: (isValid: boolean) => void) => { diff --git a/packages/terminal/src/browser/terminal-theme-service.ts b/packages/terminal/src/browser/terminal-theme-service.ts index e29babde72e0b..ed844ecb01bd3 100644 --- a/packages/terminal/src/browser/terminal-theme-service.ts +++ b/packages/terminal/src/browser/terminal-theme-service.ts @@ -14,7 +14,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ -import * as Xterm from 'xterm'; +import { ITheme } from 'xterm'; import { injectable, inject } from 'inversify'; import { ColorRegistry, ColorDefaults } from '@theia/core/lib/browser/color-registry'; import { ThemeService } from '@theia/core/lib/browser/theming'; @@ -161,14 +161,14 @@ export class TerminalThemeService { readonly onDidChange = ThemeService.get().onThemeChange; - get theme(): Xterm.ITheme { + get theme(): ITheme { const foregroundColor = this.colorRegistry.getCurrentColor('terminal.foreground'); const backgroundColor = this.colorRegistry.getCurrentColor('terminal.background') || this.colorRegistry.getCurrentColor('panel.background'); const cursorColor = this.colorRegistry.getCurrentColor('terminalCursor.foreground') || foregroundColor; const cursorAccentColor = this.colorRegistry.getCurrentColor('terminalCursor.background') || backgroundColor; const selectionColor = this.colorRegistry.getCurrentColor('terminal.selectionBackground'); - const theme: Xterm.ITheme = { + const theme: ITheme = { background: backgroundColor, foreground: foregroundColor, cursor: cursorColor, diff --git a/packages/terminal/src/browser/terminal-widget-impl.ts b/packages/terminal/src/browser/terminal-widget-impl.ts index 617bfa23824ef..7abab545f1e2d 100644 --- a/packages/terminal/src/browser/terminal-widget-impl.ts +++ b/packages/terminal/src/browser/terminal-widget-impl.ts @@ -14,8 +14,8 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ -import * as Xterm from 'xterm'; -import { proposeGeometry } from 'xterm/lib/addons/fit/fit'; +import { Terminal, RendererType } from 'xterm'; +import { FitAddon } from 'xterm-addon-fit'; import { inject, injectable, named, postConstruct } from 'inversify'; import { ContributionProvider, Disposable, Event, Emitter, ILogger, DisposableCollection } from '@theia/core'; import { Widget, Message, WebSocketConnectionProvider, StatefulWidget, isFirefox, MessageLoop, KeyCode } from '@theia/core/lib/browser'; @@ -49,7 +49,8 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget private readonly TERMINAL = 'Terminal'; protected readonly onTermDidClose = new Emitter(); protected terminalId = -1; - protected term: Xterm.Terminal; + protected fitAddon: FitAddon; + protected term: Terminal; protected searchBox: TerminalSearchWidget; protected restored = false; protected closeOnDispose = true; @@ -91,8 +92,7 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget this.title.closable = true; this.addClass('terminal-container'); - this.term = new Xterm.Terminal({ - experimentalCharAtlas: 'dynamic', + this.term = new Terminal({ cursorBlink: false, fontFamily: this.preferences['terminal.integrated.fontFamily'], fontSize: this.preferences['terminal.integrated.fontSize'], @@ -105,6 +105,9 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget theme: this.themeService.theme }); + this.fitAddon = new FitAddon(); + this.term.loadAddon(this.fitAddon); + this.hoverMessage = document.createElement('div'); this.hoverMessage.textContent = 'Cmd + click to follow link'; this.hoverMessage.style.position = 'fixed'; @@ -206,7 +209,7 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget * * @param terminalRendererType desired terminal renderer type */ - private getTerminalRendererType(terminalRendererType?: string | TerminalRendererType): Xterm.RendererType { + private getTerminalRendererType(terminalRendererType?: string | TerminalRendererType): RendererType { if (terminalRendererType && isTerminalRendererType(terminalRendererType)) { return terminalRendererType; } @@ -224,7 +227,7 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget this.hoverMessage.style.display = 'none'; } - getTerminal(): Xterm.Terminal { + getTerminal(): Terminal { return this.term; } @@ -434,7 +437,9 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget if (isFirefox) { // The software scrollbars don't work with xterm.js, so we disable the scrollbar if we are on firefox. - (this.term.element.children.item(0) as HTMLElement).style.overflow = 'hidden'; + if (this.term.element) { + (this.term.element.children.item(0) as HTMLElement).style.overflow = 'hidden'; + } } } protected write(data: string): void { @@ -489,7 +494,7 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget } protected resizeTerminal(): void { - const geo = proposeGeometry(this.term); + const geo = this.fitAddon.proposeDimensions(); const cols = geo.cols; const rows = geo.rows - 1; // subtract one row for margin this.term.resize(cols, rows); diff --git a/yarn.lock b/yarn.lock index 1a2f28ca6f641..883a4616e1da4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13163,10 +13163,20 @@ xtend@~2.1.1: dependencies: object-keys "~0.4.0" -xterm@3.13.0: - version "3.13.0" - resolved "https://registry.yarnpkg.com/xterm/-/xterm-3.13.0.tgz#d0e06c3cf4c1f079aa83f646948457db3b04220b" - integrity sha512-FZVmvkkbkky3zldJ2NNOZ9h8jirtbGTlF4sIKMDrejR4wPsVZ3o4F++DQVkdeZqjAwtNOMoR17PMSOTZ+h070g== +xterm-addon-fit@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/xterm-addon-fit/-/xterm-addon-fit-0.3.0.tgz#341710741027de9d648a9f84415a01ddfdbbe715" + integrity sha512-kvkiqHVrnMXgyCH9Xn0BOBJ7XaWC/4BgpSWQy3SueqximgW630t/QOankgqkvk11iTOCwWdAY9DTyQBXUMN3lw== + +xterm-addon-search@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/xterm-addon-search/-/xterm-addon-search-0.5.0.tgz#cd3a2f8056084c28e236d4e732da37682010bcc2" + integrity sha512-zLVqVTrg5w2nk9fRj3UuVKCPo/dmFe/cLf3EM9Is5Dm6cgOoXmeo9eq2KgD8A0gquAflTFTf0ya2NaFmShHwyg== + +xterm@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.4.0.tgz#5915d3c4c8800fadbcf555a0a603c672ab9df589" + integrity sha512-JGIpigWM3EBWvnS3rtBuefkiToIILSK1HYMXy4BCsUpO+O4UeeV+/U1AdAXgCB6qJrnPNb7yLgBsVCQUNMteig== y18n@^3.2.1: version "3.2.1"