Skip to content

Commit c14a80e

Browse files
committed
Ticket #4096: use set_escdelay interface instead of ESCDELAY variable
Signed-off-by: Yury V. Zaytsev <[email protected]>
1 parent 3f20f9d commit c14a80e

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

lib/tty/tty-ncurses.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -230,17 +230,18 @@ tty_init (gboolean mouse_enable, gboolean is_xterm)
230230

231231
initscr ();
232232

233-
#ifdef HAVE_ESCDELAY
233+
#ifdef HAVE_SET_ESCDELAY
234234
/*
235-
* If ncurses exports the ESCDELAY variable, it should be set to
236-
* a low value, or you'll experience a delay in processing escape
237-
* sequences that are recognized by mc (e.g. Esc-Esc). On the other
238-
* hand, making ESCDELAY too small can result in some sequences
239-
* (e.g. cursor arrows) being reported as separate keys under heavy
240-
* processor load, and this can be a problem if mc hasn't learned
241-
* them in the "Learn Keys" dialog. The value is in milliseconds.
235+
* ESCDELAY variable should be set to a low value, or you'll experience a
236+
* delay in processing escape sequences recognized by mc (e.g. Esc-Esc).
237+
* Making ESCDELAY too small can result in some sequences (like cursor
238+
* arrows) being reported as separate keys under heavy processor load,
239+
* and this can be a problem if mc hasn't learned them in the "Learn Keys"
240+
* dialog. The value is in milliseconds (AIX defaults to 0.1s, ncurses 1s).
242241
*/
243-
ESCDELAY = 200;
242+
const char *user_escdelay = g_getenv ("ESCDELAY");
243+
const int escdelay = user_escdelay != NULL ? atoi (user_escdelay) : 100;
244+
set_escdelay (escdelay);
244245
#endif
245246

246247
tcgetattr (STDIN_FILENO, &mode);

m4.include/mc-with-screen-ncurses.m4

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,7 @@ AC_DEFUN([mc_WITH_NCURSES], [
107107
AS_IF([test x"$ncurses_term_h_found" != xyes],
108108
[AC_MSG_ERROR([NCurses(w) term.h header file not found])])
109109
110-
dnl If ncurses exports the ESCDELAY variable it should be set to 0
111-
dnl or you'll have to press Esc three times to dismiss a dialog box.
112-
AC_CACHE_CHECK([for ESCDELAY variable], [mc_cv_ncurses_escdelay],
113-
[AC_LINK_IFELSE(
114-
[AC_LANG_PROGRAM([[extern int ESCDELAY;]],[[ESCDELAY = 0;]])],
115-
[mc_cv_ncurses_escdelay=yes], [mc_cv_ncurses_escdelay=no])
116-
])
117-
118-
AS_IF([test x"$mc_cv_ncurses_escdelay" = xyes],
119-
[AC_DEFINE([HAVE_ESCDELAY], [1], [Define if NCurses(w) has ESCDELAY variable])])
120-
121-
AC_CHECK_FUNCS(resizeterm)
110+
AC_CHECK_FUNCS([resizeterm set_escdelay])
122111
123112
AC_DEFINE([HAVE_NCURSES], [1], [Define to use NCurses for screen management])
124113
AC_DEFINE_UNQUOTED([NCURSES_LIB_DISPLAYNAME], ["$screen_msg"], [Define NCurses library display name])

0 commit comments

Comments
 (0)