Problem reading in function keys with curses
John W. DeBoskey
jwd at unx.sas.com
Fri Jul 13 19:53:37 AEST 1990
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 at 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 at sas.sas.com (w) rti.rti.org!sas!jwd (919) 677-8000 x6915
jwd at baggins.UUCP (h) mcnc.mcnc.org!baggins!jwd (919) 481-1057 (preferred)
More information about the Comp.unix.i386
mailing list