detection of xterm mouse support
- From: Oskar Liljeblad <oskar osk mine nu>
- To: mc-devel gnome org
- Subject: detection of xterm mouse support
- Date: Sat, 8 Dec 2001 23:19:43 +0100
Right now mc detects xterm mouse support by looking at the TERM
environment variable. This is not good because mouse support would
not be enabled in terminals like rxvt or Eterm (and a whole bunch other
like).
The correct way to determine _xterm_ (not generic) mouse support
is to check the "kmous" terminfo ("Km" termcap) capability.
If this is set to "\033[M", then xterm mouse support is available.
This is how ncurses (at least 5.2.20010318) does it.
This patch illustrates against src/main.c how to do it. Only
problem is that 1) tgetstr is not available and 2) before
calling tgetstr, the termcap/terminfo structures need to be
initialized with setupterm (ncurses) or tgetent. Any ideas
how to get it right?
Oskar Liljeblad (oskar osk mine nu)
--- src/main.c Mon Aug 20 07:39:21 2001
+++ /home/usel/_deb/mc-4.5.55/build-tree/mc-4.5.55/src/main.c Sat Dec 8 23:15:59 2001
@@ -2367,13 +2367,15 @@
char *mc_libdir;
#ifndef HAVE_X
char *termvalue;
+ char *mousecap;
termvalue = getenv ("TERM");
if (!termvalue || !(*termvalue)){
fprintf (stderr, _("The TERM environment variable is unset!\n"));
exit (1);
}
- if (force_xterm || (strncmp (termvalue, "xterm", 5) == 0 || strcmp (termvalue, "dtterm") == 0)){
+ mousecap = tgetstr ("Km", NULL);
+ if (force_xterm || (mousecap != NULL && strcmp(mousecap, "\033[M") == 0)) {
use_mouse_p = XTERM_MOUSE;
xterm_flag = 1;
# ifdef SET_TITLE
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]