top: a few small adjustments to reduce display flicker
This change involves the Fields Management logic only.
With user position being maintained after signals, the
previous algorithm unfortunately used Cap_clr_eos with
each iteration of the loop. The screen flicker invited
with that choice was not apparent under all emulators.
With this commit, clearing to end-of-screen has become
conditional on whether or not there was a true resize.
(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)
Reference(s):
commit ba9092ad83
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
cc61198318
commit
6f25f956e7
17
top/top.c
17
top/top.c
@ -1841,6 +1841,7 @@ static void display_fields (int focus, int extend) {
|
|||||||
int xadd = 0; // spacing between data columns
|
int xadd = 0; // spacing between data columns
|
||||||
int cmax = Screen_cols; // total data column width
|
int cmax = Screen_cols; // total data column width
|
||||||
int rmax = Screen_rows - yRSVD; // total useable rows
|
int rmax = Screen_rows - yRSVD; // total useable rows
|
||||||
|
static int col_sav, row_sav;
|
||||||
|
|
||||||
i = (P_MAXPFLGS % mxCOL) ? 1 : 0;
|
i = (P_MAXPFLGS % mxCOL) ? 1 : 0;
|
||||||
if (rmax < i + (P_MAXPFLGS / mxCOL)) error_exit("++rows"); // nls_maybe
|
if (rmax < i + (P_MAXPFLGS / mxCOL)) error_exit("++rows"); // nls_maybe
|
||||||
@ -1851,6 +1852,15 @@ static void display_fields (int focus, int extend) {
|
|||||||
smax = cmax - xPRFX;
|
smax = cmax - xPRFX;
|
||||||
if (smax < 0) error_exit("++cols"); // nls_maybe
|
if (smax < 0) error_exit("++cols"); // nls_maybe
|
||||||
|
|
||||||
|
/* we'll go the extra distance to avoid any potential screen flicker
|
||||||
|
which occurs under some terminal emulators (but it was our fault) */
|
||||||
|
if (col_sav != Screen_cols || row_sav != Screen_rows) {
|
||||||
|
col_sav = Screen_cols;
|
||||||
|
row_sav = Screen_rows;
|
||||||
|
putp(Cap_clr_eos);
|
||||||
|
}
|
||||||
|
fflush(stdout);
|
||||||
|
|
||||||
for (i = 0; i < P_MAXPFLGS; ++i) {
|
for (i = 0; i < P_MAXPFLGS; ++i) {
|
||||||
int b = FLDviz(w, i), x = (i / rmax) * cmax, y = (i % rmax) + yRSVD;
|
int b = FLDviz(w, i), x = (i / rmax) * cmax, y = (i % rmax) + yRSVD;
|
||||||
const char *e = (i == focus && extend) ? w->capclr_hdr : "";
|
const char *e = (i == focus && extend) ? w->capclr_hdr : "";
|
||||||
@ -1860,7 +1870,7 @@ static void display_fields (int focus, int extend) {
|
|||||||
// prep sacrificial suffix
|
// prep sacrificial suffix
|
||||||
snprintf(sbuf, sizeof(sbuf), "= %s", N_fld(f));
|
snprintf(sbuf, sizeof(sbuf), "= %s", N_fld(f));
|
||||||
|
|
||||||
PUTT("%s%c%s%s %s%-7.7s%s%s%s %-*.*s%s%s"
|
PUTT("%s%c%s%s %s%-7.7s%s%s%s %-*.*s%s"
|
||||||
, tg2(x, y)
|
, tg2(x, y)
|
||||||
, b ? '*' : ' '
|
, b ? '*' : ' '
|
||||||
, b ? w->cap_bold : Cap_norm
|
, b ? w->cap_bold : Cap_norm
|
||||||
@ -1872,8 +1882,7 @@ static void display_fields (int focus, int extend) {
|
|||||||
, e
|
, e
|
||||||
, smax, smax
|
, smax, smax
|
||||||
, sbuf
|
, sbuf
|
||||||
, Cap_norm
|
, Cap_norm);
|
||||||
, !x ? Cap_clr_eol : "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
putp(Caps_off);
|
putp(Caps_off);
|
||||||
@ -1915,8 +1924,6 @@ signify_that:
|
|||||||
putp(Cap_home);
|
putp(Cap_home);
|
||||||
show_special(1, fmtmk(N_unq(FIELD_header_fmt)
|
show_special(1, fmtmk(N_unq(FIELD_header_fmt)
|
||||||
, w->grpname, CHKw(w, Show_FOREST) ? N_txt(FOREST_views_txt) : h));
|
, w->grpname, CHKw(w, Show_FOREST) ? N_txt(FOREST_views_txt) : h));
|
||||||
putp(Cap_nl_clreos);
|
|
||||||
fflush(stdout);
|
|
||||||
display_fields(i, (p != NULL));
|
display_fields(i, (p != NULL));
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
|
@ -568,7 +568,7 @@ static void build_uniq_nlstab (void) {
|
|||||||
Uniq_nlstab[FIELD_header_fmt] = _(""
|
Uniq_nlstab[FIELD_header_fmt] = _(""
|
||||||
"Fields Management~2 for window ~1%s~6, whose current sort field is ~1%s~2\n"
|
"Fields Management~2 for window ~1%s~6, whose current sort field is ~1%s~2\n"
|
||||||
" Navigate with Up/Dn, Right selects for move then <Enter> or Left commits,\n"
|
" Navigate with Up/Dn, Right selects for move then <Enter> or Left commits,\n"
|
||||||
" 'd' or <Space> toggles display, 's' sets sort. Use 'q' or <Esc> to end! ");
|
" 'd' or <Space> toggles display, 's' sets sort. Use 'q' or <Esc> to end!\n");
|
||||||
|
|
||||||
Uniq_nlstab[STATE_line_1_fmt] = _("%s:~3"
|
Uniq_nlstab[STATE_line_1_fmt] = _("%s:~3"
|
||||||
" %3u ~2total,~3 %3u ~2running,~3 %3u ~2sleeping,~3 %3u ~2stopped,~3 %3u ~2zombie~3\n");
|
" %3u ~2total,~3 %3u ~2running,~3 %3u ~2sleeping,~3 %3u ~2stopped,~3 %3u ~2zombie~3\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user