From 2e780cb10e79b447d082d3efa961836a31a00422 Mon Sep 17 00:00:00 2001 From: yamadapc Date: Fri, 1 Aug 2014 04:29:24 -0300 Subject: [PATCH] Add brief section about the `cwrite..` functions. This is mainly to try to explain why it's best practice to use them for any kind of colorized output. --- README.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/README.md b/README.md index 81eb1d3..11e93f8 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,45 @@ void main() cwritefln("This is %s".color(c), c); } ``` +- - - +## Supporting cross-platform color printing +Colorize exports functions for wrapping strings around ANSI color escape +sequences. Simply printing these strings should work fine for any UNIX system. +However, for "colorized" printing to work on Windows, it's necessary to use one +of the exported helper printing functions, provided by +[p0nce](https://github.com/p0nce), also in this module. + +Colorizing output works by using the `color` API described below and for Windows +compatibility, we provide functions which parse the escape sequences and call +appropriate system-level. On all platforms other than Windows, these functions +should work just as their `std.stdio` counterparts. + +These are: +### cwrite +```d +void cwrite(T...)(T args) if (!is(T[0] : File)) +``` +#### With an overloaded version for File output: +```d +void cwrite(S...)(File f, S args) +``` +### cwritef +```d +void cwritef(Char, T...)(in Char[] fmt, T args) if (!is(T[0] : File)) +``` +#### With an overloaded version for File output: +```d +void cwritef(Char, A...)(File f, in Char[] fmt, A args) +``` +### cwriteln +```d +void cwriteln(T...)(T args) +``` +### cwritefln +```d +void cwritefln(Char, T...)(in Char[] fmt, T args) +``` - - - ## Setting background, foreground and text modes: