top: refactor the 'scroll coordinates' message support
This patch is simply preparation for upcoming vertical scrolling enhancements. With those changes, it will be impossible to predict what the beginning task position should be at the time the message is currently issued. This patch will allow such a message to be shown after the individual windows' tasks have all been displayed. Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
3943b185a9
commit
78dcaffad7
73
top/top.c
73
top/top.c
@ -112,10 +112,6 @@ static int Screen_cols, Screen_rows, Max_lines;
|
|||||||
stick the cursor between frames. */
|
stick the cursor between frames. */
|
||||||
static int Msg_row;
|
static int Msg_row;
|
||||||
|
|
||||||
/* The nearly complete scroll coordinates message for the current
|
|
||||||
window, built at the time column headers are constructed */
|
|
||||||
static char Scroll_fmts [SMLBUFSIZ];
|
|
||||||
|
|
||||||
/* Global/Non-windows mode stuff that is NOT persistent */
|
/* Global/Non-windows mode stuff that is NOT persistent */
|
||||||
static int Batch = 0, // batch mode, collect no input, dumb output
|
static int Batch = 0, // batch mode, collect no input, dumb output
|
||||||
Loops = -1, // number of iterations, -1 loops forever
|
Loops = -1, // number of iterations, -1 loops forever
|
||||||
@ -905,6 +901,32 @@ static int show_pmt (const char *str) {
|
|||||||
} // end: show_pmt
|
} // end: show_pmt
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create and print the optional scroll coordinates message */
|
||||||
|
static void show_scroll (void) {
|
||||||
|
char tmp1[SMLBUFSIZ], tmp2[SMLBUFSIZ];
|
||||||
|
int totpflgs = Curwin->totpflgs;
|
||||||
|
int begpflgs = Curwin->begpflg + 1;
|
||||||
|
|
||||||
|
#ifndef USE_X_COLHDR
|
||||||
|
if (CHKw(Curwin, Show_HICOLS)) {
|
||||||
|
totpflgs -= 2;
|
||||||
|
if (ENUpos(Curwin, Curwin->rc.sortindx) < Curwin->begpflg) begpflgs -= 2;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (1 > totpflgs) totpflgs = 1;
|
||||||
|
if (1 > begpflgs) begpflgs = 1;
|
||||||
|
snprintf(tmp1, sizeof(tmp1), N_fmt(SCROLL_coord_fmt), Curwin->begtask + 1, Frame_maxtask, begpflgs, totpflgs);
|
||||||
|
#ifndef SCROLLVAR_NO
|
||||||
|
if (Curwin->varcolbeg) {
|
||||||
|
snprintf(tmp2, sizeof(tmp2), " + %d", Curwin->varcolbeg);
|
||||||
|
scat(tmp1, tmp2);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
PUTT("%s%s %.*s%s", tg2(0, Msg_row), Caps_off, Screen_cols - 3, tmp1, Cap_clr_eol);
|
||||||
|
} // end: show_scroll
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show lines with specially formatted elements, but only output
|
* Show lines with specially formatted elements, but only output
|
||||||
* what will fit within the current screen width.
|
* what will fit within the current screen width.
|
||||||
@ -1011,36 +1033,6 @@ static void show_special (int interact, const char *glob) {
|
|||||||
'fit-to-screen' thingy while also leaving room for the cursor... */
|
'fit-to-screen' thingy while also leaving room for the cursor... */
|
||||||
if (*glob) PUTT("%.*s", utf8_embody(glob, Screen_cols - 1), glob);
|
if (*glob) PUTT("%.*s", utf8_embody(glob, Screen_cols - 1), glob);
|
||||||
} // end: show_special
|
} // end: show_special
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create a nearly complete scroll coordinates message, but still
|
|
||||||
* a format string since we'll be missing the current total tasks. */
|
|
||||||
static void updt_scroll_msg (void) {
|
|
||||||
char tmp1[SMLBUFSIZ], tmp2[SMLBUFSIZ];
|
|
||||||
int totpflgs = Curwin->totpflgs;
|
|
||||||
int begpflgs = Curwin->begpflg + 1;
|
|
||||||
|
|
||||||
#ifndef USE_X_COLHDR
|
|
||||||
if (CHKw(Curwin, Show_HICOLS)) {
|
|
||||||
totpflgs -= 2;
|
|
||||||
if (ENUpos(Curwin, Curwin->rc.sortindx) < Curwin->begpflg) begpflgs -= 2;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (1 > totpflgs) totpflgs = 1;
|
|
||||||
if (1 > begpflgs) begpflgs = 1;
|
|
||||||
snprintf(tmp1, sizeof(tmp1)
|
|
||||||
, N_fmt(SCROLL_coord_fmt), Curwin->begtask + 1, begpflgs, totpflgs);
|
|
||||||
strcpy(tmp2, tmp1);
|
|
||||||
#ifndef SCROLLVAR_NO
|
|
||||||
if (Curwin->varcolbeg)
|
|
||||||
snprintf(tmp2, sizeof(tmp2), "%s + %d", tmp1, Curwin->varcolbeg);
|
|
||||||
#endif
|
|
||||||
// this Scroll_fmts string no longer provides for termcap tgoto so that
|
|
||||||
// the usage timing is critical -- see frame_make() for additional info
|
|
||||||
snprintf(Scroll_fmts, sizeof(Scroll_fmts)
|
|
||||||
, "%s %.*s%s", Caps_off, Screen_cols - 3, tmp2, Cap_clr_eol);
|
|
||||||
} // end: updt_scroll_msg
|
|
||||||
|
|
||||||
/*###### Low Level Memory/Keyboard/File I/O support ####################*/
|
/*###### Low Level Memory/Keyboard/File I/O support ####################*/
|
||||||
|
|
||||||
@ -2148,8 +2140,6 @@ static void calibrate_fields (void) {
|
|||||||
} while (w != Curwin);
|
} while (w != Curwin);
|
||||||
|
|
||||||
build_headers();
|
build_headers();
|
||||||
if (CHKw(Curwin, View_SCROLL))
|
|
||||||
updt_scroll_msg();
|
|
||||||
} // end: calibrate_fields
|
} // end: calibrate_fields
|
||||||
|
|
||||||
|
|
||||||
@ -6316,12 +6306,8 @@ static void frame_make (void) {
|
|||||||
Max_lines = (Screen_rows - Msg_row) - 1;
|
Max_lines = (Screen_rows - Msg_row) - 1;
|
||||||
OFFw(w, INFINDS_xxx);
|
OFFw(w, INFINDS_xxx);
|
||||||
|
|
||||||
/* one way or another, rid us of any prior frame's msg
|
// we're now on Msg_row so clear out any residual messages ...
|
||||||
[ now that this is positioned after the call to summary_show(), ]
|
putp(Cap_clr_eol);
|
||||||
[ we no longer need or employ tg2(0, Msg_row) since all summary ]
|
|
||||||
[ lines end with a newline, and header lines begin with newline ] */
|
|
||||||
if (VIZISw(w) && CHKw(w, View_SCROLL)) PUTT(Scroll_fmts, Frame_maxtask);
|
|
||||||
else putp(Cap_clr_eol);
|
|
||||||
|
|
||||||
if (!Rc.mode_altscr) {
|
if (!Rc.mode_altscr) {
|
||||||
// only 1 window to show so, piece o' cake
|
// only 1 window to show so, piece o' cake
|
||||||
@ -6344,6 +6330,9 @@ static void frame_make (void) {
|
|||||||
putp(Cap_nl_clreos);
|
putp(Cap_nl_clreos);
|
||||||
PSU_CLREOS(Pseudo_row);
|
PSU_CLREOS(Pseudo_row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CHKw(w, View_SCROLL) && VIZISw(Curwin))
|
||||||
|
show_scroll();
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
/* we'll deem any terminal not supporting tgoto as dumb and disable
|
/* we'll deem any terminal not supporting tgoto as dumb and disable
|
||||||
|
@ -696,8 +696,8 @@ typedef struct WIN_t {
|
|||||||
//atic void capsmk (WIN_t *q);
|
//atic void capsmk (WIN_t *q);
|
||||||
//atic void show_msg (const char *str);
|
//atic void show_msg (const char *str);
|
||||||
//atic int show_pmt (const char *str);
|
//atic int show_pmt (const char *str);
|
||||||
|
//atic void show_scroll (void);
|
||||||
//atic void show_special (int interact, const char *glob);
|
//atic void show_special (int interact, const char *glob);
|
||||||
//atic void updt_scroll_msg (void);
|
|
||||||
/*------ Low Level Memory/Keyboard/File I/O support --------------------*/
|
/*------ Low Level Memory/Keyboard/File I/O support --------------------*/
|
||||||
//atic void *alloc_c (size_t num);
|
//atic void *alloc_c (size_t num);
|
||||||
//atic void *alloc_r (void *ptr, size_t num);
|
//atic void *alloc_r (void *ptr, size_t num);
|
||||||
|
@ -377,7 +377,7 @@ static void build_norm_nlstab (void) {
|
|||||||
Norm_nlstab[BAD_max_task_txt] = _("Invalid maximum");
|
Norm_nlstab[BAD_max_task_txt] = _("Invalid maximum");
|
||||||
Norm_nlstab[GET_user_ids_txt] = _("Which user (blank for all)");
|
Norm_nlstab[GET_user_ids_txt] = _("Which user (blank for all)");
|
||||||
Norm_nlstab[UNKNOWN_cmds_txt] = _("Unknown command - try 'h' for help");
|
Norm_nlstab[UNKNOWN_cmds_txt] = _("Unknown command - try 'h' for help");
|
||||||
Norm_nlstab[SCROLL_coord_fmt] = _("scroll coordinates: y = %d/%%d (tasks), x = %d/%d (fields)");
|
Norm_nlstab[SCROLL_coord_fmt] = _("scroll coordinates: y = %d/%d (tasks), x = %d/%d (fields)");
|
||||||
Norm_nlstab[FAIL_alloc_c_txt] = _("failed memory allocate");
|
Norm_nlstab[FAIL_alloc_c_txt] = _("failed memory allocate");
|
||||||
Norm_nlstab[FAIL_alloc_r_txt] = _("failed memory re-allocate");
|
Norm_nlstab[FAIL_alloc_r_txt] = _("failed memory re-allocate");
|
||||||
Norm_nlstab[BAD_numfloat_txt] = _("Unacceptable floating point");
|
Norm_nlstab[BAD_numfloat_txt] = _("Unacceptable floating point");
|
||||||
|
Loading…
Reference in New Issue
Block a user