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

9
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. */
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,14 +2907,19 @@ 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
#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
}
break;