How can I immplement colour into my ansi C programs. ie for an example how can
I change the following program to make each letter in the printf statement a
different colour.
#include <stdio.h>
int main(void)
{
printf( "Colourful man\n" );
return 0;
}
Thanx guys *8)
Kieran Farrell
--
Increase the Peace!
Charles LaCour
cla...@cwix.com
Kez404 wrote in message <19981230040931...@ng21.aol.com>...
one way would be to put in ansi escape characters...ansi escape characters
look something like this:
^[[35mhey ^[[00mthere
where ^[ is ctrl-[ (escape), and [ is just a normal [...35 or 00 is the
colour (35 is foreground magenta, 00 sets everything back to normal), and m
just marks the end of the escape sequence
also you can combine a bunch of them like so:
^[[05;36;41mtest^[[00m
05 makes it blinking, 36 sets it to cyan foreground, and 41 sets it to red
background
anyway hopefully you can find a text which will tell you a bit more about
ansi escape sequences
--
m i k e b u r r e l l
mik...@home.com
http://mikpos.dyndns.org
In no way ANSI C compatible. Colour are unknown to the standard.
Ciao Paolo
> #include <stdio.h>
>
> int main(void)
> {
> printf( "Colourful man\n" );
> return 0;
> }
>
> Thanx guys *8)
>
> Kieran Farrell
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
--
Increase the Peace!
Charles LaCour
cla...@cwix.com
mike burrell wrote in message ...
>In article <19981230040931...@ng21.aol.com>,
>Kez404 <kez...@aol.comspamless> wrote:
>>Hi *8)
>>
>>How can I immplement colour into my ansi C programs. ie for an example how
can
>>I change the following program to make each letter in the printf statement
a
>>different colour.
>>
>>#include <stdio.h>
>>
>>int main(void)
>>{
>> printf( "Colourful man\n" );
>> return 0;
>>}
>
ANSI escape characters aren't a part of ANSI C. Daft but true.
============================================
Graeme Fenwick | gfen...@BYESPAMprimex.co.uk
"Please remove BYESPAM filter when replying by mail"
-- WILLIAM SHAKESPEARE, Hamlet.
What 'job' are you talking about? If you want colored text you simply
have to compile different versions of your programs and indicate for
which platform they are designed to run. Colored text is possible, not
portable.
-matt
--
{Matt Weber}
{mrw...@erols.com}
"The horror ... the horror" - Col. Kurtz
Well that's just grand isn't it, a language people claim to be the most
powerful and flexible yet I can't do a simple thing like have coloured text.
This isn't a programming language it's a joke. Even pascal can do more than
this crappy code base. I will not accept that there is no way to do it, I've
put too much into learning C to have the rug pulled out from underneath me!! If
anyone can help me I'll appreciate it otherwise I'm giving C away for a code
base that can do the job. like BASIC!!! (insults intended)
I'll say it again. ANSI C has no support for color text. Now go play
in comp.os.msdos.programmer.
--
(supporter of the campaign for grumpiness where grumpiness is due in c.l.c)
Please: do not email me copies of your posts to comp.lang.c
do not ask me C questions via email; post them instead
Unfortunately, the clueless cannot even formulate insults. We know,
unlike you, that neither BASIC nor Pascal can do what you want. No
doubt you have suffered at the hands of implementations that never told
you that you were using non-standard, non-portable,
implementation-defined additions to the language. I look in my Turbo
Pascal 7 docs and find no reference to which implementations support
what.
In standard C, just as in standard Pscal, there is no way provided in
the language for doing what you want. In standard C, as in standard
Pascal, you accomplish these with non-standard functionality provided
either by your implementation or by a 3rd party. For maximum
portability in C, use curses. For maximum portability in Pascal, shoot
your brains out.
--
Martin Ambuhl (mam...@earthlink.net)
Note: mam...@tiac.net will soon be inactive
>Well that's just grand isn't it, a language people claim to be the most
>powerful and flexible yet I can't do a simple thing like have coloured text.
Of course it can, but you'll need to work at it. Look for an
implementation of the "curses" library for your machine. It does
colours, cursor positioning and all sorts of other |<-rad text type
stuff.
>This isn't a programming language it's a joke. Even pascal can do more than
>this crappy code base.
Which non-standard, unsupported, proprietary variant of Pascal would
that be?
> I will not accept that there is no way to do it, I've
>put too much into learning C to have the rug pulled out from underneath me!! If
>anyone can help me I'll appreciate it otherwise I'm giving C away for a code
>base that can do the job. like BASIC!!! (insults intended)
Visual Basic sounds like just what you're after. Colourful, but not
very portable. Good luck!
-- Mat.
Depending on what you are doing, and what system you are using to do it,
Visual Basic might well be a better bet. I used it for some rapid
prototyping (a while back) and it was pretty straightforward, and of
course in color.
C is powerful, but has no idea of colors or indeed graphics of any
description. You need a terminal-handling or graphics library
(eg. OpenGL); what you use will again depend on your system. Try
asking in a system-related newsgroup, since someone will have solved
this problem before.
> Well that's just grand isn't it, a language people claim to be the most
> powerful and flexible yet I can't do a simple thing like have coloured text.
> This isn't a programming language it's a joke. Even pascal can do more than
> this crappy code base. I will not accept that there is no way to do it, I've
> put too much into learning C to have the rug pulled out from underneath me!! If
> anyone can help me I'll appreciate it otherwise I'm giving C away for a code
> base that can do the job. like BASIC!!! (insults intended)
<Jack>
Yes, please give away your C compiler and forget the name of this
group.
</Jack>
--
Do not email me with questions about programming.
Post them to the appropriate newsgroup.
Followups to my posts are welcome.
Andy P Bretten - bre...@fuse.net
On Wed, 30 Dec 1998 19:34:12 GMT, "Charles LaCour" <cla...@cwix.com>
wrote:
--
Increase the Peace!
Charles LaCour
cla...@cwix.com
Andy & Deobrah Bretten wrote in message <368b233...@news.fuse.net>...
I think that you are confusing ANSI C (a language specification) with
ANSI terminals (a terminal specification). There is no connection
besides the standards body that oversaw the spec.
What you are asking for is impossible to put into the specification of
a portable language. What if your program runs on a computer without
a colour display? What of the various GUIs? Any language that
includes this in the standard specification is a joke because it is
incapable of being transferred from machine to machine. This type of
feature is best added on by means of a library of functions that deals
with the ANSI escape codes if you wish to write your program for a
computer with that sort of display. There should be a few out there.
Reg.
--
----------------------------------------------------------------------
"It is not always the same thing to be a good man and a good citizen."
Aristotle.
Yes you can. You can do anything your particular compiler supports- but
you'll have to rewrite the non-ANSI parts (i.e. the coloured text in this
case) if you want to port it. How is having a standard that you can write
most of your program in inferior to nothing at all?
>This isn't a programming language it's a joke.
Is this a troll, or what?
>Even pascal can do more than this crappy code base.
Okay- use Pascal if you like.
>I will not accept that there is no way to do it, I've
>put too much into learning C to have the rug pulled out from underneath
me!!
You spent all that time learning C, and you still don't understand why the
ANSI standard is so important. Where the heck did you learn it from?
>If anyone can help me I'll appreciate it otherwise I'm giving C away for a
code
>base that can do the job. like BASIC!!! (insults intended)
Okay then. What job would that be? (No insult required).
--
William McBrine | http://www.clark.net/~wmcbrine/
wmcb...@clark.net | ./\./\./\./\./\./\./\./\./\./\.
>Well that's just grand isn't it, a language people claim to be the most
>powerful and flexible yet I can't do a simple thing like have coloured text.
>This isn't a programming language it's a joke. Even pascal can do more than
>this crappy code base. I will not accept that there is no way to do it, I've
>put too much into learning C to have the rug pulled out from underneath me!! If
>anyone can help me I'll appreciate it otherwise I'm giving C away for a code
>base that can do the job. like BASIC!!! (insults intended)
Kez404, please don't come here and badmouth the language in which we
program. Most of us here have no problems with C (appart from the
difficulties in learning the intricasies of this language). In fact,
we love it.
The problem of coloured text in C programs is not impossible to
solve. There are perfectly simple ways to achiev this goal. However,
such things are dependant on the system for which a program is
written. Standard C is designed to be useable on as many systems as
possible, some of which don't support coloured output. This means that
standard C cannot support such system specifics as colour.
If you'd like to ask your question again in a more apropriate group,
such as comp.os.msdos.programmer (if you're programming for DOS),
you're more likely to get a useful answer. Then you'll see how
powerful C can be.
--
----- Dig the EVEN NEWER, MORE IMPROVED news sig!! -----
-------------- Shaggy was here! ---------------
http://aardvark.apana.org.au/~phaywood/
============= Ain't I'm a dawg!! ==============
I suggest you have a look at this web page, especially if you are
working in DOS, if you are not working in DOS sorry for the bandwidth.
http://www.c-for-dummies.com/lessons/chapter.13/05/
Another thing if you are working in DOS, try Borlands Turbo C++ 3.0, it
has some video functions that will do what you want in C I believe. $89
will get you Borlands Turbo C++ suite, with C++ Builder, C++ 4.5 for
Windows and C==3.0 for DOS.
Best Regards
Bryn Joynes.......
Kez404 wrote:
>
> Well that's just grand isn't it, a language people claim to be the most
> powerful and flexible yet I can't do a simple thing like have coloured text.
--
To reply to my e-mail, remove the REMOVE from my e-mail address. Thank
You.
Bryn Joynes
Secondly I would like to thank Bryn for pointing me to a web page that helped
me.
*8)
Kieran Farrell
(observation here: i'd be able to grab this newsgroup 3 times faster
if 10 people didn't all flame the same post for being non-related to
the newsgroup).
All you have to worry about is using a terminal that supports ANSI
codes but then its not a writing C issue...its a finding a program
issue. So yes it does prove your point.....but it also offers a way
around the problem/question put forward....isn't that the purpose of
us all reading/posting these messages ?
Andy P Bretten - bre...@fuse.net
On Thu, 31 Dec 1998 09:58:28 GMT, "Charles LaCour" <cla...@cwix.com>
Andy & Deobrah Bretten wrote:
> (observation here: i'd be able to grab this newsgroup 3 times faster
> if 10 people didn't all flame the same post for being non-related to
> the newsgroup).
>
observation here - we're not all sitting in the same room. Duh. When I see a
new Bretten post, I have no idea who else out there - in the rest of the world
- might be crafting up an elegant and pithy flame for you, or who might have
already sent one that just hasn't shown up on my server yet. So we all see
ourselves as the first flame, and the multiples don't even show up until the
next day, usually. Would you prefer we sent the flames to your e-mail
account? Don't even go there.
>My point is though....you can write such a program in ANSI C without
>any portability problems.....assuming you can cope with the socket
>code, though that really kicks off another debate about writing C for
>unix or dos or windoze etc which I dont think anyone needs rehashed.
The point is that if you are writing socket code you aren't writing in
standard C, the code will not be portable.
--
-----------------------------------------
Lawrence Kirby | fr...@genesis.demon.co.uk
Wilts, England | 7073...@compuserve.com
-----------------------------------------
>My point is though....you can write such a program in ANSI C without
>any portability problems.....assuming you can cope with the socket
Well, yes. You won't have any problems compiling such a program. But
there's more to portability than compiling. The program just won't run
under all circumstances, and that's what makes it non-portable.