colored

Simple coloring module for strings

Members

Enums

AnsiColor
enum AnsiColor

Available Colors

Style
enum Style

Available Styles

Functions

all
bool all(uint[] )

Predicate to select all

backgroundColor
bool backgroundColor(uint[] token)

Predicate to select background color ansi escapes

colorMixin
auto colorMixin()

Create color and onColor functions for all enum members. e.g. "abc".green.onRed

filterAnsiEscapes
string filterAnsiEscapes(string s)

Remove classes of ansi escapes from a styled string.

forceStyle
auto forceStyle(string text, Style style)

Force a style on possible preformatted text

foregroundColor
bool foregroundColor(uint[] token)

Predicate to select foreground color ansi escapes

leftJustifyFormattedString
auto leftJustifyFormattedString(string s, ulong width, dchar fillChar)

Add fillChar to the right of the string until width is reached

none
bool none(uint[] )

Predicate select nothing

onRgb
string onRgb(string s, ubyte r, ubyte g, ubyte b)

Convinient helper function

rgb
string rgb(string s, ubyte r, ubyte g, ubyte b)

Convinient helper function

rightJustifyFormattedString
auto rightJustifyFormattedString(string s, ulong width, char fillChar)

Add fillChar to the left of the string until width is reached

style
bool style(uint[] token)

Predicate to select style ansi escapes

styleMixin
auto styleMixin()

Create style functions for all enum mebers, e.g. "abc".bold

tokenize
auto tokenize(Range parts)

Range to work with ansi escapes. The ESC[ parts and m must be already removed and the numbers need to be converted to uints. See https://en.wikipedia.org/wiki/ANSI_escape_code

unformattedLength
ulong unformattedLength(string s)

Calculate length of string excluding all formatting escapes

Structs

RGBString
struct RGBString

Truecolor string

StyledString
struct StyledString

Internal structure to style a string

Meta

Authors

Christian Koestlin, Christian Köstlin