top: reduce minimum terminal width with 2 abreast mode

For the original implementation of the '4' toggle, the
minimum width was set at 165 columns. This was done to
avoid truncations when detailed cpu statistics (versus
graphs) were being displayed. Those can not be scaled.

Upon reflection, it seems more appropriate to give the
user the choice of whether or not to truncate. And, by
reducing that minimum width requirement to 80 columns,
we'll vastly expand potential use of two abreast mode.

[ we'll keep that original as '#define TOG4_NOTRUNC' ]

The patch also updates the man document appropriately.
Along the way, we will trade the potentially confusing
word 'adjacent' for the more natural 'additional' when
detailing the '!' toggle in 4b. Summary-Area-Commands.

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/172
https://www.freelists.org/post/procps/two-major-changes-to-top

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2020-05-28 00:00:00 -05:00 committed by Craig Small
parent e5ddd7ff55
commit 6db0d5eab6
3 changed files with 18 additions and 9 deletions

View File

@ -1460,28 +1460,32 @@ This \*(CI is only available if a system has the requisite NUMA support.
\ \ \ \fB4\fR\ \ :\fIDisplay-Cpus-Two-Abreast \fR
This command turns the `1' toggle \*F for individual \*(Pu display
but prints the results two abreast.
It requires a terminal with a minimum width of 165 columns.
It requires a terminal with a minimum width of 80 columns.
If a terminal's width is decreased below the minimum while \*(We
is running, \*(We reverts to the normal `1' toggle \*F state.
To avoid truncation when displaying detailed \*(Pu statistcs,
as opposed to the graphic representations, a minimum width
of 165 columns would be required.
.TP 7
\ \ \ \fB!\fR\ \ :\fICombine-Cpus-Mode \fR
This \*(CT is intended for massively parallel SMP environments where,
even with the `4' \*(CT, not all processors can be displayed.
With each press of `!' the number of adjacent \*(Pu's combined is
With each press of `!' the number of additional \*(Pu's combined is
doubled thus reducing the total number of \*(Pu lines displayed.
For example, with the first press of `!' one adjacent \*(Pu will be
For example, with the first press of `!' one additional \*(Pu will be
combined and displayed as `0-1, 2-3, ...' instead of the normal
`%Cpu0, %Cpu1, %Cpu2, %Cpu3, ...'.
With a second `!' \*(CT two adjacent \*(Pus are combined and shown
With a second `!' \*(CT two additional \*(Pus are combined and shown
as `0-2, 3-5, ...'.
Then the third '!' press, combining four adjacent \*(Pus, shows
as `0-4, 5-7, ...', etc.
Then the third '!' press, combining four additional \*(Pus, shows
as `0-4, 5-9, ...', etc.
Such progression continues until individual \*(Pus are again displayed
and impacts both the `1' and `4' toggles (one or two columns).
Use the `=' \*(CT to exit \fBCombine Cpus\fR mode.
Use the `=' command to exit \fBCombine Cpus\fR mode.
.PP
\*(NT If the entire \*(SA has been toggled \*F for any window, you would

View File

@ -237,7 +237,11 @@ static const char Osel_filterI_fmt[] = "\ttype=%d,\t" OSEL_FILTER "%*s\n";
/* Support for 2 abreast Cpu display (if terminal is wide enough) */
static char Double_sp[] = " ";
#define DOUBLE_space (sizeof(Double_sp) - 1)
#define DOUBLE_limit (160 + DOUBLE_space)
#ifdef TOG4_NOTRUNC
#define DOUBLE_limit (160 + DOUBLE_space)
#else
#define DOUBLE_limit ( 80 )
#endif
/*###### Sort callbacks ################################################*/

View File

@ -55,6 +55,7 @@
//#define STRINGCASENO /* case insenstive compare/locate versions */
//#define TERMIOS_ONLY /* just limp along with native input only */
//#define TOG4_NOFORCE /* no force 2 abreast mode with '4' toggle */
//#define TOG4_NOTRUNC /* ensure no truncation in 2 abreast mode */
//#define TREE_NORESET /* sort keys do NOT force forest view OFF */
//#define TREE_SCANALL /* rescan array w/ forest view, avoid sort */
//#define TREE_VALTMRK /* use an indented '+' with collapsed pids */
@ -437,7 +438,7 @@ typedef struct WIN_t {
char *findstr; // window's current/active search string
int findlen; // above's strlen, without call overhead
int double_up; // show individual cpus 2 abreast
int combine_cpus; // keep combining adjacent cpus
int combine_cpus; // keep combining additional cpus
proc_t **ppt; // this window's proc_t ptr array
struct WIN_t *next, // next window in window stack
*prev; // prior window in window stack