+/*
+ * Header/legend take up no more than 8 lines, leaving 16 lines on a 24-line
+ * display. If there are no repeats, we could normally display 16 lines of 64
+ * characters (1024 total). However, taking repeats and double-width cells
+ * into account, use 256 characters for the page.
+ */
+static void
+show_paged_widechars(int base,
+ int pagesize,
+ int repeat,
+ int space,
+ attr_t attr,
+ NCURSES_PAIRS_T pair)
+{
+ int first = base * pagesize;
+ int last = first + pagesize - 1;
+ int per_line = 16;
+ cchar_t temp;
+ wchar_t code;
+ wchar_t codes[10];
+
+ erase();
+ attron(A_BOLD);
+ MvPrintw(0, 20, "Display of Character Codes %#x to %#x", first, last);
+ attroff(A_BOLD);
+
+ for (code = (wchar_t) first; (int) code <= last; code++) {
+ int row = (2 + ((int) code - first) / per_line);
+ int col = 5 * ((int) code % per_line);
+ int count;
+
+ memset(&codes, 0, sizeof(codes));
+ codes[0] = code;
+ setcchar(&temp, codes, attr, pair, 0);
+ move(row, col);
+ if (wcwidth(code) == 0 && code != 0) {
+ AddCh((chtype) space |
+ (A_REVERSE ^ attr) |
+ (attr_t) COLOR_PAIR(pair));
+ }
+ add_wch(&temp);
+ for (count = 1; count < repeat; ++count) {
+ add_wch(&temp);
+ }
+ }
+}
+
+static void
+show_upper_widechars(int first, int repeat, int space, attr_t attr, NCURSES_PAIRS_T pair)
+{
+ cchar_t temp;
+ wchar_t code;
+ int last = first + 31;
+
+ erase();
+ attron(A_BOLD);
+ MvPrintw(0, 20, "Display of Character Codes %d to %d", first, last);
+ attroff(A_BOLD);
+
+ for (code = (wchar_t) first; (int) code <= last; code++) {
+ int row = 2 + ((code - first) % 16);
+ int col = ((code - first) / 16) * COLS / 2;
+ wchar_t codes[10];
+ char tmp[80];
+ int count = repeat;
+ int y, x;
+
+ _nc_SPRINTF(tmp, _nc_SLIMIT(sizeof(tmp))
+ "%3ld (0x%lx)", (long) code, (long) code);
+ MvPrintw(row, col, "%*s: ", COLS / 4, tmp);
+
+ memset(&codes, 0, sizeof(codes));
+ codes[0] = code;
+ setcchar(&temp, codes, attr, pair, 0);
+
+ do {
+ /*
+ * Give non-spacing characters something to combine with. If we
+ * don't, they'll bunch up in a heap on the space after the ":".
+ * Mark them with reverse-video to make them simpler to find on
+ * the display.
+ */
+ if (wcwidth(code) == 0) {
+ AddCh((chtype) space |
+ (A_REVERSE ^ attr) |
+ (attr_t) COLOR_PAIR(pair));
+ }
+ /*
+ * This uses echo_wchar(), for comparison with the normal 'f'
+ * test (and to make a test-case for echo_wchar()). The screen
+ * may flicker because the erase() at the top of the function
+ * is met by the builtin refresh() in echo_wchar().
+ */
+ echo_wchar(&temp);
+ /*
+ * The repeat-count may make text wrap - avoid that.
+ */
+ getyx(stdscr, y, x);
+ (void) y;
+ if (x >= col + (COLS / 2) - 2)
+ break;
+ } while (--count > 0);
+ }
+}
+
+static int
+show_1_wacs(int n, int repeat, const char *name, const cchar_t *code)
+{
+ const int height = 16;
+ int row = 2 + (n % height);
+ int col = (n / height) * COLS / 2;
+
+ MvPrintw(row, col, "%*s : ", COLS / 4, name);
+ while (--repeat >= 0) {
+ add_wch(code);
+ }
+ return n + 1;
+}
+
+#define MERGE_ATTR(wch) merge_wide_attr(&temp, wch, attr, pair)
+
+static void
+show_wacs_chars(int repeat, attr_t attr, NCURSES_PAIRS_T pair)
+/* display the wide-ACS character set */
+{
+ cchar_t temp;
+
+ int n;
+
+/*#define BOTH2(name) #name, &(name) */
+#define BOTH2(name) #name, MERGE_ATTR(name)
+
+ erase();
+ attron(A_BOLD);
+ MvAddStr(0, 20, "Display of the Wide-ACS Character Set");
+ attroff(A_BOLD);
+ refresh();
+
+ n = show_1_wacs(0, repeat, BOTH2(WACS_ULCORNER));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_URCORNER));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_LLCORNER));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_LRCORNER));
+
+ n = show_1_wacs(n, repeat, BOTH2(WACS_LTEE));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_RTEE));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_TTEE));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_BTEE));
+
+ n = show_1_wacs(n, repeat, BOTH2(WACS_HLINE));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_VLINE));
+
+ n = show_1_wacs(n, repeat, BOTH2(WACS_LARROW));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_RARROW));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_UARROW));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_DARROW));
+
+ n = show_1_wacs(n, repeat, BOTH2(WACS_BLOCK));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_BOARD));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_LANTERN));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_BULLET));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_CKBOARD));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_DEGREE));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_DIAMOND));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_PLMINUS));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_PLUS));
+
+#ifdef CURSES_WACS_ARRAY
+ n = show_1_wacs(n, repeat, BOTH2(WACS_GEQUAL));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_NEQUAL));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_LEQUAL));
+
+ n = show_1_wacs(n, repeat, BOTH2(WACS_STERLING));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_PI));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_S1));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_S3));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_S7));
+ (void) show_1_wacs(n, repeat, BOTH2(WACS_S9));
+#endif
+}
+
+#ifdef WACS_D_PLUS