summary refs log tree commit diff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-09-25 10:45:38 +0200
committerLudovic Courtès <ludo@gnu.org>2019-09-25 15:46:47 +0200
commit0876e9c116125b28806286b0313ff78de5948562 (patch)
tree010d092ef73648b4d0fd94747d9daa5c44672949
parentdd2a83270bccb539439b2fc831d0db04e5276f11 (diff)
downloadguix-0876e9c116125b28806286b0313ff78de5948562.tar.gz
colors: Add 'dim'.
* guix/colors.scm (coloring-procedure): New procedure.
(%highlight-color): Remove.
(highlight): Define in terms of 'coloring-procedure'.
(dim): New procedure.
-rw-r--r--guix/colors.scm18
1 files changed, 11 insertions, 7 deletions
diff --git a/guix/colors.scm b/guix/colors.scm
index 7949cf5763..b63ac37027 100644
--- a/guix/colors.scm
+++ b/guix/colors.scm
@@ -31,6 +31,8 @@
 
             colorize-string
             highlight
+            dim
+
             color-rules
             color-output?
             isatty?*))
@@ -133,14 +135,16 @@ that subsequent output will not have any colors in effect."
        (not (getenv "NO_COLOR"))
        (isatty?* port)))
 
-(define %highlight-color (color BOLD))
+(define (coloring-procedure color)
+  "Return a procedure that applies COLOR to the given string."
+  (lambda* (str #:optional (port (current-output-port)))
+    "Return STR with extra ANSI color attributes if PORT supports it."
+    (if (color-output? port)
+        (colorize-string str color)
+        str)))
 
-(define* (highlight str #:optional (port (current-output-port)))
-  "Return STR with extra ANSI color attributes to highlight it if PORT
-supports it."
-  (if (color-output? port)
-      (colorize-string str %highlight-color)
-      str))
+(define highlight (coloring-procedure (color BOLD)))
+(define dim (coloring-procedure (color DARK)))
 
 (define (colorize-matches rules)
   "Return a procedure that, when passed a string, returns that string