This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Colors in a console

 
Joshua Austin
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to make a BBS door game, and I need to make the text display localy as well as through the existing bbs connection.
My question applys to displaying text locally (in a console, not in a gui). How do I change the color of the text that is displayed? Also, how do I change the location on the screen that the text is displayed to?
I have done some searching(google.com), and so far the only examples I can find are in a gui app.
 
John Dale
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This can be done in DOS/Windows using ANSI.SYS. I'm sure you'll find plenty to wade through in google about the escape sequences to specify colors, etc. Since config.sys is not so widely used today, it may not be so obvious how to install it. But I did spot this: http://www.nthelp.com/40/ansiNT.htm
 
Joshua Austin
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so there is no real way to have it automaticly do color without the end user having to do all this stuff to load ansi.sys?
 
John Dale
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There only thing I recall for DOS windows. The APIs I recall for supporting color in DOS windows required ANSI.SYS, I think. (Installing it on DOS or Win95 systems was routine. But I don't know about anything more recent.) Of course, if your console is some terminal emulator instead of a DOS window, it probably supports color escape directly. See the program documentation. You can buy terminal emulators. I suspect there are some good free ones as well.
 
Joshua Austin
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am just printing to whatever the standard console is (using System.out.print) . Weather the console supports ANSI codes depends on what the end user is using to run the program. Its kind of hard to make an installer that does ansi.sys, considering the door game (written in java) will be run under linux, and other OSs' as well, which probably dont use ansi.sys, and may or may not allow ANSI codes.
[ September 09, 2002: Message edited by: Joshua Austin ]
[ September 09, 2002: Message edited by: Joshua Austin ]
 
John Dale
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I recall, the ANSI codes supported by ANSI.SYS are supported by the terminal emulators often used for accessing Unix systems. Perhaps some Unix/Linux user can tell you whether their consoles are typically set up this way.
But, as you observe, it is a pain now, at least on the windows side. It was even a pain back when it was routine, and worse now that it isn't commonly used, at least in the Windows world.
However, among the last widespread consumer (as opposed to business) users of this stuff may be (or have been) the BBS community, so you may find your BBS users are already set up for this. Perhaps you should try to find a older BBS techie. Maybe there are BBS's about BBS technology. :-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic