colors: Add 'dim'.
* guix/colors.scm (coloring-procedure): New procedure. (%highlight-color): Remove. (highlight): Define in terms of 'coloring-procedure'. (dim): New procedure.
This commit is contained in:
parent
dd2a83270b
commit
0876e9c116
|
@ -31,6 +31,8 @@
|
||||||
|
|
||||||
colorize-string
|
colorize-string
|
||||||
highlight
|
highlight
|
||||||
|
dim
|
||||||
|
|
||||||
color-rules
|
color-rules
|
||||||
color-output?
|
color-output?
|
||||||
isatty?*))
|
isatty?*))
|
||||||
|
@ -133,14 +135,16 @@ that subsequent output will not have any colors in effect."
|
||||||
(not (getenv "NO_COLOR"))
|
(not (getenv "NO_COLOR"))
|
||||||
(isatty?* port)))
|
(isatty?* port)))
|
||||||
|
|
||||||
(define %highlight-color (color BOLD))
|
(define (coloring-procedure color)
|
||||||
|
"Return a procedure that applies COLOR to the given string."
|
||||||
(define* (highlight str #:optional (port (current-output-port)))
|
(lambda* (str #:optional (port (current-output-port)))
|
||||||
"Return STR with extra ANSI color attributes to highlight it if PORT
|
"Return STR with extra ANSI color attributes if PORT supports it."
|
||||||
supports it."
|
|
||||||
(if (color-output? port)
|
(if (color-output? port)
|
||||||
(colorize-string str %highlight-color)
|
(colorize-string str color)
|
||||||
str))
|
str)))
|
||||||
|
|
||||||
|
(define highlight (coloring-procedure (color BOLD)))
|
||||||
|
(define dim (coloring-procedure (color DARK)))
|
||||||
|
|
||||||
(define (colorize-matches rules)
|
(define (colorize-matches rules)
|
||||||
"Return a procedure that, when passed a string, returns that string
|
"Return a procedure that, when passed a string, returns that string
|
||||||
|
|
Loading…
Reference in New Issue