Skip to content

Commit

Permalink
xterm 5
Browse files Browse the repository at this point in the history
  • Loading branch information
LabhanshAgrawal committed Nov 6, 2022
1 parent 084d5f3 commit 553f0ab
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 71 deletions.
64 changes: 28 additions & 36 deletions lib/components/term.tsx
Expand Up @@ -13,6 +13,7 @@ import processClipboard from '../utils/paste';
import SearchBox from './searchBox';
import {TermProps} from '../hyper';
import {ObjectTypedKeys} from '../utils/object';
import _ from 'lodash';

const isWindows = ['Windows', 'Win16', 'Win32', 'WinCE'].includes(navigator.platform);

Expand Down Expand Up @@ -53,14 +54,14 @@ const getTermOptions = (props: TermProps): ITerminalOptions => {
letterSpacing: props.letterSpacing,
allowTransparency: needTransparency,
macOptionClickForcesSelection: props.macOptionSelectionMode === 'force',
bellStyle: props.bell === 'SOUND' ? 'sound' : 'none',
// bellStyle: props.bell === 'SOUND' ? 'sound' : 'none',
windowsMode: isWindows,
theme: {
foreground: props.foregroundColor,
background: backgroundColor,
cursor: props.cursorColor,
cursorAccent: props.cursorAccentColor,
selection: props.selectionColor,
selectionBackground: props.selectionColor,
black: props.colors.black,
red: props.colors.red,
green: props.colors.green,
Expand All @@ -78,7 +79,8 @@ const getTermOptions = (props: TermProps): ITerminalOptions => {
brightCyan: props.colors.lightCyan,
brightWhite: props.colors.lightWhite
},
screenReaderMode: props.screenReaderMode
screenReaderMode: props.screenReaderMode,
allowProposedApi: true
};
};

