Path: utzoo!attcan!uunet!pdn!boake2!jc3b21!larry From: larry@jc3b21.UUCP (Lawrence F. Strickland) Newsgroups: comp.lang.c Subject: Re: Using arrow keys with curses. Message-ID: <412@jc3b21.UUCP> Date: 14 Jun 88 11:28:23 GMT References: <1162@mcgill-vision.UUCP> Distribution: na Organization: St. Petersburg Jr. College, FL Lines: 39 From article <1162@mcgill-vision.UUCP>, by mouse@mcgill-vision.UUCP (der Mouse): > In article <485@cieunix.rpi.edu>, curt@cieunix.rpi.edu (Curt Signorino) writes: >> I've also been trying to access the arrow keys with curses, but >> haven't quite got the hang of it. What I'd had in mind was doing a > > Arrow keys generally send multi-character sequences; doing just one > getchar() will get just one character. You'd need to look up the Of course, it goes without saying that if you are using System V.2.0.4 or later, curses comes with a routine (wgetch) that picks up these as 'extended' key codes (KEY_UP, etc). However, if you use BSD 4.2 routines or if you use XENIX (SCO style) or other earlier systems, this doesn't work. I use most of the above at one time or another during the day, so I came up with a set of functions (getkeys and wgetch) that could be linked with your program to simulate the latter curses. It uses the same key definitions so that it is compatible with curses and works with the various versions of SCO XENIX as well (these were the HARDEST to get to work!) Unfortunately, the algorithm I use is somewhat slow and with slower processors (notably the AT&T 3b2/300) it is prone to lose characters occasionally. In my defense, so is vi in the same circumstances. On faster processors, I've had little trouble. The same routine(s) were installed in Micro-EMACS 3.9e to make a version that works with curses/termcap/terminfo instead of against it so that cursor control and function control keys will work under UNIX. If anyone is interested, I could probably post the routines to comp.sources.misc or alt.sources or whatever. Please let me know. They are fairly short. -l -- +--------------------------------------+-- St. Petersburg Junior College --+ | Lawrence F. Strickland | P.O. Box 13489 | | ...gatech!codas!usfvax2!jc3b21!larry | St. Petersburg, FL 33733 | +-(or) ...gatech!usfvax2!jc3b21!larry -+-- Phone: +1 813 341 4705 ---------+