jaster.cli.ansi

Utilities to create ANSI coloured text.

Members

Aliases

AnsiComponents
alias AnsiComponents = string[2 + FLAG_COUNT]

An alias for a string[] containing exactly enough elements for the following ANSI strings: * [0] = Foreground ANSI code. * [1] = Background ANSI code. * [2..n] = The code for any AnsiTextFlags that are set.

AnsiSection
alias AnsiSection = AnsiSectionBase!char

An AnsiSectionBase that uses char as the character type, a.k.a what's going to be used 99% of the time.

IsBgColour
alias IsBgColour = Flag!"isBackgroundAnsi"

Undocumented in source.

Enums

Ansi4BitColour
enum Ansi4BitColour

An enumeration of standard 4-bit colours.

AnsiColourType
enum AnsiColourType

Defines what type of colour an AnsiColour stores.

AnsiSectionType
enum AnsiSectionType

Describes whether an AnsiSectionBase contains a piece of text, or an ANSI escape sequence.

AnsiTextFlags
enum AnsiTextFlags

Undocumented in source.

Functions

ansi
AnsiText ansi(char[] text)

A helper UFCS function used to fluently convert any piece of text into an AnsiText.

asAnsiChars
AsAnsiCharRange!R asAnsiChars(R range)

Notes: Reminder that AnsiSection.value shouldn't include the starting "\033[" and ending 'm' when it contains an ANSI sequence.

asAnsiChars
AsAnsiCharRange!(AnsiSectionRange!char) asAnsiChars(char[] input)
asAnsiSections
AnsiSectionRange!Char asAnsiSections(Char[] input)
asAnsiTexts
AsAnsiTextRange!R asAnsiTexts(R range)

Notes: Reminder that AnsiSection.value shouldn't include the starting "\033[" and ending 'm' when it contains an ANSI sequence.

asAnsiTexts
AsAnsiTextRange!(AnsiSectionRange!char) asAnsiTexts(char[] input)
createAnsiCommandString
string createAnsiCommandString(AnsiComponents components)

Creates an ANSI command string using the given active components.

populateActiveAnsiComponents
size_t populateActiveAnsiComponents(AnsiComponents components, AnsiColour fg, AnsiColour bg, AnsiTextFlags flags)

Populates an AnsiComponents with all the strings required to construct a full ANSI command string.

stripAnsi
auto stripAnsi(char[] input)

Provides an InputRange that iterates over all non-ANSI related parts of input.

Structs

AnsiChar
struct AnsiChar

Contains a single character, with ANSI styling.

AnsiColour
struct AnsiColour

Contains either a 4-bit, 8-bit, or 24-bit colour, which can then be turned into an its ANSI form (not a valid command, just the actual values needed to form the final command).

AnsiRgbColour
struct AnsiRgbColour

A very simple RGB struct, used to store an RGB value.

AnsiSectionBase
struct AnsiSectionBase(Char)

Contains an section of text, with an additional field to specify whether the section contains plain text, or an ANSI escape sequence.

AnsiSectionRange
struct AnsiSectionRange(Char)

An InputRange that turns an array of Chars into a range of AnsiSections.

AnsiText
struct AnsiText

A struct used to compose together a piece of ANSI text.

AsAnsiCharRange
struct AsAnsiCharRange(R)

An InputRange that converts a range of AnsiSections into a range of AnsiChars.

AsAnsiTextRange
struct AsAnsiTextRange(R)

An InputRange that converts a range of AnsiSections into a range of AnsiTexts.

Meta