Trouble with curses

Donald Yuniskis akcs.dgy at vpnet.chi.il.us
Mon Oct 29 13:55:03 AEST 1990


>Basically what is happening is the the user presses ESCAPE key follow by 
>'E' key to exit. But I have to press 'E' twice after pressing ESCAPE 
>to get an exit. I can't figure out why. Does anybody know ?

most "magic buttons" (function keys, etc) send an escape sequence.  curses
tries to build these escape sequences into special "KEY_" (see curses.h)
codes to make you life easier (:->).  to do this, when an ESC is received,
curses starts a nominal one second timer.  if other keys come in before this
timer expires, curses tries to combine them into a recognized escape
sequence which is then reduced to a "KEY_" constant and propagated through
the getch() mechanism.  Presumably, this process only is acive when you
have enabled keypad() mode.  Suggestions:  try a pause after the ESC to
verify this is the mechanism which is hosing you.  A work around is to
use a "non-escape" sequence (the ESC key is frowned upon even tho' _everyone_
uses it!) or, try to find a "KEY_" code which may be supported by the
variety of terminals you intend to support and code _that_ as the "ESC e"
you are trying to use (if ((ch = getch()) == KEY_?????) ....)
also, may wish to explicitly disable keypad() mode...
(are we having fun yet??)



More information about the Comp.lang.c mailing list