From 5c3fffcf289c89f6a1171f18e33365f909d096d5 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Fri, 22 Feb 2013 00:00:00 -0600 Subject: [PATCH] top: improve the response to ^Z if awaiting line input Now that line input offers users full editing freedom, if top were to be suspended after issuing a prompt for input, upon resumption an extra keystroke is necessary to satisfy the outstanding read & refresh the display. With this patch that extra keystroke is not necessary. (everything is perfectly justified plus right margins) (are completely filled, but of course it must be luck) Reference(s): commit 477b10c0bd00ed8750c02a9580e606baadb0e6f4 Signed-off-by: Jim Warner --- top/top.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/top/top.c b/top/top.c index e254e202..94f4f1d1 100644 --- a/top/top.c +++ b/top/top.c @@ -1109,6 +1109,7 @@ static char *ioline (const char *prompt) { len = strlen(buf); key = iokey(2); switch (key) { + case 0: case kbd_ESC: buf[0] = '\0'; // fall through ! case kbd_ENTER: @@ -1156,7 +1157,7 @@ static char *ioline (const char *prompt) { } putp(fmtmk("%s%s%s", tg2(beg, Msg_row), Cap_clr_eol, buf)); putp(tg2(beg+pos, Msg_row)); - } while (key != kbd_ENTER && key != kbd_ESC); + } while (key && key != kbd_ENTER && key != kbd_ESC); // weed out duplicates, including empty strings (top-of-stack)... for (i = 0, plin = anchor; ; i++) {