From: Sahithi Yarlagadda <sahi@swecha.net>
To: Ricardo Wurmus <rekado@elephly.net>
Cc: guix-devel@gnu.org
Subject: Re: Status of Submitted Patches
Date: Sat, 12 May 2018 02:46:38 +0530 [thread overview]
Message-ID: <aff2d5c9-b497-6ead-3bb7-e7d7abf0d00a@swecha.net> (raw)
In-Reply-To: <87o9hycwl6.fsf@elephly.net>
Hi
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)
(newline)
(display stdout)
(newline)
(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))
(activate-colorized)
(define stdout (current-output-port))
(define stdin (current-input-port))
(display stdin)
(newline)
(display stdout)
(newline)
(define a (char-upcase(read-char (current-input-port))))
(display a)
(newline)
(display "\x1b[31ma\x1b[0m")
(newline)
(define b (colorize-string a '(GREEN)))
(display b)
Resulted:
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.
>
>
--
Regards
Sahithi
next parent reply other threads:[~2018-05-11 21:17 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <8ea5d026-fab9-7b12-198e-610ad7743cb2@swecha.net>
[not found] ` <871sfxev9w.fsf@elephly.net>
[not found] ` <7626275c-3eee-bb05-ab9d-4c88ec6f0329@swecha.net>
[not found] ` <87r2nvjte6.fsf@elephly.net>
[not found] ` <5ab51417-b635-9725-9f48-3bc3f9b61fdf@swecha.net>
[not found] ` <87tvsko2wd.fsf@elephly.net>
[not found] ` <7290013c-990d-3f7d-d8db-38e090ed766a@swecha.net>
[not found] ` <87zi28kt82.fsf@elephly.net>
[not found] ` <8573e97d-d107-cde6-cd17-35f4ef6d2de3@swecha.net>
[not found] ` <87k1takumm.fsf@elephly.net>
[not found] ` <87o9hycwl6.fsf@elephly.net>
2018-05-11 21:16 ` Sahithi Yarlagadda [this message]
2018-05-11 22:21 ` Status of Submitted Patches Ricardo Wurmus
2018-05-12 7:50 ` Ricardo Wurmus
2018-05-15 17:41 ` Sahitihi
2018-05-20 9:40 ` Ricardo Wurmus
2018-05-20 10:47 ` Gábor Boskovits
2018-05-20 13:46 ` Ricardo Wurmus
2018-05-23 7:53 ` Sahitihi
2018-05-23 8:21 ` Ricardo Wurmus
2018-05-24 17:16 ` Sahitihi
2018-05-24 20:00 ` Ricardo Wurmus
2018-05-25 3:43 ` Sahitihi
2018-05-25 5:18 ` Ricardo Wurmus
2018-05-25 17:59 ` Patch file for colorize module Sahitihi
2018-05-26 6:06 ` Sahitihi
2018-05-26 9:35 ` Ricardo Wurmus
2018-05-26 12:06 ` Sahitihi
2018-05-26 14:16 ` Ricardo Wurmus
2018-05-26 18:22 ` Sahitihi
2018-05-26 18:38 ` Sahitihi
2018-05-26 21:20 ` Ricardo Wurmus
2018-05-27 15:49 ` Gábor Boskovits
2018-05-31 6:26 ` Fwd: " Ricardo Wurmus
2018-05-31 18:25 ` Sahitihi
2018-05-31 19:28 ` Ricardo Wurmus
2018-06-02 15:01 ` Ricardo Wurmus
2018-06-03 14:18 ` Sahitihi
2018-06-03 19:30 ` Ricardo Wurmus
2018-06-04 7:48 ` Sahitihi
2018-06-04 10:03 ` Ricardo Wurmus
2018-06-04 18:51 ` Sahitihi
2018-06-05 19:44 ` Ricardo Wurmus
2018-06-06 19:49 ` Sahitihi
2018-06-06 20:06 ` Ricardo Wurmus
2018-06-06 21:20 ` Sahitihi
2018-06-06 21:28 ` Ricardo Wurmus
2018-06-07 3:29 ` Sahitihi
2018-06-07 5:22 ` Ricardo Wurmus
2018-06-07 7:47 ` Sahitihi
2018-06-07 8:25 ` Ricardo Wurmus
2018-06-08 17:01 ` Sahitihi
2018-06-09 0:57 ` Ricardo Wurmus
2018-06-09 18:08 ` Sahitihi
2018-06-09 20:57 ` Ricardo Wurmus
2018-06-11 12:14 ` Sahitihi
2018-06-11 12:28 ` Gábor Boskovits
2018-06-11 16:21 ` Sahitihi
2018-06-12 14:12 ` Ricardo Wurmus
2018-06-12 21:06 ` Sahitihi
2018-06-12 22:12 ` Ricardo Wurmus
2018-06-13 16:08 ` Sahithi Yarlagadda
2018-06-13 19:15 ` Ricardo Wurmus
2018-06-15 20:16 ` Sahitihi
2018-06-15 21:47 ` Next steps Ricardo Wurmus
2018-06-16 14:55 ` Sahitihi
2018-06-21 11:05 ` Ricardo Wurmus
2018-06-21 16:54 ` Sahithi Yarlagadda
2018-06-25 20:13 ` Sahithi Yarlagadda
2018-06-25 20:28 ` Ricardo Wurmus
2018-06-26 20:01 ` Gábor Boskovits
2018-06-29 22:51 ` Sahithi Yarlagadda
2018-07-03 2:29 ` Sahithi Yarlagadda
2018-06-24 18:25 ` Sahithi Yarlagadda
2018-06-24 20:22 ` Ricardo Wurmus
2018-06-24 20:33 ` Sahithi Yarlagadda
2018-06-11 12:37 ` Fwd: Re: Patch file for colorize module Ricardo Wurmus
2018-06-11 16:31 ` Sahitihi
2018-06-04 11:41 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aff2d5c9-b497-6ead-3bb7-e7d7abf0d00a@swecha.net \
--to=sahi@swecha.net \
--cc=guix-devel@gnu.org \
--cc=rekado@elephly.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).