An compiler that supports colored text?

This is a discussion on An compiler that supports colored text? within the C Programming forums, part of the General Programming Boards category; I searched through the messageboards first, found some info about ANSI, and a win32 way to do it, but also ...

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    119

    An compiler that supports colored text?

    I searched through the messageboards first, found some info about ANSI, and a win32 way to do it, but also some were saying that one compiler has textcolor and textattrib, which you can use to change text color and all since c doesn't support it by itself. So I was wondering if anyone knew of a freeware compiler that does have commands similiar to those?

    I heard of curses, and downloaded curses.h, but don't I have to download another file as well (like a library file?) to use that.

    The way I understand that is usually works is that a header only declares the prototype for a function, and that the rest of the info is in a library file, is that correct?

    Sorry for all the questions, but I'm determined to learn c, and I always do a google search and the like before I ask a question on here.

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    I presume you are talking about colouring text in a console application. My six part console tutorial starting there covers that and much other stuff.

    It is written in C++ but if you change the cout's to printf's it will work. The functions you use are Windows API so will be the same in either case.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    You can get WinCurses here

  4. #4
    Registered User
    Join Date
    Dec 2005
    Posts
    119
    Thanks to you both, I've started to read the tutorial, nicely done. Also I'm going to go check out WinCurses now. Just out of curiousity though, it seems like both of these will work for "windows dos boxes", but not in real dos mode. Is that so, and if so, I'm still looking for a way to have color in true DOS mode, but don't get me wrong, I'm glad to learn how to do it in Windows as well. In fact, I know that the majority these days don't even use "true DOS" anymore, but I'd like to know how just to know, you know?

  5. #5
    Registered User
    Join Date
    Dec 2005
    Posts
    119
    I went to the WinCurses page, it said it's for the MS compiler, does that mean I can still use it with my compiler? I have pacific c, and dev-c++...

  6. #6
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    you really don't need curses library. Did you read Adrian's link?

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    There's also an FAQ on the subject: http://faq.cprogramming.com/cgi-bin/...&id=1043284392

    Just out of curiousity though, it seems like both of these will work for "windows dos boxes", but not in real dos mode. Is that so, and if so, I'm still looking for a way to have color in true DOS mode
    For that you'd need to use something like Borland's putch() or something. Anyway, no one would have DOS nowadays.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  8. #8
    cwr
    cwr is offline
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    868
    You can use ANSI escape codes for colour in DOS mode provided that the ANSI.SYS driver is loaded.

    http://en.wikipedia.org/wiki/ANSI_escape_code

    This is probably the most portable way to do coloured text.

  9. #9
    Registered User
    Join Date
    Dec 2005
    Posts
    119
    Quote Originally Posted by cwr
    You can use ANSI escape codes for colour in DOS mode provided that the ANSI.SYS driver is loaded.

    http://en.wikipedia.org/wiki/ANSI_escape_code

    This is probably the most portable way to do coloured text.
    Thanks everyone for your replies.

    Also, about the ANSI escape codes, I can't seem to test them on my WinXp system. I edited config.nt in the windows/system32 directory and added "device=C:\windows\system32\ansi.sys", and rebooted, but still no luck. Unfourtunatly, I have no other older computer to test it on. So does anyone know of anything else I can do to get ansi.sys to load up on my winxp comp?

  10. #10
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,546
    > This is probably the most portable way to do coloured text.
    I'm in shock - "most portable"
    *picks self off the floor and sits down*

    > I heard of curses, and downloaded curses.h, but don't I have to download another file as well (like a library file?) to use that.
    Yes - you'll probably download many different libraries in your career so there's really nothing to worry about here. This is definitely the most portable solution for any OS which isn't ancient DOS.

    Or if you want to stick to Win32, then use Adrian's tutorials.

    > I'm still looking for a way to have color in true DOS mode
    > I have no other older computer to test it on
    These statements are inconsistent. If your base OS is XP, then all you have is a win32 console.

  11. #11
    cwr
    cwr is offline
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    868
    Quote Originally Posted by Salem
    > This is probably the most portable way to do coloured text.
    I'm in shock - "most portable"
    *picks self off the floor and sits down*
    You're right, "most portable" was the wrong term. It is very portable, though, being supported on all modern unix terminals and emulation layers. Granted, ncurses would be the most portable and terminal independent solution, but it relies on yet another library, which seems huge overkill for just coloured text. Whereas ANSI escape codes do not require any extra libraries.

  12. #12
    Cached User mako's Avatar
    Join Date
    Dec 2005
    Location
    Germany.Stuttgart
    Posts
    69
    Code:
    void main(void)
    {
    
    //initalize variables
    
    system("color 4d");
    
    printf("bla");
    }
    this will give your background and font a color according to the hexadec value...

  13. #13
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    1 - "void main" is wrong. Read the FAQ.
    2 - Read the FAQ on why using system is generally frowned upon.
    3 - My OS doesn't have "color" as a command.
    4 - Naturally this is just a code fragment for example's sake, right? Because you're missing the required headers for things like printf...


    Quzah.
    Hope is the first step on the road to disappointment.

  14. #14
    Registered User
    Join Date
    Dec 2005
    Posts
    119
    [QUOTE=Salem

    > I'm still looking for a way to have color in true DOS mode
    > I have no other older computer to test it on
    These statements are inconsistent. If your base OS is XP, then all you have is a win32 console.[/QUOTE]

    What I mean is, I know win32 console isn't really DOS, but I do have something called DOSBOX which emulates DOS so that I can test programs I make and see that color in fact wouldn't work on a computer that had, for example, win95, where a person could exit to actual DOS.

  15. #15
    Cached User mako's Avatar
    Join Date
    Dec 2005
    Location
    Germany.Stuttgart
    Posts
    69
    Quote Originally Posted by quzah
    1 - "void main" is wrong. Read the FAQ.
    2 - Read the FAQ on why using system is generally frowned upon.
    3 - My OS doesn't have "color" as a command.
    4 - Naturally this is just a code fragment for example's sake, right? Because you're missing the required headers for things like printf...


    Quzah.

    1 - only pages 1-4 work, void wasn't mentioned once in those 4 pages. I realise int and return 0 works, but void isn't wrong as far as I can tell. Maybe it's mentioned in the last 2 pages...
    2 - didn't find anything regarding the system command, only that you prefer handles... or summink...
    3 - okay, I'll avoid that command from now on...
    4 - yes, of course...

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DirectX | Drawing text
    By gavra in forum Game Programming
    Replies: 4
    Last Post: 06-08-2009, 12:23 AM
  2. Colored Text
    By P4r4digm in forum C Programming
    Replies: 5
    Last Post: 01-22-2007, 04:04 PM
  3. colored text
    By raze in forum C++ Programming
    Replies: 13
    Last Post: 07-09-2006, 03:24 AM
  4. Constantly updated editable colored text
    By _Elixia_ in forum Windows Programming
    Replies: 2
    Last Post: 06-15-2003, 04:21 PM
  5. Ok, Structs, I need help I am not familiar with them
    By incognito in forum C++ Programming
    Replies: 7
    Last Post: 06-29-2002, 09:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21