top: improve vertical scroll management for 'i' toggle
authorJim Warner <james.warner@comcast.net>
Sun, 12 Jul 2015 09:44:44 +0000 (04:44 -0500)
committerCraig Small <csmall@enc.com.au>
Tue, 21 Jul 2015 11:23:44 +0000 (21:23 +1000)
When a user is taking advantage of the scroll features
it is likely a scrolled vertical position is well past
the first displayable task. That is especially true of
top's forest view ('V') mode where those early systemd
attached processes are generally not very interesting.

As such, should the idle mode toggle ('i') be employed
a distorted display is almost guaranteed because tasks
that have used some cpu, and thus should be displayed,
have already been skipped by virtue of their position.

So this patch temporarily nullifies vertical scrolling
during the period when idle tasks are not being shown.

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

index 273c4a54dcea2dced6aa758f8f0f943b09e81b59..5a805345dd4b7d7b1266cc657fa709b49e208b63 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -4612,6 +4612,12 @@ static void keys_task (int ch) {
          VIZTOGw(w, Show_CMDLIN);
          break;
       case 'i':
+      {  static WIN_t *w_sav;
+         static int beg_sav;
+         if (w_sav != w) { beg_sav = 0; w_sav = w; }
+         if (CHKw(w, Show_IDLEPS)) { beg_sav = w->begtask; w->begtask = 0; }
+         else { w->begtask = beg_sav; beg_sav = 0; }
+      }
          VIZTOGw(w, Show_IDLEPS);
          break;
       case 'J':