]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/ncurses.c
ncurses 5.7 - patch 20090829
[ncurses.git] / test / ncurses.c
index f1bab0e2ba616318c5d02bbaa8764b9b38c9671c..42670c31438eb15bc5a5ce2889ed3f08c70b6387 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,7 +40,7 @@ AUTHOR
    Author: Eric S. Raymond <esr@snark.thyrsus.com> 1993
            Thomas E. Dickey (beginning revision 1.27 in 1996).
 
-$Id: ncurses.c,v 1.328 2008/09/13 18:56:02 tom Exp $
+$Id: ncurses.c,v 1.345 2009/08/29 20:24:57 tom Exp $
 
 ***************************************************************************/
 
@@ -232,7 +232,7 @@ wGetstring(WINDOW *win, char *buffer, int limit)
 
     echo();
     getyx(win, y0, x0);
-    wattrset(win, A_REVERSE);
+    (void) wattrset(win, A_REVERSE);
 
     x = (int) strlen(buffer);
     while (!done) {
@@ -318,6 +318,7 @@ make_narrow_text(wchar_t *target, const char *source)
     *target = 0;
 }
 
+#if USE_LIBPANEL
 static void
 make_fullwidth_digit(cchar_t *target, int digit)
 {
@@ -327,6 +328,7 @@ make_fullwidth_digit(cchar_t *target, int digit)
     source[1] = 0;
     setcchar(target, source, A_NORMAL, 0, 0);
 }
+#endif
 
 static int
 wGet_wchar(WINDOW *win, wint_t *result)
@@ -363,7 +365,7 @@ wGet_wstring(WINDOW *win, wchar_t *buffer, int limit)
 
     echo();
     getyx(win, y0, x0);
-    wattrset(win, A_REVERSE);
+    (void) wattrset(win, A_REVERSE);
 
     x = (int) wcslen(buffer);
     while (!done) {
@@ -483,7 +485,11 @@ ShellOut(bool message)
        addstr("Shelling out...");
     def_prog_mode();
     endwin();
+#ifdef __MINGW32__
+    system("cmd.exe");
+#else
     system("sh");
+#endif
     if (message)
        addstr("returned from shellout.\n");
     refresh();
@@ -569,8 +575,11 @@ mouse_decode(MEVENT const *ep)
  *
  ****************************************************************************/
 
+#define NUM_GETCH_FLAGS 256
+typedef bool GetchFlags[NUM_GETCH_FLAGS];
+
 static void
-setup_getch(WINDOW *win, bool flags[])
+setup_getch(WINDOW *win, GetchFlags flags)
 {
     keypad(win, flags['k']);   /* should be redundant, but for testing */
     meta(win, flags['m']);     /* force this to a known state */
@@ -581,7 +590,17 @@ setup_getch(WINDOW *win, bool flags[])
 }
 
 static void
-wgetch_help(WINDOW *win, bool flags[])
+init_getch(WINDOW *win, GetchFlags flags)
+{
+    memset(flags, FALSE, NUM_GETCH_FLAGS);
+    flags[UChar('k')] = (win == stdscr);
+    flags[UChar('m')] = TRUE;
+
+    setup_getch(win, flags);
+}
+
+static void
+wgetch_help(WINDOW *win, GetchFlags flags)
 {
     static const char *help[] =
     {
@@ -610,12 +629,12 @@ wgetch_help(WINDOW *win, bool flags[])
        int flg = ((strstr(help[n], "toggle") != 0)
                   && (flags[UChar(*help[n])] != FALSE));
        if (flg)
-           standout();
+           (void) standout();
        mvprintw(row, col, "%s", help[n]);
        if (col == 0)
            clrtoeol();
        if (flg)
-           standend();
+           (void) standend();
     }
     wrefresh(stdscr);
     wmove(win, y, x);
@@ -657,7 +676,7 @@ remember_boxes(unsigned level, WINDOW *txt_win, WINDOW *box_win)
 {
     unsigned need = (level + 1) * 2;
 
-    assert(level < COLS);
+    assert(level < (unsigned) COLS);
 
     if (winstack == 0) {
        len_winstack = 20;
@@ -731,13 +750,10 @@ wgetch_test(unsigned level, WINDOW *win, int delay)
     int first_y, first_x;
     int c;
     int incount = 0;
-    bool flags[256];
+    GetchFlags flags;
     bool blocking = (delay < 0);
 
-    memset(flags, FALSE, sizeof(flags));
-    flags[UChar('k')] = (win == stdscr);
-
-    setup_getch(win, flags);
+    init_getch(win, flags);
     wtimeout(win, delay);
     getyx(win, first_y, first_x);
 
@@ -835,12 +851,18 @@ wgetch_test(unsigned level, WINDOW *win, int delay)
                }
 #endif
                (void) waddstr(win, keyname(c));
-           } else if (c > 0x80) {
-               unsigned c2 = (unsigned) (c & 0x7f);
-               if (isprint(c2))
-                   (void) wprintw(win, "M-%c", UChar(c2));
-               else
+           } else if (c >= 0x80) {
+               unsigned c2 = (unsigned) c;
+#if !(defined(NCURSES_VERSION) || defined(_XOPEN_CURSES))
+               /* at least Solaris SVR4 curses breaks unctrl(128), etc. */
+               c2 &= 0x7f;
+#endif
+               if (isprint(c))
+                   (void) wprintw(win, "%c", UChar(c));
+               else if (c2 != UChar(c))
                    (void) wprintw(win, "M-%s", unctrl(c2));
+               else
+                   (void) wprintw(win, "%s", unctrl(c2));
                waddstr(win, " (high-half character)");
            } else {
                if (isprint(c))
@@ -854,6 +876,9 @@ wgetch_test(unsigned level, WINDOW *win, int delay)
     }
 
     wtimeout(win, -1);
+
+    if (!level)
+       init_getch(win, flags);
 }
 
 static int
@@ -905,6 +930,7 @@ getch_test(void)
     wgetch_test(0, stdscr, delay);
     forget_boxes();
     finish_getch_test();
+    slk_clear();
 }
 
 #if USE_WIDEC_SUPPORT
