]> granicus.if.org Git - procps-ng/commitdiff
top: add visual clue when focus toggle ('F') is active
authorJim Warner <james.warner@comcast.net>
Thu, 13 Jan 2022 19:13:13 +0000 (13:13 -0600)
committerCraig Small <csmall@dropbear.xyz>
Mon, 17 Jan 2022 09:27:21 +0000 (20:27 +1100)
When in forest view mode, that focus toggle ('F') is a
useful tool occasionally. But, if a focused parent has
enough cloned siblings to exceed screen rows, it could
be hard to remember that such a toggle remains active.

So, this patch will provide a subtle visual clue added
to the leftmost position in the COMMAND column. Now if
the focus toggle was active, regardless of total tasks
affected, the users will always know when it's active.

Reference(s):
. 07/28/21, introduced new focus toggle ('F')
commit bdd50fa2fc00edb51f6125334d2329fdce12c4ba
. 09/23/21, ensure focused tasks stay focused
commit d7e6c27a7944fbaa1493f207fd521bd59984c955

Signed-off-by: Jim Warner <james.warner@comcast.net>
top/top.c
top/top.h

index 891eaeba3fc5c2ad57b971c86ba648253b7f076b..82eeb7c3793b9d58280fe42996ebe0313bd22e3f 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -4905,8 +4905,16 @@ static inline const char *forest_display (const WIN_t *q, int idx) {
 #endif
       return buf;
    }
-   if (level > 100) snprintf(buf, sizeof(buf), "%400s%s", " +  ", which);
+   if (level > 100) {
+      snprintf(buf, sizeof(buf), "%400s%s", " +  ", which);
+      return buf;
+   }
+#ifndef FOCUS_VIZOFF
+   if (q->focus_pid) snprintf(buf, sizeof(buf), "|%*s%s", ((4 * level) - 1), "`- ", which);
    else snprintf(buf, sizeof(buf), "%*s%s", (4 * level), " `- ", which);
+#else
+   snprintf(buf, sizeof(buf), "%*s%s", (4 * level), " `- ", which);
+#endif
    return buf;
 } // end: forest_display
 
index a1f1629cea30b084ae5e12815da11c7e53a1e969..082710d27e0ca741904a8d5e48769bf3f88b868d 100644 (file)
--- a/top/top.h
+++ b/top/top.h
@@ -35,6 +35,7 @@
 //#define EQUCOLHDRYES            /* yes, equalize the column header lengths */
 //#define FOCUS_HARD_Y            /* 'F' will avoid topmost task distortions */
 //#define FOCUS_TREE_X            /* 'F' resets forest view indentation to 0 */
+//#define FOCUS_VIZOFF            /* 'F' doesn't provide the visual clue '|' */
 //#define GETOPTFIX_NO            /* do not address getopt_long deficiencies */
 //#define INSP_JUSTNOT            /* do not smooth unprintable right margins */
 //#define INSP_OFFDEMO            /* disable demo screens, issue msg instead */