delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/25/21:06:47

Comments: Authenticated sender is <mert0407 AT sable DOT ox DOT ac DOT uk>
From: "George Foot" <george DOT foot AT merton DOT oxford DOT ac DOT uk>
To: bhyde AT connectu DOT net
Date: Wed, 26 Aug 1998 02:04:36 +0000
MIME-Version: 1.0
Subject: Re: [help] Text Coloring
Reply-to: george DOT foot AT merton DOT oxford DOT ac DOT uk
CC: djgpp AT delorie DOT com
Message-Id: <E0zBU2C-0006Q8-00@sable.ox.ac.uk>

On 25 Aug 98 at 21:13, Blake Hyde wrote:

> HOw does one go about changing the text & background color in DJGPP?  I
> included the conio.h file, and used the textcolor(6); function, expecting
> to get the ugly type brown which is gotten in BASIC.  However, on execution
> of this statement, nothing discernible happened.  What gives?

What did you expect to happen?  It only affects text printed after 
you call it, using conio functions.  Example:

    #include <conio.h>
    
    int main (void)
    {
        textcolor(6);
        cputs ("This will be in the ugly brown colour.");
        return 0;
    }

I suspect that you're trying to use the conio function `textcolor'
in conjunction with non-conio output functions like `printf'.  The
interaction between the two is awkward -- they're not designed to
work together.  IIRC, if the screen scrolls with coloured text on
the bottom line, the newly created line will share those colours. 
You shouldn't rely on this to let you mix conio functions with other
output functions though -- and it should discourage you too, because
you can't rely on the `textcolor' function having no effect on other
output routines.  If you want colours, stick to conio functions (like
`cputs' and `cprintf'). 

PS: When you ask for help, as a courtesy please don't encrypt your
email address.  The newsgroup is linked to a mailing list, and my
email software doesn't understand ROT-13.  The amount of spam sent 
personally to my address is negligible, so I don't think there's a 
significant risk of spam when posting to comp.os.msdos.djgpp.

-- 
george DOT foot AT merton DOT oxford DOT ac DOT uk

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019