Teen Programmers Unite  
 

 

Return to forum top

console applicatons backround color

Posted by JACKsprat [send private reply] at January 08, 2002, 04:06:07 PM

Is it possible to change the screen from black to another color or the text from white to another color? Or are these types of applications only done in b/w?

Posted by gian [send private reply] at January 08, 2002, 04:56:12 PM

I'm not sure if you can do it from within an app, but clicking on the top left corner of a dos box, and going to "Properties".

This will give you a bunch of options...

Posted by DakeDesuDx [send private reply] at January 08, 2002, 05:20:04 PM

I think what JACKsprat was asking is how in a console app you change text and background colors... I _-THINK-_ you might use escapes of some kind... though I am not sure of what kind. I am pretty sure that is how you would do it in Perl.

Posted by DakeDesuDx [send private reply] at January 08, 2002, 05:22:30 PM

(/me reads the first thing gian said)
(/me realising scanning the posts for the most important stuff is not his apparent skill)

Yes you can do it in a console app... Lynx does it all the time, along with various other console apps. Otherwise how would all those really old ASCII games work? (where your main character, the enemies and even the walls are all ASCII characters.)

Posted by grandsnafu [send private reply] at January 08, 2002, 11:20:08 PM

ncurses (http://www.gnu.org/software/ncurses/ncurses.html or `man ncurses`) might help.

Posted by CViper [send private reply] at January 09, 2002, 07:49:33 AM

You might want to take a look at "conio.h"... i think it has a couple of functions:
void textbackground( int __newcolor );
void textcolor( int __newcolor );

i think theres a function for setting the background aswell, but didnt find it right now... (somthing like backgrndcolor() or whatever)

Posted by RootPrompt [send private reply] at January 11, 2002, 08:35:07 PM

I think ncurses would be a better choice than using the various functions declared within conio.h. The last time I used Cygwin, it came with ncurses ported to work with the Win32 console. A program written with ncurses would probably work on a wider range of platforms (Linux, BSD, UNIX, Win32, etc.) than one using the non-standard conio.h functions.

Al

Posted by DakeDesuDx [send private reply] at January 12, 2002, 05:53:09 PM

I would suggest statically linking in ncurses into the program, cause I am honestly not sure if the windows platform comes with ncurses... or you can distribute ncurses with your program. Just be careful when statically linking it... I am not sure if ncurses is GPL'd or not.

Posted by RootPrompt [send private reply] at January 12, 2002, 07:57:36 PM

According to their GNU project directory entry (http://www.gnu.org/gnulist/production/ncurses.html), ncurses is released under the MIT license. Legality issues might arise if it has to link to the Cygwin libraries, which I think are under the GPL (not the LGPL).

Al

Posted by buzgub [send private reply] at January 12, 2002, 10:02:15 PM

If you use a free copy of cygwin and haven't got a paid-for license you need to distribute your stuff under the GPL (if you distribute it, that is). You can keep it to yourself if you want to, then you don't need any license at all. Much easier.

Posted by taubz [send private reply] at January 13, 2002, 01:26:59 PM

Who among us has actually distributed their software? For learning purposes, the GPL and other licenses don't mean a thing.

Posted by JACKsprat [send private reply] at January 14, 2002, 08:05:10 AM

Howdy,

conio.h? I will at it. My reference sheet says its not standard, I guess I am not really supposed to use it I guess. Is there a header that acts like conio.h that is standard?

thanks berry berry much for all the info dudes.

Posted by Psion [send private reply] at January 14, 2002, 08:44:28 AM

There are no standard C libraries that involve color in the least. Do you want C to only compile on machines with color displays?

Posted by DakeDesuDx [send private reply] at January 15, 2002, 05:26:44 PM

Well, I guess licensing is not an issue at this point, I just like to keep that in mind, so that I do not get too attached to something, if I ever get good enough to get an actual job.

As for nonstandard C libraries, you can use them. I use the reasoning that DirectX is not really standard C library in the way that ANSI has not bestowed there blessing on it, and it is used a lot. If you say it is standard based on, its on every M$ Windows 9x/2k/ME/NT OS, I will say ncurses, or some varient is on most *n?x box, it is not a bickering match I would like to get into though.
If displaying colour is a problem, I am sure you can either probe(correct term, please?) their monitor, or simply ask them if they want it in colour, or black and white, with black and white as the default. Similar to how some Linux Distros install.

(I prolly should not argue with the ops. They prolly know more than me)

Posted by CViper [send private reply] at January 18, 2002, 01:52:45 PM

Just saw, that vc++ didnt support the functions i listed (i usually use vc++)...
havent done console applications for a while (anyway ones that use such stuff)

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.