Update xterm to v3.8.0 (#3255)

This commit is contained in:
CHaBou 2018-12-07 00:56:29 +01:00 committed by Guillermo Rauch
parent 6079ca35c2
commit f3a2f0211d
4 changed files with 40 additions and 37 deletions

View file

@ -95,13 +95,22 @@ export default class StyleSheet extends React.PureComponent {
left: -9999em; left: -9999em;
} }
.xterm {
cursor: text;
}
.xterm.enable-mouse-events { .xterm.enable-mouse-events {
/* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */ /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
cursor: default; cursor: default;
} }
.xterm:not(.enable-mouse-events) { .xterm.xterm-cursor-pointer {
cursor: text; cursor: pointer;
}
.xterm.xterm-cursor-crosshair {
/* Column selection mode */
cursor: crosshair;
} }
.xterm .xterm-accessibility, .xterm .xterm-accessibility,

View file

@ -77,6 +77,7 @@ export default class Term extends React.PureComponent {
this.onTermWrapperRef = this.onTermWrapperRef.bind(this); this.onTermWrapperRef = this.onTermWrapperRef.bind(this);
this.onMouseUp = this.onMouseUp.bind(this); this.onMouseUp = this.onMouseUp.bind(this);
this.termOptions = {}; this.termOptions = {};
this.disposableListeners = [];
} }
componentDidMount() { componentDidMount() {
@ -100,35 +101,39 @@ export default class Term extends React.PureComponent {
this.onOpen(this.termOptions); this.onOpen(this.termOptions);
if (props.onTitle) { if (props.onTitle) {
this.term.on('title', props.onTitle); this.disposableListeners.push(this.term.addDisposableListener('title', props.onTitle));
} }
if (props.onActive) { if (props.onActive) {
this.term.on('focus', props.onActive); this.disposableListeners.push(this.term.addDisposableListener('focus', props.onActive));
} }
if (props.onData) { if (props.onData) {
this.term.on('data', props.onData); this.disposableListeners.push(this.term.addDisposableListener('data', props.onData));
} }
if (props.onResize) { if (props.onResize) {
this.term.on('resize', ({cols, rows}) => { this.disposableListeners.push(
props.onResize(cols, rows); this.term.addDisposableListener('resize', ({cols, rows}) => {
}); props.onResize(cols, rows);
})
);
} }
if (props.onCursorMove) { if (props.onCursorMove) {
this.term.on('cursormove', () => { this.disposableListeners.push(
const cursorFrame = { this.term.addDisposableListener('cursormove', () => {
x: this.term.buffer.x * this.term.renderer.dimensions.actualCellWidth, const cursorFrame = {
y: this.term.buffer.y * this.term.renderer.dimensions.actualCellHeight, x: this.term.buffer.x * this.term.renderer.dimensions.actualCellWidth,
width: this.term.renderer.dimensions.actualCellWidth, y: this.term.buffer.y * this.term.renderer.dimensions.actualCellHeight,
height: this.term.renderer.dimensions.actualCellHeight, width: this.term.renderer.dimensions.actualCellWidth,
col: this.term.buffer.y, height: this.term.renderer.dimensions.actualCellHeight,
row: this.term.buffer.x col: this.term.buffer.y,
}; row: this.term.buffer.x
props.onCursorMove(cursorFrame); };
}); props.onCursorMove(cursorFrame);
})
);
} }
window.addEventListener('resize', this.onWindowResize, { window.addEventListener('resize', this.onWindowResize, {
@ -142,18 +147,11 @@ export default class Term extends React.PureComponent {
terms[this.props.uid] = this; terms[this.props.uid] = this;
} }
onOpen(termOptions) { onOpen() {
// we need to delay one frame so that styles // we need to delay one frame so that styles
// get applied and we can make an accurate measurement // get applied and we can make an accurate measurement
// of the container width and height // of the container width and height
requestAnimationFrame(() => { requestAnimationFrame(() => {
// at this point it would make sense for character
// measurement to have taken place but it seems that
// xterm.js might be doing this asynchronously, so
// we force it instead
// eslint-disable-next-line no-debugger
//debugger;
this.term.charMeasure.measure(termOptions);
this.fitResize(); this.fitResize();
}); });
} }
@ -261,7 +259,6 @@ export default class Term extends React.PureComponent {
if (!this.props.isTermActive && nextProps.isTermActive) { if (!this.props.isTermActive && nextProps.isTermActive) {
requestAnimationFrame(() => { requestAnimationFrame(() => {
this.term.charMeasure.measure(this.termOptions);
this.fitResize(); this.fitResize();
}); });
} }
@ -272,10 +269,6 @@ export default class Term extends React.PureComponent {
this.props.lineHeight !== nextProps.lineHeight || this.props.lineHeight !== nextProps.lineHeight ||
this.props.letterSpacing !== nextProps.letterSpacing this.props.letterSpacing !== nextProps.letterSpacing
) { ) {
// invalidate xterm cache about how wide each
// character is
this.term.charMeasure.measure(this.termOptions);
// resize to fit the container // resize to fit the container
this.fitResize(); this.fitResize();
} }
@ -301,7 +294,8 @@ export default class Term extends React.PureComponent {
// instead of invoking `destroy`, since it will make the // instead of invoking `destroy`, since it will make the
// term insta un-attachable in the future (which we need // term insta un-attachable in the future (which we need
// to do in case of splitting, see `componentDidMount` // to do in case of splitting, see `componentDidMount`
['title', 'focus', 'data', 'resize', 'cursormove'].forEach(type => this.term.removeAllListeners(type)); this.disposableListeners.forEach(handler => handler.dispose());
this.disposableListeners = [];
window.removeEventListener('resize', this.onWindowResize, { window.removeEventListener('resize', this.onWindowResize, {
passive: true passive: true

View file

@ -207,7 +207,7 @@
"styled-jsx": "2.2.6", "styled-jsx": "2.2.6",
"stylis": "3.5.0", "stylis": "3.5.0",
"uuid": "3.1.0", "uuid": "3.1.0",
"xterm": "3.4.1" "xterm": "3.8.0"
}, },
"devDependencies": { "devDependencies": {
"ava": "0.25.0", "ava": "0.25.0",

View file

@ -6693,9 +6693,9 @@ xtend@~2.1.1:
dependencies: dependencies:
object-keys "~0.4.0" object-keys "~0.4.0"
xterm@3.4.1: xterm@3.8.0:
version "3.4.1" version "3.8.0"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-3.4.1.tgz#12452979ea2db3371f8195832d7407abba988980" resolved "https://registry.yarnpkg.com/xterm/-/xterm-3.8.0.tgz#55d1de518bdc9c9793823f5e4e97d6898972938d"
y18n@^3.2.1: y18n@^3.2.1:
version "3.2.1" version "3.2.1"