From 057467f6b33b9f7c942bd2327561b74e738285b7 Mon Sep 17 00:00:00 2001 From: "Diogo Franco (Kovensky)" Date: Sun, 21 Jul 2013 22:27:58 -0300 Subject: getch2: Refactor/rewrite Still uses termcap, but uses terminfo for loading the termcap database if possible. Adds configure test to find terminfo; skips the termcap test if terminfo is found since terminfo provides termcap. Use termcap completely for special keys; if we can't get it from termcap and it isn't one of the known fallbacks, we ignore its specialness and treat as a sequence of UTF-8 codes. Further hardcoded fallbacks can be added by calling keys_push_once in load_termcap; there is no limit to the amount of keys pushed. Uses the "ke" and "ks" capabilities to start / exit application mode, which is necessary on vt100 emulators (including screen, xterm and all terminals that emulate either of those) to correctly receive arrow keys. It's now possible to compile getch2 even without termcap, though it won't be of much use since it'll be unable to detect special keys. Converted to 4 spaces per tab, prettified some statements. --- configure | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'configure') diff --git a/configure b/configure index 723cc96fa9..67df30c033 100755 --- a/configure +++ b/configure @@ -293,6 +293,7 @@ Installation directories: Optional features: --disable-encoding disable encoding functionality [enable] --disable-libguess disable libguess [autodetect] + --enable-terminfo use terminfo database for key codes [autodetect] --enable-termcap use termcap database for key codes [autodetect] --enable-termios use termios database for key codes [autodetect] --disable-iconv disable iconv for encoding conversion [autodetect] @@ -464,6 +465,7 @@ _libguess=auto _joystick=no _lirc=auto _lircc=auto +_terminfo=auto _termcap=auto _termios=auto _shm=auto @@ -668,6 +670,8 @@ for ac_option do --disable-lirc) _lirc=no ;; --enable-lircc) _lircc=yes ;; --disable-lircc) _lircc=no ;; + --enable-terminfo) _terminfo=yes ;; + --disable-terminfo) _terminfo=no ;; --enable-termcap) _termcap=yes ;; --disable-termcap) _termcap=no ;; --enable-termios) _termios=yes ;; @@ -1409,6 +1413,27 @@ header_check sys/videoio.h && sys_videoio_h=yes && echores "$sys_videoio_h" +echocheck "terminfo" +if test "$_terminfo" = auto ; then + _terminfo=no + for _ld_tmp in "-lncurses" "-lncursesw"; do + statement_check term.h 'setupterm(NULL, 1, NULL)' $_ld_tmp && + libs_mplayer="$libs_mplayer $_ld_tmp" && _terminfo=yes && break + done +fi +if test "$_terminfo" = yes ; then + def_terminfo='#define HAVE_TERMINFO 1' + test $_ld_tmp && res_comment="using $_ld_tmp" + + if test "$_termcap" = auto ; then + _termcap = yes # terminfo provides termcap + fi +else + def_terminfo='#undef HAVE_TERMINFO' +fi +echores "$_terminfo" + + echocheck "termcap" if test "$_termcap" = auto ; then _termcap=no @@ -3098,6 +3123,7 @@ $def_posix_select $def_select $def_setmode $def_shm +$def_terminfo $def_termcap $def_termios -- cgit v1.2.3