Cursor api (#2629)

* Add onCursorMove API on Term
This commit is contained in:
CHaBou 2018-01-22 18:12:03 +01:00 committed by GitHub
parent 215e03e0d5
commit f4e32eee49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -106,6 +106,20 @@ export default class Term extends PureComponent {
});
}
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);
});
}
window.addEventListener('resize', this.onWindowResize, {
passive: true
});
@ -271,7 +285,7 @@ export default class Term extends 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'].forEach(type => this.term.removeAllListeners(type));
['title', 'focus', 'data', 'resize', 'cursormove'].forEach(type => this.term.removeAllListeners(type));
window.removeEventListener('resize', this.onWindowResize, {
passive: true