d-colorize
d-colorize copied to clipboard
Colors not reset properly with only fg.init or bg.init
import std.stdio;
import colorize;
void main()
{
string a = color("a", fg.light_green, bg.light_red);
string b = color("b", fg.red, bg.init);
cwriteln(a, b);
}
This code should print out a green a with a red background, then a red b, with the default background color as background. However, the results end up with the b having the same background color as a.
This is not the expected behavior, as setting both b's foreground and background to init
gives the default colors of the console.
This bug happens only on Windows, not POSIX.
Tested on Windows 7 64-bit (CMD.exe, Powershell.exe), GNU+Linux Debian 64-bit (terminator, gnome-terminal), OS X some-bit (thenameoftheterminalthere).
Yoyo, vladde
If you wish you could reverse the fg and bg, string b = color("b", fg.init, bg.blue);
will make the foreground green.