Re: Xcode-users Digest, Vol 6, Issue 92
Re: Xcode-users Digest, Vol 6, Issue 92
- Subject: Re: Xcode-users Digest, Vol 6, Issue 92
- From: George Warner <email@hidden>
- Date: Sun, 15 Feb 2009 12:31:17 -0800
- Thread-topic: Xcode-users Digest, Vol 6, Issue 92
on 2/15/09 12:08 PM, email@hidden at
<email@hidden> wrote:
> I am new to Xcode and was wondering if someone could advise me about the
> best approach to writing a simple program that outputs text in color. It
> could be output to a file or to the console I just need to be able to
> print the color output. For example, how can I write ³hello world² with the
> characters in different colors? Can I do this using C++ and the console for
> output? Or must I use cocoa (if so, how?)? Or is there some simpler
> option? I only need to use a few basic colors (nothing fancy).
> Thanks for any help!
> Ellie
I wrote this quick program as an Xcode C tool:
[BEGIN]
#include <stdio.h>
int main (int argc, const char * argv[]) {
// insert code here...
printf("Hello, World!\n");
char esc = '\033';
int idx;
for (idx = 0; idx < 8; idx++ ) {
printf("idx: %d %c[%dm test %c[m four.\n", idx, esc, idx + 30, esc);
}
return 0;
}
[END]
When ran in Xcode it output (no color):
[BEGIN]
Hello, World!
idx: 0 [30m test [m four.
idx: 1 [31m test [m four.
idx: 2 [32m test [m four.
idx: 3 [33m test [m four.
idx: 4 [34m test [m four.
idx: 5 [35m test [m four.
idx: 6 [36m test [m four.
idx: 7 [37m test [m four.
[END]
But when ran in terminal:
[BEGIN]
Hello, World!
idx: 0 test four. (test in black)
idx: 1 test four. (test in red)
idx: 2 test four. (test in green)
idx: 3 test four. (test in yellow)
idx: 4 test four. (test in blue)
idx: 5 test four. (test in violet)
idx: 6 test four. (test in cyan)
idx: 7 test four. (test in white)
[END]
term> man ncurses
--
Enjoy,
George Warner,
Schizophrenic Optimization Scientist
Apple Developer Technical Support (DTS)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden