top: add the ability to suppress zeros in most columns

With the increased width and precision of memory and %
columns, the proliferation of 0's when there's nothing
to report seems like a distraction versus useful data.

This commit introduces the '0' toggle which can either
display or suppress those zeros. And, like the scaling
states this new state is also preserved in the rcfile.

(now that we know a '.' + 2 spaces is squeezed to one)
(everything's perfectly justified, but it's just luck)

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2012-12-15 00:00:00 -06:00 committed by Craig Small
parent 21e550bc08
commit 688f4e7399
2 changed files with 15 additions and 6 deletions

View File

@ -836,7 +836,7 @@ depending on the context in which they are issued.
.Bd -literal
4a.\fI Global-Commands \fR
<Ent/Sp> ?, =,
<Ent/Sp> ?, =, 0,
A, B, d, E, g, h, H, I, k, q, r, s, W, X, Y, Z
4b.\fI Summary-Area-Commands \fR
C, l, t, 1, m
@ -900,6 +900,12 @@ vertical and horizontal scrolling.
When operating in \*(AM this command has a broader meaning.
.TP 7
\ \ \'\fB0\fR\' :\fIZero-Suppress\fR toggle \fR
This command determines whether zeros are shown or suppressed for many
of the fields in a \*(TW.
Fields like UID, GID, NI, PR or P are not affected by this toggle.
.TP 7
\ \ \'\fBA\fR\' :\fIAlternate-Display-Mode\fR toggle \fR
This command will switch between \*(FM and \*(AM.

View File

@ -3113,8 +3113,8 @@ static void configs_read (void) {
} // end: for (GROUPSMAX)
// any new addition(s) last, for older rcfiles compatibility...
fscanf(fp, "Fixed_widest=%d, Summ_mscale=%d, Task_mscale=%d\n"
, &Rc.fixed_widest, &Rc.summ_mscale, &Rc.task_mscale);
fscanf(fp, "Fixed_widest=%d, Summ_mscale=%d, Task_mscale=%d, Zero_suppress=%d\n"
, &Rc.fixed_widest, &Rc.summ_mscale, &Rc.task_mscale, &Rc.zero_suppress);
try_inspect_entries:
@ -3702,8 +3702,8 @@ static void file_writerc (void) {
}
// any new addition(s) last, for older rcfiles compatibility...
fprintf(fp, "Fixed_widest=%d, Summ_mscale=%d, Task_mscale=%d\n"
, Rc.fixed_widest, Rc.summ_mscale, Rc.task_mscale);
fprintf(fp, "Fixed_widest=%d, Summ_mscale=%d, Task_mscale=%d, Zero_suppress=%d\n"
, Rc.fixed_widest, Rc.summ_mscale, Rc.task_mscale, Rc.zero_suppress);
if (Inspect.raw)
fputs(Inspect.raw, fp);
@ -3901,6 +3901,9 @@ static void keys_global (int ch) {
case 'Z':
wins_colors();
break;
case '0':
Rc.zero_suppress = !Rc.zero_suppress;
break;
case kbd_ENTER: // these two have the effect of waking us
case kbd_SPACE: // from 'select()', updating hotplugged
sysinfo_refresh(1); // resources and refreshing the display
@ -4364,7 +4367,7 @@ static void do_key (int ch) {
} key_tab[] = {
{ keys_global,
{ '?', 'B', 'd', 'E', 'e', 'F', 'f', 'g', 'H', 'h'
, 'I', 'k', 'r', 's', 'X', 'Y', 'Z'
, 'I', 'k', 'r', 's', 'X', 'Y', 'Z', '0'
, kbd_ENTER, kbd_SPACE, '\0' } },
{ keys_summary,
{ '1', 'C', 'l', 'm', 't', '\0' } },