top: finish the job of correcting the response to a ^Z
if top is suspended while on the 2nd level help screen the <Enter> key is no longer honored. Thus, users must use <Esc> to exit help and return to the main display. Also, line input that was only partially complete when suspended would still require one additional keystroke before the read was aborted and the display refreshed. Lastly, some user interactions might require two input lines before an operation can be considered completed. Thus the 2nd line offers another opportunity for users to suspend top. Resumption would require an extra key. These issues stem from 2 recent enhancements: preserve the user context when signaled; complete input editing with cursor movement keys, insert/overtype modes, etc. With this patch, the <Enter> key is once again honored on help screen #2 and partial reads are now completed. (everything is perfectly justified plus right margins) (are completely filled, but of course it must be luck) Reference(s): bug reported http://www.freelists.org/post/procps/top-over-the-top,25 response to ^Z (partial solution) commit5c3fffcf28
line input editing commit477b10c0bd
preserve context with SIGWINCH commitba9092ad83
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
709785e20b
commit
b9976f7056
12
top/top.c
12
top/top.c
@ -966,7 +966,7 @@ static int iokey (int action) {
|
||||
const char *str;
|
||||
int key;
|
||||
} tinfo_tab[] = {
|
||||
{ "\n", kbd_ENTER }, { NULL, kbd_UP }, { NULL, kbd_DOWN },
|
||||
{ "\033\n",kbd_ENTER }, { NULL, kbd_UP }, { NULL, kbd_DOWN },
|
||||
{ NULL, kbd_LEFT }, { NULL, kbd_RIGHT }, { NULL, kbd_PGUP },
|
||||
{ NULL, kbd_PGDN }, { NULL, kbd_HOME }, { NULL, kbd_END },
|
||||
{ NULL, kbd_BKSP }, { NULL, kbd_INS }, { NULL, kbd_DEL },
|
||||
@ -1115,7 +1115,7 @@ static char *ioline (const char *prompt) {
|
||||
case kbd_ESC:
|
||||
buf[0] = '\0'; // fall through !
|
||||
case kbd_ENTER:
|
||||
break;
|
||||
continue;
|
||||
case kbd_INS:
|
||||
ovt = !ovt;
|
||||
putp(ovt ? Cap_curs_huge : Cap_curs_norm);
|
||||
@ -1245,7 +1245,8 @@ static float get_float (const char *prompt) {
|
||||
char *line;
|
||||
float f;
|
||||
|
||||
if (!(*(line = ioline(prompt)))) return -1.0;
|
||||
line = ioline(prompt);
|
||||
if (!line[0] || Frames_resize) return -1.0;
|
||||
// note: we're not allowing negative floats
|
||||
if (strcspn(line, "+,.0123456789")) {
|
||||
show_msg(N_txt(BAD_numfloat_txt));
|
||||
@ -1265,7 +1266,9 @@ static int get_int (const char *prompt) {
|
||||
char *line;
|
||||
int n;
|
||||
|
||||
if (!(*(line = ioline(prompt)))) return GET_INTNONE;
|
||||
line = ioline(prompt);
|
||||
if (Frames_resize) return GET_INT_BAD;
|
||||
if (!line[0]) return GET_INTNONE;
|
||||
// note: we've got to allow negative ints (renice)
|
||||
if (strcspn(line, "-+0123456789")) {
|
||||
show_msg(N_txt(BAD_integers_txt));
|
||||
@ -4097,6 +4100,7 @@ static void keys_global (int ch) {
|
||||
if (0 > pid) pid = def;
|
||||
str = ioline(fmtmk(N_fmt(GET_sigs_num_fmt), pid, SIGTERM));
|
||||
if (*str) sig = signal_name_to_number(str);
|
||||
if (Frames_resize) break;
|
||||
if (0 < sig && kill(pid, sig))
|
||||
show_msg(fmtmk(N_fmt(FAIL_signals_fmt)
|
||||
, pid, sig, strerror(errno)));
|
||||
|
@ -141,7 +141,7 @@ char *strcasestr(const char *haystack, const char *needle);
|
||||
// support for keyboard stuff (cursor motion keystrokes, mostly)
|
||||
#define kbd_ESC '\033'
|
||||
#define kbd_SPACE ' '
|
||||
#define kbd_ENTER 128
|
||||
#define kbd_ENTER '\n'
|
||||
#define kbd_UP 129
|
||||
#define kbd_DOWN 130
|
||||
#define kbd_LEFT 131
|
||||
|
Loading…
Reference in New Issue
Block a user