]> granicus.if.org Git - procps-ng/commitdiff
top: prevent display corruption in Locate highlighting
authorJim Warner <james.warner@comcast.net>
Fri, 4 Jan 2013 06:00:00 +0000 (00:00 -0600)
committerCraig Small <csmall@enc.com.au>
Wed, 23 Jan 2013 10:23:36 +0000 (21:23 +1100)
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>
top/top.1
top/top.c
top/top.h

index 6620d63249afa66ef90f54c0eb6d51cf31d7a13c..3d8c2d64e40e666552e71d6319eb6cdb50921fd4 100644 (file)
--- a/top/top.1
+++ b/top/top.1
@@ -90,7 +90,7 @@
 .
 .\" Document /////////////////////////////////////////////////////////////
 .\" ----------------------------------------------------------------------
-.TH TOP 1 "November 2012" "procps-ng" "User Commands"
+.TH TOP 1 "January 2013" "procps-ng" "User Commands"
 .\" ----------------------------------------------------------------------
 
 .\" ----------------------------------------------------------------------
@@ -1662,6 +1662,10 @@ available in \*(AM if the \*(CW's \*(TD has been toggled \*F.
 filtering \*F to ensure that every task is encountered.
 \*(XC 'i' and 'u/U' \*(CIs for additional information on how displayed tasks
 might be filtered.
+Additionally, \*(We will turn column highlighting \*F to prevent false
+matches on internal non-display escape sequences.
+Such highlighting will be restored when a window's search string is empty.
+\*(XC 'x' \*(CI for additional information on sort column highlighting.
 
 .\" ----------------------------------------------------------------------
 .SH 6. FILES
index 1257f4de5962f3d54048ec2e24bb78ded47f676d..92ea0f37e9ca90c283dd0661be78400d9e6e5160 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -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)))
index 4ef4efc50f2ef5dd3910a1218fbc7121a0c15039..2474536ec1208fbc6796aaeef32c1e66eddeec90 100644 (file)
--- a/top/top.h
+++ b/top/top.h
@@ -298,6 +298,9 @@ typedef struct CPU_t {
         // these flag(s) have no command as such - they're for internal use
 #define INFINDS_xxx  0x010000     // build rows for find_string, not display
 #define EQUWINS_xxx  0x000001     // rebalance all wins & tasks (off i,n,u/U)
+#ifndef USE_X_COLHDR
+#define NOHICOL_xxx  0x100000     // must restrict Show_HICOLS temporarily
+#endif
 
         // Default flags if there's no rcfile to provide user customizations
 #define DEF_WINFLGS ( View_LOADAV | View_STATES | View_CPUSUM | View_MEMORY \