+ setlocale(LC_ALL, "");
+
+ CATCHALL(trap);
+
+ initscr();
+ 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) {
+ endwin();
+ ExitProgram(EXIT_FAILURE);
+ }
+
+ while (1) {
+ 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;
+ strcpy(buffer, message);
+ while (j < NMESSAGES) {
+ while ((int) strlen(buffer) < w) {
+ strcat(buffer, " ... ");
+ strcat(buffer, messages[++j % NMESSAGES]);
+ }
+
+ if (i < w)
+ (void) mvwaddnstr(win, height / 2, w - i, buffer, i);
+ else
+ (void) mvwaddnstr(win, height / 2, 1, buffer, w);
+
+ wrefresh(win);
+ nodelay(win, TRUE);
+ if (wgetch(win) != ERR) {
+ flushinp();
+ break;
+ }
+ if (i++ >= w) {
+ for (k = 0; (buffer[k] = buffer[k + 1]) != '\0'; k++) ;
+ }
+ delay_output(100);
+ }
+
+ j = 0;
+ /* Draw running As across in RED */
+ set_colors(win, 7, COLOR_RED, COLOR_GREEN);
+ memset(save, ' ', sizeof(save));
+ for (i = 2; i < width - 4; ++i) {
+ k = (int) mvwinch(win, 4, i);
+ if (k == ERR)
+ break;
+ save[j++] = c = (chtype) k;
+ c &= A_CHARTEXT;
+ MvWAddCh(win, 4, i, c);
+ }
+ wrefresh(win);
+
+ /* Put a message up wait for a key */
+ i = height - 2;
+ use_colors(win, 5, A_NORMAL);
+ MvWAddStr(win, i, 5, " Type a key to continue or 'Q' to quit ");
+ wrefresh(win);
+
+ if (WaitForUser(win) == 1)
+ break;
+
+ j = 0; /* Restore the old line */
+ for (i = 2; i < width - 4; ++i)
+ MvWAddCh(win, 4, i, save[j++]);
+ wrefresh(win);
+
+ BouncingBalls(win);
+ /* Put a message up wait for a key */
+ i = height - 2;
+ use_colors(win, 5, A_NORMAL);
+ MvWAddStr(win, i, 5, " Type a key to continue or 'Q' to quit ");
+ wrefresh(win);
+ if (WaitForUser(win) == 1)
+ break;
+ }