Suzanne Soy
Suzanne Soy

Reputation: 3244

Get mouse position in pixels using escape sequences

I'm trying to obtain the position of the mouse in pixels within an application running in a terminal.

The goal is to embed small GUI elements in mostly text-based applications. It is currently possible on quite a few terminal emulators using Sixel, Tektronix or ReGIS do draw things, and \e[1000h or similar escape codes to get mouse events, unfortunately these mouse events are low-resolution (the coordinates in character cells, not in pixels).

Upvotes: 4

Views: 2156

Answers (1)

Olaf Rogalsky
Olaf Rogalsky

Reputation: 126

xterm reports the mouse position with pixel resolution with the following escape sequences:

  • switch on pixel resolution: \e[2;1'z
  • report mouse position: \e['|

Details are described at http://invisible-island.net/xterm/ctlseqs/ctlseqs.html

Upvotes: 11

Related Questions