PLEASE NOTE - This project is not being actively maintained at the moment - I am taking a break - not sure when I will return.
Pretty ANSI Colors for your terminal output.
using DUB:
"dependencies": {
"rainbow":"~master"
}
- OSX
- Unix
Windows support coming soon (maybe)
There are 3 items supported:
- foreground color
- background color
- effects
import net.masterthought.rainbow;
import std.stdio;
void main(){
writeln("Hello".rainbow.white.onCyan, " World!".rainbow.cyan.onWhite);
}
produces:
You can use .colorName for foreground and .onColorName for background e.g.
writeln("Hello".rainbow.red.onWhite);
You can use effects in the same way
writeln("Hello".rainbow.green.onBlack.underlined.blink);
There are 3 methods you can call:
- fg(FgColor color)
- bg(BgColor color)
- ef(Effect effect)
writeln(Rainbow.apply(" Hello ").fg(FgColor.green).bg(BgColor.c221).ef(Effect.underlined));
Colours are all on either the FgColor enum or the BgColor enum:
FgColor.red
BgColor.cyan
You can also use any of the colors from 0 to 255 (if supported on your system)
FgColor.c99
BgColor.c208
It's easy with shortcuts:
writeln("hello".rainbow.c33.onC45);
note the upcased C when using the on notation.
The following basic colors are supported for foreground and background:
- original
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- lightGray
- darkGray
- lightRed
- lightGreen
- lightYellow
- lightBlue
- lightMagenta
- lightCyan
- white
The following effects are supported:
- bold
- dim
- underlined
- blink
- inverted
- hidden
Read this site to understand which colors and effects are available: