jwd@unx.sas.com (John W. DeBoskey) (07/13/90)
Hello Everyone: I've got a sample program that uses curses that doesn't work correctly (or at least the way I think it should). The value returned from the keypad() function is garbage, but it's consistant to within about x100. This I think is my problem which leads to the function key problem. They don't work. With the program below, I should be able to hit KEY_UP have the bell beep... but it doesn't.. Can someone point out why I can't get function keys to work? If anyone has any ideas, please send them to me at jwd@baggins.ral.nc.us and I'll summarize... PS: I'm running ISC 1.0.6 on a PS2 Model 80... It doesn't work on a vt100 logged in via a serial line either. /* Use cc ctest.c -o test -lcurses to make */ #include <curses.h> int main() { WINDOW *mwin; /* main menu window */ int cmd; /* incoming command char */ int rc; /* rc from functions */ initscr(); cbreak(); noecho(); /* box(stdscr,ACS_VLINE,ACS_HLINE); */ box(stdscr,0,0); wmove(stdscr,LINES-2,2); wprintw(stdscr, "%s Baud: %d", longname(), baudrate() ); wrefresh(stdscr); mwin = newwin(LINES-3,COLS-2,1,1); rc = -2; rc = keypad(stdscr,TRUE); /* returns a garbage value */ wmove(mwin,12,20); wprintw(mwin,"%x %d rc from keypad(): TRUE=%x",rc,rc,TRUE); wrefresh(mwin); cmd = ' '; while (cmd != 'q') { wmove(mwin,0,0); waddstr(mwin,"q-uit k-KEY_UP ? "); wrefresh(mwin); cmd = wgetch(mwin); /* Never returns a function key def */ wmove(mwin,1,0); wclrtoeol(mwin); switch (cmd) { case 'k': case KEY_UP: beep(); break; case 'q': break; default : wmove(mwin,1,0); wprintw(mwin, "%x command unknown", cmd); break; } } delwin(mwin); echo(); nocbreak(); endwin(); } -- jwd@sas.sas.com (w) rti.rti.org!sas!jwd (919) 677-8000 x6915 jwd@baggins.UUCP (h) mcnc.mcnc.org!baggins!jwd (919) 481-1057 (preferred)
cpcahil@virtech.uucp (Conor P. Cahill) (07/14/90)
In article <1990Jul13.095337.8429@unx.sas.com> jwd@unx.sas.com (John W. DeBoskey) writes: > mwin = newwin(LINES-3,COLS-2,1,1); > > rc = -2; rc = keypad(stdscr,TRUE); /* returns a garbage value */ ^^^^^^ > cmd = wgetch(mwin); /* Never returns a function key def */ If you want to do a wgetch(mwin) you need to do a keypad(mwin) -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc., uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170