From: Jim Warner <james.warner@comcast.net>
Date: Sat, 1 Dec 2012 06:00:00 +0000 (-0600)
Subject: top: correct input anomaly if 'key repeat' is too fast
X-Git-Tag: v3.3.6~41
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a99f410d41a8cdb0f538feb6ecf006eafb75eb6f;p=procps-ng

top: correct input anomaly if 'key repeat' is too fast

Signed-off-by: Jim Warner <james.warner@comcast.net>
---

diff --git a/top/top.c b/top/top.c
index d68172d9..bab542fd 100644
--- a/top/top.c
+++ b/top/top.c
@@ -958,8 +958,8 @@ static int keyin (int init) {
       if (!strcmp(tinfo_tab[i].str, pb))
          return tinfo_tab[i].key;
 
-   // no match, so we'll return single keystrokes only
-   if (buf[1]) return 0;
+   // no match, so we'll return single non-escaped keystrokes only
+   if (buf[0] == '\033' && buf[1]) return 0;
    return buf[0];
 } // end: keyin
 
@@ -2597,6 +2597,9 @@ static int insp_view_this (char *hdr) {
       putp(Cap_curs_hide);
       show_special(1, fmtmk(N_unq(INSP_hdrview_fmt), hdr));
       insp_show_pg(curcol, curlin, maxLN);
+      /* fflush(stdin) didn't do the trick, so we'll just dip a little deeper
+         lest repeated <Enter> keys produce immediate re-selection in caller */
+      tcflush(STDIN_FILENO, TCIFLUSH);
 
       switch (key = keyin(0)) {
          case kbd_ENTER:          // must force new keyin()