termcolor-d - Colors with writeln(...);

Vladimirs Nordholm v at vladde.net
Wed Nov 21 18:36:06 UTC 2018


https://github.com/vladdeSV/termcolor-d

Saw a library recently which allowed you to color text, but it 
had an odd syntax.

Since I already had some code for coloring text in terminals, I 
made this (hackish, POSIX only) project during lunch break. It in 
action:

     import std.stdio : writeln;
     import termcolor;

     // Color → Green → Foreground
     writeln(C.green.fg, "Green text", resetColor);

     // Color → Red → Background
     writeln(C.red.bg, "Red background", resetColor);

     // only tested on macOS running zsh using 
iTerm2/Hyper.js/Terminal.app

Hope this helps those who are making CLI applications :^)


More information about the Digitalmars-d-announce mailing list