Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update xterm to v3.8.0 #3255

Merged
merged 1 commit into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/components/style-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,22 @@ export default class StyleSheet extends React.PureComponent {
left: -9999em;
}

.xterm {
cursor: text;
}

.xterm.enable-mouse-events {
/* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
cursor: default;
}

.xterm:not(.enable-mouse-events) {
cursor: text;
.xterm.xterm-cursor-pointer {
cursor: pointer;
}

.xterm.xterm-cursor-crosshair {
/* Column selection mode */
cursor: crosshair;
}

.xterm .xterm-accessibility,
Expand Down
56 changes: 25 additions & 31 deletions lib/components/term.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export default class Term extends React.PureComponent {
this.onTermWrapperRef = this.onTermWrapperRef.bind(this);
this.onMouseUp = this.onMouseUp.bind(this);
this.termOptions = {};
this.disposableListeners = [];
}

componentDidMount() {
Expand All @@ -100,35 +101,39 @@ export default class Term extends React.PureComponent {
this.onOpen(this.termOptions);

if (props.onTitle) {
this.term.on('title', props.onTitle);
this.disposableListeners.push(this.term.addDisposableListener('title', props.onTitle));
}

if (props.onActive) {
this.term.on('focus', props.onActive);
this.disposableListeners.push(this.term.addDisposableListener('focus', props.onActive));
}

if (props.onData) {
this.term.on('data', props.onData);
this.disposableListeners.push(this.term.addDisposableListener('data', props.onData));
}

if (props.onResize) {
this.term.on('resize', ({cols, rows}) => {
props.onResize(cols, rows);
});
this.disposableListeners.push(
this.term.addDisposableListener('resize', ({cols, rows}) => {
props.onResize(cols, rows);
})
);
}

if (props.onCursorMove) {
this.term.on('cursormove', () => {
const cursorFrame = {
x: this.term.buffer.x * this.term.renderer.dimensions.actualCellWidth,
y: this.term.buffer.y * this.term.renderer.dimensions.actualCellHeight,
width: this.term.renderer.dimensions.actualCellWidth,
height: this.term.renderer.dimensions.actualCellHeight,
col: this.term.buffer.y,
row: this.term.buffer.x
};
props.onCursorMove(cursorFrame);
});
this.disposableListeners.push(
this.term.addDisposableListener('cursormove', () => {
const cursorFrame = {
x: this.term.buffer.x * this.term.renderer.dimensions.actualCellWidth,
y: this.term.buffer.y * this.term.renderer.dimensions.actualCellHeight,
width: this.term.renderer.dimensions.actualCellWidth,
height: this.term.renderer.dimensions.actualCellHeight,
col: this.term.buffer.y,
row: this.term.buffer.x
};
props.onCursorMove(cursorFrame);
})
);
}

window.addEventListener('resize', this.onWindowResize, {
Expand All @@ -142,18 +147,11 @@ export default class Term extends React.PureComponent {
terms[this.props.uid] = this;
}

onOpen(termOptions) {
onOpen() {
// we need to delay one frame so that styles
// get applied and we can make an accurate measurement
// of the container width and height
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();
});
}
Expand Down Expand Up @@ -261,7 +259,6 @@ export default class Term extends React.PureComponent {

if (!this.props.isTermActive && nextProps.isTermActive) {
requestAnimationFrame(() => {
this.term.charMeasure.measure(this.termOptions);
this.fitResize();
});
}
Expand All @@ -272,10 +269,6 @@ export default class Term extends React.PureComponent {
this.props.lineHeight !== nextProps.lineHeight ||
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
this.fitResize();
}
Expand All @@ -301,7 +294,8 @@ export default class Term extends React.PureComponent {
// instead of invoking `destroy`, since it will make the
// term insta un-attachable in the future (which we need
// 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, {
passive: true
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
"styled-jsx": "2.2.6",
"stylis": "3.5.0",
"uuid": "3.1.0",
"xterm": "3.4.1"
"xterm": "3.8.0"
},
"devDependencies": {
"ava": "0.25.0",
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6693,9 +6693,9 @@ xtend@~2.1.1:
dependencies:
object-keys "~0.4.0"

xterm@3.4.1:
version "3.4.1"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-3.4.1.tgz#12452979ea2db3371f8195832d7407abba988980"
xterm@3.8.0:
version "3.8.0"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-3.8.0.tgz#55d1de518bdc9c9793823f5e4e97d6898972938d"

y18n@^3.2.1:
version "3.2.1"
Expand Down