Skip to content

Commit

Permalink
bump version of xterm
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Logan <Alex.Logan@arm.com>
  • Loading branch information
Alex Logan authored and AndrienkoAleksandr committed Mar 4, 2020
1 parent c5569a4 commit 357b8e9
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 23 deletions.
4 changes: 3 additions & 1 deletion packages/terminal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 7 additions & 4 deletions packages/terminal/src/browser/search/terminal-search-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand All @@ -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();
}
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/terminal/src/browser/terminal-frontend-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/terminal/src/browser/terminal-linkmatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/terminal/src/browser/terminal-theme-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down
23 changes: 14 additions & 9 deletions packages/terminal/src/browser/terminal-widget-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -49,7 +49,8 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
private readonly TERMINAL = 'Terminal';
protected readonly onTermDidClose = new Emitter<TerminalWidget>();
protected terminalId = -1;
protected term: Xterm.Terminal;
protected fitAddon: FitAddon;
protected term: Terminal;
protected searchBox: TerminalSearchWidget;
protected restored = false;
protected closeOnDispose = true;
Expand Down Expand Up @@ -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'],
Expand All @@ -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';
Expand Down Expand Up @@ -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;
}
Expand All @@ -224,7 +227,7 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
this.hoverMessage.style.display = 'none';
}

getTerminal(): Xterm.Terminal {
getTerminal(): Terminal {
return this.term;
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 14 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 357b8e9

Please sign in to comment.