>From 4e4acbe884716b0c84f1c39bc054244112daf17d Mon Sep 17 00:00:00 2001 From: Nala Ginrut Date: Tue, 22 Jan 2013 19:02:06 +0800 Subject: [PATCH] Update manual for (ice-9 colorized). * doc/ref/misc-modules.texi: Add (ice-9 colorized). * doc/ref/scheme-using.texi: Add colorized REPL usage. --- doc/ref/misc-modules.texi | 91 +++++++++++++++++++++++++++++++++++++++++++++ doc/ref/scheme-using.texi | 35 ++++++++++++++++- 2 files changed, 125 insertions(+), 1 deletion(-) diff --git a/doc/ref/misc-modules.texi b/doc/ref/misc-modules.texi index cf1e0e4..770f354 100644 --- a/doc/ref/misc-modules.texi +++ b/doc/ref/misc-modules.texi @@ -1789,6 +1789,97 @@ example with the Scheme @code{read} function (@pxref{Scheme Read}), @end deffn address@hidden Colorized address@hidden Colorized + address@hidden Colorized +The module @code{(ice-9 colorized)} provides the procedure address@hidden, which provides colored REPL output. + +The module is loaded and activated by entering the following: + address@hidden +(use-modules (ice-9 colorized)) +(activate-colorized) address@hidden lisp + +And you may add your own color scheme with @code{add-color-scheme!}: + address@hidden +(add-color-scheme! `((,(lambda (data) + (and (number? data) (> data 10000))) + MY-LONG-NUM ,color-it (RED)))) address@hidden +Result: 10001 (in red color) address@hidden lisp + address@hidden {Scheme Procedure} activate-colorized +Activate colorized REPL. address@hidden deffn + address@hidden {Scheme Procedure} add-color-scheme! color-scheme-list +Add user defined color scheme. @code{color-scheme-list} consisted as: address@hidden +(list (pred scheme-name color-method color-list) + ;; other color scheme) address@hidden lisp +While @code{pred} is the predicate to checkout if it's the type you need, address@hidden is a symbol you named this color scheme, address@hidden is the color function, and it could be @code{color-it} +in default, and @code{color-list} is a ansi-color specific color list. address@hidden deffn + address@hidden Colorized String +Also exported by the @code{(ice-9 colorized)} module is address@hidden, a procedure to format a string in certain color. + address@hidden +(use-modules (ice-9 colorized)) +(colorize-display "hello" '(BLUE BOLD)) address@hidden hello (in blue color and bold style) +(colorize-string "hello" '(BLUE BOLD)) address@hidden "\x1b[32;1mhello\x1b[0m" +(display (colorize-string "hello" '(BLUE BOLD))) address@hidden hello (in blue color and bold style) address@hidden lisp + address@hidden {Scheme Procedure} colorize-string str color +Return a string formated with @var{str} in @var{color} according to ansi +color specific. address@hidden deffn + address@hidden {Scheme Procedure} colorize-display str color +Print @var{str} in @var{color}. address@hidden deffn + +Here is the available colors: +CLEAR, +RESET, +BOLD, +DARK, +UNDERLINE, +UNDERSCORE, +BLINK, +REVERSE, +CONCEALED, +BLACK, +RED, +GREEN, +YELLOW, +BLUE, +MAGENTA, +CYAN, +WHITE, +ON-BLACK, +ON-RED, +ON-GREEN, +ON-YELLOW, +ON-BLUE, +ON-MAGENTA, +ON-CYAN, +ON-WHITE + + @c Local Variables: @c TeX-master: "guile.texi" @c End: diff --git a/doc/ref/scheme-using.texi b/doc/ref/scheme-using.texi index e0f91af..fe302c2 100644 --- a/doc/ref/scheme-using.texi +++ b/doc/ref/scheme-using.texi @@ -37,6 +37,7 @@ support for languages other than Scheme. @menu * Init File:: * Readline:: +* Colorized REPL:: * Value History:: * REPL Commands:: * Error Handling:: @@ -79,6 +80,37 @@ It's a good idea to put these two lines (without the @xref{Init File}, for more on @file{.guile}. address@hidden Colorized REPL address@hidden Colorized REPL + +To make colorized result in Guile REPL, or add your own color +schemes to show the result in colors. + address@hidden +scheme@@(guile-user)> (use-modules (ice-9 colorized)) +scheme@@(guile-user)> (activate-colorized) address@hidden lisp + +It's a good idea to put these two lines (without the address@hidden@@(guile-user)>} prompts) in your @file{.guile} file. +Besides, you may add your color schemes for the result: address@hidden +(add-color-scheme! (list (pred scheme-name color-method color-list))) +example: +(add-color-scheme! `((,(lambda (data) + (and (number? data) (> data 10000))) + MY-LONG-NUM ,color-it (RED)))) +10001 address@hidden 10001 (in red color) address@hidden lisp +While @code{pred} is the predicate to checkout if it's the type you need, address@hidden is a symbol you named this color scheme, address@hidden is the color function, and it could be @code{color-it} +in default, and @code{color-list} is a ansi-color specific color list, +please see @xref{Colorized}. address@hidden File}, for more on @file{.guile}. + + @node Value History @subsection Value History @@ -147,7 +179,8 @@ data structure or closure, they may then be reclaimed by the garbage collector. @cindex commands The REPL exists to read expressions, evaluate them, and then print their -results. But sometimes one wants to tell the REPL to evaluate an +results. But sometimes o +ne wants to tell the REPL to evaluate an expression in a different way, or to do something else altogether. A user can affect the way the REPL works with a @dfn{REPL command}. -- 1.7.10.4