Hi Ricardo,

Please find the attachment. Hope I made it correct this time. :)


On Saturday 26 May 2018 03:05 PM, Ricardo Wurmus wrote:
> git rebase -i
> $start_commit

>From 1bd9eaca576e7d958062197b9931d64c0882484e Mon Sep 17 00:00:00 2001
From: root <root@localhost.localdomain>
Date: Sat, 26 May 2018 17:34:23 +0530
Subject: [PATCH] Added Colorize module and Copyrights line to ui

---
 guix/ui.scm | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 51 insertions(+), 2 deletions(-)

diff --git a/guix/ui.scm b/guix/ui.scm
index 8d351607d..20fbf761f 100755
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -9,7 +9,9 @@
 ;;; Copyright © 2015, 2016 Mathieu Lirzin <m...@gnu.org>
 ;;; Copyright © 2016 Roel Janssen <r...@gnu.org>
 ;;; Copyright © 2016 Benz Schenk <benz.sch...@uzh.ch>
-;;;
+;;; Copyright © 2013,2014 Free Software Foundation, Inc.
+;;; Copyright © 2018 Sahithi Yarlagadda <s...@swecha.net>
+;;; 
 ;;; This file is part of GNU Guix.
 ;;;
 ;;; GNU Guix is free software; you can redistribute it and/or modify it
@@ -106,7 +108,9 @@
             guix-warning-port
             warning
             info
-            guix-main))
+            guix-main
+            color
+            colorize-string))
 
 ;;; Commentary:
 ;;;
@@ -1578,4 +1582,49 @@ and signal handling has already been set up."
   (initialize-guix)
   (apply run-guix args))
 
+(define ansi-color-tables
+  `((CLEAR       .   "0")
+    (RESET       .   "0")
+    (BOLD        .   "1")
+    (DARK        .   "2")
+    (UNDERLINE   .   "4")
+    (UNDERSCORE  .   "4")
+    (BLINK       .   "5")
+    (REVERSE     .   "6")
+    (CONCEALED   .   "8")
+    (BLACK       .  "30")
+    (RED         .  "31")
+    (GREEN       .  "32")
+    (YELLOW      .  "33")
+    (BLUE        .  "34")
+    (MAGENTA     .  "35")
+    (CYAN        .  "36")
+    (WHITE       .  "37")
+    (ON-BLACK    .  "40")
+    (ON-RED      .  "41")
+    (ON-GREEN    .  "42")
+    (ON-YELLOW   .  "43")
+    (ON-BLUE     .  "44")
+    (ON-MAGENTA  .  "45")
+    (ON-CYAN     .  "46")
+    (ON-WHITE    .  "47")))
+
+(define (color . lst)
+  (let ((color-list 
+         (remove not 
+                 (map (lambda (color) (assq-ref ansi-color-tables color))
+                      lst))))
+    (if (null? color-list)
+        ""
+        (string-append 
+         (string #\esc #\[)
+         (string-join color-list ";" 'infix)
+         "m"))))
+  
+(define (colorize-string str . color-list)
+  (string-append
+   (apply color color-list)
+   str
+   (color 'RESET)))
+
 ;;; ui.scm ends here
-- 
2.11.0

Reply via email to