@@ -978,15 +1004,12 @@ wget_wch_test(unsigned level, WINDOW *win, int delay)
     int first_y, first_x;
     wint_t c;
     int incount = 0;
-    bool flags[256];
+    GetchFlags flags;
     bool blocking = (delay < 0);
     int y, x, code;
     char *temp;
 
-    memset(flags, FALSE, sizeof(flags));
-    flags[UChar('k')] = (win == stdscr);
-
-    setup_getch(win, flags);
+    init_getch(win, flags);
     wtimeout(win, delay);
     getyx(win, first_y, first_x);
 
@@ -1096,14 +1119,14 @@ wget_wch_test(unsigned level, WINDOW *win, int delay)
                    resize_wide_boxes(level, win);
                }
 #endif
-               (void) waddstr(win, key_name((wchar_t) c));
+               (void) waddstr(win, keyname((wchar_t) c));
            } else {
+               (void) waddstr(win, key_name((wchar_t) c));
                if (c < 256 && iscntrl(c)) {
-                   (void) wprintw(win, "%s (control character)", unctrl(c));
+                   (void) wprintw(win, " (control character)");
                } else {
-                   wchar_t c2 = (wchar_t) c;
-                   waddnwstr(win, &c2, 1);
-                   (void) wprintw(win, " = %#x (printable character)", (unsigned) c);
+                   (void) wprintw(win, " = %#x (printable character)",
+                                  (unsigned) c);
                }
            }
            wgetch_wrap(win, first_y);
@@ -1111,6 +1134,9 @@ wget_wch_test(unsigned level, WINDOW *win, int delay)
     }
 
     wtimeout(win, -1);
+
+    if (!level)
+       init_getch(win, flags);
 }
 
 static void
@@ -1122,6 +1148,7 @@ get_wch_test(void)
     wget_wch_test(0, stdscr, delay);
     forget_boxes();
     finish_getch_test();
+    slk_clear();
 }
 #endif
 
@@ -1331,7 +1358,7 @@ show_attr(int row, int skip, bool arrow, chtype attr, const char *name)
            addch(ch | attr);
        }
     } else {
-       attrset(attr);
+       (void) attrset(attr);
        addstr(attr_test_string);
        attroff(attr);
     }
@@ -1840,6 +1867,8 @@ show_color_name(int y, int x, int color, bool wide)
            width = 4;
        } else if (color >= 8) {
            sprintf(temp, "[%02d]", color);
+       } else if (color < 0) {
+           strcpy(temp, "default");
        } else {
            strcpy(temp, the_color_names[color]);
        }
