|
From: | Sahitihi |
Subject: | Re: Status of Submitted Patches |
Date: | Tue, 15 May 2018 23:11:26 +0530 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 |
Hi Ricardo,Here you are reading a character from the current input port. The result is fed to “char-upcase”, which turns it into an upper-case variant, and then you write that character to the current default output port. While this achieves the goal for a single character it does not constitute a custom port. Have you read the documentation for “make-custom-port” in the Guile manual? I have tried with the following code for, Gábor helped me in process (use-modules (ice-9 binary-ports)) (use-modules (ice-9 i18n)) (define stdout (current-output-port)) (define s (read(current-input-port))) (define p (make-soft-port (vector (lambda (c) (write c stdout)) (lambda (s) (display (string-upcase! s) stdout)) (lambda () (display "." stdout)) (lambda () (char-upcase (read-char))) (lambda () (display "@" stdout))) "rw")) (write s p) The above resulted me with a capitalized output (use-modules (ice-9 binary-ports)) ;Though name is binary, All ports in Guile are both binary and textual ports.What type is the value in the variable with name “a”? “read-char” takes a port and returns a single character from it, “char-upcase” takes a character and returns a different character, so “a” holds a character. As you know, the implementation of “colorize-string” internally glues a bunch of strings together: a terminal escape sequence to set the colour, the string to be coloured, and a terminal escape sequence to disable the colour. You gave a character to the procedure, but it expects a string. (use-modules (ice-9 i18n)) ; The (ice-9 i18n) module
provides procedures to manipulate text
and other data(use-modules (ice-9 colorized)) ;Colorizing module (activate-colorized) (define stdout (current-output-port)) ;stdout variable act as an output port (define s (read(current-input-port))) ; s variable reads the input from input port ;soft ports are used for customization on how output port works (define p (make-soft-port (vector (lambda (c) (write c stdout)) ;accepting one character for output (lambda (s) (display (colorized-display (string-upcase! s) '(GREEN)) stdout)) ;accepting a string, Capitalizing it and then colorizing with for output (lambda () (display "." stdout)) (lambda () (char-upcase (read-char))) (lambda () (display "@" stdout))) "rw")) (write s p) This results out with a capitalized, colorized output the description for that goes this way.... The input taken from input port is read and stored in variable "s". This variable is passed to make-soft-port. The variable s is capitalized by locale conversion then binded with color. the result is displayed when called. I have tried the other process using escape codes however failed with the result i will come with this implementation and procedure in my next mail |
[Prev in Thread] | Current Thread | [Next in Thread] |