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 colouring 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
auto expandIRCTags(T line, bool extendedOutgoingColours, bool 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
auto 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.

expandIRCTagsImpl
T expandIRCTagsImpl(T line, bool extendedOutgoingColours, bool strip)

Implementation function for expandIRCTags. Kept separate so that UTFException can be neatly caught.

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, bool 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.

ircColourByHash
dstring ircColourByHash(dstring word, bool extendedOutgoingColours)

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

ircColourByHashImpl
void ircColourByHashImpl(Sink sink, String word, bool extendedOutgoingColours)

Implementation function used by ircColourByHash. Breaks out common functionality and reuses it.

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.

mapColoursImpl
string mapColoursImpl(string line, TerminalForeground fgFallback, TerminalBackground bgFallback)

Maps mIRC effect colour tokens to terminal ones, or strip them entirely. Now with less regex.

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

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

mapEffectsImpl
string mapEffectsImpl(string line)

Replaces mIRC tokens with terminal effect codes, in an alternating fashion so as to support repeated effects toggling behaviour. Now with less regex.

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
auto 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(extendedOutgoingColours: true);
immutable nameInBold = "kameloso".ircBold;

See Also

Meta