1

I use Midnight Commander 4.8.16. If I set xterm 256 colors: export TERM=screen-256color then my mouse does not work, but forcing xterm: mc -x resolves the issue.

How to permanently force xterm (in mc config w/o using alias)?

2

Using TERM=screen-256color seems to be the problem. In the source code (tty_check_term), Midnight Commander treats that as "xterm" (and decides it supports a mouse) only if DISPLAY also is set. Ignore the comment (it is wrong), and just read the source code. The function return value is used in one place, from main.c (again, ignore the comment...).

Midnight Commander ignores the actual contents of the terminal description, which happens to say that this configuration supports xterm-style mouse (i.e., the existence of kmous=\E[M, in the description). It does this to work around its problems using slang, which also ignores the terminal description, looking only at TERM. This is an old bug, dating back to the 1990s.

As a workaround, you could set DISPLAY to a dummy value if it is unset, since Midnight Commander does nothing more with it than this check. Depending on your environment, that may have other side effects.

Further reading:

  • Extensions (terminfo - terminal capability data base)

Be careful assigning the kmous capability. The ncurses wants to interpret it as KEY_MOUSE, for use by terminals and emulators like xterm that can return mouse-tracking information in the keyboard-input stream.

1
  • Great, thanks for your elaborative answer! Setting export DISPLAY=_ works like a charm. And should I tell you what am I using? - mintty in Windows 10 Subsystem for Linux (Ubuntu 14.04 currently), and everything seem to work fine :)
    – vlad
    Aug 22 '16 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.