Thread overview
Colors in console
Dec 01, 2004
Lionello Lunesu
Dec 01, 2004
Stewart Gordon
Dec 01, 2004
Lionello Lunesu
Dec 01, 2004
David L. Davis
December 01, 2004
Is there any way to print text in different colors in the console?
ANSI escape sequences have no effect. Do I have to use the Win32 console API
directly?

(Will there ever be ANSI support in Phobos' writef, or a std.console with wrappers for different platforms? Or, uh, should I create a GUI instead :-S....)

Lionello.

-- Get the CACert root certificate (and a personal one) at http://cacert.org/


December 01, 2004
Lionello Lunesu wrote:
> Is there any way to print text in different colors in the console?
> ANSI escape sequences have no effect. 

Yes, these always required the ANSI.SYS driver to be loaded.  AIUI this was set up in most MS-DOS installations before Windows 95 came along.

> Do I have to use the Win32 console API directly?
<snip>

No.  In the dmc package, there's a disp.h file with functions to do things like this.  You can turn it into a D module and then use it.

Stewart.

-- 
My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.
December 01, 2004
> No.  In the dmc package, there's a disp.h file with functions to do things like this.  You can turn it into a D module and then use it.

Wauw! Thanks a lot, that did the trick.
I've attached the converted header-file to this message. Please, anyone, let
me know if this is inappropriate.

Lionello.



December 01, 2004
In article <cojsi1$19ct$1@digitaldaemon.com>, Lionello Lunesu says...
>
>Is there any way to print text in different colors in the console?
>ANSI escape sequences have no effect. Do I have to use the Win32 console API
>directly?
>
>(Will there ever be ANSI support in Phobos' writef, or a std.console with wrappers for different platforms? Or, uh, should I create a GUI instead :-S....)
>
>Lionello.
>
>-- Get the CACert root certificate (and a personal one) at http://cacert.org/
>
>
Lionello:

For an example that uses Win32 APIs, please follow the link to my D web site page at http://spottedtiger.tripod.com/D_Language/D_Hub_Adv_Tutor_XP.html and grab WinCon01aug04.zip which includes an example file called rainbow.d that does 16 colors foreground and 16 colors background (256 combinations). I think this is what you're looking for.

David L.

-------------------------------------------------------------------
"Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"