-int
-main(
- int argc GCC_UNUSED,
- char *argv[]GCC_UNUSED)
-{
- WINDOW *win;
- int key;
- int old_option = (-1);
- int new_option = 0;
- bool quit = FALSE;
- int n;
-
- setlocale(LC_ALL, "");
-
-#ifdef PDCDEBUG
- PDC_debug("testcurs started\n");
-#endif
- if (!initTest(&win))
- ExitProgram(EXIT_FAILURE);
-
- erase();
- display_menu(old_option, new_option);
- for (;;) {
-#ifdef A_COLOR
- if (has_colors()) {
- init_pair(1, COLOR_WHITE, COLOR_BLUE);
- wbkgd(win, (chtype) COLOR_PAIR(1));
- } else
- wbkgd(win, A_REVERSE);
-#else
- wbkgd(win, A_REVERSE);
-#endif
- werase(win);
-
- noecho();
- keypad(stdscr, TRUE);
- raw();
- key = getch();
- if (key < KEY_MIN && key > 0 && isalpha(key)) {
- if (islower(key))
- key = toupper(key);
- for (n = 0; n < MAX_OPTIONS; ++n) {
- if (key == command[n].text[0]) {
- display_menu(old_option, new_option = n);
- key = ' ';
- break;
- }
- }
- }
- switch (key) {
- case 10:
- case 13:
- case KEY_ENTER:
- erase();
- refresh();
- (*command[new_option].function) (win);
- erase();
- display_menu(old_option, new_option);
- break;
- case KEY_UP:
- new_option = ((new_option == 0)
- ? new_option
- : new_option - 1);
- display_menu(old_option, new_option);
- break;
- case KEY_DOWN:
- new_option = ((new_option == (MAX_OPTIONS - 1))
- ? new_option
- : new_option + 1);
- display_menu(old_option, new_option);
- break;
- case 'Q':
- case 'q':
- quit = TRUE;
- break;
- default:
- beep();
- break;
- case ' ':
- break;
- }
- if (quit == TRUE)
- break;
- }
-
- delwin(win);
-
- endwin();
-#ifdef XCURSES
- XCursesExit();
-#endif
- ExitProgram(EXIT_SUCCESS);
-}
-