Bug in curses ( SunOS 4.0.3 )

George Pontis moldev!!geo at uunet.uu.net
Wed Dec 19 07:28:29 AEST 1990


The ATT version of curses ( /usr/5bin/cc ... -lcurses ) has an annoying
bug that makes it impossible to read a single ESCAPE key when keypad() is
set true. Calling keypad(win,TRUE) asks the curses package to interpret a
function or cursor control key, normally returned as an escape followed by
several printing characters. The interpreted result is a single integer
defined in curses.h, which makes keyboard handling straightforward.

However, when a single escape is typed the library routine waits forever
for more characters. It's supposed to just set a timer based on baud rate
and return the escape even if that's all that it has. After the next key
key press, both the escape and that next character are returned.

Anybody know of a workaround for this problem, or if it has been fixed in
releases after 4.0.3 ? Alternatively, are any of you aware of source for a
curses alternative ?

Demo program:

#include <stdio.h>
#include <ctype.h>
#include <curses.h>

main(argc, argv)
int	argc;
char	*argv[];
{
	int	c, cc;

	initscr();
	cbreak();
	noecho();
	scrollok(stdscr,TRUE);
	keypad(stdscr,TRUE);	/* Setting FALSE allows ESC to work	*/

	do {
		c = getch();
		cc = ( isprint(c) ? c : ' ' );
		printw("0x%x  %3d  %c\n", c, c, cc);
	} while ( c != 4 );

	endwin();
	exit(0);
}

---

Thanks again,
George
-- 
George Pontis ( geo at moldev.com )



More information about the Comp.sys.sun mailing list