diff --git a/src/ChangeLog b/src/ChangeLog index 4cdfd3151..aba38d4ae 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2006-05-15 Pavel Tsekov + + * tty.h [USE_NCURSES]: Pull in term.h if WANT_TERM_H is defined. + (tty_tgetstr): Declare new function. + * tty.c [USE_NCURSES]: Request the inclusion of term.h. + (tty_tgetstr): Define new function + * main.c (init_xterm_support): Use tty_tgetstr(). + 2006-05-10 Pavel Tsekov * user.c: Do not include subshell.h . diff --git a/src/main.c b/src/main.c index 3e25287a1..55122d02a 100644 --- a/src/main.c +++ b/src/main.c @@ -1344,9 +1344,6 @@ static void init_xterm_support (void) { const char *termvalue; -#ifdef HAVE_SLANG - char *term_entry; -#endif termvalue = getenv ("TERM"); if (!termvalue || !(*termvalue)) { @@ -1355,17 +1352,7 @@ init_xterm_support (void) } /* Check mouse capabilities */ -#ifdef HAVE_SLANG - term_entry = SLtt_tigetent (str_unconst (termvalue)); - xmouse_seq = SLtt_tigetstr ("Km", &term_entry); -#else - xmouse_seq = tigetstr ("kmous"); -#endif - - /* -1 means invalid capability, shouldn't happen, but let's make it 0 */ - if ((long) xmouse_seq == -1) { - xmouse_seq = NULL; - } + xmouse_seq = tty_tgetstr ("Km"); if (strcmp (termvalue, "cygwin") == 0) { force_xterm = 1; diff --git a/src/tty.c b/src/tty.c index 48abc2bb3..d25f646d8 100644 --- a/src/tty.c +++ b/src/tty.c @@ -32,6 +32,10 @@ #include "global.h" #include "color.h" #include "main.h" /* for slow_terminal */ + +#ifdef USE_NCURSES +#define WANT_TERM_H +#endif #include "tty.h" /*** file scope macro definitions **************************************/ @@ -214,3 +218,16 @@ tty_printf(const char *fmt, ...) #endif va_end(args); } + +extern char * +tty_tgetstr (const char *cap) +{ +#ifdef HAVE_SLANG + return SLtt_tgetstr (cap); +#else + { + char *unused; + return tgetstr (str_unconst (cap), &unused); + } +#endif +} diff --git a/src/tty.h b/src/tty.h index 0df7a6046..85d286b72 100644 --- a/src/tty.h +++ b/src/tty.h @@ -20,6 +20,9 @@ # else # include # endif +#ifdef WANT_TERM_H +# include +#endif /* WANT_TERM_H */ #endif /* USE_NCURSES */ /* {{{ Input }}} */ @@ -50,6 +53,8 @@ extern void tty_print_vline(int top, int left, int length); extern void tty_print_hline(int top, int left, int length); extern void tty_printf(const char *, ...); +extern char *tty_tgetstr (const char *name); + /* legacy interface */ #define enable_interrupt_key() tty_enable_interrupt_key()