mapEffects

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

version(Colours)
@safe pure
mapEffects

Parameters

origLine string

String line to map effects of.

fgBase TerminalForeground

Optional foreground base code to reset to after end colour tags.

bgBase TerminalBackground

Optional background base code to reset to after end colour tags.

Return Value

Type: auto

A new string based on origLine with mIRC tokens mapped to terminal ones.

Examples

string mIRCEffectString = "...";
string TerminalFormatString = mapEffects(mIRCEffectString);
import kameloso.terminal : TerminalToken;
import lu.conv : toAlpha;

alias I = IRCControlCharacter;

enum bBold = TerminalToken.format ~ "[" ~ TerminalFormat.bold.toAlpha ~ "m";
enum bReset = TerminalToken.format ~ "[22m";
//enum bResetAll = TerminalToken.format ~ "[0m";

immutable line1 = "ABC"~I.bold~"DEF"~I.bold~"GHI"~I.bold~"JKL"~I.bold~"MNO";
immutable line2 = "ABC"~bBold~"DEF"~bReset~"GHI"~bBold~"JKL"~bReset~"MNO";//~bResetAll;
immutable mapped = mapEffects(line1);

assert((mapped == line2), mapped);