]> granicus.if.org Git - procps-ng/commitdiff
top: correct an obscure column highlighting buglet
authorJim Warner <james.warner@comcast.net>
Tue, 6 Dec 2011 00:57:46 +0000 (18:57 -0600)
committerCraig Small <csmall@enc.com.au>
Sun, 11 Dec 2011 11:27:47 +0000 (22:27 +1100)
An anomaly would surface whenever the sort column was
made non-display under fields management.

The scroll message would report incorrect x coordinates
and the 'x' toggle would produce an unintentional
horizontal scroll.

This patch forces column highlighting off whenever field
changes are made (as is done for horizontal scrolling).
It also inactivates the 'x' toggle whenever the sort
column is not visible.

This bug has yet to be reported.

top.c

diff --git a/top.c b/top.c
index abaa917e01d3d82b086922d797d39e0333a73401..2e0ef1311c44932a40cee5e7f78399ea723bc215 100644 (file)
--- a/top.c
+++ b/top.c
@@ -1595,7 +1595,7 @@ static void display_fields (int focus, int extend) {
         /*
          * Manage all fields aspects (order/toggle/sort), for all windows. */
 static void fields_utility (void) {
- #define unSCRL  w->begpflg = 0;
+ #define unSCRL  { w->begpflg = 0; OFFw(w, Show_HICOLS); }
  #define swapEM  { char c; unSCRL; c = w->rc.fieldscur[i]; \
        w->rc.fieldscur[i] = *p; *p = c; p = &w->rc.fieldscur[i]; }
  #define spewFI  { char *t; f = w->rc.sortindx; t = strchr(w->rc.fieldscur, f + FLD_OFFSET); \
@@ -2907,13 +2907,18 @@ static void keys_task (int ch) {
          break;
       case 'x':
          if (VIZCHKw(w)) {
+#ifdef USE_X_COLHDR
             TOGw(w, Show_HICOLS);
             capsmk(w);
-#ifndef USE_X_COLHDR
-            if (ENUpos(w, w->rc.sortindx) < w->begpflg) {
-               if (CHKw(w, Show_HICOLS)) w->begpflg += 2;
-               else w->begpflg -= 2;
-               if (0 > w->begpflg) w->begpflg = 0;
+#else
+            if (ENUviz(w, w->rc.sortindx)) {
+               TOGw(w, Show_HICOLS);
+               if (ENUpos(w, w->rc.sortindx) < w->begpflg) {
+                  if (CHKw(w, Show_HICOLS)) w->begpflg += 2;
+                  else w->begpflg -= 2;
+                  if (0 > w->begpflg) w->begpflg = 0;
+               }
+               capsmk(w);
             }
 #endif
          }