• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Xcode-users Digest, Vol 6, Issue 92
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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  test  four.
idx: 1  test  four.
idx: 2  test  four.
idx: 3  test  four.
idx: 4  test  four.
idx: 5  test  four.
idx: 6  test  four.
idx: 7  test  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

  • Prev by Date: Re: How can I do color text output?
  • Next by Date: Making a set of targets where only one source file varies
  • Previous by thread: Re: How can I do color text output?
  • Next by thread: Making a set of targets where only one source file varies
  • Index(es):
    • Date
    • Thread