Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!usc!snorkelwacker!paperboy!meissner From: meissner@osf.org (Michael Meissner) Newsgroups: comp.unix.questions Subject: Re: Curses and the arrow keys Message-ID: Date: 26 Aug 90 21:32:07 GMT References: <1990Aug24.175453.4310@irscscm.UUCP> Sender: news@OSF.ORG Organization: Open Software Foundation Lines: 54 In-reply-to: mlake@irscscm.UUCP's message of 24 Aug 90 17:54:53 GMT In article <1990Aug24.175453.4310@irscscm.UUCP> mlake@irscscm.UUCP (Marshall Lake) writes: | I am writing a program which will be taking advantage of curses. I am | trying to utilize the arrow keys and am confused (actually all of | curses confuses me). I am doing a getch () and if I get an ESCAPE I do | another getch (). If I addch () for each character I get (the ESCAPE | and the next character) then the cursor moves around properly on the | screen but the x/y coordinates in the window structure do not follow | suit. Curses is recognizing the arrow keys simply as regular | characters. Am I naive in thinking that curses is smart enough to | handle the arrow keys specially? Should I be moving the cursor | manually via the move function? If your curses is based on the System V.2 curses, it will have a 'keypad' function which turns on recognizing any arrow keys or function keys. Here is a copy of the documentation: NAME keypad - enable keypad SYNTAX keypad(win, bf) WINDOW *win; bool bf; DESCRIPTION This option enables the keypad of the user's terminal. If the keypad is enabled, pressing a function key (such as an arrow key) will return a single value representing the function key. For example, pressing the left arrow key results in the value KEY_LEFT being returned.. For more information see the Guide to Curses Screen-Handling. The routine is used to return the character. If the keypad is disabled, does not treat function keys as special keys and the program interprets the escape sequences itself. Keypad layout is terminal dependent; some terminals do not even have a keypad. SEE ALSO getch(3cur) Guide to Curses Screen-Handling Note that KEY_LEFT and friends will not fit in an ordinary character, so make sure getch's result is stored in an int. If your curses is still based on the Berkeley curses, you have my sympathies. This is one area where System V is better than BSD. -- Michael Meissner email: meissner@osf.org phone: 617-621-8861 Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142 Do apple growers tell their kids money doesn't grow on bushes?