Skip to content

Commit 7f46c74

Browse files
update to xterm4
1 parent 5bc8e0b commit 7f46c74

File tree

4 files changed

+54
-25
lines changed

4 files changed

+54
-25
lines changed

lib/components/term-group.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class TermGroup_ extends React.PureComponent {
8787
onResize: this.bind(this.props.onResize, null, uid),
8888
onTitle: this.bind(this.props.onTitle, null, uid),
8989
onData: this.bind(this.props.onData, null, uid),
90-
onURLAbort: this.bind(this.props.onURLAbort, null, uid),
90+
// onURLAbort: this.bind(this.props.onURLAbort, null, uid),
9191
toggleSearch: this.bind(this.props.toggleSearch, null, uid),
9292
onContextMenu: this.bind(this.props.onContextMenu, null, uid),
9393
borderColor: this.props.borderColor,

lib/components/term.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
/* global Blob,URL,requestAnimationFrame,ResizeObserver */
22
import React from 'react';
33
import {Terminal} from 'xterm';
4-
import * as fit from 'xterm/lib/addons/fit/fit';
5-
import * as webLinks from 'xterm/lib/addons/webLinks/webLinks';
6-
import * as search from 'xterm/lib/addons/search';
7-
import * as winptyCompat from 'xterm/lib/addons/winptyCompat/winptyCompat';
4+
import {FitAddon} from 'xterm-addon-fit';
5+
import {WebLinksAddon} from 'xterm-addon-web-links';
6+
import {SearchAddon} from 'xterm-addon-search';
7+
import {WebglAddon} from 'xterm-addon-webgl';
88
import {clipboard} from 'electron';
99
import * as Color from 'color';
1010
import terms from '../terms';
1111
import processClipboard from '../utils/paste';
1212
import SearchBox from './searchBox';
1313

14-
Terminal.applyAddon(fit);
15-
Terminal.applyAddon(webLinks);
16-
Terminal.applyAddon(winptyCompat);
17-
Terminal.applyAddon(search);
14+
const fitAddon = new FitAddon();
15+
const webLinksAddon = new WebLinksAddon();
16+
const searchAddon = new SearchAddon();
17+
const webglAddon = new WebglAddon();
1818

1919
// map old hterm constants to xterm.js
2020
const CURSOR_STYLES = {
@@ -73,8 +73,8 @@ const getTermOptions = props => {
7373
// HACK: Terminal.setOption breaks if we don't apply these in this order
7474
// TODO: The above notice can be removed once this is addressed:
7575
// https://github.com/xtermjs/xterm.js/pull/1790#issuecomment-450000121
76-
rendererType: useWebGL ? 'webgl' : 'canvas',
77-
experimentalCharAtlas: useWebGL ? 'webgl' : 'dynamic',
76+
// rendererType: useWebGL ? 'webgl' : 'canvas',
77+
// experimentalCharAtlas: useWebGL ? 'webgl' : 'dynamic',
7878
theme: {
7979
foreground: props.foregroundColor,
8080
background: backgroundColor,
@@ -144,38 +144,42 @@ export default class Term extends React.PureComponent {
144144

145145
if (!props.term) {
146146
this.term.attachCustomKeyEventHandler(this.keyboardHandler);
147+
this.term.loadAddon(fitAddon);
148+
this.term.loadAddon(webLinksAddon);
149+
this.term.loadAddon(searchAddon);
147150
this.term.open(this.termRef);
148-
this.term.webLinksInit();
149-
this.term.winptyCompatInit();
151+
this.term.loadAddon(webglAddon);
152+
// this.term.webLinksInit();
153+
// this.term.winptyCompatInit();
150154
}
151155

152156
if (this.props.isTermActive) {
153157
this.term.focus();
154158
}
155159

156160
if (props.onTitle) {
157-
this.disposableListeners.push(this.term.addDisposableListener('title', props.onTitle));
161+
this.disposableListeners.push(this.term.onTitleChange(props.onTitle));
158162
}
159163

160-
if (props.onActive) {
161-
this.disposableListeners.push(this.term.addDisposableListener('focus', props.onActive));
162-
}
164+
// if (props.onActive) {
165+
// this.disposableListeners.push(this.term.addDisposableListener('focus', props.onActive));
166+
// }
163167

164168
if (props.onData) {
165-
this.disposableListeners.push(this.term.addDisposableListener('data', props.onData));
169+
this.disposableListeners.push(this.term.onData(props.onData));
166170
}
167171

168172
if (props.onResize) {
169173
this.disposableListeners.push(
170-
this.term.addDisposableListener('resize', ({cols, rows}) => {
174+
this.term.onResize(({cols, rows}) => {
171175
props.onResize(cols, rows);
172176
})
173177
);
174178
}
175179

176180
if (props.onCursorMove) {
177181
this.disposableListeners.push(
178-
this.term.addDisposableListener('cursormove', () => {
182+
this.term.onCursorMove(() => {
179183
const cursorFrame = {
180184
x: this.term._core.buffer.x * this.term._core.renderer.dimensions.actualCellWidth,
181185
y: this.term._core.buffer.y * this.term._core.renderer.dimensions.actualCellHeight,
@@ -278,7 +282,7 @@ export default class Term extends React.PureComponent {
278282
if (!this.termWrapperRef) {
279283
return;
280284
}
281-
this.term.fit();
285+
fitAddon.fit();
282286
}
283287

284288
keyboardHandler(e) {

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,11 @@
213213
"stylis": "3.5.0",
214214
"uuid": "3.1.0",
215215
"webpack-cli": "3.3.7",
216-
"xterm": "https://registry.npmjs.org/@zeit/xterm/-/xterm-3.12.0-1.tgz"
216+
"xterm": "4.0.2",
217+
"xterm-addon-fit": "^0.2.0",
218+
"xterm-addon-search": "^0.2.0",
219+
"xterm-addon-webgl": "^0.2.0",
220+
"xterm-addon-web-links": "^0.2.0"
217221
},
218222
"devDependencies": {
219223
"@babel/cli": "7.5.5",

yarn.lock

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8672,9 +8672,30 @@ xtend@~2.1.1:
86728672
dependencies:
86738673
object-keys "~0.4.0"
86748674

8675-
"xterm@https://registry.npmjs.org/@zeit/xterm/-/xterm-3.12.0-1.tgz":
8676-
version "3.12.0-1"
8677-
resolved "https://registry.npmjs.org/@zeit/xterm/-/xterm-3.12.0-1.tgz#df7bb98fe53d621c0bfd559d0ae87be401c8f246"
8675+
xterm-addon-fit@^0.2.0:
8676+
version "0.2.1"
8677+
resolved "https://registry.yarnpkg.com/xterm-addon-fit/-/xterm-addon-fit-0.2.1.tgz#353f43921eb78e3f9ad3f3afbb14e7ac183ca738"
8678+
integrity sha512-BlR57O3t1/bmVcnS81bn9ZnNf+GiGNbeXdNUKSBa9tKEwNUMcU3S+KFLIRv7rm1Ty0D5pMOu0vbz/RDorKRwKQ==
8679+
8680+
xterm-addon-search@^0.2.0:
8681+
version "0.2.1"
8682+
resolved "https://registry.yarnpkg.com/xterm-addon-search/-/xterm-addon-search-0.2.1.tgz#f2c02fa92198d5115bde5cc518bff9d7998f2b9c"
8683+
integrity sha512-zT2TD0szNIgYYMJuCXMyjY2oF5YzhJ4QqKDO/KyPCm+d67x/7DvPxcg4DWkrPHhBc14jvo0iaTqpdPnSAUvhgg==
8684+
8685+
xterm-addon-web-links@^0.2.0:
8686+
version "0.2.1"
8687+
resolved "https://registry.yarnpkg.com/xterm-addon-web-links/-/xterm-addon-web-links-0.2.1.tgz#6d1f2ce613e09870badf17615e7a1170a31542b2"
8688+
integrity sha512-2KnHtiq0IG7hfwv3jw2/jQeH1RBk2d5CH4zvgwQe00rLofSJqSfgnJ7gwowxxpGHrpbPr6Lv4AmH/joaNw2+HQ==
8689+
8690+
xterm-addon-webgl@^0.2.0:
8691+
version "0.2.1"
8692+
resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.2.1.tgz#86452460601dc29b7d907dbcd0b8a058bcbc6bcf"
8693+
integrity sha512-MZyh/KGbOBEEOqGpgilHuKHSj0OCXiZsBedTtLesHNerc79710shUHnfBlk31ggYU9G/WJ91qoNNux3ek5QBPA==
8694+
8695+
xterm@4.0.2:
8696+
version "4.0.2"
8697+
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.0.2.tgz#c6a1b9586c0786627625e2ee9e78ad519dbc8c99"
8698+
integrity sha512-NIr11b6C782TZznU8e6K/IMfmwlWMWRI6ba9GEDG9uX25SadkpjoMnzvxOS0Z/15sfrbn0rghPiarGDmmP0uhQ==
86788699

86798700
y18n@^3.2.1:
86808701
version "3.2.1"

0 commit comments

Comments
 (0)