Skip to content

Commit 0332519

Browse files
xterm 5
1 parent 618384c commit 0332519

File tree

3 files changed

+73
-72
lines changed

3 files changed

+73
-72
lines changed

lib/components/term.tsx

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {FitAddon} from 'xterm-addon-fit';
44
import {WebLinksAddon} from 'xterm-addon-web-links';
55
import {SearchAddon, ISearchDecorationOptions} from 'xterm-addon-search';
66
import {WebglAddon} from 'xterm-addon-webgl';
7+
import {CanvasAddon} from 'xterm-addon-canvas';
78
import {LigaturesAddon} from 'xterm-addon-ligatures';
89
import {Unicode11Addon} from 'xterm-addon-unicode11';
910
import {clipboard, shell} from 'electron';
@@ -15,6 +16,7 @@ import {TermProps} from '../hyper';
1516
import {ObjectTypedKeys} from '../utils/object';
1617
import {decorate} from '../utils/plugins';
1718
import 'xterm/css/xterm.css';
19+
import _ from 'lodash';
1820

1921
const SearchBox = decorate(_SearchBox, 'SearchBox');
2022

@@ -57,14 +59,14 @@ const getTermOptions = (props: TermProps): ITerminalOptions => {
5759
letterSpacing: props.letterSpacing,
5860
allowTransparency: needTransparency,
5961
macOptionClickForcesSelection: props.macOptionSelectionMode === 'force',
60-
bellStyle: props.bell === 'SOUND' ? 'sound' : 'none',
62+
// bellStyle: props.bell === 'SOUND' ? 'sound' : 'none',
6163
windowsMode: isWindows,
6264
theme: {
6365
foreground: props.foregroundColor,
6466
background: backgroundColor,
6567
cursor: props.cursorColor,
6668
cursorAccent: props.cursorAccentColor,
67-
selection: props.selectionColor,
69+
selectionBackground: props.selectionColor,
6870
black: props.colors.black,
6971
red: props.colors.red,
7072
green: props.colors.green,
@@ -83,7 +85,8 @@ const getTermOptions = (props: TermProps): ITerminalOptions => {
8385
brightWhite: props.colors.lightWhite
8486
},
8587
screenReaderMode: props.screenReaderMode,
86-
overviewRulerWidth: 20
88+
overviewRulerWidth: 20,
89+
allowProposedApi: true
8790
};
8891
};
8992

@@ -158,7 +161,7 @@ export default class Term extends React.PureComponent<
158161

159162
this.termOptions = getTermOptions(props);
160163
this.term = props.term || new Terminal(this.termOptions);
161-
this.termDefaultBellSound = this.term.getOption('bellSound');
164+
// this.termDefaultBellSound = this.term.getOption('bellSound');
162165

