|
|
2006ba |
From eee15b862dd5b051f16c719bf3c974591783a8f8 Mon Sep 17 00:00:00 2001
|
|
|
2006ba |
From: Jim Warner <james.warner@comcast.net>
|
|
|
2006ba |
Date: Mon, 1 Jul 2013 00:00:00 -0500
|
|
|
2006ba |
Subject: [PATCH 2/2] top: cursor repositioning includes line oriented input
|
|
|
2006ba |
|
|
|
2006ba |
A recent patch introduced the ability to recognize the
|
|
|
2006ba |
need to reposition the cursor at suspension or program
|
|
|
2006ba |
end. There remained unmet 1 additional potential need.
|
|
|
2006ba |
|
|
|
2006ba |
This commit extends that ability to embrace line input
|
|
|
2006ba |
so that if a user issues ^Z or ^C while being prompted
|
|
|
2006ba |
the resulting shell output will no longer be embedded.
|
|
|
2006ba |
|
|
|
2006ba |
Reference(s):
|
|
|
2006ba |
http://www.freelists.org/post/procps/top-library-miscellaneous-tweaks,7
|
|
|
2006ba |
commit 5c974ff44da4fbbb9170dd15bdd81555c62c31a9
|
|
|
2006ba |
|
|
|
2006ba |
Signed-off-by: Jim Warner <james.warner@comcast.net>
|
|
|
2006ba |
---
|
|
|
2006ba |
top/top.c | 4 ++++
|
|
|
2006ba |
1 file changed, 4 insertions(+)
|
|
|
2006ba |
|
|
|
2006ba |
diff --git a/top/top.c b/top/top.c
|
|
|
2006ba |
index c1c61dd..138f3ee 100644
|
|
|
2006ba |
--- a/top/top.c
|
|
|
2006ba |
+++ b/top/top.c
|
|
|
2006ba |
@@ -1081,12 +1081,14 @@ static char *ioline (const char *prompt) {
|
|
|
2006ba |
static char buf[MEDBUFSIZ];
|
|
|
2006ba |
char *p;
|
|
|
2006ba |
|
|
|
2006ba |
+ Cursor_repos = 1;
|
|
|
2006ba |
show_pmt(prompt);
|
|
|
2006ba |
memset(buf, '\0', sizeof(buf));
|
|
|
2006ba |
ioch(1, buf, sizeof(buf)-1);
|
|
|
2006ba |
|
|
|
2006ba |
if ((p = strpbrk(buf, ws))) *p = '\0';
|
|
|
2006ba |
// note: we DO produce a vaid 'string'
|
|
|
2006ba |
+ Cursor_repos = 0;
|
|
|
2006ba |
return buf;
|
|
|
2006ba |
} // end: ioline
|
|
|
2006ba |
|
|
|
2006ba |
@@ -1117,6 +1119,7 @@ static char *ioline (const char *prompt) {
|
|
|
2006ba |
};
|
|
|
2006ba |
static struct lin_s *anchor, *plin;
|
|
|
2006ba |
|
|
|
2006ba |
+ Cursor_repos = 1;
|
|
|
2006ba |
if (!anchor) {
|
|
|
2006ba |
anchor = alloc_c(sizeof(struct lin_s));
|
|
|
2006ba |
anchor->str = alloc_s(""); // top-of-stack == empty str
|
|
|
2006ba |
@@ -1182,6 +1185,7 @@ static char *ioline (const char *prompt) {
|
|
|
2006ba |
putp(tg2(beg+pos, Msg_row));
|
|
|
2006ba |
} while (key && key != kbd_ENTER && key != kbd_ESC);
|
|
|
2006ba |
|
|
|
2006ba |
+ Cursor_repos = 0;
|
|
|
2006ba |
// weed out duplicates, including empty strings (top-of-stack)...
|
|
|
2006ba |
for (i = 0, plin = anchor; ; i++) {
|
|
|
2006ba |
#ifdef RECALL_FIXED
|
|
|
2006ba |
--
|
|
|
2006ba |
1.8.1.2
|
|
|
2006ba |
|