kameloso.irccolours

Functions related to IRC colouring and formatting; mapping it to ANSI terminal such, stripping it, etc.

IRC colours are not in the standard per se, but there is a de-facto standard based on the mIRC coluring syntax of \3fg,bg...\3, where '\3' is byte 3, fg is a foreground colour number (of IRCColour) and bg is a similar background colour number.

Members

Enums

IRCColour
enum IRCColour

Official mIRC colour table.

Functions

expandIRCTags
T expandIRCTags(T line, Flag!"extendedOutgoingColours" extendedOutgoingColours, Flag!"strip" strip)

Slightly more complicated, but essentially string-replaces <tags> in an outgoing IRC string with correlating formatting using IRCControlCharacters in their syntax. Overload that takes an explicit strip Flag.

expandIRCTags
T expandIRCTags(T line)

Slightly more complicated, but essentially string-replaces <tags> in an outgoing IRC string with correlating formatting using IRCControlCharacters in their syntax. Overload that does not take a strip Flag.

ircBold
auto ircBold(T something)

Returns the passed something wrapped in between IRC bold control characters.

ircColour
string ircColour(string line, int fg, int bg)

Colour-codes the passed string with mIRC colouring, foreground and background. Direct overload that leverages the output range version to colour an internal Appender, and returns the resulting string.

ircColour
string ircColour(IRCColour fg, IRCColour bg)

Returns a mIRC colour code for the passed foreground and background colour. Overload that doesn't take a string to tint, only the IRCColours to produce a colour code from.

ircColourByHash
string ircColourByHash(string word, Flag!"extendedOutgoingColours" extendedOutgoingColours)

Returns the passed string coloured with an IRC colour depending on the hash of the string, making for good "random" (uniformly distributed) nick colours in IRC messages.

ircColourInto
void ircColourInto(string line, Sink sink, int fg, int bg)

Colour-codes the passed string with mIRC colouring, foreground and background. Takes an output range sink and writes to it instead of allocating a new string.

ircItalics
auto ircItalics(T something)

Returns the passed something wrapped in between IRC italics control characters.

ircReset
auto ircReset()

Returns an IRC formatting reset token.

ircUnderlined
auto ircUnderlined(T something)

Returns the passed something wrapped in between IRC underlined control characters.

mapColours
auto mapColours(string line, TerminalForeground fgFallback, TerminalBackground bgFallback)

Maps mIRC effect colour tokens to terminal ones.

mapEffects
auto mapEffects(string origLine, TerminalForeground fgBase, TerminalBackground bgBase)

Maps mIRC effect tokens (colour, bold, italics, underlined) to terminal ones.

stripColours
auto stripColours(string line)

Removes IRC colouring from a passed string.

stripEffects
auto stripEffects(string line)

Removes all form of mIRC formatting (colours, bold, italics, underlined) from a string.

stripIRCTags
T stripIRCTags(T line)

Removes <tags> in an outgoing IRC string where the tags correlate to formatting using IRCControlCharacters.

Variables

ircANSIColourMap
uint[99] ircANSIColourMap;

Map of IRC colour values above 16 to ANSI terminal colours, as per ircdocs.

Examples

immutable nameInColour = "kameloso".ircColour(IRCColour.red);
immutable nameInHashedColour = "kameloso".ircColourByHash(Yes.extendedOutgoingColours);
immutable nameInBold = "kameloso".ircBold;

See Also

Meta