]> granicus.if.org Git - procps-ng/commitdiff
top: add a visual separator to lines printed 2 abreast
authorJim Warner <james.warner@comcast.net>
Thu, 5 Aug 2021 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Fri, 6 Aug 2021 10:19:18 +0000 (20:19 +1000)
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 <james.warner@comcast.net>
top/top.c
top/top.h

index f5125f76979b26715b2048bda7857a4f9b6a4f6b..6a3d79df73b461765f0d1133b29479c63cd3eed2 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -224,7 +224,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[] = "                                                                                                    ";
@@ -239,8 +239,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
@@ -1968,7 +1973,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;
index 90b162baa28f2db66683bbe8b9e62b25d40e2037..ee3e9fff8c605a3000cf27830a9e6f198bcd2ea8 100644 (file)
--- a/top/top.h
+++ b/top/top.h
@@ -56,6 +56,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 */