+ setlocale(LC_ALL, "");
+
+ InitAndCatch(initscr(), trap);
+ if (has_colors())
+ start_color();
+ cbreak();
+ curs_set(0);
+ width = 48;
+ height = 14; /* Create a drawing window */
+ win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2);
+ if (win == NULL) {
+ stop_curses();
+ ExitProgram(EXIT_FAILURE);
+ }
+
+ while (1) {
+ int w;
+ int j;
+ chtype c;
+ const char *message;
+
+ set_colors(win, 1, COLOR_WHITE, COLOR_BLUE);
+ werase(win);
+
+ set_colors(win, 2, COLOR_RED, COLOR_RED);
+ box(win, ACS_VLINE, ACS_HLINE);
+ wrefresh(win);
+ /* Do ramdom output of a character */
+ use_colors(win, 1, A_NORMAL);
+ c = 'a';
+ for (i = 0; i < 5000; ++i) {
+ x = rand() % (width - 2) + 1;
+ y = rand() % (height - 2) + 1;
+ MvWAddCh(win, y, x, c);
+ wrefresh(win);
+ nodelay(win, TRUE);
+ if (wgetch(win) != ERR)
+ break;
+ if (i == 2000) {
+ c = 'b';
+ set_colors(win, 3, COLOR_CYAN, COLOR_YELLOW);
+ }
+ }
+
+ SubWinTest(win);
+ /* Erase and draw green window */
+ set_colors(win, 4, COLOR_YELLOW, COLOR_GREEN);
+ wbkgd(win, use_colors(win, 4, A_BOLD));
+ werase(win);
+ wrefresh(win);
+ /* Draw RED bounding box */
+ use_colors(win, 2, A_NORMAL);
+ box(win, ' ', ' ');
+ wrefresh(win);
+ /* Display Australia map */
+ use_colors(win, 4, A_BOLD);
+ i = 0;
+ while (*AusMap[i]) {
+ MvWAddStr(win, i + 1, 8, AusMap[i]);
+ wrefresh(win);
+ delay_output(50);
+ ++i;
+ }
+
+ set_colors(win, 5, COLOR_BLUE, COLOR_WHITE);
+ use_colors(win, 5, A_BLINK);
+ MvWAddStr(win, height - 2, 6, " PDCurses 2.1 for DOS, OS/2 and Unix");
+ wrefresh(win);
+
+ /* Draw running messages */
+ set_colors(win, 6, COLOR_YELLOW, COLOR_WHITE);
+ message = messages[j = 0];
+ i = 1;
+ w = width - 2;
+ _nc_STRCPY(buffer, message, sizeof(buffer));
+ while (j < NMESSAGES) {
+ while ((int) strlen(buffer) < w) {
+ _nc_STRCAT(buffer, " ... ", sizeof(buffer));
+ _nc_STRCAT(buffer, messages[++j % NMESSAGES], sizeof(buffer));
+ }
+
+ if (i < w)
+ (void) mvwaddnstr(win, height / 2, w - i, buffer, i);
+ else
+ (void) mvwaddnstr(win, height / 2, 1, buffer, w);