]> granicus.if.org Git - procps-ng/commitdiff
watch: Support ANSI 39,49 reset sequences
authorCraig Small <csmall@enc.com.au>
Wed, 20 Dec 2017 11:09:41 +0000 (22:09 +1100)
committerCraig Small <csmall@enc.com.au>
Wed, 20 Dec 2017 11:09:41 +0000 (22:09 +1100)
ANSI colour sequences 39 and 49 reset the foreground and background
colours respectively. This feature was missing from watch using the
colour "-c" option.

References:
 Fixes #73
 https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters

NEWS
watch.c

diff --git a/NEWS b/NEWS
index 173ec21efdad3d258fd76b987448a9956d563824..c968987fc0a9cb6ad3469d003a8a5891dda069e3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,7 @@ procps-ng-NEXT
   * top: provide proper multi-byte string handling         issue #68
   * watch: define HOST_NAME_MAX where not defined          Debian #830734
   * vmstat: Fix alignment for disk partition format        issue #69
+  * watch: Support ANSI 39,49 reset sequences              issue #73
 
 procps-ng-3.3.12
 ----------------
diff --git a/watch.c b/watch.c
index e8bfb75fb2da8f455a5dcfde78e569c639f96cd4..048a4507db6e45c16fafd67b8207537889655cf0 100644 (file)
--- a/watch.c
+++ b/watch.c
@@ -186,6 +186,12 @@ static int set_ansi_attribute(const int attrib)
        case 27:        /* unset inversed */
                attributes &= ~A_REVERSE;
                break;
+    case 39:
+        fg_col = 0;
+        break;
+    case 49:
+        bg_col = 0;
+        break;
        default:
                if (attrib >= 30 && attrib <= 37) {     /* set foreground color */
                        fg_col = attrib - 30 + 1;