On 10/21/2012 05:01 PM, Jens Mueller wrote:
Robik wrote:
Hello,
I would like to introduce ColorD, small library that allows to
simply manipulate console output colors, both on Windows and Posix
operating systems. It also supports font styles such as underline
and strikethrough(Posix feature only).
Simple example:
import std.stdio, colord;
void main()
{
setConsoleColors(Fg.red, Bg.blue);
writeln("Red text on blue background.");
resetConsoleColors(); // Bring back initial state
}
Feedback welcome.
GitHub: https://github.com/robik/ColorD
Interesting looks solid to me.
Some nit-picks:
* Coloring on Posix depends a ANSI terminal. Can you check that a
terminal is ANSI compatible?
* There are some magic numbers in the code. These may be difficult to
figure out for maintaining.
* enum Color should maybe be same on all systems.
This is a rather small issue. But I may transfer the Color to another
system. So if it is possible there should only be one enum Color for
all systems.
* Call it terminal or similar. Because other terminal related stuff can
be added and IMHO it's a better name.
I have written a similar library. Not finished. Let's join forces.
https://github.com/jkm/terminal
Johannes Pfau has written a progress bar. I will add this.
Jens
Hey that looks cool.
It seems to have a hard ncurses/termcap/etc dependency.
I'll admit when I started trying to work on doing this thing, I never
got anything onto the screen. What stopped me was that I couldn't
figure out how to detect ncurses/termcap/etc. I was going to shoot for
Phobos inclusion and making Phobos always link with ncurses seems like a
bad idea.
Ultimately I expect it to work with writeln or writefln to make it
discoverable and easy to work with.
Back then I did design a format spec for introducing colors into format
strings:
www.chadjoan.com/d/dmd.2.058/html/d/phobos/std_format.html