Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mward333

macrumors 6502a
Original poster
Jan 24, 2004
574
33
I'm writing a C++ program that runs in the terminal. It would be absolutely wonderful to send some of the characters to the terminal in color instead of the usual black.

Of course C++ does not have built-in color support...

Instead, what I am hoping to do, for instance, is send an ASCII or Unicode sequence to the terminal as the program runs, saying (for instance), ok now we want the current text to be red, ok now we want the current text to be blue, etc., etc.

There must be an ASCII or Unicode sequence that tells the terminal to switch colors as the program executes. Can somebody point me to a useful example about this?
 

mward333

macrumors 6502a
Original poster
Jan 24, 2004
574
33
No problem…*but will your 8 core Mac and 3 30" displays be able to handle the stress of displaying ascii in colour :)

b e n

b e n...... Your advice did the trick. I just got it working perfectly. Thank you. By the way, I really appreciate your help.

ha ha.... can my Mac Pro handle it? That was funny! :)

Thanks again.
 

mward333

macrumors 6502a
Original poster
Jan 24, 2004
574
33
OK, so now I have colors working great using the escape sequences, as "b e n" suggested.

Is there a way to use more than 8 text colors? (Sure, I know switching from C++ to Java is an obvious tip, but I need to stick with C++.)

Any thoughts?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.