String to hash and base colour on.
A copy of the program-global CoreSettings.
A uint that can be used in an ANSI foreground colour sequence.
immutable nickColour = "kameloso".getColourByHash(*kameloso.common.settings);
import std.conv : to; CoreSettings brightSettings; CoreSettings darkSettings; brightSettings.brightTerminal = true; { immutable hash = getColourByHash("kameloso", darkSettings); assert((hash == 227), hash.to!string); } { immutable hash = getColourByHash("kameloso^", darkSettings); assert((hash == 46), hash.to!string); } { immutable hash = getColourByHash("zorael", brightSettings); assert((hash == 35), hash.to!string); } { immutable hash = getColourByHash("NO", brightSettings); assert((hash == 90), hash.to!string); }
Hashes the passed string and picks an ANSI colour for it by modulo.
Picks any colour, taking care not to pick black or white based on the passed CoreSettings struct (which has a field that signifies a bright terminal background). It also only picks from the basic colour range unless the passed CoreSettings has values that signify that the terminal supports extended colours.