Path: utzoo!mnetor!uunet!husc6!mit-eddie!ll-xn!ames!pasteur!ucbvax!ulysses!cjc From: cjc@ulysses.homer.nj.att.com (Chris Calabrese[rs]) Newsgroups: comp.unix.questions Subject: Re: a question about using curses lib Message-ID: <10105@ulysses.homer.nj.att.com> Date: 22 Feb 88 16:45:07 GMT References: <7078@oberon.USC.EDU> <2931@sdsu.UUCP> Distribution: na Organization: AT&T Bell Laboratories, Murray Hill Lines: 43 Summary: Keypad, curses, terminfo In article <2931@sdsu.UUCP>, turtle@sdsu.UUCP (Andrew Scherpbier) writes: > In article <7078@oberon.USC.EDU> xwu@pollux.usc.edu (Xinhua Wu) writes: > >I'm writing a program using curses lib. I want to use function keys (eg, > >use arrow keys to choose from a menu). The program should work for different > > (I do not know if the following holds true for BSD 4.*, I only have access > to Xenix V.2 and SysV.3) > Yes, there is a function called `keypad()'. The call should look someting > like this: > keypad(stdscr,TRUE); /* the 'TRUE' is to enable keypad mode */ Keypad is a feature of the Terminfo terminal independant input and output database. Essentially the system keeps keyboard maps around so that various terminals will all map to one standard. Unfortunately, BSD unix does not have Terminfo, it has termcap instead, so it doesn't have keypad(). The way to get arround this is to assume that the arrow keys (and home keys, etc) return the same escape sequences as the corresponding screen functions. In other words, the up arrow probably returns the sequence which moves the cursor up, etc. These output codes are kept in the termcap database, and the termcap library can be used to bring them out and test for them. Of course, the above idea will not produce portable code, so you should include things like: #if _TermCap ... #else #if _TermInfo ... #endif #endif In the dependant code. Christopher Calabrese AT&T Bell Laboratories ulysses!cjc