Coloring terminal output.
Adam D. Ruppe via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Mon Jul 14 13:09:04 PDT 2014
On Monday, 14 July 2014 at 19:57:32 UTC, Suliman wrote:
> Cool! Would it be hard to add windows support?
I don't think it can be done with this setup - the colorize thing
returns a string, but Windows does color via API calls
independently of the string.
My terminal.d offers color output through special function calls:
https://github.com/adamdruppe/arsd/blob/master/terminal.d
works on both platforms.
import terminal;
void main() {
// get the terminal object for linear output
auto terminal = Terminal(ConsoleOutputType.linear);
// set foreground and background colors
terminal.color(Color.green | Bright, Color.black);
// to use default btw:
// terminal.color(Color.DEFAULT, Color.DEFAULT);
// write with this instead of regular stdout
terminal.write("hello\n");
}
More information about the Digitalmars-d-announce
mailing list