From 497e366375b6a472a8a3284f30cc27fc350f477a Mon Sep 17 00:00:00 2001 From: CHaBou Date: Mon, 22 Jan 2018 17:00:25 +0100 Subject: [PATCH 1/2] Add onCursorMove API on Term --- lib/components/term.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/components/term.js b/lib/components/term.js index 80d3c2eaa7d4..881f6a1ef95d 100644 --- a/lib/components/term.js +++ b/lib/components/term.js @@ -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 }); From b2c194f0cecfcea80fe406eb37a0d38315281383 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Mon, 22 Jan 2018 17:53:50 +0100 Subject: [PATCH 2/2] Remove listener --- lib/components/term.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/term.js b/lib/components/term.js index 881f6a1ef95d..312c3ea366a6 100644 --- a/lib/components/term.js +++ b/lib/components/term.js @@ -285,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