From: Jim Warner Date: Mon, 1 Jul 2013 05:00:00 +0000 (-0500) Subject: top: cursor repositioning includes line oriented input X-Git-Tag: v3.3.9~56 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=33104a2bcc321495107d72e4cfee4090b1d90f76;p=procps-ng top: cursor repositioning includes line oriented input A recent patch introduced the ability to recognize the need to reposition the cursor at suspension or program end. There remained unmet 1 additional potential need. This commit extends that ability to embrace line input so that if a user issues ^Z or ^C while being prompted the resulting shell output will no longer be embedded. Reference(s): http://www.freelists.org/post/procps/top-library-miscellaneous-tweaks,7 commit 5c974ff44da4fbbb9170dd15bdd81555c62c31a9 Signed-off-by: Jim Warner --- diff --git a/top/top.c b/top/top.c index cb7f3b86..223ed70b 100644 --- a/top/top.c +++ b/top/top.c @@ -1081,12 +1081,14 @@ static char *ioline (const char *prompt) { static char buf[MEDBUFSIZ]; char *p; + Cursor_repos = 1; show_pmt(prompt); memset(buf, '\0', sizeof(buf)); ioch(1, buf, sizeof(buf)-1); if ((p = strpbrk(buf, ws))) *p = '\0'; // note: we DO produce a vaid 'string' + Cursor_repos = 0; return buf; } // end: ioline @@ -1117,6 +1119,7 @@ static char *ioline (const char *prompt) { }; static struct lin_s *anchor, *plin; + Cursor_repos = 1; if (!anchor) { anchor = alloc_c(sizeof(struct lin_s)); anchor->str = alloc_s(""); // top-of-stack == empty str @@ -1182,6 +1185,7 @@ static char *ioline (const char *prompt) { putp(tg2(beg+pos, Msg_row)); } while (key && key != kbd_ENTER && key != kbd_ESC); + Cursor_repos = 0; // weed out duplicates, including empty strings (top-of-stack)... for (i = 0, plin = anchor; ; i++) { #ifdef RECALL_FIXED