Replies: 2 comments
-
It's a little tricky until #702 is implemented. The way VS Code does it is re-calculates the dimensions using similar logic (which is dangerous and will likely break) and then listens to regular mouse events on the xterm element. |
Beta Was this translation helpful? Give feedback.
0 replies
-
You can work around missing official API by using private terminal methods: // some fake mouse event
const me = new MouseEvent('mousedown', {clientX: 100, clientY: 100});
// grab translated coords from private API Terminal._core._mouseService.getMouseReportCoords
// in demo:
const position = term._core._mouseService.getMouseReportCoords(me, term.element);
// --> {col: 10, row: 0, x: 90, y: 18} Benefit here - it uses the same metrics the terminal would use internally for mouse handling, so no weird offset corrections to be done on your end. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello All, I have been searching for a way to grab x , y cursor position when user click in my xterm screen.
Seems that [https://github.com//issues/2336] was quite interesting but was not implemented.
As a last chance I did ask chatGPT and got an interesting answer:
Does not work ... but this is exactly what I am looking for ... maybe chatGPT is aware of 5.2 ?
Beta Was this translation helpful? Give feedback.
All reactions