Skip to content

Commit

Permalink
Update to Xterm 4.3
Browse files Browse the repository at this point in the history
Update how addons are handle
Include the fit addon which is now a separate package
Update to use new event handlers
  • Loading branch information
lresende committed Dec 12, 2019
1 parent 0156857 commit 2a13976
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
5 changes: 3 additions & 2 deletions packages/terminal/package.json
Expand Up @@ -41,7 +41,8 @@
"@lumino/domutils": "^1.1.5",
"@lumino/messaging": "^1.3.1",
"@lumino/widgets": "^1.9.4",
"xterm": "~3.13.2"
"xterm": "~4.3.0",
"xterm-addon-fit": "~0.3.0"
},
"devDependencies": {
"rimraf": "~3.0.0",
Expand All @@ -54,7 +55,7 @@
"jupyterlab": {
"extraStyles": {
"xterm": [
"src/xterm.css"
"css/xterm.css"
]
}
}
Expand Down
12 changes: 8 additions & 4 deletions packages/terminal/src/widget.ts
Expand Up @@ -11,7 +11,7 @@ import { Widget } from '@lumino/widgets';

import { Terminal as Xterm } from 'xterm';

import { fit } from 'xterm/lib/addons/fit/fit';
import { FitAddon } from 'xterm-addon-fit';

import { ITerminal } from '.';

Expand Down Expand Up @@ -57,6 +57,9 @@ export class Terminal extends Widget implements ITerminal.ITerminal {

// Create the xterm.
this._term = new Xterm(xtermOptions);
this._fitAddon = new FitAddon();
this._term.loadAddon(this._fitAddon);

this._initializeTerm();

this.id = `jp-Terminal-${Private.id++}`;
Expand Down Expand Up @@ -240,7 +243,7 @@ export class Terminal extends Widget implements ITerminal.ITerminal {
*/
private _initializeTerm(): void {
const term = this._term;
term.on('data', (data: string) => {
term.onData((data: string) => {
if (this.isDisposed) {
return;
}
Expand All @@ -250,7 +253,7 @@ export class Terminal extends Widget implements ITerminal.ITerminal {
});
});

term.on('title', (title: string) => {
term.onTitleChange((title: string) => {
this.title.label = title;
});

Expand Down Expand Up @@ -301,7 +304,7 @@ export class Terminal extends Widget implements ITerminal.ITerminal {
* Resize the terminal based on computed geometry.
*/
private _resizeTerminal() {
fit(this._term);
this._fitAddon.fit();
if (this._offsetWidth === -1) {
this._offsetWidth = this.node.offsetWidth;
}
Expand All @@ -328,6 +331,7 @@ export class Terminal extends Widget implements ITerminal.ITerminal {
}

private readonly _term: Xterm;
private readonly _fitAddon: FitAddon;
private _needsResize = true;
private _termOpened = false;
private _offsetWidth = -1;
Expand Down
2 changes: 1 addition & 1 deletion packages/terminal/style/index.css
Expand Up @@ -6,6 +6,6 @@
/* This file was auto-generated by ensurePackage() in @jupyterlab/buildutils */
@import url('~@lumino/widgets/style/index.css');
@import url('~@jupyterlab/apputils/style/index.css');
@import url('~xterm/src/xterm.css');
@import url('~xterm/css/xterm.css');

@import url('./base.css');
13 changes: 9 additions & 4 deletions yarn.lock
Expand Up @@ -13681,10 +13681,15 @@ xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1:
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"
integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==

xterm@~3.13.2:
version "3.13.2"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-3.13.2.tgz#987c3a7fe3d23d6c03ce0eaf06c0554c38935570"
integrity sha512-4utKoF16/pzH6+EkFaaay+qPCozf5RP2P0JuH6rvIGHY0CRwgU2LwbQ/24DY+TvaZ5m+kwvIUvPqIBoMZYfgOg==
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@~4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.3.0.tgz#9a302efefe75172d4f7ea3afc20f9bd983f05027"
integrity sha512-6dnrC4nxgnRKQzIWwC5HA0mnT9/rpDPZflUIr24gdcdSMTKM1QQcor4qQ/xz4Zerz6AIL/CuuBPypFfzsB63dQ==

y18n@^3.2.0:
version "3.2.1"
Expand Down

0 comments on commit 2a13976

Please sign in to comment.