jansi

Utilities for writing and reading ANSI styled text.

Members

Aliases

Ansi8BitColour
alias Ansi8BitColour = ubyte

An 8-bit ANSI colour - an index into the terminal's colour palette.

AnsiOnly
alias AnsiOnly = Flag!"ansiOnly"

Used by certain functions to determine if they should only output an ANSI sequence, or output their entire sequence + data.

AnsiTextGC
alias AnsiTextGC = AnsiText!AnsiTextGCImplementation

A basic implementation that uses the GC for memory storage.

AnsiTextMalloc
alias AnsiTextMalloc = AnsiText!AnsiTextMallocImplementation

A basic implementation using malloc backed memory.

AnsiTextStack
alias AnsiTextStack(size_t Capacity) = AnsiText!(AnsiTextStackImplementation!Capacity)

A basic implementation using a static amount of stack memory.

IsBgColour
alias IsBgColour = Flag!"isBg"

Used to determine if an AnsiColour is a background or foreground colour.

Enums

Ansi4BitColour
enum Ansi4BitColour

An enumeration of standard 4-bit colours.

AnsiColourType
enum AnsiColourType

Defines what type of colour an AnsiColour stores.

AnsiSgrStyle
enum AnsiSgrStyle

A list of styling options provided by ANSI SGR.

AnsiTextImplementationFeatures
enum AnsiTextImplementationFeatures

An enumeration used by an AnsiText implementation to describe any special features that AnsiText needs to mold itself around.

isUserDefinedRgbType
eponymoustemplate isUserDefinedRgbType(CT)

PUBLIC HELPERS ++ Determines if CT is a valid RGB data type.

Functions

ansi
AnsiTextLite ansi(const(char)[] text)

Creates an AnsiTextLite from the given text. This function is mostly used when using the fluent UFCS chaining pattern.

ansiEnableWindowsSupport
void ansiEnableWindowsSupport()

Enables ANSI support on windows via SetConsoleMode. This function is no-op on non-Windows platforms.

ansiExecuteSgrSequence
string ansiExecuteSgrSequence(const(char)[] input, AnsiStyleSet style, size_t charsRead)

Executes the SGR sequence found in input, and populates the passed in style based on the command sequence.

asAnsiSections
AnsiSectionRange asAnsiSections(const(char)[] slice)

Constructs an AnsiSectionRange from the given slice.

to
AnsiColour to(CT colour)
toBg
AnsiColour toBg(T c)

Converts any suitable data type into an AnsiColour.

Mixin templates

AnsiTextGCImplementation
mixintemplate AnsiTextGCImplementation()
AnsiTextMallocImplementation
mixintemplate AnsiTextMallocImplementation()

Structs

AnsiColour
struct AnsiColour

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

AnsiRgbColour
struct AnsiRgbColour

Contains a 3-byte, RGB colour.

AnsiSection
struct AnsiSection

The resulting object from AnsiSectionRange, describes whether a slice of text is an ANSI sequence or not.

AnsiSectionRange
struct AnsiSectionRange

An input range of AnsiSections that splits a piece of text up into ANSI sequence and plain text sections.

AnsiStyle
struct AnsiStyle

Contains any number of styling options from AnsiStyleSgr, and provides the ability to generate an ANSI SGR command to apply all of the selected styling options.

AnsiStyleSet
struct AnsiStyleSet

Contains an AnsiColour for the foreground, an AnsiColour for the background, and an AnsiStyle for additional styling, and provides the ability to create an ANSI SGR command to set the foreground, background, and overall styling of the terminal.

AnsiText
struct AnsiText(alias ImplementationMixin)

Contains a string that supports the ability for different parts of the string to be styled seperately.

AnsiTextLite
struct AnsiTextLite

A lightweight alternative to AnsiText which only supports a singular coloured string, at the cost of removing most of the other complexity & dynamic allocation needs of AnsiText.

Templates

AnsiTextStackImplementation
template AnsiTextStackImplementation(size_t Capacity)

Variables

ANSI_COLOUR_END
auto ANSI_COLOUR_END;

The character used to denote that the sequence is an SGR sequence.

ANSI_COLOUR_RESET
auto ANSI_COLOUR_RESET;

The sequence used to reset all styling.

ANSI_CSI
auto ANSI_CSI;

The string that starts an ANSI command sequence.

ANSI_FG_TO_BG_INCREMENT
auto ANSI_FG_TO_BG_INCREMENT;

The amount to increment an Ansi4BitColour by in order to access the background version of the colour.

ANSI_SEPARATOR
auto ANSI_SEPARATOR;

The character that delimits ANSI parameters.

Meta