Add separate functions for each coloring type.

This is more than a draft; I'm just jotting down ideas to see how they
look on the screen.
This commit is contained in:
yamadapc 2014-07-11 20:30:13 -03:00
parent 3bf0b6844c
commit 9f4fddd188

View file

@ -83,7 +83,7 @@ static enum mode : int
* ---
*/
string colorize(string str, fg c, bg b=bg.init, mode m=mode.init)
string colorize(string str, fg c=fg.init, bg b=bg.init, mode m=mode.init)
pure
{
return format("\033[%d;%d;%dm%s\033[0m", m, c, b, str);
@ -110,3 +110,18 @@ unittest
writeln(ret);
assert(ret == "\033[5;31;44mThis is red on blue blinking\033[0m");
}
string background(string str, bg b=bg.init)
{
return colorize(str, fg.init, b, mode.init);
}
string foreground(string str, fg c=fg.init)
{
return colorize(str, c, bg.init, mode.init);
}
string style(string str, mode m=mode.init)
{
return colorize(str, fg.init, bg.init, m);
}