|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (9 bit)
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.
|
|
|
|
|
|
#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 |
|
|
|
|
|
#3 |
|
Member (9 bit)
Join Date: Jul 2001
Posts: 355
|
thanks alfie2, it works perfectly.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|