ColorD

Marco Leise Marco.Leise at gmx.de
Mon May 28 06:08:50 PDT 2012


Am Sat, 26 May 2012 16:30:58 +0200
schrieb "Robik" <szadows at gmail.com>:

> I would like to share with my new library written in D. As name 
> may suggest (or not) it adds color to your console output, it 
> works on both Linux and Windows platforms. I haven't seen any 
> similar library for D language, so I decided to create this one.
> 
> Source and examples(included in Readme file) can be found on 
> GitHub repo: https://github.com/robik/ColorD
> 
> Regards,
> Robik.

Ah, this can be used to pimp the console output.
Give it the following additions to make it complete and useful:

* fg/bg colors are just two attributes, add e.g. bold, underline, italic
  (http://en.wikipedia.org/wiki/ANSI_escape_code)

* detect type of "stdout"; terminal or pipe/file
  (Posix: http://linux.die.net/man/3/isatty)

The latter is important to not accidentally write escape codes into a file if output is redirected. Some tools let you chose to output with or without colors, so it would be nice if you library could offer a "isAnsiTerminal" function, so the programmer can chose to output with or without colors. :)
This is a good idea!

-- 
Marco



More information about the Digitalmars-d mailing list