String line to map effects of.
Optional foreground base code to reset to after end colour tags.
Optional background base code to reset to after end colour tags.
A new string based on origLine with mIRC tokens mapped to terminal ones.
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);
Maps mIRC effect tokens (colour, bold, italics, underlined) to terminal ones.