+ mvaddstr(0, 20, "Display of the ACS Character Set");
+ attroff(A_BOLD);
+ refresh();
+
+ n = show_1_acs(0, BOTH(ACS_ULCORNER));
+ n = show_1_acs(n, BOTH(ACS_URCORNER));
+ n = show_1_acs(n, BOTH(ACS_LLCORNER));
+ n = show_1_acs(n, BOTH(ACS_LRCORNER));
+
+ n = show_1_acs(n, BOTH(ACS_LTEE));
+ n = show_1_acs(n, BOTH(ACS_RTEE));
+ n = show_1_acs(n, BOTH(ACS_TTEE));
+ n = show_1_acs(n, BOTH(ACS_BTEE));
+
+ n = show_1_acs(n, BOTH(ACS_HLINE));
+ n = show_1_acs(n, BOTH(ACS_VLINE));
+
+ /*
+ * HPUX's ACS definitions are broken here. Just give up.
+ */
+#if !(defined(__hpux) && !defined(NCURSES_VERSION))
+ n = show_1_acs(n, BOTH(ACS_LARROW));
+ n = show_1_acs(n, BOTH(ACS_RARROW));
+ n = show_1_acs(n, BOTH(ACS_UARROW));
+ n = show_1_acs(n, BOTH(ACS_DARROW));
+
+ n = show_1_acs(n, BOTH(ACS_BLOCK));
+ n = show_1_acs(n, BOTH(ACS_BOARD));
+ n = show_1_acs(n, BOTH(ACS_LANTERN));
+ n = show_1_acs(n, BOTH(ACS_BULLET));
+ n = show_1_acs(n, BOTH(ACS_CKBOARD));
+ n = show_1_acs(n, BOTH(ACS_DEGREE));
+ n = show_1_acs(n, BOTH(ACS_DIAMOND));
+ n = show_1_acs(n, BOTH(ACS_PLMINUS));
+ n = show_1_acs(n, BOTH(ACS_PLUS));
+
+ n = show_1_acs(n, BOTH(ACS_GEQUAL));
+ n = show_1_acs(n, BOTH(ACS_NEQUAL));
+ n = show_1_acs(n, BOTH(ACS_LEQUAL));
+
+ n = show_1_acs(n, BOTH(ACS_STERLING));
+ n = show_1_acs(n, BOTH(ACS_PI));
+ n = show_1_acs(n, BOTH(ACS_S1));
+ n = show_1_acs(n, BOTH(ACS_S3));
+ n = show_1_acs(n, BOTH(ACS_S7));
+ n = show_1_acs(n, BOTH(ACS_S9));
+#endif
+}
+
+static void
+acs_display(void)
+{
+ int c = 'a';
+ char *term = getenv("TERM");
+ const char *pch_kludge = ((term != 0 && strstr(term, "linux"))
+ ? "p=PC, "
+ : "");
+
+ do {
+ switch (c) {
+ case CTRL('L'):
+ Repaint();
+ break;
+ case 'a':
+ show_acs_chars();
+ break;
+ case 'x':
+ show_box_chars();
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ show_upper_chars((unsigned) ((c - '0') * 32 + 128));
+ break;
+ case 'p':
+ show_pc_chars();
+ break;
+ default:
+ beep();
+ break;
+ }
+ mvprintw(LINES - 3, 0,
+ "Note: ANSI terminals may not display C1 characters.");
+ mvprintw(LINES - 2, 0,
+ "Select: a=ACS, x=box, %s0=C1, 1,2,3=GR characters, ESC=quit",
+ pch_kludge);
+ refresh();
+ } while (!isQuit(c = Getchar()));
+
+ Pause();
+ erase();
+ endwin();
+}
+
+#if USE_WIDEC_SUPPORT
+static cchar_t *
+merge_wide_attr(cchar_t *dst, 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;
+
+ *dst = *src;
+ if (count > 0) {
+ if ((wch = typeMalloc(wchar_t, count)) != 0) {
+ if (getcchar(src, wch, &ignore_attr, &ignore_pair, 0) != ERR) {
+ attr |= (ignore_attr & A_ALTCHARSET);
+ setcchar(dst, wch, attr, pair, 0);
+ }
+ free(wch);
+ }
+ }
+ return dst;
+}
+
+static void
+show_upper_widechars(int first, int repeat, int space, attr_t attr, short 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 = first; 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;
+
+ memset(&codes, 0, sizeof(codes));
+ codes[0] = code;
+ sprintf(tmp, "%3ld (0x%lx)", (long) code, (long) code);
+ mvprintw(row, col, "%*s: ", COLS / 4, tmp);
+ 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(space | A_REVERSE);
+ /*
+ * This could use add_wch(), but is done for comparison with the
+ * normal 'f' test (and to make a test-case for echo_wchar()).
+ * The screen will 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);
+ if (x >= col + (COLS / 2) - 2)
+ break;
+ } while (--count > 0);
+ }
+}
+
+static int
+show_1_wacs(int n, 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);
+ add_wchnstr(code, 1);
+ return n + 1;
+}
+
+#define MERGE_ATTR(wch) merge_wide_attr(&temp, wch, attr, pair)
+
+static void
+show_wacs_chars(attr_t attr, short 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, BOTH2(WACS_ULCORNER));
+ n = show_1_wacs(n, BOTH2(WACS_URCORNER));
+ n = show_1_wacs(n, BOTH2(WACS_LLCORNER));
+ n = show_1_wacs(n, BOTH2(WACS_LRCORNER));
+
+ n = show_1_wacs(n, BOTH2(WACS_LTEE));
+ n = show_1_wacs(n, BOTH2(WACS_RTEE));
+ n = show_1_wacs(n, BOTH2(WACS_TTEE));
+ n = show_1_wacs(n, BOTH2(WACS_BTEE));
+
+ n = show_1_wacs(n, BOTH2(WACS_HLINE));
+ n = show_1_wacs(n, BOTH2(WACS_VLINE));
+
+ n = show_1_wacs(n, BOTH2(WACS_LARROW));
+ n = show_1_wacs(n, BOTH2(WACS_RARROW));
+ n = show_1_wacs(n, BOTH2(WACS_UARROW));
+ n = show_1_wacs(n, BOTH2(WACS_DARROW));
+
+ n = show_1_wacs(n, BOTH2(WACS_BLOCK));
+ n = show_1_wacs(n, BOTH2(WACS_BOARD));
+ n = show_1_wacs(n, BOTH2(WACS_LANTERN));
+ n = show_1_wacs(n, BOTH2(WACS_BULLET));
+ n = show_1_wacs(n, BOTH2(WACS_CKBOARD));
+ n = show_1_wacs(n, BOTH2(WACS_DEGREE));
+ n = show_1_wacs(n, BOTH2(WACS_DIAMOND));
+ n = show_1_wacs(n, BOTH2(WACS_PLMINUS));
+ n = show_1_wacs(n, BOTH2(WACS_PLUS));
+
+#ifdef CURSES_WACS_ARRAY
+ n = show_1_wacs(n, BOTH2(WACS_GEQUAL));
+ n = show_1_wacs(n, BOTH2(WACS_NEQUAL));
+ n = show_1_wacs(n, BOTH2(WACS_LEQUAL));
+
+ n = show_1_wacs(n, BOTH2(WACS_STERLING));
+ n = show_1_wacs(n, BOTH2(WACS_PI));
+ n = show_1_wacs(n, BOTH2(WACS_S1));
+ n = show_1_wacs(n, BOTH2(WACS_S3));
+ n = show_1_wacs(n, BOTH2(WACS_S7));
+ n = show_1_wacs(n, BOTH2(WACS_S9));
+#endif
+}
+
+#undef MERGE_ATTR
+
+#define MERGE_ATTR(wch) merge_wide_attr(&temp, wch, attr, pair)
+
+static void
+show_wbox_chars(attr_t attr, short pair)
+{
+ cchar_t temp;
+
+ erase();
+ attron(A_BOLD);
+ mvaddstr(0, 20, "Display of the Wide-ACS Line-Drawing Set");
+ attroff(A_BOLD);
+ refresh();
+
+ attr_set(attr, pair, 0);
+ box_set(stdscr, 0, 0);
+ attr_set(A_NORMAL, 0, 0);
+ /* *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));
+ /* *INDENT-ON* */
+
+}
+
+#undef MERGE_ATTR
+
+static int
+show_2_wacs(int n, const char *name, const char *code, attr_t attr, short pair)
+{
+ const int height = 16;
+ int row = 2 + (n % height);
+ int col = (n / height) * COLS / 2;
+ char temp[80];
+
+ mvprintw(row, col, "%*s : ", COLS / 4, name);
+ attr_set(attr, pair, 0);
+ addstr(strcpy(temp, code));
+ attr_set(A_NORMAL, 0, 0);
+ return n + 1;
+}
+
+#define SHOW_UTF8(n, name, code) show_2_wacs(n, name, code, attr, pair)
+
+static void
+show_utf8_chars(attr_t attr, short pair)
+{
+ int n;
+
+ erase();
+ attron(A_BOLD);
+ mvaddstr(0, 20, "Display of the Wide-ACS Character Set");