TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [TCLUG:16879] (OT)Color Programminmg in C
Jonathan Kline wrote:
>
> Has any1 ever used C/c++ to code ANSI graphics? Like having colored
> output.... so maybe prices could be one color, warnings could be another?
No, I think I only did that in Pascal..
Like Dave said, you might want to use an intermediate library like
ncurses or s-lang to make the job a little easier, but I don't think it
would be too difficult to do it by hand (although some of the more
tricky stuff like drawing boxes would be implemented in those
libraries).
Probably one good way of handling just colored text would be to make a
color parsing function. BitchX, for example, will go through and look
for %'s in an input string. If you put in a %b, all the text after that
point will be marked as dark blue.
A couple of things to note -- If you start coding in straght ANSI, you
are forgetting about all of the other terminal types out there. Xterms,
for example, can understand ANSI, but they can also be resized, which
ANSI doesn't understand very well (or at least I don't think it does, as
BitchX appears to be mostly written to do ANSI, but it can't handle a
resized window very well..
On the other hand, doing straight ANSI codes will allow for the most
flexibility in what you want to do. I'm not sure that ncurses or s-lang
understand how to do _full_ ANSI color (which is pretty surprising --
it's just 16 foreground colors, 8 background, some blinking and possibly
underlining..)
--
_ _ _ _ _ ___ _ _ _ ___ _ _ __ Any fool can criticize,
/ \/ \(_)| ' // ._\ / - \(_)/ ./| ' /(__ condemn, & complain. And
\_||_/|_||_|_\\___/ \_-_/|_|\__\|_|_\ __) most do.
[ Mike Hicks | http://umn.edu/~hick0088/ | mailto:hick0088@umn.edu ]