Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 11-29-2005, 11:37 PM   #1
Member (9 bit)
 
ironzombie99's Avatar
 
Join Date: Jul 2001
Posts: 355
C programming language question

This may seem like an off the wall question but i was wondering how to format/change the text color of a block of text that is printed to the screen in the compiled program (not talking about the colored syntax options in some editors) I am using Vim on a linux machine to write my code but I also have access to VB6 if it matters.
ironzombie99 is offline   Reply With Quote
Old 11-30-2005, 04:38 AM   #2
Member (9 bit)
 
Join Date: Feb 2005
Posts: 392
you can use 'escape sequences' code " ESC = "\033" under VT100 terminal specs.
(what is VT100, you asked, it was a term spec for DEC's VAX/VMS Mini-computers; very popular in the 1960s-80s, DEC was brought by COMPAQ)
(if anyone knows what VAX is then he/she is as old as me...hehehe)

example:

To print "Hello, world.\!" in red YOU would write the printf statement to:

printf("\033[22;31mHello, world!");

Note: this will change all text output to RED after that; you have to do a "\033[0m" or another "esc seq." to change it.

==========================================
All the VT100 colors are:
\033[22;30m - black
\033[22;31m - red
\033[22;32m - green
\033[22;33m - brown
\033[22;34m - blue
\033[22;35m - magenta
\033[22;36m - cyan
\033[22;37m - gray
\033[01;30m - dark gray
\033[01;31m - light red
\033[01;32m - light green
\033[01;33m - yellow
\033[01;34m - light blue
\033[01;35m - light magenta
\033[01;36m - light cyan
\033[01;37m - white
==========================================


Note: you can also use the ESC sequence to move the cursor anywhere in the terminal.

If you want portability use ncurses/xcurses libraries in LINUX's GCC.
VBasic has color text functions built-in, see help.
__________________
words to live by:
others don't know, I know.
others know, I know more.
others know more, I excel.
one shouldnt read this far; above, is meant as an encouragement, translated from a Chinese Proverb.
"He who angers you conquers you." : Elizabeth Kenny
alfie2 is offline   Reply With Quote
Old 11-30-2005, 05:11 PM   #3
Member (9 bit)
 
ironzombie99's Avatar
 
Join Date: Jul 2001
Posts: 355
thanks alfie2, it works perfectly.
ironzombie99 is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:01 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2