Fix of mouse and ca capabilities check.

Based on patch from Andrey V. Malyshev <amal krasn ru>
http://mail.gnome.org/archives/mc-devel/2005-November/msg00052.html

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2011-09-02 13:30:59 +04:00
parent 09123c9fc9
commit ad0a5015d3
3 changed files with 23 additions and 4 deletions

View File

@ -36,6 +36,10 @@ extern gboolean ugly_line_drawing;
/* The mouse is currently: TRUE - enabled, FALSE - disabled */
extern gboolean mouse_enabled;
/* terminal ca capabilities */
extern char *smcup;
extern char *rmcup;
/*** declarations of public functions ************************************************************/
char *mc_tty_normalize_from_utf8 (const char *);

View File

@ -298,8 +298,19 @@ tty_init_xterm_support (gboolean is_xterm)
termvalue = getenv ("TERM");
/* Check mouse capabilities */
xmouse_seq = tty_tgetstr ("Km");
/* Check mouse and ca capabilities */
/* terminfo/termcap structures have been already initialized,
in slang_init() or/and init_curses() */
/* Check terminfo at first, then check termcap */
xmouse_seq = tty_tgetstr ("kmous");
if (xmouse_seq == NULL)
xmouse_seq = tty_tgetstr ("Km");
smcup = tty_tgetstr ("smcup");
if (smcup == NULL)
smcup = tty_tgetstr ("ti");
rmcup = tty_tgetstr ("rmcup");
if (rmcup == NULL)
rmcup = tty_tgetstr ("te");
if (strcmp (termvalue, "cygwin") == 0)
{

View File

@ -34,6 +34,7 @@
#include "lib/global.h"
#include "lib/util.h" /* is_printable() */
#include "tty-internal.h"
#include "tty.h" /* tty_gotoyx, tty_print_char */
#include "win.h"
@ -43,6 +44,9 @@
/* It is used by function view_other_cmd() */
gboolean xterm_flag = FALSE;
char *smcup = NULL;
char *rmcup = NULL;
/*** file scope macro definitions ****************************************************************/
/*** file scope type declarations ****************************************************************/
@ -92,7 +96,7 @@ anything_ready (void)
void
do_enter_ca_mode (void)
{
if (xterm_flag)
if (xterm_flag && smcup != NULL)
{
fprintf (stdout, /* ESC_STR ")0" */ ESC_STR "7" ESC_STR "[?47h");
fflush (stdout);
@ -104,7 +108,7 @@ do_enter_ca_mode (void)
void
do_exit_ca_mode (void)
{
if (xterm_flag)
if (xterm_flag && rmcup != NULL)
{
fprintf (stdout, ESC_STR "[?47l" ESC_STR "8" ESC_STR "[m");
fflush (stdout);