A terminal ansi colorizer for D programming language
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.README
src/net/masterthought
.gitignore
README.md
__test__library__
dub.json
dub.selections.json

README.md

PLEASE NOTE - This project is not being actively maintained at the moment - I am taking a break - not sure when I will return.

Rainbow

Pretty ANSI Colors for your terminal output.

logo

Install

using DUB:

  	"dependencies": {
          "rainbow":"~master"
	}

Supported Platforms

  • OSX
  • Unix

Windows support coming soon (maybe)

Usage

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:

hello world

short cuts

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);

long hand

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));

Basic colors (foreground and background)

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

Effects

The following effects are supported:

  • bold
  • dim
  • underlined
  • blink
  • inverted
  • hidden

References

Read this site to understand which colors and effects are available:

http://misc.flogisoft.com/bash/tip_colors_and_formatting