I've implemented a terminal emulator and a corresponding terminfo entry that allows me to run ncurses programs like emacs, mc (midnight commander) or tig (git browser). I want to add mouse support to the terminal, most notably to position the cursor in emacs by clicking into the window. After a lot of googling and some help on stackoverflow I learned about the required terminfo fields (most notably kmous
) and control (e.g. \E[?1000h
) and "key" (\E[M...
) sequences and implemented mouse button events in my terminal. I've written a small ncurses program that goes something like this:
initscr ();
clear ();
noecho ();
cbreak ();
keypad (stdscr, TRUE);
mousemask (ALL_MOUSE_EVENT, NULL);
if (has_mouse ())
{
while (1)
{
switch (getch ())
{
case KEY_MOUSE:
if (getmouse (&event) == OK)
{
printf ("mouse event 0x%x at %i,%i\n", event.bstate, event.x, event.y);
This program works fine on xterm and my terminal, so both my terminal and its terminfo entry can't be completely wrong.
However, mc appears to not recognize mouse support in my terminal, does not even issue any \E[?1000h
sequence to activate it and is therefore utterly confused by the mouse button events my terminal sends (even without \E[?1000h
activation).
What am I missing?