Commit 33104a2b authored by jim warner's avatar jim warner Committed by Jaromir Capik

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 5c974ff4Signed-off-by: jim warner's avatarJim Warner <james.warner@comcast.net>
parent 25ed080e
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment