From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sahitihi Subject: Patch file for colorize module Date: Fri, 25 May 2018 23:29:58 +0530 Message-ID: <3e099b0b-e3ec-2bbb-6d10-5b7e48c4dff6@swecha.net> References: <8ea5d026-fab9-7b12-198e-610ad7743cb2@swecha.net> <871sfxev9w.fsf@elephly.net> <7626275c-3eee-bb05-ab9d-4c88ec6f0329@swecha.net> <87r2nvjte6.fsf@elephly.net> <5ab51417-b635-9725-9f48-3bc3f9b61fdf@swecha.net> <87tvsko2wd.fsf@elephly.net> <7290013c-990d-3f7d-d8db-38e090ed766a@swecha.net> <87zi28kt82.fsf@elephly.net> <8573e97d-d107-cde6-cd17-35f4ef6d2de3@swecha.net> <87k1takumm.fsf@elephly.net> <87o9hycwl6.fsf@elephly.net> <87r2mhdeap.fsf@elephly.net> <618c131c-6ba6-e525-aefc-72acca1c910f@swecha.net> <87a7suwtp7.fsf@elephly.net> <149bfb8c-22b5-797d-e88a-ca4077b0a4cc@swecha.net> <87d0xmok8e.fsf@elephly.net> <87k1rsb9ex.fsf@elephly.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1B3CB958617DA78ED0ED787C" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fMH1G-0000w0-5R for guix-devel@gnu.org; Fri, 25 May 2018 14:00:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fMH1D-0007kW-3c for guix-devel@gnu.org; Fri, 25 May 2018 14:00:50 -0400 In-Reply-To: <87k1rsb9ex.fsf@elephly.net> Content-Language: en-US List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Ricardo Wurmus Cc: guix-devel@gnu.org This is a multi-part message in MIME format. --------------1B3CB958617DA78ED0ED787C Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Hi Ricardo, Please find the attachment.. > Please attach the file of that same name in an email. Also add any corrections that i need too and next steps to proceed further. :) Thanks! -- Sahithi --------------1B3CB958617DA78ED0ED787C Content-Type: text/x-patch; name="0001-Added-colorize-module-to-ui.scm.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0001-Added-colorize-module-to-ui.scm.patch" >From 93f3c964250587d6272065d555fa07e9bdd47325 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 25 May 2018 23:23:57 +0530 Subject: [PATCH] Added colorize module to ui.scm --- guix/ui.scm | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/guix/ui.scm b/guix/ui.scm index 8d351607d..e7c5d2972 100755 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -9,7 +9,9 @@ ;;; Copyright © 2015, 2016 Mathieu Lirzin ;;; Copyright © 2016 Roel Janssen ;;; Copyright © 2016 Benz Schenk -;;; +;;; Copyright © 2013,2014 Free Software Foundation, Inc. +;;; Copyright © 2016 Sahithi Yarlagadda +;;; ;;; 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 --------------1B3CB958617DA78ED0ED787C--