]> granicus.if.org Git - procps-ng/commitdiff
top: plug a minor hole in the vertical scrolling logic
authorJim Warner <james.warner@comcast.net>
Tue, 18 Sep 2018 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Wed, 2 Jan 2019 21:01:25 +0000 (08:01 +1100)
In that commit referenced below, a few edge cases were
addressed regarding vertical positioning involving any
'hidden' tasks. But, 2 additional edge cases remained.

In a running top, if the user employed 'other filters'
(o/O) or 'user filters' (u/U) proper vertical position
was not ensured. And, while this could be easily fixed
by striking the home/end or up/down arrow keys, it was
very poor etiquette to shift this burden to the users.

So, this patch plugs that gap, automating the process.

Reference(s):
commit c6e68e2fedc21b2537066433d1b50a60e06774eb

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

index 30a2fc854c18df1ad7d762844f6e4482701288af..dd4b9481b8a9b095feda1d7897ec9f68b95460ab 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -4664,7 +4664,8 @@ static void wins_stage_2 (void) {
       ;                           // avoid -Wunused-result
 #endif
 
-   // with preserved 'other filters', ensure a visible task on row #1
+   // with preserved 'other filters' & command line 'user filters',
+   // we must ensure that we always have a visible task on row one.
    mkVIZrow1(Curwin);
 
    // lastly, initialize a signal set used to throttle one troublesome signal
@@ -5362,7 +5363,10 @@ static void keys_task (int ch) {
       case 'O':
       case 'o':
       case kbd_CtrlO:
-         if (VIZCHKw(w)) other_filters(ch);
+         if (VIZCHKw(w)) {
+            other_filters(ch);
+            mkVIZrow1(w);
+         }
          break;
       case 'U':
       case 'u':
@@ -5371,6 +5375,7 @@ static void keys_task (int ch) {
             if (*str != kbd_ESC
             && (errmsg = user_certify(w, str, ch)))
                 show_msg(errmsg);
+            mkVIZrow1(w);
          }
          break;
       case 'V':
@@ -6254,7 +6259,7 @@ static const char *task_show (const WIN_t *q, const int idx) {
          * In reality, this function is called:
          *   1) exclusively for the 'current' window
          *   2) immediately after interacting with the user
-         *   3) who struck 1 of these: up, down, pgup, pgdn, home or end
+         *   3) who struck: up, down, pgup, pgdn, home, end, 'o/O' or 'u/U'
          *   4) or upon the user switching from one window to another window */
 static void window_hlp (void) {
    WIN_t *w = Curwin;             // avoid gcc bloat with a local copy
index 4a7c49a869a7a1e3d94d3f5d21dcbef0723119e0..d274d1094583ecb48b002d0c4f3be2e2e31c1a8b 100644 (file)
--- a/top/top.h
+++ b/top/top.h
@@ -471,7 +471,7 @@ typedef struct WIN_t {
 #endif
 
         // Support for a proper (visible) row #1 whenever Curwin changes
-        // ( or a certain vertical scrolling key has been struck )
+        // ( or a key which might affect vertical scrolling was struck )
 #define mkVIZrow1(q) { q->begtask -= 1; q->begnext = +1; }
 
         /* Special Section: end ------------------------------------------ */