top: correct an obscure column highlighting buglet

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.
This commit is contained in:
Jim Warner 2011-12-05 18:57:46 -06:00 committed by Craig Small
parent c8bbcec5db
commit 242be5194c

17
top.c
View File

@ -1595,7 +1595,7 @@ static void display_fields (int focus, int extend) {
/* /*
* Manage all fields aspects (order/toggle/sort), for all windows. */ * Manage all fields aspects (order/toggle/sort), for all windows. */
static void fields_utility (void) { 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]; \ #define swapEM { char c; unSCRL; c = w->rc.fieldscur[i]; \
w->rc.fieldscur[i] = *p; *p = c; p = &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); \ #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; break;
case 'x': case 'x':
if (VIZCHKw(w)) { if (VIZCHKw(w)) {
#ifdef USE_X_COLHDR
TOGw(w, Show_HICOLS); TOGw(w, Show_HICOLS);
capsmk(w); capsmk(w);
#ifndef USE_X_COLHDR #else
if (ENUpos(w, w->rc.sortindx) < w->begpflg) { if (ENUviz(w, w->rc.sortindx)) {
if (CHKw(w, Show_HICOLS)) w->begpflg += 2; TOGw(w, Show_HICOLS);
else w->begpflg -= 2; if (ENUpos(w, w->rc.sortindx) < w->begpflg) {
if (0 > w->begpflg) w->begpflg = 0; if (CHKw(w, Show_HICOLS)) w->begpflg += 2;
else w->begpflg -= 2;
if (0 > w->begpflg) w->begpflg = 0;
}
capsmk(w);
} }
#endif #endif
} }