Expand Down Expand Up @@ -121,7 +123,7 @@ export default class Term extends React.PureComponent<TermProps> {

this.termOptions = getTermOptions(props);
this.term = props.term || new Terminal(this.termOptions);
this.termDefaultBellSound = this.term.getOption('bellSound');
// this.termDefaultBellSound = this.term.getOption('bellSound');

// The parent element for the terminal is attached and removed manually so
// that we can preserve it across mounts and unmounts of the component
Expand Down Expand Up @@ -158,21 +160,21 @@ export default class Term extends React.PureComponent<TermProps> {
this.term.attachCustomKeyEventHandler(this.keyboardHandler);
this.term.loadAddon(this.fitAddon);
this.term.loadAddon(this.searchAddon);
this.term.loadAddon(
new WebLinksAddon(
(event: MouseEvent | undefined, uri: string) => {
if (shallActivateWebLink(event)) void shell.openExternal(uri);
},
{
// prevent default electron link handling to allow selection, e.g. via double-click
willLinkActivate: (event: MouseEvent | undefined) => {
event?.preventDefault();
return shallActivateWebLink(event);
},
priority: Date.now()
}
)
);
// this.term.loadAddon(
// new WebLinksAddon(
// (event: MouseEvent | undefined, uri: string) => {
// if (shallActivateWebLink(event)) void shell.openExternal(uri);
// },
// {
// // prevent default electron link handling to allow selection, e.g. via double-click
// willLinkActivate: (event: MouseEvent | undefined) => {
// event?.preventDefault();
// return shallActivateWebLink(event);
// },
// priority: Date.now()
// }
// )
// );
this.term.open(this.termRef);
if (useWebGL) {
this.term.loadAddon(new WebglAddon());
Expand Down Expand Up @@ -342,37 +344,27 @@ export default class Term extends React.PureComponent<TermProps> {

// Use bellSound in nextProps if it exists
// otherwise use the default sound found in xterm.
nextTermOptions.bellSound = this.props.bellSound || this.termDefaultBellSound!;
// nextTermOptions.bellSound = this.props.bellSound || this.termDefaultBellSound!;

if (!prevProps.search && this.props.search) {
this.search();
}

// Update only options that have changed.
ObjectTypedKeys(nextTermOptions)
.filter((option) => option !== 'theme' && nextTermOptions[option] !== this.termOptions[option])
.forEach((option) => {
try {
this.term.setOption(option, nextTermOptions[option]);
} catch (_e) {
const e = _e as {message: string};
if (/The webgl renderer only works with the webgl char atlas/i.test(e.message)) {
// Ignore this because the char atlas will also be changed
} else {
throw e;
}
}
});
this.term.options = _.pickBy(
nextTermOptions,
(value, key) => this.termOptions[key as keyof ITerminalOptions] !== value && key !== 'theme'
);

// Do we need to update theme?
const shouldUpdateTheme =
!this.termOptions.theme ||
nextTermOptions.rendererType !== this.termOptions.rendererType ||
// nextTermOptions.rendererType !== this.termOptions.rendererType ||
ObjectTypedKeys(nextTermOptions.theme!).some(
(option) => nextTermOptions.theme![option] !== this.termOptions.theme![option]
);
if (shouldUpdateTheme) {
this.term.setOption('theme', nextTermOptions.theme);
this.term.options.theme = nextTermOptions.theme!;
}

this.termOptions = nextTermOptions;
Expand Down
14 changes: 7 additions & 7 deletions package.json
Expand Up @@ -56,13 +56,13 @@
"stylis": "3.5.4",
"uuid": "9.0.0",
"webpack-cli": "4.10.0",
"xterm": "4.19.0",
"xterm-addon-fit": "^0.5.0",
"xterm-addon-ligatures": "0.6.0-beta.19",
"xterm-addon-search": "^0.9.0",
"xterm-addon-unicode11": "^0.3.0",
"xterm-addon-web-links": "^0.6.0",
"xterm-addon-webgl": "0.12.0"
"xterm": "5.0.0",
"xterm-addon-fit": "0.6.0",
"xterm-addon-ligatures": "0.6.0",
"xterm-addon-search": "0.10.0",
"xterm-addon-unicode11": "0.4.0",
"xterm-addon-web-links": "0.7.0",
"xterm-addon-webgl": "0.13.0"
},
"devDependencies": {
"@ava/babel": "2.0.0",
Expand Down
56 changes: 28 additions & 28 deletions yarn.lock
Expand Up @@ -8306,43 +8306,43 @@ xtend@^4.0.0, xtend@^4.0.2, xtend@~4.0.0:
resolved "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"
integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==

xterm-addon-fit@^0.5.0:
version "0.5.0"
resolved "https://registry.npmjs.org/xterm-addon-fit/-/xterm-addon-fit-0.5.0.tgz#2d51b983b786a97dcd6cde805e700c7f913bc596"
integrity sha512-DsS9fqhXHacEmsPxBJZvfj2la30Iz9xk+UKjhQgnYNkrUIN5CYLbw7WEfz117c7+S86S/tpHPfvNxJsF5/G8wQ==
xterm-addon-fit@0.6.0:
version "0.6.0"
resolved "https://registry.npmjs.org/xterm-addon-fit/-/xterm-addon-fit-0.6.0.tgz#142e1ce181da48763668332593fc440349c88c34"
integrity sha512-9/7A+1KEjkFam0yxTaHfuk9LEvvTSBi0PZmEkzJqgafXPEXL9pCMAVV7rB09sX6ATRDXAdBpQhZkhKj7CGvYeg==

xterm-addon-ligatures@0.6.0-beta.19:
version "0.6.0-beta.19"
resolved "https://registry.npmjs.org/xterm-addon-ligatures/-/xterm-addon-ligatures-0.6.0-beta.19.tgz#5e43eeaf84968e014769a5f2c6a3a3601dc4771c"
integrity sha512-A0BIjFF6g5aPI0HiI2JMhhMV3gaHbpZ+ua+UNagkID0GxZ/ezn0wVOAtNQl/KlqnFueoyZIxlbyXmWNAfJVPRg==
xterm-addon-ligatures@0.6.0:
version "0.6.0"
resolved "https://registry.npmjs.org/xterm-addon-ligatures/-/xterm-addon-ligatures-0.6.0.tgz#c51801b0150c62ac1165654757b55c796457d195"
integrity sha512-DxiYCXXYEpnwr8li4/QhG64exjrLX1nHBfNNfrQgx5e8Z9tK2SjWKpxI6PZEy++8+YdL1F7VjWI4aKOaDt2VVw==
dependencies:
font-finder "^1.1.0"
font-ligatures "^1.4.1"

xterm-addon-search@^0.9.0:
version "0.9.0"
resolved "https://registry.npmjs.org/xterm-addon-search/-/xterm-addon-search-0.9.0.tgz#95278ebb818cfcf882209ae75be96e0bea5d52a5"
integrity sha512-aoolI8YuHvdGw+Qjg8g2M4kst0v86GtB7WeBm4F0jNXA005/6QbWWy9eCsvnIDLJOFI5JSSrZnD6CaOkvBQYPA==
xterm-addon-search@0.10.0:
version "0.10.0"
resolved "https://registry.npmjs.org/xterm-addon-search/-/xterm-addon-search-0.10.0.tgz#b6a5e859c0bfd83ad534233f93376640c0e0c652"
integrity sha512-l+kjDxNDQbkniU5OUo9BHknxUEPZGM0OFpVpc2sMmrb97S0FKJVJO4wAZPJvSGVJ8ZEG6KuDyzXluvnb08t71Q==

xterm-addon-unicode11@^0.3.0:
version "0.3.0"
resolved "https://registry.npmjs.org/xterm-addon-unicode11/-/xterm-addon-unicode11-0.3.0.tgz#e4435c3c91a5294a7eb8b79c380acbb28a659463"
integrity sha512-x5fHDZT2j9tlTlHnzPHt++9uKZ2kJ/lYQOj3L6xJA22xoJsS8UQRw/5YIFg2FUHqEAbV77Z1fZij/9NycMSH/A==
xterm-addon-unicode11@0.4.0:
version "0.4.0"
resolved "https://registry.npmjs.org/xterm-addon-unicode11/-/xterm-addon-unicode11-0.4.0.tgz#59a4abbb591befb69ca0c5f7c3f9fa9c1c05353e"
integrity sha512-HkUwR4gc8MKVFy2Ux8zUnjqARYpfl7dJ9na3TwRbAUbF4JlCv707m4Z07WVaDMIRUZsfZ+5LgSi+Ss7PfZqNcw==

xterm-addon-web-links@^0.6.0:
version "0.6.0"
resolved "https://registry.npmjs.org/xterm-addon-web-links/-/xterm-addon-web-links-0.6.0.tgz#0296cb6c99588847894670d998c9ea6a6aeb26ee"
integrity sha512-H6XzjWWZu8FBo+fnYpxdPk9w5M6drbsvwPEJZGRS38MihiQaVFpKlCMKdfRgDbKGE530tw1yH54rhpZfHgt2/A==
xterm-addon-web-links@0.7.0:
version "0.7.0"
resolved "https://registry.npmjs.org/xterm-addon-web-links/-/xterm-addon-web-links-0.7.0.tgz#dceac36170605f9db10a01d716bd83ee38f65c17"
integrity sha512-6PqoqzzPwaeSq22skzbvyboDvSnYk5teUYEoKBwMYvhbkwOQkemZccjWHT5FnNA8o1aInTc4PRYAl4jjPucCKA==

xterm-addon-webgl@0.12.0:
version "0.12.0"
resolved "https://registry.npmjs.org/xterm-addon-webgl/-/xterm-addon-webgl-0.12.0.tgz#2fba8d31890a122adafa1c2fb945482e2ae12973"
integrity sha512-3P5ihdjPnxH6Wrvqjki9UD+duoVrp1fvnO/pSpXP2F1L2GwY6TDNExgj8Yg141vMCNgQbcVqmsTLYEYZxjY92A==
xterm-addon-webgl@0.13.0:
version "0.13.0"
resolved "https://registry.npmjs.org/xterm-addon-webgl/-/xterm-addon-webgl-0.13.0.tgz#b1d42ec454390ad8595aa8c8dde714b98a5eb896"
integrity sha512-xL4qBQWUHjFR620/8VHCtrTMVQsnZaAtd1IxFoiKPhC63wKp6b+73a45s97lb34yeo57PoqZhE9Jq5pB++ksPQ==

xterm@4.19.0:
version "4.19.0"
resolved "https://registry.npmjs.org/xterm/-/xterm-4.19.0.tgz#c0f9d09cd61de1d658f43ca75f992197add9ef6d"
integrity sha512-c3Cp4eOVsYY5Q839dR5IejghRPpxciGmLWWaP9g+ppfMeBChMeLa1DCA+pmX/jyDZ+zxFOmlJL/82qVdayVoGQ==
xterm@5.0.0:
version "5.0.0"
resolved "https://registry.npmjs.org/xterm/-/xterm-5.0.0.tgz#0af50509b33d0dc62fde7a4ec17750b8e453cc5c"
integrity sha512-tmVsKzZovAYNDIaUinfz+VDclraQpPUnAME+JawosgWRMphInDded/PuY0xmU5dOhyeYZsI0nz5yd8dPYsdLTA==

y18n@^5.0.5:
version "5.0.5"
Expand Down

0 comments on commit 553f0ab

Please sign in to comment.