ANSI C screen manipulation?

F

Fogus

I have written a portable chess program using ANSI C, however at the
moment my 'console' display is quite ugly. It currently uses rote
printfs to output a page at a time of the board as well as other
useful information. These pages simply scroll one after the other.
However, in reality a better solution would be to (at minimum) clear
the screen (or a portion thereof) before displaying the next page.
However, I want portability and therefore do not want to rely on
system calls or non-standard libs such as curses. Are there common
implementations available that I may have missed?

Thank you in advance.
-m
 
M

Mike Wahler

Fogus said:
I have written a portable chess program using ANSI C, however at the
moment my 'console' display is quite ugly. It currently uses rote
printfs to output a page at a time of the board as well as other
useful information. These pages simply scroll one after the other.
However, in reality a better solution would be to (at minimum) clear
the screen (or a portion thereof) before displaying the next page.
However, I want portability and therefore do not want to rely on
system calls or non-standard libs such as curses. Are there common
implementations available that I may have missed?

There are many implementations, all of which are platform-dependent.
Standard C does not have any inherent support for video displays,
or any other hardware device. You'll need a platform-specific
solution. If you intend to port the code, then isolate this part,
so it can be easily be replaced with code specific to the
other platforms.

-Mike
 
T

Thomas Matthews

Fogus said:
I have written a portable chess program using ANSI C, however at the
moment my 'console' display is quite ugly. It currently uses rote
printfs to output a page at a time of the board as well as other
useful information. These pages simply scroll one after the other.
However, in reality a better solution would be to (at minimum) clear
the screen (or a portion thereof) before displaying the next page.
However, I want portability and therefore do not want to rely on
system calls or non-standard libs such as curses. Are there common
implementations available that I may have missed?

Thank you in advance.
-m

There are no common functions for manipulating cursors or screens
since not every platform has a screen and those that do have
different methods for handling them.

You could build yourself a interface of functions available on
your target platforms. Create a library for each platform that
uses system specific features. Link in a different library
based upon the target platform.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
 
N

Nudge

I have written a portable chess program using ANSI C, however at
the moment my 'console' display is quite ugly. It currently uses
rote printfs to output a page at a time of the board as well as
other useful information. These pages simply scroll one after
the other. However, in reality a better solution would be to (at
minimum) clear the screen (or a portion thereof) before
displaying the next page. However, I want portability and
therefore do not want to rely on system calls or non-standard
libs such as curses. Are there common implementations available
that I may have missed?

Your question seems close to FAQ 19.4
http://www.eskimo.com/~scs/c-faq/q19.4.html
 
C

CBFalconer

Fogus said:
I have written a portable chess program using ANSI C, however at the
moment my 'console' display is quite ugly. It currently uses rote
printfs to output a page at a time of the board as well as other
useful information. These pages simply scroll one after the other.
However, in reality a better solution would be to (at minimum) clear
the screen (or a portion thereof) before displaying the next page.
However, I want portability and therefore do not want to rely on
system calls or non-standard libs such as curses. Are there common
implementations available that I may have missed?

Not in portable standard C. Congratulations on building a
portable system. You can now supply non-portable alternatives by
isolating those output routines in a file, and writing custom
replacements for particular systems.
 
M

Mike Wahler

I've always been interested in chess and computer chess
programs. May I see your code? (if it's very large, you could
post it on the web and send a link, or email me directly.)

If you'd rather not share it, I understand, and thanks anyway.

-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top