ircColourInto

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.

@safe
void
ircColourInto
(
Sink
)
(
const string line
,
auto ref Sink sink
,
const int fg
,
const int bg = IRCColour.unset
)

Parameters

line string

Line to tint.

sink Sink

Output range sink to fill with the function's output.

fg int

Foreground IRCColour integer.

bg int

Optional background IRCColour integer.

Examples

import std.array : Appender;

alias I = IRCControlCharacter;
Appender!(char[]) sink;

"kameloso".ircColourInto(sink, IRCColour.red, IRCColour.white);
assert((sink.data == I.colour ~ "04,00kameloso" ~ I.colour), sink.data);
sink.clear();

"harbl".ircColourInto(sink, IRCColour.green);
assert((sink.data == I.colour ~ "03harbl" ~ I.colour), sink.data);