prim/source/style/package.d

23 lines
490 B
D

module style;
import std.conv;
import core.stdc.stdlib : getenv;
import style.color;
string set(string s, int code) {
if (getenv("NO_COLOR"))
return s;
return ("%{\x1b[" ~ to!string(code) ~ "m%}") ~ s ~ (
"%{\x1b[" ~ to!string((Color.reset + 0)) ~ "m%}");
}
string set(string s, int code, bool close) {
if (getenv("NO_COLOR"))
return s;
return ("%{\x1b[" ~ to!string(code) ~ "m%}") ~ s ~ (close ? (
"%{\x1b[" ~ to!string((Color.reset + 0)) ~ "m%}") : "");
}