@@ -1873,6 +1902,8 @@ color_legend(WINDOW *helpwin, bool wide)
              "  b/B     toggle bold off/on");
     mvwprintw(helpwin, row++, col,
              "  n/N     toggle text/number on/off");
+    mvwprintw(helpwin, row++, col,
+             "  r/R     toggle reverse on/off");
     mvwprintw(helpwin, row++, col,
              "  w/W     toggle width between 8/16 colors");
 #if USE_WIDEC_SUPPORT
@@ -1906,12 +1937,19 @@ color_test(void)
     bool done = FALSE;
     bool opt_acsc = FALSE;
     bool opt_bold = FALSE;
-    bool opt_wide = FALSE;
+    bool opt_revs = FALSE;
     bool opt_nums = FALSE;
+    bool opt_wide = FALSE;
     WINDOW *helpwin;
 
-    if (pairs_max > COLOR_PAIRS)
-       pairs_max = COLOR_PAIRS;
+    if (COLORS * COLORS == COLOR_PAIRS) {
+       int limit = (COLORS - min_colors) * (COLORS - min_colors);
+       if (pairs_max > limit)
+           pairs_max = limit;
+    } else {
+       if (pairs_max > COLOR_PAIRS)
+           pairs_max = COLOR_PAIRS;
+    }
 
     while (!done) {
        int shown = 0;
@@ -1926,12 +1964,14 @@ color_test(void)
            hello = "Hello";
            per_row = 8;
        }
+       per_row -= min_colors;
 
        row_limit = (pairs_max + per_row - 1) / per_row;
 
        move(0, 0);
