[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Status of Submitted Patches

From: Sahithi Yarlagadda
Subject: Re: Status of Submitted Patches
Date: Sat, 12 May 2018 02:46:38 +0530
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0


On Wednesday 02 May 2018 01:34 PM, Ricardo Wurmus wrote:
> Hi Sahithi,
> I’ve previously sent the message below.  Have you been able to take a
> look at this yet?
> --
> Ricardo
>>> I have gone through the code under guix/store/ and the outputs are sent
>>> to a specified scheme variable "current-build-output-port"
>> Yes, the “(guix store)” module implements this.
>> “current-build-output-port” is a parameter, which is a dynamically bound
>> variable (i.e. its value can be changed by the caller) and it defaults
>> to the “current-error-port”.
I Understood this.

>> According to the Guile manual
>>    Ports are the way that Guile performs input and output.  Guile can
>>    read in characters or bytes from an “input port”, or write them out
>>    to an “output port”.
>> Ports allow the programmer to ignore the details of input/output sources
>> and sinks and concentrate on shuffling characters or bytes around.  We
>> don’t need to know if the port is connected to a terminal or a file or a
>> network socket.
>> A programmer can implement custom ports with “make-soft-port” and a
>> vector of up to five procedures that provide implementations of certain
>> operations (such as writing a string to the port).  A silly example
>> would be a custom port that reads characters from standard input and
>> turns them to upper-case characters before passing them to whoever reads
>> from the custom port.
(use-modules (ice-9 binary-ports))
(define stdout (current-output-port))
(define stdin (current-input-port))
(display stdin)
(display stdout)
(write (char-upcase(read-char(current-input-port))))

>> With what you know about terminal escape codes and the port facility
>> that is used in “(guix store)”, can you describe an approach to add
>> colours to some text fragments before they are printed?  There are at
>> least two ways this can be done; one of the two options is more
>> complicated but might result in a clearer and more modular
>> implementation.

For this i tried using

(use-modules (ice-9 binary-ports))
(use-modules (ice-9 colorized)) 
(define stdout (current-output-port))
(define stdin (current-input-port))
(display stdin)
(display stdout)

(define a (char-upcase(read-char (current-input-port))))
(display a)   

(display "\x1b[31ma\x1b[0m")

(define b (colorize-string a '(GREEN)))
(display b)


4058: 2 [#<procedure 560e4a6de9c0 at ice-9/boot-9.scm:4051:3 ()>]
In /home/sripathroy/Documents/GNUGuix/experiments/sam.scm:
  17: 1 [#<procedure 560e4ab74920 ()>]
In unknown file:
   ?: 0 [string-append "\x1b[32m" #\S "\x1b[0m"]

ERROR: In procedure string-append:
ERROR: In procedure string-append: Wrong type (expecting string): #\S

I found that the output is stored as #\<char>. How should i convert to
valid format.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]