Category : C++ Source Code
Archive   : CURSESP.ZIP
Filename : HINTS.TXT

 
Output of file : HINTS.TXT contained in archive : CURSESP.ZIP

HINTS for using this copy of pc curses.

Compiler
--------
BorlandC++ is recommended. I use this compiler to build this version
of PC curses. The C++ interface is also supported well. I check for
the macros __CPLUSPLUS__ in the header file curses.h

If your compiler is not from Borland then you have to define this
before the #include

Example:
#define __CPLUSPLUS__
#include "curses.h"

EGA/VGA modes
-------------
Different textmodes (lines number > 25, more columns etc ...) are not
supported directly by pc curses. However you are free to set the text
mode up using calls from your C library. BorlandC provides all the functions
to tailor the text mode. I have not tried this! just hope it will be OK.
The inform curses about the new dimensions by

COLS = number_of_columns;
LINES = number_of_lines;


Undestructive messages
-----------------------
This is an advanced feature you may want to do. You will sometime want
to display a message then redraw the window quickly. To avoid overhead you
can save the area to be overwritten away, display the message, wait for
the reaction from the user, then paste the saved buffer back instantly.

The two routines to use are :

int winch (WINDOW *win, int y, int x) read
void winsch(WINDOW *win, int y, int x, int c) write

However, these two routines are not working. I suspect that they
are buggy. I check the documentation of curses on UNIX and think
that they are not correct in PC curses. For the moment I provides
two routines until I get all the problems fixed.

int wgetatpos(WINDOW *win, int x, int y) read
void wputatpos(WINDOW *win, int x, int y, int c) write

Simply declare an integer array, save the text (to be overwritten)
into it. Then go on draw your message. Then later put the message
back character by character using winsch()

Problems affecting Novice users.
-------------------------------

- Your machine simply hang. This means your program corrupts the
memory of the system badly. This tend to happen when you use a bad
pointer returned by a library call. The solution is always to chech
for the NULL pointer. If it is NULL it is not OK, your program should
exits.

- Your window does not update (drawn). This is because you have forgot
to call wrefresh(WINDOW *win). Sometimes you draw at the last line in
the window and nothing shows up. Perhaps, you forget that lines start
from 0 and finish at lines - 1.

- Your call to subwin() returns NULL. This is becuse subwin() expected
the co-ordinates supplied to it to be absolute, in other words relative
to the screen, not the parent window.

- You like to have a nice background colour for you window but
as soon as you draw text, the text background destroys the window
background. To solve this you have to make the text background colour
the same as your window background colour.

Example:

wattrset(B_BLUE); // set the BLUE background
werase(win); // erase your window 'win'
wattrset(B_BLUE | F_GRAY); // set text bg = BLUE, fg = GREY
waddstr(win, 1, 1, "Hello"); // write a string out



  3 Responses to “Category : C++ Source Code
Archive   : CURSESP.ZIP
Filename : HINTS.TXT

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/