* src/mouse.h (Mouse_Type): Add new enumerated values to describe

the xterm mouse reporting modes offered by various xterm-like
terminals.
* src/mouse.c: Adjust the code to reflect the changes above.
Send the proper terminal control codes when xterm normal mouse
tracking is requested.
* src/main.c (init_xterm_support): Try to fine-tune the mouse tracking
mode based on the terminal type.
This commit is contained in:
Pavel Tsekov 2006-03-06 09:28:14 +00:00
parent 118b31fa91
commit dc50393a8f
4 changed files with 45 additions and 5 deletions

View File

@ -1,3 +1,14 @@
2006-03-06 Pavel Tsekov <ptsekov@gmx.net>
* mouse.h (Mouse_Type): Add new enumerated values to describe
the xterm mouse reporting modes offered by various xterm-like
terminals.
* mouse.c: Adjust the code to reflect the changes above.
Send the proper terminal control codes when xterm normal mouse
tracking is requested.
* main.c (init_xterm_support): Try to fine-tune the mouse tracking
mode based on the terminal type.
2006-02-28 Pavel Tsekov <ptsekov@gmx.net>
* widget.h (struct WRadio): Remove unused field

View File

@ -1385,7 +1385,14 @@ init_xterm_support (void)
/* Enable mouse unless explicitly disabled by --nomouse */
if (use_mouse_p != MOUSE_DISABLED) {
use_mouse_p = MOUSE_XTERM;
const char *color_term = getenv ("COLORTERM");
if (strncmp (termvalue, "rxvt", 4) == 0 ||
(color_term != NULL && strncmp (color_term, "rxvt", 4) == 0) ||
strcmp (termvalue, "Eterm") == 0) {
use_mouse_p = MOUSE_XTERM_NORMAL_TRACKING;
} else {
use_mouse_p = MOUSE_XTERM_BUTTON_EVENT_TRACKING;
}
}
}
}

View File

@ -50,7 +50,8 @@ void init_mouse (void)
use_mouse_p = MOUSE_GPM;
break;
#endif /* HAVE_LIBGPM */
case MOUSE_XTERM:
case MOUSE_XTERM_NORMAL_TRACKING:
case MOUSE_XTERM_BUTTON_EVENT_TRACKING:
define_sequence (MCKEY_MOUSE, xmouse_seq, MCKEY_NOACTION);
break;
default:
@ -86,7 +87,17 @@ void enable_mouse (void)
}
break;
#endif /* HAVE_LIBGPM */
case MOUSE_XTERM:
case MOUSE_XTERM_NORMAL_TRACKING:
/* save old highlight mouse tracking */
printf(ESC_STR "[?1001s");
/* enable mouse tracking */
printf(ESC_STR "[?1000h");
fflush (stdout);
mouse_enabled = 1;
break;
case MOUSE_XTERM_BUTTON_EVENT_TRACKING:
/* save old highlight mouse tracking */
printf(ESC_STR "[?1001s");
@ -115,7 +126,16 @@ void disable_mouse (void)
Gpm_Close ();
break;
#endif
case MOUSE_XTERM:
case MOUSE_XTERM_NORMAL_TRACKING:
/* disable mouse tracking */
printf(ESC_STR "[?1000l");
/* restore old highlight mouse tracking */
printf(ESC_STR "[?1001r");
fflush (stdout);
break;
case MOUSE_XTERM_BUTTON_EVENT_TRACKING:
/* disable mouse tracking */
printf(ESC_STR "[?1002l");

View File

@ -55,7 +55,9 @@ typedef enum {
MOUSE_NONE, /* Not detected yet */
MOUSE_DISABLED, /* Explicitly disabled by -d */
MOUSE_GPM, /* Support using GPM on Linux */
MOUSE_XTERM /* Support using xterm-style mouse reporting */
MOUSE_XTERM, /* Support using xterm-style mouse reporting */
MOUSE_XTERM_NORMAL_TRACKING = MOUSE_XTERM,
MOUSE_XTERM_BUTTON_EVENT_TRACKING
} Mouse_Type;
/* Type of the currently used mouse */