colors: Introduce a disjoint type and pre-compute ANSI escapes.

* guix/colors.scm (color-table, color): Remove.
(<color>): New record type.
(print-color): New procedure.
(define-color-table, color): New macros.
(color-codes->ansi): New procedure.
(%reset): New variable.
(colorize-string): Rewrite accordingly.
(color-rules): Adjust accordingly.
* guix/status.scm (print-build-event): Adjust to new 'colorize-string'
interface.
* guix/ui.scm (%highlight-argument): Likewise.
(%warning-colors, %info-colors, %error-colors, %hint-colors)
(%highlight-colors): Remove.
(%warning-color, %info-color, %error-color, %hint-color)
(%highlight-color): New variables.
This commit is contained in:
Ludovic Courtès 2019-04-11 16:57:38 +02:00
parent c1df77e215
commit 2569ef9dab
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
3 changed files with 101 additions and 65 deletions

View file

@ -410,17 +410,17 @@ produce colorful output. When PRINT-LOG? is true, display the build log in
addition to build events."
(define info
(if colorize?
(cut colorize-string <> 'BOLD)
(cute colorize-string <> (color BOLD))
identity))
(define success
(if colorize?
(cut colorize-string <> 'GREEN 'BOLD)
(cute colorize-string <> (color GREEN BOLD))
identity))
(define failure
(if colorize?
(cut colorize-string <> 'RED 'BOLD)
(cute colorize-string <> (color RED BOLD))
identity))
(define (report-build-progress phase %)