163166
// The parent element for the terminal is attached and removed manually so
164167
// that we can preserve it across mounts and unmounts of the component
@@ -195,26 +198,28 @@ export default class Term extends React.PureComponent<
195198
this.term.attachCustomKeyEventHandler(this.keyboardHandler);
196199
this.term.loadAddon(this.fitAddon);
197200
this.term.loadAddon(this.searchAddon);
198-
this.term.loadAddon(
199-
new WebLinksAddon(
200-
(event: MouseEvent | undefined, uri: string) => {
201-
if (shallActivateWebLink(event)) void shell.openExternal(uri);
202-
},
203-
{
204-
// prevent default electron link handling to allow selection, e.g. via double-click
205-
willLinkActivate: (event: MouseEvent | undefined) => {
206-
event?.preventDefault();
207-
return shallActivateWebLink(event);
208-
},
209-
priority: Date.now()
210-
}
211-
)
212-
);
201+
// this.term.loadAddon(
202+
// new WebLinksAddon(
203+
// (event: MouseEvent | undefined, uri: string) => {
204+
// if (shallActivateWebLink(event)) void shell.openExternal(uri);
205+
// },
206+
// {
207+
// // prevent default electron link handling to allow selection, e.g. via double-click
208+
// willLinkActivate: (event: MouseEvent | undefined) => {
209+
// event?.preventDefault();
210+
// return shallActivateWebLink(event);
211+
// },
212+
// priority: Date.now()
213+
// }
214+
// )
215+
// );
213216
this.term.open(this.termRef);
214217
if (useWebGL) {
215218
this.term.loadAddon(new WebglAddon());
219+
} else {
220+
this.term.loadAddon(new CanvasAddon());
216221
}
217-
if (props.disableLigatures !== true && !useWebGL) {
222+
if (props.disableLigatures !== true) {
218223
this.term.loadAddon(new LigaturesAddon());
219224
}
220225
this.term.loadAddon(new Unicode11Addon());
@@ -402,37 +407,27 @@ export default class Term extends React.PureComponent<
402407

403408
// Use bellSound in nextProps if it exists
404409
// otherwise use the default sound found in xterm.
405-
nextTermOptions.bellSound = this.props.bellSound || this.termDefaultBellSound!;
410+
// nextTermOptions.bellSound = this.props.bellSound || this.termDefaultBellSound!;
406411

407412
if (prevProps.search && !this.props.search) {
408413
this.closeSearchBox();
409414
}
410415

411416
// Update only options that have changed.
412-
ObjectTypedKeys(nextTermOptions)
413-
.filter((option) => option !== 'theme' && nextTermOptions[option] !== this.termOptions[option])
414-
.forEach((option) => {
415-
try {
416-
this.term.setOption(option, nextTermOptions[option]);
417-
} catch (_e) {
418-
const e = _e as {message: string};
419-
if (/The webgl renderer only works with the webgl char atlas/i.test(e.message)) {
420-
// Ignore this because the char atlas will also be changed
421-
} else {
422-
throw e;
423-
}
424-
}
425-
});
417+
this.term.options = _.pickBy(
418+
nextTermOptions,
419+
(value, key) => this.termOptions[key as keyof ITerminalOptions] !== value && key !== 'theme'
420+
);
426421

427422
// Do we need to update theme?
428423
const shouldUpdateTheme =
429424
!this.termOptions.theme ||
430-
nextTermOptions.rendererType !== this.termOptions.rendererType ||
425+
// nextTermOptions.rendererType !== this.termOptions.rendererType ||
431426
ObjectTypedKeys(nextTermOptions.theme!).some(
432427
(option) => nextTermOptions.theme![option] !== this.termOptions.theme![option]
433428
);
434429
if (shouldUpdateTheme) {
435-
this.term.setOption('theme', nextTermOptions.theme);
430+
this.term.options.theme = nextTermOptions.theme!;
436431
}
437432

438433
this.termOptions = nextTermOptions;

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,14 @@
6060
"typescript-json-schema": "0.55.0",
6161
"uuid": "9.0.0",
6262
"webpack-cli": "5.0.1",
63-
"xterm": "4.19.0",
64-
"xterm-addon-fit": "^0.5.0",
65-
"xterm-addon-ligatures": "0.6.0-beta.19",
66-
"xterm-addon-search": "^0.9.0",
67-
"xterm-addon-unicode11": "^0.3.0",
68-
"xterm-addon-web-links": "^0.6.0",
69-
"xterm-addon-webgl": "0.12.0"
63+
"xterm": "5.1.0",
64+
"xterm-addon-canvas": "0.3.0",
65+
"xterm-addon-fit": "0.7.0",
66+
"xterm-addon-ligatures": "0.6.0",
67+
"xterm-addon-search": "0.11.0",
68+
"xterm-addon-unicode11": "0.5.0",
69+
"xterm-addon-web-links": "0.8.0",
70+
"xterm-addon-webgl": "0.14.0"
7071
},
7172
"devDependencies": {
7273
"@ava/babel": "2.0.0",

yarn.lock

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7881,43 +7881,48 @@ xtend@^4.0.0, xtend@^4.0.2, xtend@~4.0.0:
78817881
resolved "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"
78827882
integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==
78837883

7884-
xterm-addon-fit@^0.5.0:
7885-
version "0.5.0"
7886-
resolved "https://registry.npmjs.org/xterm-addon-fit/-/xterm-addon-fit-0.5.0.tgz#2d51b983b786a97dcd6cde805e700c7f913bc596"
7887-
integrity sha512-DsS9fqhXHacEmsPxBJZvfj2la30Iz9xk+UKjhQgnYNkrUIN5CYLbw7WEfz117c7+S86S/tpHPfvNxJsF5/G8wQ==
7884+
xterm-addon-canvas@0.3.0:
7885+
version "0.3.0"
7886+
resolved "https://registry.npmjs.org/xterm-addon-canvas/-/xterm-addon-canvas-0.3.0.tgz#8cfb5a13297f4a31a12870c1119af2c139392b50"
7887+
integrity sha512-2deF4ev6T+NjgSM56H+jcAWz4k5viEoaBtuDEyfo5Qdh1r7HOvNzLC45HSeegdH38qmEcL9XIt0KXyOINpSFRA==
7888+
7889+
xterm-addon-fit@0.7.0:
7890+
version "0.7.0"
7891+
resolved "https://registry.npmjs.org/xterm-addon-fit/-/xterm-addon-fit-0.7.0.tgz#b8ade6d96e63b47443862088f6670b49fb752c6a"
7892+
integrity sha512-tQgHGoHqRTgeROPnvmtEJywLKoC/V9eNs4bLLz7iyJr1aW/QFzRwfd3MGiJ6odJd9xEfxcW36/xRU47JkD5NKQ==
78887893

7889-
xterm-addon-ligatures@0.6.0-beta.19:
7890-
version "0.6.0-beta.19"
7891-
resolved "https://registry.npmjs.org/xterm-addon-ligatures/-/xterm-addon-ligatures-0.6.0-beta.19.tgz#5e43eeaf84968e014769a5f2c6a3a3601dc4771c"
7892-
integrity sha512-A0BIjFF6g5aPI0HiI2JMhhMV3gaHbpZ+ua+UNagkID0GxZ/ezn0wVOAtNQl/KlqnFueoyZIxlbyXmWNAfJVPRg==
7894+
xterm-addon-ligatures@0.6.0:
7895+
version "0.6.0"
7896+
resolved "https://registry.npmjs.org/xterm-addon-ligatures/-/xterm-addon-ligatures-0.6.0.tgz#c51801b0150c62ac1165654757b55c796457d195"
7897+
integrity sha512-DxiYCXXYEpnwr8li4/QhG64exjrLX1nHBfNNfrQgx5e8Z9tK2SjWKpxI6PZEy++8+YdL1F7VjWI4aKOaDt2VVw==
78937898
dependencies:
78947899
font-finder "^1.1.0"
78957900
font-ligatures "^1.4.1"
78967901

7897-
xterm-addon-search@^0.9.0:
7898-
version "0.9.0"
7899-
resolved "https://registry.npmjs.org/xterm-addon-search/-/xterm-addon-search-0.9.0.tgz#95278ebb818cfcf882209ae75be96e0bea5d52a5"
7900-
integrity sha512-aoolI8YuHvdGw+Qjg8g2M4kst0v86GtB7WeBm4F0jNXA005/6QbWWy9eCsvnIDLJOFI5JSSrZnD6CaOkvBQYPA==
7902+
xterm-addon-search@0.11.0:
7903+
version "0.11.0"
7904+
resolved "https://registry.npmjs.org/xterm-addon-search/-/xterm-addon-search-0.11.0.tgz#2a00ff7f9848f6140e7c4d1782486b0b18b06e0d"
7905+
integrity sha512-6U4uHXcQ7G5igsdaGqrJ9ehm7vep24bXqWxuy3AnIosXF2Z5uy2MvmYRyTGNembIqPV/x1YhBQ7uShtuqBHhOQ==
79017906

7902-
xterm-addon-unicode11@^0.3.0:
7903-
version "0.3.0"
7904-
resolved "https://registry.npmjs.org/xterm-addon-unicode11/-/xterm-addon-unicode11-0.3.0.tgz#e4435c3c91a5294a7eb8b79c380acbb28a659463"
7905-
integrity sha512-x5fHDZT2j9tlTlHnzPHt++9uKZ2kJ/lYQOj3L6xJA22xoJsS8UQRw/5YIFg2FUHqEAbV77Z1fZij/9NycMSH/A==
7907+
xterm-addon-unicode11@0.5.0:
7908+
version "0.5.0"
7909+
resolved "https://registry.npmjs.org/xterm-addon-unicode11/-/xterm-addon-unicode11-0.5.0.tgz#41c0d96acc1e3bb6c6596eee64e163b6bca74be7"
7910+
integrity sha512-Jm4/g4QiTxiKiTbYICQgC791ubhIZyoIwxAIgOW8z8HWFNY+lwk+dwaKEaEeGBfM48Vk8fklsUW9u/PlenYEBg==
79067911

7907-
xterm-addon-web-links@^0.6.0:
7908-
version "0.6.0"
7909-
resolved "https://registry.npmjs.org/xterm-addon-web-links/-/xterm-addon-web-links-0.6.0.tgz#0296cb6c99588847894670d998c9ea6a6aeb26ee"
7910-
integrity sha512-H6XzjWWZu8FBo+fnYpxdPk9w5M6drbsvwPEJZGRS38MihiQaVFpKlCMKdfRgDbKGE530tw1yH54rhpZfHgt2/A==
7912+
xterm-addon-web-links@0.8.0:
7913+
version "0.8.0"
7914+
resolved "https://registry.npmjs.org/xterm-addon-web-links/-/xterm-addon-web-links-0.8.0.tgz#2cb1d57129271022569208578b0bf4774e7e6ea9"
7915+
integrity sha512-J4tKngmIu20ytX9SEJjAP3UGksah7iALqBtfTwT9ZnmFHVplCumYQsUJfKuS+JwMhjsjH61YXfndenLNvjRrEw==
79117916

7912-
xterm-addon-webgl@0.12.0:
7913-
version "0.12.0"
7914-
resolved "https://registry.npmjs.org/xterm-addon-webgl/-/xterm-addon-webgl-0.12.0.tgz#2fba8d31890a122adafa1c2fb945482e2ae12973"
7915-
integrity sha512-3P5ihdjPnxH6Wrvqjki9UD+duoVrp1fvnO/pSpXP2F1L2GwY6TDNExgj8Yg141vMCNgQbcVqmsTLYEYZxjY92A==
7917+
xterm-addon-webgl@0.14.0:
7918+
version "0.14.0"
7919+
resolved "https://registry.npmjs.org/xterm-addon-webgl/-/xterm-addon-webgl-0.14.0.tgz#bd9136710bd5d130a0a51fd42e6d14ea39348236"
7920+
integrity sha512-zcxL4RVVjeS7NNFeKe5HHQI8OUEx3wZpE4EqLoTVipa2UrTR+qLsigo16UEp/yVcYBMhK7tsJ/AJokoEe/f0mw==
79167921

7917-
xterm@4.19.0:
7918-
version "4.19.0"
7919-
resolved "https://registry.npmjs.org/xterm/-/xterm-4.19.0.tgz#c0f9d09cd61de1d658f43ca75f992197add9ef6d"
7920-
integrity sha512-c3Cp4eOVsYY5Q839dR5IejghRPpxciGmLWWaP9g+ppfMeBChMeLa1DCA+pmX/jyDZ+zxFOmlJL/82qVdayVoGQ==
7922+
xterm@5.1.0:
7923+
version "5.1.0"
7924+
resolved "https://registry.npmjs.org/xterm/-/xterm-5.1.0.tgz#3e160d60e6801c864b55adf19171c49d2ff2b4fc"
7925+
integrity sha512-LovENH4WDzpwynj+OTkLyZgJPeDom9Gra4DMlGAgz6pZhIDCQ+YuO7yfwanY+gVbn/mmZIStNOnVRU/ikQuAEQ==
79217926

79227927
y18n@^5.0.5:
79237928
version "5.0.5"

0 commit comments

Comments
 (0)