AnsiColour

Contains any type of ANSI colour and provides the ability to create a valid SGR command to set the foreground/background.

This struct overloads opAssign allowing easy assignment from Ansi4BitColour, Ansi8BitColour, AnsiRgbColour, and any user-defined type that satisfies isUserDefinedRgbType.

Constructors

this
this(Ansi4BitColour colour, IsBgColour isBg)

Construct a 4-bit colour.

this
this(Ansi8BitColour colour, IsBgColour isBg)

Construct an 8-bit colour.

this
this(AnsiRgbColour colour, IsBgColour isBg)

Construct an RGB colour.

this
this(ubyte r, ubyte g, ubyte b, IsBgColour isBg)

Construct an RGB colour.

this
this(T colour, IsBgColour isBg)

Construct an RGB colour.

Members

Functions

opAssign
auto opAssign(T colour)

Allows direct assignment from any type that can also be used in any of this struct's ctors.

toSequence
char[] toSequence(char[MAX_CHARS_NEEDED] buffer)

Creates an ANSI SGR command that either sets the foreground, or the background (isBg) to the colour stored inside of this AnsiColour.

toString
string toString()

[Not enabled in -betterC] Converts this AnsiColour into a GC-allocated sequence string.

Manifest constants

MAX_CHARS_NEEDED
enum MAX_CHARS_NEEDED;

The maximum amount of characters any singular AnsiColour sequence may use.

Properties

asEightBit
ubyte asEightBit [@property getter]

Assertions: This colour's type must be AnsiColourType.eightBit

asFourBit
Ansi4BitColour asFourBit [@property getter]

Assertions: This colour's type must be AnsiColourType.fourBit

asRgb
AnsiRgbColour asRgb [@property getter]

Assertions: This colour's type must be AnsiColourType.rgb

isBg
IsBgColour isBg [@property getter]
IsBgColour isBg [@property setter]
bool isBg [@property setter]
type
AnsiColourType type [@property getter]

Static variables

bgInit
auto bgInit;

A variant of .init that is used for background colours.

Meta