mirror of
https://github.com/yamadapc/d-colorize
synced 2024-11-14 21:14:00 +01:00
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.
This commit is contained in:
parent
05107daa5a
commit
2e780cb10e
38
README.md
38
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:
|
||||
|
|
Loading…
Reference in a new issue