Whether or not to strip effects or map them.
mIRC token for a particular text effect.
Terminal equivalent of the mircToken effect.
The mIRC-formatted string to translate.
The passed line, now with terminal formatting.
import kameloso.terminal : TerminalToken; import lu.conv : toAlpha; alias I = IRCControlCharacter; alias TF = TerminalFormat; enum bBold = TerminalToken.format ~ "[" ~ TF.bold.toAlpha ~ "m"; enum bReset = TerminalToken.format ~ "[22m"; { enum line = "derp " ~ I.bold ~ "herp derp" ~ I.bold ~ "der dper"; immutable mapped = mapEffectsImpl!(No.strip, I.bold, TF.bold)(line); assert((mapped == "derp " ~ bBold ~ "herp derp" ~ bReset ~ "der dper"), mapped); }
Replaces mIRC tokens with terminal effect codes, in an alternating fashion so as to support repeated effects toggling behaviour. Now with less regex.
It seems to be the case that a token for bold text will trigger bold text up until the next bold token. If we only naïvely replace all mIRC tokens for bold text then, we'll get lines that start off bold and continue as such until the very end.
Instead we iterate all occurrences of the passed mircToken, toggling the effect on and off.