Enum definitions of ANSI codes.
A collection of functions used to translate tags in messages into terminal colours.
Applies an ANSI code to a passed output range.
Produces a terminal colour token for the colour passed, expressed in terms of red, green and blue, then writes it to the passed output range.
Returns an ANSI format sequence containing the passed code.
Produces a terminal colour token for the colour passed, expressed in terms of red, green and blue. Convenience function to colour a piece of text without being passed an output sink to fill into.
Shorthand function to colour a passed word by the hash of it.
Hashes the passed string and picks an ANSI colour for it by modulo.
Terminal-inverts the colours of a piece of text in a string.
Applies an ANSI code to a passed string and returns it as a new one. Convenience function to colour a piece of text without being passed an output sink to fill into.
Appender!(char[]) sink; // Output range version sink.put("Hello "); sink.applyANSI(TerminalForeground.red, ANSICodeType.foreground); sink.put("world!"); sink.applyANSI(TerminalForeground.default_, ANSICodeType.foreground); with (TerminalForeground) { // Normal string-returning versions writeln("Hello ", red.asANSI, "world!", default_.asANSI); writeln("H3LL0".withANSI(red), ' ', "W0RLD!".withANSI(default_)); } // Also accepts RGB form sink.put(" Also"); sink.applyTruecolour(128, 128, 255); sink.put("magic"); sink.applyANSI(TerminalForeground.default_); with (TerminalForeground) { writeln("Also ", asTruecolour(128, 128, 255), "magic", default_.asANSI); } immutable line = "Surrounding text kameloso surrounding text"; immutable kamelosoInverted = line.invert("kameloso"); assert(line != kamelosoInverted); immutable nicknameTint = "nickname".getColourByHash(*kameloso.common.settings); immutable substringTint = "substring".getColourByHash(*kameloso.common.settings);
It is used heavily in the Printer plugin, to format sections of its output in different colours, but it's generic enough to use anywhere.
The output range versions are cumbersome but necessary to minimise the number of strings generated.
A collection of functions that relate to applying ANSI effects to text.
This submodule has to do with terminal text colouring and is therefore gated behind version Colours.