PDA

View Full Version : Console text color



skyphyr
11th December 2006, 15:43
Hi All,

I'm making some console tools and would like it to highlight directories etc as appropriate.

Anyone know how I could do this in Qt and whether it would impact functionality on windows (not really a concern, but if I can leave it cross platform then it'd be nice).

Cheers,

Alan.

sunil.thaha
11th December 2006, 16:15
You can use the ascii color codes with qDebug() in unix flavours. And in windows maybe remove those and implement windows specific code ( Not really sure how it can be done in windows console )

Just found this
http://www-128.ibm.com/developerworks/linux/library/l-tip-prompt/
http://www.linuxfocus.org/English/May2004/article335.shtml
http://www.expertsrt.com/tutorials/Matt/CmdPrompt.html

skyphyr
11th December 2006, 17:56
Hi Sunil,

Thanks very much :-) I got it working with

QTextStream qout(stdout);
qout << "\033[0;32mSeqLs Constructor\033[0;0m\n";

I'll just need to implement processing of the LS_COLORS environment variable and it should follow the users preferences.

Cheers,

Alan.

skyphyr
11th December 2006, 17:56
Hi Sunil,

Thanks very much :-) I got it working with

QTextStream qout(stdout);
qout << "\033[0;32mSeqLs Constructor\033[0;0m\n";

I'll just need to implement processing of the LS_COLORS environment variable and it should follow the users preferences.

Cheers,

Alan.

danadam
11th December 2006, 18:19
Acording to wikipedia (http://en.wikipedia.org/wiki/ANSI_escape_code) you need some kind of device driver (ANSI.SYS), to get it working under Windows. I don't know if it is installed by default.