top: prevent display corruption in Locate highlighting

There existed a small chance that the display could be
corrupted when a search string was found within a row.
For that to happen, conditions like these were needed:

. a very short Locate string was active in some window
. the string matched part of a terminfo <esc> sequence
. that sequence was used in highlighting running tasks
. the 'x' toggle was active (sort column highlighting)

One solution to this potential problem was to manually
turn off sort column highlighting before using Locate.
But rather than rely on a user remedy, we'll automate.

Since other top provisions were already being enforced
when Locate was in use (off 'i' and/or 'u'/'U'), we'll
now also force column highlighting off when the search
string in a given window is not empty. However, unlike
idle tasks and user filtering, when that search string
*is* emptied, we restore highlighting for that window.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner
2013-01-04 00:00:00 -06:00
committed by Craig Small
parent 1da293bf59
commit d9f7c76114
3 changed files with 16 additions and 2 deletions

View File

@@ -3123,6 +3123,9 @@ static void configs_read (void) {
goto default_or_error;
break;
}
#ifndef USE_X_COLHDR
OFFw(w, NOHICOL_xxx);
#endif
} // end: for (GROUPSMAX)
// any new addition(s) last, for older rcfiles compatibility...
@@ -3766,6 +3769,10 @@ static void find_string (int ch) {
snprintf(Curwin->findstr, FNDBUFSIZ, "%s", linein(N_txt(GET_find_str_txt)));
Curwin->findlen = strlen(Curwin->findstr);
found = 0;
#ifndef USE_X_COLHDR
if (Curwin->findstr[0]) SETw(Curwin, NOHICOL_xxx);
else OFFw(Curwin, NOHICOL_xxx);
#endif
}
if (Curwin->findstr[0]) {
SETw(Curwin, INFINDS_xxx);
@@ -4626,7 +4633,7 @@ static const char *task_show (const WIN_t *q, const proc_t *p) {
case X_XON:
case X_XOF:
cp = NULL;
if (!CHKw(q, INFINDS_xxx)) {
if (!CHKw(q, INFINDS_xxx | NOHICOL_xxx)) {
/* treat running tasks specially - entire row may get highlighted
so we needn't turn it on and we MUST NOT turn it off */
if (!('R' == p->state && CHKw(q, Show_HIROWS)))