+static int
+overlap_test(bool recur GCC_UNUSED)
+{
+ WINDOW *win1, *win2;
+ int ch;
+ int shift = 0, last_refresh = -1;
+ int state, flavor[OVERLAP_FLAVORS];
+
+ if ((win1 = make_overlap(0)) == 0) {
+ return ERR;
+ } else if ((win2 = make_overlap(1)) == 0) {
+ delwin(win1);
+ return ERR;
+ }
+
+ curs_set(0);
+ raw();
+ refresh();
+ move(0, 0);
+ printw("Test wnoutrefresh() for two overlapping windows:");
+
+ memset(flavor, 0, sizeof(flavor));
+ state = overlap_help(0, flavor);
+
+ while (!isQuit(ch = Getchar(), TRUE)) {
+ switch (ch) {
+ case 'a': /* refresh window A first, then B */
+ overlap_test_0(win1, win2);
+ break;
+
+ case 'b': /* refresh window B first, then A */
+ overlap_test_0(win2, win1);
+ break;
+
+ case 'c': /* fill window A so it's visible */
+ overlap_test_1(flavor[otBASE_fill], 0, win1, 'A');
+ break;
+
+ case 'd': /* fill window B so it's visible */
+ overlap_test_1(flavor[otBASE_fill], 1, win2, 'B');
+ break;
+
+ case 'e': /* cross test pattern in window A */
+ overlap_test_2(flavor[otBASE_draw], 0, win1, 'A');
+ break;
+
+ case 'f': /* cross test pattern in window A */
+ overlap_test_2(flavor[otBASE_draw], 1, win2, 'B');
+ break;
+
+ case 'g': /* clear window A */
+ overlap_test_3(win1);
+ break;
+
+ case 'h': /* clear window B */
+ overlap_test_3(win2);
+ break;
+
+ case 'i': /* overwrite A onto B */
+ overlap_test_4(flavor[otBASE_copy], win1, win2);
+ break;
+
+ case 'j': /* overwrite B onto A */
+ overlap_test_4(flavor[otBASE_copy], win2, win1);
+ break;
+
+ case CTRL('n'):
+ case KEY_DOWN:
+ state = overlap_help(state + 1, flavor);
+ break;
+
+ case CTRL('p'):
+ case KEY_UP:
+ state = overlap_help(state - 1, flavor);
+ break;
+
+ case ' ':
+ flavor[state] += 1;
+ state = overlap_help(state, flavor);
+ break;
+
+ case HELP_KEY_1:
+ state = overlap_help(state, flavor);
+ break;
+
+ case '<':
+ /* FALLTHRU */
+ case '>':
+ /* see below */
+ break;
+
+ default:
+ beep();
+ break;
+ }
+
+ switch (ch) {
+ case 'a':
+ /* FALLTHRU */
+ case 'b':
+ last_refresh = ch;
+ break;
+ case '<':
+ shift -= 2;
+ /* FALLTHRU */
+ case '>':
+ shift += 1;
+ if (move_overlap(shift, win1) != OK) {
+ flash();
+ shift += (ch == '>') ? -1 : 1;
+ } else if (last_refresh > 0) {
+ clear_overlap();
+ wnoutrefresh(stdscr);
+ if (last_refresh == 'a')
+ overlap_test_0(win1, win2);
+ else
+ overlap_test_0(win2, win1);
+ }
+ break;
+ default:
+ last_refresh = -1;
+ break;
+ }
+ }
+
+ delwin(win2);
+ delwin(win1);
+ erase();
+ exit_curses();
+ return OK;
+}
+
+#if USE_WIDEC_SUPPORT
+static void
+x_fillwin(WINDOW *win, wchar_t ch)
+{
+ int y, x;
+ int y1, x1;
+
+ getmaxyx(win, y1, x1);
+ x1 /= 2;
+ for (y = 0; y < y1; y++) {
+ wmove(win, y, 0);
+ for (x = 0; x < x1; x++)
+ waddnwstr(win, &ch, 1);
+ }
+}
+
+static void
+x_crosswin(WINDOW *win, wchar_t ch)
+{
+ int y, x;
+ int y1, x1;
+ int xw = 2;
+
+ getmaxyx(win, y1, x1);
+ for (y = 0; y < y1; y++) {
+ for (x = 0; x < x1; x += xw) {
+ if (InCross(x, y, x1, y1)) {
+ wmove(win, y, x);
+ waddnwstr(win, &ch, 1);
+ }
+ }
+ }
+}
+
+static void
+x_overlap_test_1(int flavor, int col, WINDOW *a, wchar_t fill)
+{
+ overlap_test_1_attr(a, flavor, col);
+ x_fillwin(a, fill);
+ (void) wattrset(a, A_NORMAL);
+}
+