I wonder if there is such a thing as mouse movement events in NCurses, and if there is a way to catch them. Following the Interfacing with the mouse (from the NCurses progra
You need:
$TERM
pointing to a terminfo entry which has an appropriate XM
entry to initialise the terminal correctly.xterm
at least satisfies (1); for (2), it's likely that you'll need to set a different value for TERM
.
Try:
TERM=xterm-1002
to get a position event when the cursor moves to a different cell while a button is being held down; orTERM=xterm-1003
to always get a position event whenever the cursor moves to a different cell, even if no button is pressed.The resulting events have the REPORT_MOUSE_POSITION
bit set on the bstate
field.
(The "PORTABILITY" section of the curs_mouse(3x) man page describes the terminal initialisation, and the "Mouse Tracking" section of the Xterm Control Sequences documentation describes the relevant "private mode" extensions.)
The code that you've given above needs to use getch()
, not getchar()
; and needs a refresh()
inside the loop! Other than that, it works for me with xterm
when using one of the appropriate TERM
settings.