-       (void) printw("There are %d color pairs and %d colors\n",
-                     pairs_max, COLORS);
+       (void) printw("There are %d color pairs and %d colors%s\n",
+                     pairs_max, COLORS,
+                     min_colors ? " besides 'default'" : "");
 
        clrtobot();
        (void) mvprintw(top + 1, 0,
@@ -1942,7 +1982,7 @@ color_test(void)
 
        /* show color names/numbers across the top */
        for (i = 0; i < per_row; i++)
-           show_color_name(top + 2, (i + 1) * width, i, opt_wide);
+           show_color_name(top + 2, (i + 1) * width, i + min_colors, opt_wide);
 
        /* show a grid of colors, with color names/ numbers on the left */
        for (i = (short) (base_row * per_row); i < pairs_max; i++) {
@@ -1950,9 +1990,11 @@ color_test(void)
            int col = (i % per_row + 1) * width;
            short pair = i;
 
+#define InxToFG(i) (short) ((i % (COLORS - min_colors)) + min_colors)
+#define InxToBG(i) (short) ((i / (COLORS - min_colors)) + min_colors)
            if (row >= 0 && move(row, col) != ERR) {
-               short fg = (short) (i % COLORS);
-               short bg = (short) (i / COLORS);
+               short fg = InxToFG(i);
+               short bg = InxToBG(i);
 
                init_pair(pair, fg, bg);
                attron((attr_t) COLOR_PAIR(pair));
@@ -1960,16 +2002,18 @@ color_test(void)
                    attron((attr_t) A_ALTCHARSET);
                if (opt_bold)
                    attron((attr_t) A_BOLD);
+               if (opt_revs)
+                   attron((attr_t) A_REVERSE);
 
                if (opt_nums) {
                    sprintf(numbered, "{%02X}", i);
                    hello = numbered;
                }
                printw("%-*.*s", width, width, hello);
-               attrset(A_NORMAL);
+               (void) attrset(A_NORMAL);
 
-               if ((i % per_row) == 0 && (i % COLORS) == 0) {
-                   show_color_name(row, 0, i / COLORS, opt_wide);
+               if ((i % per_row) == 0 && InxToFG(i) == min_colors) {
+                   show_color_name(row, 0, InxToBG(i), opt_wide);
                }
                ++shown;
            } else if (shown) {
@@ -1996,6 +2040,12 @@ color_test(void)
        case 'N':
            opt_nums = TRUE;
            break;
+       case 'r':
+           opt_revs = FALSE;
+           break;
+       case 'R':
+           opt_revs = TRUE;
+           break;
        case case_QUIT:
            done = TRUE;
            continue;
@@ -2073,7 +2123,7 @@ wide_color_test(void)
     int base_row = 0;
     int grid_top = top + 3;
     int page_size = (LINES - grid_top);
-    int pairs_max = COLOR_PAIRS;
+    int pairs_max = (unsigned short) (-1);
     int row_limit;
     int per_row;
     char numbered[80];
@@ -2081,12 +2131,22 @@ wide_color_test(void)
     bool done = FALSE;
     bool opt_acsc = FALSE;
     bool opt_bold = FALSE;
+    bool opt_revs = FALSE;
     bool opt_wide = FALSE;
     bool opt_nums = FALSE;
     bool opt_xchr = FALSE;
     wchar_t buffer[10];
     WINDOW *helpwin;
 
+    if (COLORS * COLORS == COLOR_PAIRS) {
+       int limit = (COLORS - min_colors) * (COLORS - min_colors);
+       if (pairs_max > limit)
+           pairs_max = limit;
+    } else {
+       if (pairs_max > COLOR_PAIRS)
+           pairs_max = COLOR_PAIRS;
+    }
+
     while (!done) {
        int shown = 0;
 
@@ -2100,6 +2160,8 @@ wide_color_test(void)
            hello = "Hello";
            per_row = 8;
        }
+       per_row -= min_colors;
+
        if (opt_xchr) {
            make_fullwidth_text(buffer, hello);
            width *= 2;
@@ -2111,8 +2173,9 @@ wide_color_test(void)
        row_limit = (pairs_max + per_row - 1) / per_row;
 
        move(0, 0);
-       (void) printw("There are %d color pairs and %d colors\n",
-                     pairs_max, COLORS);
+       (void) printw("There are %d color pairs and %d colors%s\n",
+                     pairs_max, COLORS,
+                     min_colors ? " besides 'default'" : "");
 
        clrtobot();
        (void) mvprintw(top + 1, 0,
@@ -2123,7 +2186,7 @@ wide_color_test(void)
 
        /* show color names/numbers across the top */
        for (i = 0; i < per_row; i++)
-           show_color_name(top + 2, (i + 1) * width, i, opt_wide);
+           show_color_name(top + 2, (i + 1) * width, i + min_colors, opt_wide);
 
        /* show a grid of colors, with color names/ numbers on the left */
        for (i = (base_row * per_row); i < pairs_max; i++) {
@@ -2132,12 +2195,14 @@ wide_color_test(void)
            short pair = (short) i;
 
            if (row >= 0 && move(row, col) != ERR) {
-               init_pair(pair, (short) (i % COLORS), (short) (i / COLORS));
+               init_pair(pair, InxToFG(i), InxToBG(i));
                color_set(pair, NULL);
                if (opt_acsc)
                    attr_on((attr_t) A_ALTCHARSET, NULL);
                if (opt_bold)
                    attr_on((attr_t) A_BOLD, NULL);
+               if (opt_revs)
+                   attr_on((attr_t) A_REVERSE, NULL);
 
                if (opt_nums) {
                    sprintf(numbered, "{%02X}", i);
@@ -2150,8 +2215,8 @@ wide_color_test(void)
                addnwstr(buffer, width);
                attr_set(A_NORMAL, 0, NULL);
 
-               if ((i % per_row) == 0 && (i % COLORS) == 0) {
-                   show_color_name(row, 0, i / COLORS, opt_wide);
+               if ((i % per_row) == 0 && InxToFG(i) == min_colors) {
+                   show_color_name(row, 0, InxToBG(i), opt_wide);
                }
                ++shown;
            } else if (shown) {
@@ -2178,6 +2243,12 @@ wide_color_test(void)
        case 'N':
            opt_nums = TRUE;
            break;
+       case 'r':
+           opt_revs = FALSE;
+           break;
+       case 'R':
+           opt_revs = TRUE;
+           break;
        case case_QUIT:
            done = TRUE;
            continue;
@@ -2324,9 +2395,9 @@ color_edit(void)
                     (i == current ? '>' : ' '),
                     (i < (int) SIZEOF(the_color_names)
                      ? the_color_names[i] : numeric));
-           attrset(COLOR_PAIR(i));
+           (void) attrset(COLOR_PAIR(i));
            addstr("        ");
-           attrset(A_NORMAL);
+           (void) attrset(A_NORMAL);
 
            color_content((short) i, &red, &green, &blue);
            addstr("   R = ");
@@ -2334,20 +2405,20 @@ color_edit(void)
                attron(A_STANDOUT);
            printw("%04d", red);
            if (current == i && field == 0)
-               attrset(A_NORMAL);
+               (void) attrset(A_NORMAL);
            addstr(", G = ");
            if (current == i && field == 1)
                attron(A_STANDOUT);
            printw("%04d", green);
            if (current == i && field == 1)
-               attrset(A_NORMAL);
+               (void) attrset(A_NORMAL);
            addstr(", B = ");
            if (current == i && field == 2)
                attron(A_STANDOUT);
            printw("%04d", blue);
            if (current == i && field == 2)
-               attrset(A_NORMAL);
-           attrset(A_NORMAL);
+               (void) attrset(A_NORMAL);
+           (void) attrset(A_NORMAL);
            printw(" ( %3d %3d %3d )",
                   scaled_rgb(red),
                   scaled_rgb(green),
@@ -2513,7 +2584,7 @@ slk_help(void)
 #if HAVE_SLK_COLOR
        ,"F/B        -- cycle through foreground/background colors"
 #endif
-       ,"ESC  -- return to main menu"
+       ,"ESC        -- return to main menu"
        ,""
        ,"Note: if activating the soft keys causes your terminal to scroll up"
        ,"one line, your terminal auto-scrolls when anything is written to the"
@@ -2802,6 +2873,7 @@ static struct {
 } attrs_to_cycle[] = {
     { A_NORMAL,                "normal" },
     { A_BOLD,          "bold" },
+    { A_BLINK,         "blink" },
     { A_REVERSE,       "reverse" },
     { A_UNDERLINE,     "underline" },
 };
@@ -2818,7 +2890,7 @@ cycle_attr(int ch, unsigned *at_code, chtype *attr)
            *at_code = 0;
        break;
     case 'V':
-       if (*at_code == 1)
+       if (*at_code == 0)
            *at_code = SIZEOF(attrs_to_cycle) - 1;
        else
            *at_code -= 1;
@@ -2902,7 +2974,7 @@ show_upper_chars(unsigned first, int repeat, attr_t attr, short pair)
        do {
            if (C1)
                nodelay(stdscr, TRUE);
-           echochar(code | attr | COLOR_PAIR(pair));
+           echochar(colored_chtype(code, attr, pair));
            if (C1) {
                /* (yes, this _is_ crude) */
                while ((reply = Getchar()) != ERR) {
@@ -2951,7 +3023,7 @@ show_pc_chars(int repeat, attr_t attr, short pair)
                 */
                break;
            default:
-               addch(code | A_ALTCHARSET | attr | COLOR_PAIR(pair));
+               addch(colored_chtype(code, A_ALTCHARSET | attr, pair));
                break;
            }
        } while (--count > 0);
@@ -2969,15 +3041,23 @@ show_box_chars(int repeat, attr_t attr, short pair)
     mvaddstr(0, 20, "Display of the ACS Line-Drawing Set");
     attroff(A_BOLD);
     refresh();
-    box(stdscr, 0, 0);
     /* *INDENT-OFF* */
-    mvhline(LINES / 2, 0,        ACS_HLINE | attr, COLS);
-    mvvline(0,         COLS / 2, ACS_VLINE | attr, LINES);
-    mvaddch(0,         COLS / 2, ACS_TTEE | attr);
-    mvaddch(LINES / 2, COLS / 2, ACS_PLUS | attr);
-    mvaddch(LINES - 1, COLS / 2, ACS_BTEE | attr);
-    mvaddch(LINES / 2, 0,        ACS_LTEE | attr);
-    mvaddch(LINES / 2, COLS - 1, ACS_RTEE | attr);
+    wborder(stdscr,
+           colored_chtype(ACS_VLINE,    attr, pair),
+           colored_chtype(ACS_VLINE,    attr, pair),
+            colored_chtype(ACS_HLINE,    attr, pair),
+           colored_chtype(ACS_HLINE,    attr, pair),
+           colored_chtype(ACS_ULCORNER, attr, pair),
+           colored_chtype(ACS_URCORNER, attr, pair),
+            colored_chtype(ACS_LLCORNER, attr, pair),
+           colored_chtype(ACS_LRCORNER, attr, pair));
+    mvhline(LINES / 2, 0,        colored_chtype(ACS_HLINE, attr, pair), COLS);
+    mvvline(0,         COLS / 2, colored_chtype(ACS_VLINE, attr, pair), LINES);
+    mvaddch(0,         COLS / 2, colored_chtype(ACS_TTEE,  attr, pair));
+    mvaddch(LINES / 2, COLS / 2, colored_chtype(ACS_PLUS,  attr, pair));
+    mvaddch(LINES - 1, COLS / 2, colored_chtype(ACS_BTEE,  attr, pair));
+    mvaddch(LINES / 2, 0,        colored_chtype(ACS_LTEE,  attr, pair));
+    mvaddch(LINES / 2, COLS - 1, colored_chtype(ACS_RTEE,  attr, pair));
     /* *INDENT-ON* */
 
 }
@@ -3002,7 +3082,7 @@ show_acs_chars(int repeat, attr_t attr, short pair)
 {
     int n;
 
-#define BOTH(name) #name, (name | attr | COLOR_PAIR(pair))
+#define BOTH(name) #name, colored_chtype(name, attr, pair)
 
     erase();
     attron(A_BOLD);
@@ -3161,21 +3241,18 @@ acs_display(void)
 static cchar_t *
 merge_wide_attr(cchar_t *dst, const cchar_t *src, attr_t attr, short pair)
 {
-    int count = getcchar(src, NULL, NULL, NULL, 0);
-    wchar_t *wch = 0;
-    attr_t ignore_attr;
-    short ignore_pair;
+    int count;
 
     *dst = *src;
-    if (count > 0) {
-       if ((wch = typeMalloc(wchar_t, (unsigned) count + 1)) != 0) {
-           if (getcchar(src, wch, &ignore_attr, &ignore_pair, 0) != ERR) {
-               attr |= (ignore_attr & A_ALTCHARSET);
-               setcchar(dst, wch, attr, pair, 0);
-           }
-           free(wch);
+    do {
+       TEST_CCHAR(src, count, {
+           attr |= (test_attrs & A_ALTCHARSET);
+           setcchar(dst, test_wch, attr, pair, NULL);
        }
-    }
+       , {
+           ;
+       });
+    } while (0);
     return dst;
 }
 
@@ -3212,7 +3289,7 @@ show_upper_widechars(int first, int repeat, int space, attr_t attr, short pair)
             * the display.
             */
            if (wcwidth(code) == 0)
-               addch(space | A_REVERSE);
+               addch(space | (A_REVERSE ^ attr) | COLOR_PAIR(pair));
            /*
             * This could use add_wch(), but is done for comparison with the
             * normal 'f' test (and to make a test-case for echo_wchar()).
@@ -3238,7 +3315,7 @@ show_1_wacs(int n, int repeat, const char *name, const cchar_t *code)
     int col = (n / height) * COLS / 2;
 
     mvprintw(row, col, "%*s : ", COLS / 4, name);
-    while (repeat-- >= 0) {
+    while (--repeat >= 0) {
        add_wch(code);
     }
     return n + 1;
@@ -3307,12 +3384,12 @@ show_wacs_chars(int repeat, attr_t attr, short pair)
 
 #undef MERGE_ATTR
 
-#define MERGE_ATTR(wch) merge_wide_attr(&temp, wch, attr, pair)
+#define MERGE_ATTR(n,wch) merge_wide_attr(&temp[n], wch, attr, pair)
 
 static void
 show_wbox_chars(int repeat, attr_t attr, short pair)
 {
-    cchar_t temp;
+    cchar_t temp[8];
 
     (void) repeat;
     erase();
@@ -3321,17 +3398,23 @@ show_wbox_chars(int repeat, attr_t attr, short pair)
     attroff(A_BOLD);
     refresh();
 
-    attr_set(attr, pair, 0);
-    box_set(stdscr, 0, 0);
-    attr_set(A_NORMAL, 0, 0);
+    wborder_set(stdscr,
+               MERGE_ATTR(0, WACS_VLINE),
+               MERGE_ATTR(1, WACS_VLINE),
+               MERGE_ATTR(2, WACS_HLINE),
+               MERGE_ATTR(3, WACS_HLINE),
+               MERGE_ATTR(4, WACS_ULCORNER),
+               MERGE_ATTR(5, WACS_URCORNER),
+               MERGE_ATTR(6, WACS_LLCORNER),
+               MERGE_ATTR(7, WACS_LRCORNER));
     /* *INDENT-OFF* */
-    mvhline_set(LINES / 2, 0,        MERGE_ATTR(WACS_HLINE), COLS);
-    mvvline_set(0,         COLS / 2, MERGE_ATTR(WACS_VLINE), LINES);
-    mvadd_wch(0,           COLS / 2, MERGE_ATTR(WACS_TTEE));
-    mvadd_wch(LINES / 2,   COLS / 2, MERGE_ATTR(WACS_PLUS));
-    mvadd_wch(LINES - 1,   COLS / 2, MERGE_ATTR(WACS_BTEE));
-    mvadd_wch(LINES / 2,   0,        MERGE_ATTR(WACS_LTEE));
-    mvadd_wch(LINES / 2,   COLS - 1, MERGE_ATTR(WACS_RTEE));
+    mvhline_set(LINES / 2, 0,        MERGE_ATTR(0, WACS_HLINE), COLS);
+    mvvline_set(0,         COLS / 2, MERGE_ATTR(0, WACS_VLINE), LINES);
+    mvadd_wch(0,           COLS / 2, MERGE_ATTR(0, WACS_TTEE));
+    mvadd_wch(LINES / 2,   COLS / 2, MERGE_ATTR(0, WACS_PLUS));
+    mvadd_wch(LINES - 1,   COLS / 2, MERGE_ATTR(0, WACS_BTEE));
+    mvadd_wch(LINES / 2,   0,        MERGE_ATTR(0, WACS_LTEE));
+    mvadd_wch(LINES / 2,   COLS - 1, MERGE_ATTR(0, WACS_RTEE));
     /* *INDENT-ON* */
 
 }
@@ -4954,7 +5037,7 @@ flushinp_test(WINDOW *win)
        wbkgd(subWin, COLOR_PAIR(2) | ' ');
     }
 #endif
-    wattrset(subWin, A_BOLD);
+    (void) wattrset(subWin, A_BOLD);
     box(subWin, ACS_VLINE, ACS_HLINE);
     mvwaddstr(subWin, 2, 1, "This is a subwindow");
     wrefresh(win);
@@ -5774,18 +5857,18 @@ overlap_test_1_attr(WINDOW *win, int flavor, int col)
 
     switch (flavor) {
     case 0:
-       wattrset(win, A_NORMAL);
+       (void) wattrset(win, A_NORMAL);
        break;
     case 1:
-       wattrset(win, A_BOLD);
+       (void) wattrset(win, A_BOLD);
        break;
     case 2:
        init_pair(cpair, COLOR_BLUE, COLOR_WHITE);
-       wattrset(win, COLOR_PAIR(cpair) | A_NORMAL);
+       (void) wattrset(win, COLOR_PAIR(cpair) | A_NORMAL);
        break;
     case 3:
        init_pair(cpair, COLOR_WHITE, COLOR_BLUE);
-       wattrset(win, COLOR_PAIR(cpair) | A_BOLD);
+       (void) wattrset(win, COLOR_PAIR(cpair) | A_BOLD);
        break;
     }
 }
@@ -5804,7 +5887,7 @@ overlap_test_2_attr(WINDOW *win, int flavor, int col)
        break;
     case 2:
        init_pair(cpair, COLOR_RED, COLOR_GREEN);
-       wbkgdset(win, ' ' | A_BLINK | COLOR_PAIR(cpair));
+       wbkgdset(win, colored_chtype(' ', A_BLINK, cpair));
        break;
     case 3:
        wbkgdset(win, ' ' | A_NORMAL);
@@ -5890,7 +5973,7 @@ overlap_help(int state, int flavors[OVERLAP_FLAVORS])
            break;
        }
        overlap_helpitem(state, item, msg);
-       wattrset(stdscr, A_NORMAL);
+       (void) wattrset(stdscr, A_NORMAL);
        wbkgdset(stdscr, ' ' | A_NORMAL);
     }
     move(LINES - 1, 0);
@@ -5915,7 +5998,7 @@ overlap_test_1(int flavor, int col, WINDOW *a, char fill)
 {
     overlap_test_1_attr(a, flavor, col);
     fillwin(a, fill);
-    wattrset(a, A_NORMAL);
+    (void) wattrset(a, A_NORMAL);
 }
 
 static void
@@ -6497,7 +6580,7 @@ main(int argc, char *argv[])
            min_colors = -1;
        }
 #if NCURSES_VERSION_PATCH >= 20000708
-       else if (assumed_colors)
+       if (assumed_colors)
            assume_default_colors(default_fg, default_bg);
 #endif
 #endif