Hello! My program use the Form library from Ncurses. It worked OK with ncurses 1.1.9g-8, but not with 1.1.9g-8.5. The form_driver() function return E_UNKNOWN_COMMAND result at any character symbols as argument. What's may be wrong?
This is source of the test program: /**************************************************************************** * * Forms test * ****************************************************************************/ #include ?form.h> #ifndef CTRL #define CTRL(x) ((x) ? 0x1f) #endif #define SIZEOF(table) (sizeof(table)/sizeof(table[0])) #define QUIT CTRL('Q') #define ESCAPE CTRL('[') #define BLANK ' ' /* this is the background character */ static FIELD *make_label(int frow, int fcol, char *label) { FIELD *f = new_field(1, strlen(label), frow, fcol, 0, 0); if (f) { set_field_buffer(f, 0, label); set_field_opts(f, field_opts(f) ? ~O_ACTIVE); } return(f); } static FIELD *make_field(int frow, int fcol, int rows, int cols) { FIELD *f = new_field(rows, cols, frow, fcol, 0, 0); if (f) set_field_back(f, A_UNDERLINE); return(f); } static void display_form(FORM *f) { WINDOW *w; int rows, cols; scale_form(f, ?rows, ?cols); if ((w =newwin(rows+2, cols+4, 0, 0)) != (WINDOW *)NULL) { set_form_win(f, w); set_form_sub(f, derwin(w, rows, cols, 1, 2)); box(w, 0, 0); keypad(w, TRUE); } if (post_form(f) != E_OK) wrefresh(w); } static void erase_form(FORM *f) { WINDOW *w = form_win(f); WINDOW *s = form_sub(f); unpost_form(f); werase(w); wrefresh(w); delwin(s); delwin(w); } static int form_virtualize(WINDOW *w) { static int mode = REQ_INS_MODE; int c = wgetch(w); switch(c) { case QUIT: case ESCAPE: return(MAX_FORM_COMMAND + 1); /* demo doesn't use these three, leave them in anyway as sample code */ case KEY_NPAGE: case CTRL('F'): return(REQ_NEXT_PAGE); case KEY_PPAGE: return(REQ_PREV_PAGE); case KEY_NEXT: case CTRL('N'): return(REQ_NEXT_FIELD); case KEY_PREVIOUS: case CTRL('P'): return(REQ_PREV_FIELD); case KEY_HOME: return(REQ_FIRST_FIELD); case KEY_END: case KEY_LL: return(REQ_LAST_FIELD); case CTRL('L'): return(REQ_LEFT_FIELD); case CTRL('R'): return(REQ_RIGHT_FIELD); case CTRL('U'): return(REQ_UP_FIELD); case CTRL('D'): return(REQ_DOWN_FIELD); case CTRL('W'): return(REQ_NEXT_WORD); case CTRL('B'): return(REQ_PREV_WORD); case CTRL('S'): return(REQ_BEG_FIELD); case CTRL('E'): return(REQ_END_FIELD); case KEY_LEFT: return(REQ_LEFT_CHAR); case KEY_RIGHT: return(REQ_RIGHT_CHAR); case KEY_UP: return(REQ_UP_CHAR); case KEY_DOWN: return(REQ_DOWN_CHAR); case CTRL('M'): return(REQ_NEW_LINE); case CTRL('I'): return(REQ_INS_CHAR); case CTRL('O'): return(REQ_INS_LINE); case CTRL('V'): return(REQ_DEL_CHAR); case CTRL('H'): case KEY_BACKSPACE: return(REQ_DEL_PREV); case CTRL('Y'): return(REQ_DEL_LINE); case CTRL('G'): return(REQ_DEL_WORD); case CTRL('C'): return(REQ_CLR_EOL); case CTRL('K'): return(REQ_CLR_EOF); case CTRL('X'): return(REQ_CLR_FIELD); case CTRL('A'): return(REQ_NEXT_CHOICE); case CTRL('Z'): return(REQ_PREV_CHOICE); case CTRL(']'): if (mode == REQ_INS_MODE) return(mode = REQ_OVL_MODE); else return(mode = REQ_INS_MODE); default: return(c); } } static int my_form_driver(FORM *form, int c) { if (c == (MAX_FORM_COMMAND + 1) ) // ?? form_driver(form, REQ_VALIDATION) == E_OK) return(TRUE); else { beep(); return(FALSE); } } void main(void) { WINDOW *w; FORM *form; FIELD *f[10]; int finished = 0, c; initscr(); keypad(stdscr, TRUE); nonl(); /* tell curses not to do NL->CR/NL on output */ cbreak(); /* take input chars one at a time, no wait for \n */ noecho(); /* don't echo input */ start_color(); refresh(); mvaddstr(10, 57, "Forms Entry Test"); move(18, 0); addstr("Defined form-traversal keys: ^Q/ESC- exit form\n"); addstr("^N -- go to next field ^P -- go to previous field\n"); addstr("Home -- go to first field End -- go to last field\n"); addstr("^L -- go to field to left ^R -- go to field to right\n"); addstr("^U -- move upward to field ^D -- move downward to field\n"); addstr("^W -- go to next word ^B -- go to previous word\n"); addstr("^S -- go to start of field ^E -- go to end of field\n"); addstr("^H -- delete previous char ^Y -- delete line\n"); addstr("^G -- delete current word ^C -- clear to end of line\n"); addstr("^K -- clear to end of field ^X -- clear field\n"); addstr("Arrow keys move within a field as you would expect."); refresh(); /* describe the form */ f[0] = make_label(0, 15, "Sample Form"); f[1] = make_label(2, 0, "Last Name"); f[2] = make_field(3, 0, 1, 18); f[3] = make_label(2, 20, "First Name"); f[4] = make_field(3, 20, 1, 12); f[5] = make_label(2, 34, "Middle Name"); f[6] = make_field(3, 34, 1, 12); f[7] = make_label(5, 0, "Comments"); f[8] = make_field(6, 0, 4, 46); f[9] = (FIELD *)NULL; form = new_form(f); display_form(form); w = form_win(form); raw(); while (!finished) { switch(form_driver(form, c = form_virtualize(w))) /* whith 'c' variable equal, for example, 'a', form_driver() return E_UNKNOWN_COMMAND instead E_OK */ { case E_OK: break; case E_UNKNOWN_COMMAND: finished = my_form_driver(form, c); break; default: beep(); break; } } erase_form(form); free_form(form); for (c = 0; f[c] != 0; c++) free_field(f[c]); noraw(); clear(); refresh(); endwin(); } -- Pavel Andreew Ekaterinburg Telegraf -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]