]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/test_add_wchstr.c
ncurses 5.9 - patch 20131110
[ncurses.git] / test / test_add_wchstr.c
index 1bca895573a9ae884519cf441e33232af5a13f4f..c509f0035ac55129d34ce3e2764620d7b9da2ada 100644 (file)
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_add_wchstr.c,v 1.17 2012/10/27 19:37:30 tom Exp $
+ * $Id: test_add_wchstr.c,v 1.20 2012/12/16 00:12:04 tom Exp $
  *
  * Demonstrate the waddwchstr() and wadd_wch functions.
  * Thomas Dickey - 2009/9/12
@@ -319,6 +319,15 @@ test_add_wchstr(int level)
        (void) cbreak();        /* take input chars one at a time, no wait for \n */
        (void) noecho();        /* don't echo input */
        keypad(stdscr, TRUE);
+
+       /*
+        * Show the characters added in color, to distinguish from those that
+        * are shifted.
+        */
+       if (has_colors()) {
+           start_color();
+           init_pair(1, COLOR_WHITE, COLOR_BLUE);
+       }
     }
 
     limit = LINES - 5;
@@ -352,13 +361,7 @@ test_add_wchstr(int level)
 
     doupdate();
 
-    /*
-     * Show the characters added in color, to distinguish from those that
-     * are shifted.
-     */
     if (has_colors()) {
-       start_color();
-       init_pair(1, COLOR_WHITE, COLOR_BLUE);
        wbkgdset(work, (chtype) (COLOR_PAIR(1) | ' '));
     }
 
@@ -368,11 +371,13 @@ test_add_wchstr(int level)
        case key_RECUR:
            test_add_wchstr(level + 1);
 
-           touchwin(look);
+           if (look)
+               touchwin(look);
            touchwin(work);
            touchwin(show);
 
-           wnoutrefresh(look);
+           if (look)
+               wnoutrefresh(look);
            wnoutrefresh(work);
            wnoutrefresh(show);
 
@@ -516,8 +521,8 @@ test_add_wchstr(int level)
            break;
        }
     }
+    delwin(show);
     if (level > 0) {
-       delwin(show);
        delwin(work);
        delwin(look);
     }