www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Colors in console

reply "Lionello Lunesu" <lionello.lunesu crystalinter.remove.com> writes:
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/ 
Nov 30 2004
next sibling parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
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?

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.
Dec 01 2004
parent "Lionello Lunesu" <lionello.lunesu crystalinter.remove.com> writes:
 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.
Dec 01 2004
prev sibling parent David L. Davis <SpottedTiger yahoo.com> writes:
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/ 

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!"
Dec 01 2004