curses question

DucharmeBL rld at drutx.ATT.COM
Sun Apr 10 04:07:11 AEST 1988


I am having trouble running the following section of code.  If this program is
compiled under the C compiler for System V, Release 2 it works correctly.  That
is, the test messages show up on the screen, the entering of a carriage return
causes the overlay message to print only wiping out the top message.  However,
if this segment is compiled under System V, Release 3.1 C compiler and curses
library, the carriage return after the printing of the test message is never
accepted.  Instead I must use getstr to observe the carriage return.  In
addition, when the second window is written, it also blanks out the lines under
the final three lines of msgw even though they have been cleared.  WHAT IS GOING
ON?  What changed between V-2 and V-3 in curses that would cause this problem.
In addition, how do I fix it?  I noticed that there is an overlay function in
the documentation, but I do not want to go back through a 35K line program
looking for all occurrances that will need modification.

If there are any ideas, please call or send a message to:

	Robert Ducharme
	ihnp4!drutx!rld
	(303)  538-4066

#include "curses.h"
WINDOW *msgw;

main(argc, argv, envp)
char **argv;
char **envp;
{
   char ps[20];

    /*
     * get home and options from environment
     */
    fflush(stdout);
    initscr();				/* Start up cursor package */
    msgw = newwin(4, 80, 0, 0);
    noecho();

    clearok(stdscr,TRUE);
    mvwaddstr(stdscr,0,0,"Test Message 1");
    mvwaddstr(stdscr,1,1,"Test MEssage 2");
    mvwaddstr(stdscr,2,2,"Test Message 3");
    mvwaddstr(stdscr,3,3,"Test Message 4");
    mvwaddstr(stdscr,4,4,"Test Message 5");
    wrefresh(stdscr);
    clearok(stdscr,FALSE);
    getstr(ps);
    msg("....  OVERWRITE MESSAGE  ....");
    echo();
    endwin();
}
/*
 * msg:
 *	Display a message at the top of the screen.
 */

static unsigned char msgbuf[BUFSIZ];

/*VARARGS1*/
msg(fmt, args)
char *fmt;
int args;
{
    doadd(fmt, &args);
    endmsg();
}

endmsg()
{
    /* Needed to track where we are for 5.0 (PC) curses */
    register int x, y;

    wmove(msgw, 0, 0);
    waddstr(msgw, msgbuf);
    getyx(msgw, y, x);
    wclrtobot(msgw);
    wmove(msgw, y, x);
    wrefresh(stdscr);
    clearok(msgw, FALSE);
    wrefresh(msgw);
}

doadd(fmt, args)
char *fmt;
int **args;
{
    static FILE junk;

    /*
     * Do the printf into buf
     */
    junk._flag = _IOWRT;  /* Under 3.0 IOUNK was IOSTRG */
    junk._file = _NFILE;
    junk._base = junk._ptr = &msgbuf[0];
    junk._cnt = 32767;
    _doprnt(fmt, args, &junk);
    putc('\0', &junk);
}



More information about the Comp.lang.c mailing list