From ee2ccccf26b05093cc3227a37b96196ec3a29182 Mon Sep 17 00:00:00 2001 From: Sahithi Yarlagadda Date: Thu, 7 Jun 2018 00:07:34 +0530 Subject: [PATCH 2/2] guix: Add coloring soft port. * guix/ui.scm (handle-string): New procedures. (colorful-build-output-port): New variable. --- guix/ui.scm | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) mode change 100644 => 100755 guix/ui.scm diff --git a/guix/ui.scm b/guix/ui.scm old mode 100644 new mode 100755 index 3a36daadc..51a1c4a46 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -109,8 +109,7 @@ warning info guix-main - colorize-string - guix-colorful-port)) + colorful-build-output-port)) ;;; Commentary: ;;; @@ -1632,43 +1631,43 @@ be reset such that subsequent output will not have any colors in effect." str (color 'RESET))) -(define target-port (current-output-port)) (define (handle-string str) (or (and=> (string-match "^(starting phase)(.*)" str) (lambda (m) (string-append - (colorized-display (match:substring m 1) '(BLUE)) - (colorized-display (match:substring m 2) '(GREEN))))) + (colorize-string (match:substring m 1) '(BLUE)) + (colorize-string (match:substring m 2) '(GREEN))))) - (and=> (string-match "^(phase)(.*) (succeeded)(.*)" str) + (and=> (string-match "^(phase) (.*) (succeeded after) (.*) (seconds)" str) (lambda (m) (string-append - (colorized-display (match:substring m 1) '(BLUE)) - (colorized-display (match:substring m 2) '(GREEN)) - (colorized-display (match:substring m 3) '(BLUE)) - (colorized-display (match:substring m 4) '(GREEN))))) + (colorize-string (match:substring m 1) '(BLUE)) + (colorize-string (match:substring m 2) '(GREEN)) + (colorize-string (match:substring m 3) '(BLUE)) + (colorize-string (match:substring m 4) '(GREEN)) + (colorize-string (match:substring m 5) '(BLUE))))) - (and=> (string-match "^(phase)(.*) (failed)(.*)" str) + (and=> (string-match "^(phase)(.*) (failed after) (.*) (seconds)" str) (lambda (m) (string-append - (colorized-display (match:substring m 1) '(BLUE)) - (colorized-display (match:substring m 2) '(GREEN)) - (colorized-display (match:substring m 3) '(BLUE)) - (colorized-display (match:substring m 4) '(GREEN))))) + (colorize-string (match:substring m 1) '(RED)) + (colorize-string (match:substring m 2) '(GREEN)) + (colorize-string (match:substring m 3) '(RED)) + (colorize-string (match:substring m 4) '(GREEN)) + (colorize-string (match:substring m 5) '(RED))))) ;; Didn’t match, so return unmodified string. - str) - (display str target-port)) + (display str current-error-port))) -(define guix-colorful-port +(define colorful-build-output-port (make-soft-port (vector - (lambda (c) (write c target-port)) + (lambda (c) (write c current-error-port)) handle-string - (lambda () (display "." target-port)) + (lambda () (display "." current-error-port)) (lambda () (char-upcase (read-char))) - (lambda () (display "@" target-port))) + (lambda () (display "@" current-error-port))) "rw")) ;;; ui.scm ends here -- 2.11.0