From be3dcaa842cb64859e356d350c17de34932e5f1b Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Thu, 28 May 2020 00:00:00 -0500 Subject: [PATCH] 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 --- top/top.1 | 18 +++++++++++------- top/top.c | 6 +++++- top/top.h | 3 ++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/top/top.1 b/top/top.1 index 54535139..b667326c 100644 --- a/top/top.1 +++ b/top/top.1 @@ -1467,28 +1467,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 diff --git a/top/top.c b/top/top.c index 6e2048ec..ea1a8fe2 100644 --- a/top/top.c +++ b/top/top.c @@ -207,7 +207,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 /* Support for the new library API -- acquired (if necessary) at program startup and referenced throughout our lifetime. */ diff --git a/top/top.h b/top/top.h index 3decada6..c4f38833 100644 --- a/top/top.h +++ b/top/top.h @@ -48,6 +48,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 */ @@ -357,7 +358,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 struct pids_stack **ppt; // this window's stacks ptr array struct WIN_t *next, // next window in window stack *prev; // prior window in window stack