From: Jim Warner Date: Wed, 4 Aug 2021 05:00:00 +0000 (-0500) Subject: top: add a visual separator to lines printed 2 abreast X-Git-Tag: v4.0.0~157 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6eb9d4b5866d1dddb0168cf94a976f50c477ea7f;p=procps-ng top: add a visual separator to lines printed 2 abreast When the '4' toggle is on, and Summary Area %Cpu lines are shown two abreast, it's not always clear where the separation is between the two processors. So with this patch we'll now print a vertical bar separator between them (looking similar to the existing field headings). We will also reduce that 'GRAPH_suffix' constant to 1, reflecting the the trailing ']' bracket only, so as to maximize top's exploitation of available screen width. [ plus a superfluous double '+ +' has now been fixed ] Signed-off-by: Jim Warner --- diff --git a/top/top.c b/top/top.c index 81fa5a9e..059ada3f 100644 --- a/top/top.c +++ b/top/top.c @@ -189,7 +189,7 @@ static int Numa_node_sel = -1; commands -- which are now both 4-way toggles */ #define GRAPH_prefix 25 // beginning text + opening '[' #define GRAPH_actual 100 // the actual bars or blocks -#define GRAPH_suffix 2 // ending ']' + trailing space +#define GRAPH_suffix 1 // ending ']' static float Graph_adj; // bars/blocks scaling factor static int Graph_len; // scaled length (<= GRAPH_actual) static const char Graph_blks[] = " "; @@ -204,8 +204,13 @@ static const char Osel_filterO_fmt[] = "\ttype=%d,\t" OSEL_FILTER "%s\n"; 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[] = " "; +#ifdef TOG4_OFF_SEP +static char Double_sp[] = " "; #define DOUBLE_space (sizeof(Double_sp) - 1) +#else +static char Double_sp[] = " ~1 ~6 "; +#define DOUBLE_space (sizeof(Double_sp) - 5) // 1 for null, 4 unprintable +#endif #ifdef TOG4_NOTRUNC #define DOUBLE_limit (160 + DOUBLE_space) #else @@ -1794,7 +1799,7 @@ static void adj_geometry (void) { else Graph_len = 80 - GRAPH_prefix - GRAPH_suffix; if (Screen_cols < DOUBLE_limit) Curwin->rc.double_up = 0; if (Curwin->rc.double_up) { - Graph_len = (Screen_cols - DOUBLE_space - (2 * (GRAPH_prefix + + GRAPH_suffix))) / 2; + Graph_len = (Screen_cols - DOUBLE_space - (2 * (GRAPH_prefix + GRAPH_suffix))) / 2; if (Graph_len > GRAPH_actual) Graph_len = GRAPH_actual; } Graph_adj = (float)Graph_len / 100.0; diff --git a/top/top.h b/top/top.h index 4d5f308c..dca25223 100644 --- a/top/top.h +++ b/top/top.h @@ -51,6 +51,7 @@ //#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 TOG4_OFF_SEP /* don't show two abreast visual separator */ //#define TREE_FOCUS_X /* 'F' resets forest view indentation to 0 */ //#define TREE_NORESET /* sort keys do NOT force forest view OFF */ //#define TREE_SCANALL /* rescan array w/ forest view, avoid sort */