]> granicus.if.org Git - procps-ng/commitdiff
top: new #define added for focus ('F') toggle tweaking
authorJim Warner <james.warner@comcast.net>
Sun, 25 Jul 2021 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Tue, 27 Jul 2021 11:17:18 +0000 (21:17 +1000)
Just to see if I could, the new #define will force the
indentation of a parent task to be reset to zero while
maintaining the proper child indentation relationship.

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

index 179b7a32527bcc92cfa0c237a6c320f9e58c0e88..3c3554fe8a41a4ff5bb93eeead847e529843c1fe 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -4478,7 +4478,8 @@ static void forest_begin (WIN_t *q) {
          * But, if the pid can no longer be found, he'll turn off focus! | */
 static void forest_config (WIN_t *q) {
   // tailored 'results stack value' extractor macro
- #define rSv(x) PID_VAL(eu_TREE_LVL, s_int, q->ppt[(x)])
+  // (TREE_FOCUS_X can't use PID_VAL w/ assignment)
+ #define rSv(x)  q->ppt[x]->head[eu_TREE_LVL].result.s_int
    int i, level;
 
    for (i = 0; i < PIDSmaxt; i++) {
@@ -4491,8 +4492,15 @@ static void forest_config (WIN_t *q) {
    if (i == PIDSmaxt)
       q->focus_pid = q->begtask = 0;
    else {
+#ifdef TREE_FOCUS_X
+      int j = rSv(i);
+      rSv(i) = 0;
+      while (i+1 < PIDSmaxt && rSv(i+1) > level)
+         rSv(++i) -= j;
+#else
       while (i+1 < PIDSmaxt && rSv(i+1) > level)
          ++i;
+#endif
       q->focus_end = i + 1;  // make 'focus_end' a proper fencpost
    }
  #undef rSv
index 4d3fe570e7c40312736bcf21d898fa15415601c9..a15d7fd64744177b063d5f90460e05c34344440b 100644 (file)
--- 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 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 */
 //#define TREE_VALTMRK            /* use an indented '+' with collapsed pids */