-struct commands {
- NCURSES_CONST char *text;
- void (*function) (WINDOW *);
-};
-typedef struct commands COMMAND;
-
-const COMMAND command[] =
-{
- {"Intro Test", introTest},
- {"Pad Test", padTest},
-#if defined(PDCURSES) && !defined(XCURSES)
- {"Resize Test", resizeTest},
-#endif
- {"Scroll Test", scrollTest},
- {"Input Test", inputTest},
- {"Output Test", outputTest}
-};
-#define MAX_OPTIONS ((sizeof(command)/sizeof(command[0])))
-
-int width, height;
-
-int
-main(
- int argc GCC_UNUSED,
- char *argv[]GCC_UNUSED)
-{
- WINDOW *win;
- int key, old_option = (-1), new_option = 0;
- bool quit = FALSE;
-
-#ifdef PDCDEBUG
- PDC_debug("testcurs started\n");
-#endif
- if (!initTest(&win))
- return EXIT_FAILURE;
-
- erase();
- display_menu(old_option, new_option);
- while (1) {
-#ifdef A_COLOR
- if (has_colors()) {
- init_pair(1, COLOR_WHITE, COLOR_BLUE);
- wbkgd(win, COLOR_PAIR(1));
- } else
- wbkgd(win, A_REVERSE);
-#else
- wbkgd(win, A_REVERSE);
-#endif
- werase(win);
-
- noecho();
- keypad(stdscr, TRUE);
- raw();
- key = getch();
- 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:
- break;
- }
- if (quit == TRUE)
- break;
- }
-
- delwin(win);
-
- endwin();
-#ifdef XCURSES
- XCursesExit();
-#endif
- return EXIT_SUCCESS;
-}