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:
Jim Warner 2013-01-29 00:00:00 -06:00 committed by Craig Small
parent cc61198318
commit 6f25f956e7
2 changed files with 13 additions and 6 deletions

View File

@ -1841,6 +1841,7 @@ static void display_fields (int focus, int extend) {
int xadd = 0; // spacing between data columns
int cmax = Screen_cols; // total data column width
int rmax = Screen_rows - yRSVD; // total useable rows
static int col_sav, row_sav;
i = (P_MAXPFLGS % mxCOL) ? 1 : 0;
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;
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) {
int b = FLDviz(w, i), x = (i / rmax) * cmax, y = (i % rmax) + yRSVD;
const char *e = (i == focus && extend) ? w->capclr_hdr : "";
@ -1860,7 +1870,7 @@ static void display_fields (int focus, int extend) {
// prep sacrificial suffix
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)
, b ? '*' : ' '
, b ? w->cap_bold : Cap_norm
@ -1872,8 +1882,7 @@ static void display_fields (int focus, int extend) {
, e
, smax, smax
, sbuf
, Cap_norm
, !x ? Cap_clr_eol : "");
, Cap_norm);
}
putp(Caps_off);
@ -1915,8 +1924,6 @@ signify_that:
putp(Cap_home);
show_special(1, fmtmk(N_unq(FIELD_header_fmt)
, w->grpname, CHKw(w, Show_FOREST) ? N_txt(FOREST_views_txt) : h));
putp(Cap_nl_clreos);
fflush(stdout);
display_fields(i, (p != NULL));
fflush(stdout);

View File

@ -568,7 +568,7 @@ static void build_uniq_nlstab (void) {
Uniq_nlstab[FIELD_header_fmt] = _(""
"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"
" '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"
" %3u ~2total,~3 %3u ~2running,~3 %3u ~2sleeping,~3 %3u ~2stopped,~3 %3u ~2zombie~3\n");