1 /****************************************************************************
2 * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc. *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
27 ****************************************************************************/
28 /****************************************************************************
31 ncurses.c --- ncurses library exerciser
37 An interactive test module for the ncurses library.
40 Author: Eric S. Raymond <esr@snark.thyrsus.com> 1993
41 Thomas E. Dickey (beginning revision 1.27 in 1996).
43 $Id: ncurses.c,v 1.373 2012/07/21 17:40:21 tom Exp $
45 ***************************************************************************/
47 #include <test.priv.h>
50 #undef mvwdelch /* HPUX 11.23 macro will not compile */
54 #if HAVE_SYS_TIME_H && HAVE_SYS_TIME_SELECT
58 #include <sys/select.h>
74 #ifdef NCURSES_VERSION
76 #define NCURSES_CONST_PARAM const void
79 static unsigned save_trace = TRACE_ORDINARY | TRACE_ICALLS | TRACE_CALLS;
80 extern unsigned _nc_tracing;
85 #define NCURSES_CONST_PARAM char
87 #define mmask_t chtype /* not specified in XSI */
90 #ifdef CURSES_ACS_ARRAY
91 #define ACS_S3 (CURSES_ACS_ARRAY['p']) /* scan line 3 */
92 #define ACS_S7 (CURSES_ACS_ARRAY['r']) /* scan line 7 */
93 #define ACS_LEQUAL (CURSES_ACS_ARRAY['y']) /* less/equal */
94 #define ACS_GEQUAL (CURSES_ACS_ARRAY['z']) /* greater/equal */
95 #define ACS_PI (CURSES_ACS_ARRAY['{']) /* Pi */
96 #define ACS_NEQUAL (CURSES_ACS_ARRAY['|']) /* not equal */
97 #define ACS_STERLING (CURSES_ACS_ARRAY['}']) /* UK pound sign */
99 #define ACS_S3 (A_ALTCHARSET + 'p') /* scan line 3 */
100 #define ACS_S7 (A_ALTCHARSET + 'r') /* scan line 7 */
101 #define ACS_LEQUAL (A_ALTCHARSET + 'y') /* less/equal */
102 #define ACS_GEQUAL (A_ALTCHARSET + 'z') /* greater/equal */
103 #define ACS_PI (A_ALTCHARSET + '{') /* Pi */
104 #define ACS_NEQUAL (A_ALTCHARSET + '|') /* not equal */
105 #define ACS_STERLING (A_ALTCHARSET + '}') /* UK pound sign */
110 #ifdef CURSES_WACS_ARRAY
111 #define WACS_S3 (&(CURSES_WACS_ARRAY['p'])) /* scan line 3 */
112 #define WACS_S7 (&(CURSES_WACS_ARRAY['r'])) /* scan line 7 */
113 #define WACS_LEQUAL (&(CURSES_WACS_ARRAY['y'])) /* less/equal */
114 #define WACS_GEQUAL (&(CURSES_WACS_ARRAY['z'])) /* greater/equal */
115 #define WACS_PI (&(CURSES_WACS_ARRAY['{'])) /* Pi */
116 #define WACS_NEQUAL (&(CURSES_WACS_ARRAY['|'])) /* not equal */
117 #define WACS_STERLING (&(CURSES_WACS_ARRAY['}'])) /* UK pound sign */
124 #define count_wchars(src, len, state) wcsrtombs(0, &src, len, state)
125 #define trans_wchars(dst, src, len, state) wcsrtombs(dst, &src, len, state)
126 #define reset_wchars(state) init_mb(state)
127 #elif HAVE_WCSTOMBS && HAVE_MBTOWC && HAVE_MBLEN
128 #define count_wchars(src, len, state) wcstombs(0, src, len)
129 #define trans_wchars(dst, src, len, state) wcstombs(dst, src, len)
130 #define reset_wchars(state) IGNORE_RC(mblen(NULL, 0)), IGNORE_RC(mbtowc(NULL, NULL, 0))
135 #define count_mbytes(src, len, state) mbsrtowcs(0, &src, len, state)
136 #define trans_mbytes(dst, src, len, state) mbsrtowcs(dst, &src, len, state)
137 #define reset_mbytes(state) init_mb(state)
138 #elif HAVE_MBSTOWCS && HAVE_MBTOWC && HAVE_MBLEN
139 #define count_mbytes(src, len, state) mbstowcs(0, src, len)
140 #define trans_mbytes(dst, src, len, state) mbstowcs(dst, src, len)
141 #define reset_mbytes(state) IGNORE_RC(mblen(NULL, 0)), IGNORE_RC(mbtowc(NULL, NULL, 0))
145 #define ToggleAcs(temp,real) temp = ((temp == real) ? 0 : real)
147 #define P(string) printw("%s\n", string)
149 #define BLANK ' ' /* this is the background character */
152 static int max_colors; /* the actual number of colors we'll use */
153 static int min_colors; /* the minimum color code */
154 static bool use_colors; /* true if we use colors */
157 static int max_pairs; /* ...and the number of color pairs */
165 static RGB_DATA *all_colors;
167 static void main_menu(bool);
169 /* The behavior of mvhline, mvvline for negative/zero length is unspecified,
170 * though we can rely on negative x/y values to stop the macro.
173 do_h_line(int y, int x, chtype c, int to)
176 MvHLine(y, x, c, (to) - (x));
180 do_v_line(int y, int x, chtype c, int to)
183 MvVLine(y, x, c, (to) - (y));
197 return ((c) == QUIT || (c) == ESCAPE);
199 #define case_QUIT QUIT: case ESCAPE
201 /* Common function to allow ^T to toggle trace-mode in the middle of a test
202 * so that trace-files can be made smaller.
205 wGetchar(WINDOW *win)
209 while ((c = wgetch(win)) == CTRL('T')) {
211 save_trace = _nc_tracing;
212 Trace(("TOGGLE-TRACING OFF"));
215 _nc_tracing = save_trace;
219 Trace(("TOGGLE-TRACING ON"));
226 #define Getchar() wGetchar(stdscr)
228 /* replaces wgetnstr(), since we want to be able to edit values */
230 wGetstring(WINDOW *win, char *buffer, int limit)
237 (void) wattrset(win, A_REVERSE);
239 x = (int) strlen(buffer);
241 if (x > (int) strlen(buffer))
242 x = (int) strlen(buffer);
244 wprintw(win, "%-*s", limit, buffer);
245 wmove(win, y0, x0 + x);
246 switch (ch = wGetchar(win)) {
259 for (j = --x; (buffer[j] = buffer[j + 1]) != '\0'; ++j) {
277 if (!isprint(ch) || ch >= KEY_MIN) {
279 } else if ((int) strlen(buffer) < limit) {
281 for (j = (int) strlen(buffer) + 1; j > x; --j) {
282 buffer[j] = buffer[j - 1];
284 buffer[x++] = (char) ch;
291 wattroff(win, A_REVERSE);
296 #if USE_WIDEC_SUPPORT
300 return (ch + 0xff10 - '0');
304 make_fullwidth_text(wchar_t *target, const char *source)
307 while ((ch = *source++) != 0) {
308 *target++ = fullwidth_of(ch);
314 make_narrow_text(wchar_t *target, const char *source)
317 while ((ch = *source++) != 0) {
325 make_fullwidth_digit(cchar_t *target, int digit)
329 source[0] = fullwidth_of(digit + '0');
331 setcchar(target, source, A_NORMAL, 0, 0);
336 wGet_wchar(WINDOW *win, wint_t *result)
340 while ((c = wget_wch(win, result)) == CTRL('T')) {
342 save_trace = _nc_tracing;
343 Trace(("TOGGLE-TRACING OFF"));
346 _nc_tracing = save_trace;
350 Trace(("TOGGLE-TRACING ON"));
353 c = wget_wch(win, result);
357 #define Get_wchar(result) wGet_wchar(stdscr, result)
359 /* replaces wgetn_wstr(), since we want to be able to edit values */
361 wGet_wstring(WINDOW *win, wchar_t *buffer, int limit)
370 (void) wattrset(win, A_REVERSE);
372 x = (int) wcslen(buffer);
374 if (x > (int) wcslen(buffer))
375 x = (int) wcslen(buffer);
377 /* clear the "window' */
379 wprintw(win, "%*s", limit, " ");
381 /* write the existing buffer contents */
383 waddnwstr(win, buffer, limit);
385 /* positions the cursor past character 'x' */
387 waddnwstr(win, buffer, x);
389 switch (wGet_wchar(win, &ch)) {
429 for (j = --x; (buffer[j] = buffer[j + 1]) != '\0'; ++j) {
449 } else if ((int) wcslen(buffer) < limit) {
451 for (j = (int) wcslen(buffer) + 1; j > x; --j) {
452 buffer[j] = buffer[j - 1];
454 buffer[x++] = (wchar_t) ch;
461 wattroff(win, A_REVERSE);
472 addstr("Press any key to continue... ");
477 Cannot(const char *what)
479 printw("\nThis %s terminal %s\n\n", getenv("TERM"), what);
484 ShellOut(bool message)
487 addstr("Shelling out...");
493 IGNORE_RC(system("sh"));
496 addstr("returned from shellout.\n");
500 #ifdef NCURSES_MOUSE_VERSION
502 * This function is the same as _tracemouse(), but we cannot count on that
503 * being available in the non-debug library.
506 mouse_decode(MEVENT const *ep)
508 static char buf[80 + (5 * 10) + (32 * 15)];
510 (void) sprintf(buf, "id %2d at (%2d, %2d, %d) state %4lx = {",
511 ep->id, ep->x, ep->y, ep->z, (unsigned long) ep->bstate);
513 #define SHOW(m, s) if ((ep->bstate & m)==m) {strcat(buf,s); strcat(buf, ", ");}
515 SHOW(BUTTON1_RELEASED, "release-1");
516 SHOW(BUTTON1_PRESSED, "press-1");
517 SHOW(BUTTON1_CLICKED, "click-1");
518 SHOW(BUTTON1_DOUBLE_CLICKED, "doubleclick-1");
519 SHOW(BUTTON1_TRIPLE_CLICKED, "tripleclick-1");
520 #if NCURSES_MOUSE_VERSION == 1
521 SHOW(BUTTON1_RESERVED_EVENT, "reserved-1");
524 SHOW(BUTTON2_RELEASED, "release-2");
525 SHOW(BUTTON2_PRESSED, "press-2");
526 SHOW(BUTTON2_CLICKED, "click-2");
527 SHOW(BUTTON2_DOUBLE_CLICKED, "doubleclick-2");
528 SHOW(BUTTON2_TRIPLE_CLICKED, "tripleclick-2");
529 #if NCURSES_MOUSE_VERSION == 1
530 SHOW(BUTTON2_RESERVED_EVENT, "reserved-2");
533 SHOW(BUTTON3_RELEASED, "release-3");
534 SHOW(BUTTON3_PRESSED, "press-3");
535 SHOW(BUTTON3_CLICKED, "click-3");
536 SHOW(BUTTON3_DOUBLE_CLICKED, "doubleclick-3");
537 SHOW(BUTTON3_TRIPLE_CLICKED, "tripleclick-3");
538 #if NCURSES_MOUSE_VERSION == 1
539 SHOW(BUTTON3_RESERVED_EVENT, "reserved-3");
542 SHOW(BUTTON4_RELEASED, "release-4");
543 SHOW(BUTTON4_PRESSED, "press-4");
544 SHOW(BUTTON4_CLICKED, "click-4");
545 SHOW(BUTTON4_DOUBLE_CLICKED, "doubleclick-4");
546 SHOW(BUTTON4_TRIPLE_CLICKED, "tripleclick-4");
547 #if NCURSES_MOUSE_VERSION == 1
548 SHOW(BUTTON4_RESERVED_EVENT, "reserved-4");
551 #if NCURSES_MOUSE_VERSION == 2
552 SHOW(BUTTON5_RELEASED, "release-5");
553 SHOW(BUTTON5_PRESSED, "press-5");
554 SHOW(BUTTON5_CLICKED, "click-5");
555 SHOW(BUTTON5_DOUBLE_CLICKED, "doubleclick-5");
556 SHOW(BUTTON5_TRIPLE_CLICKED, "tripleclick-5");
559 SHOW(BUTTON_CTRL, "ctrl");
560 SHOW(BUTTON_SHIFT, "shift");
561 SHOW(BUTTON_ALT, "alt");
562 SHOW(ALL_MOUSE_EVENTS, "all-events");
563 SHOW(REPORT_MOUSE_POSITION, "position");
567 if (buf[strlen(buf) - 1] == ' ')
568 buf[strlen(buf) - 2] = '\0';
569 (void) strcat(buf, "}");
574 show_mouse(WINDOW *win)
582 outside = !wenclose(win, event.y, event.x);
585 (void) wstandout(win);
586 waddstr(win, "KEY_MOUSE");
587 (void) wstandend(win);
589 waddstr(win, "KEY_MOUSE");
591 wprintw(win, ", %s", mouse_decode(&event));
596 show_loc = wmouse_trafo(win, &event.y, &event.x, FALSE);
600 wmove(win, event.y, event.x);
608 #endif /* NCURSES_MOUSE_VERSION */
610 /****************************************************************************
612 * Character input test
614 ****************************************************************************/
616 #define NUM_GETCH_FLAGS 256
617 typedef bool GetchFlags[NUM_GETCH_FLAGS];
620 setup_getch(WINDOW *win, GetchFlags flags)
622 keypad(win, flags['k']); /* should be redundant, but for testing */
623 meta(win, flags['m']); /* force this to a known state */
631 init_getch(WINDOW *win, GetchFlags flags)
633 memset(flags, FALSE, NUM_GETCH_FLAGS);
634 flags[UChar('k')] = (win == stdscr);
635 flags[UChar('m')] = TRUE;
637 setup_getch(win, flags);
641 wgetch_help(WINDOW *win, GetchFlags flags)
643 static const char *help[] =
645 "e -- toggle echo mode"
646 ,"g -- triggers a getstr test"
647 ,"k -- toggle keypad/literal mode"
648 ,"m -- toggle meta (7-bit/8-bit) mode"
651 ,"w -- create a new window"
653 ,"z -- suspend this process"
657 unsigned chk = ((SIZEOF(help) + 1) / 2);
662 printw("Type any key to see its %s value. Also:\n",
663 flags['k'] ? "keypad" : "literal");
664 for (n = 0; n < SIZEOF(help); ++n) {
665 int row = 1 + (int) (n % chk);
666 int col = (n >= chk) ? COLS / 2 : 0;
667 int flg = ((strstr(help[n], "toggle") != 0)
668 && (flags[UChar(*help[n])] != FALSE));
671 MvPrintw(row, col, "%s", help[n]);
682 wgetch_wrap(WINDOW *win, int first_y)
684 int last_y = getmaxy(win) - 1;
685 int y = getcury(win) + 1;
693 #if defined(KEY_RESIZE) && HAVE_WRESIZE
699 static WINSTACK *winstack = 0;
700 static unsigned len_winstack = 0;
713 remember_boxes(unsigned level, WINDOW *txt_win, WINDOW *box_win)
715 unsigned need = (level + 1) * 2;
717 assert(level < (unsigned) COLS);
721 winstack = typeMalloc(WINSTACK, len_winstack);
722 } else if (need >= len_winstack) {
724 winstack = typeRealloc(WINSTACK, len_winstack, winstack);
726 winstack[level].text = txt_win;
727 winstack[level].frame = box_win;
730 #if USE_SOFTKEYS && (defined(NCURSES_VERSION_PATCH) && NCURSES_VERSION_PATCH < 20071229) && NCURSES_EXT_FUNCS
734 /* this chunk is now done in resize_term() */
741 #define slk_repaint() /* nothing */
744 #if defined(NCURSES_VERSION) && defined(KEY_RESIZE) && HAVE_WRESIZE
746 * For wgetch_test(), we create pairs of windows - one for a box, one for text.
747 * Resize both and paint the box in the parent.
750 resize_boxes(unsigned level, WINDOW *win)
754 int high = LINES - base;
758 wnoutrefresh(stdscr);
762 for (n = 0; n < level; ++n) {
763 wresize(winstack[n].frame, high, wide);
764 wresize(winstack[n].text, high - 2, wide - 2);
767 werase(winstack[n].text);
768 box(winstack[n].frame, 0, 0);
769 wnoutrefresh(winstack[n].frame);
770 wprintw(winstack[n].text,
772 getmaxy(winstack[n].text),
773 getmaxx(winstack[n].text));
774 wnoutrefresh(winstack[n].text);
775 if (winstack[n].text == win)
780 #endif /* resize_boxes */
782 #define forget_boxes() /* nothing */
783 #define remember_boxes(level,text,frame) /* nothing */
787 * Return-code is OK/ERR or a keyname.
792 return ((code == OK) ? "OK" : ((code == ERR) ? "ERR" : keyname(code)));
796 wgetch_test(unsigned level, WINDOW *win, int delay)
799 int first_y, first_x;
803 bool blocking = (delay < 0);
805 init_getch(win, flags);
806 wtimeout(win, delay);
807 getyx(win, first_y, first_x);
809 wgetch_help(win, flags);
810 wsetscrreg(win, first_y, getmaxy(win) - 1);
814 while ((c = wGetchar(win)) == ERR) {
817 (void) wprintw(win, "%05d: input error", incount);
820 (void) wprintw(win, "%05d: input timed out", incount);
822 wgetch_wrap(win, first_y);
824 if (c == ERR && blocking) {
826 wgetch_wrap(win, first_y);
827 } else if (isQuit(c)) {
829 } else if (c == 'e') {
830 flags[UChar('e')] = !flags[UChar('e')];
831 setup_getch(win, flags);
832 wgetch_help(win, flags);
833 } else if (c == 'g') {
834 waddstr(win, "getstr test: ");
836 c = wgetnstr(win, buf, sizeof(buf) - 1);
838 wprintw(win, "I saw %d characters:\n\t`%s' (%s).",
839 (int) strlen(buf), buf,
842 wgetch_wrap(win, first_y);
843 } else if (c == 'k') {
844 flags[UChar('k')] = !flags[UChar('k')];
845 setup_getch(win, flags);
846 wgetch_help(win, flags);
847 } else if (c == 'm') {
848 flags[UChar('m')] = !flags[UChar('m')];
849 setup_getch(win, flags);
850 wgetch_help(win, flags);
851 } else if (c == 's') {
853 } else if (c == 'w') {
854 int high = getmaxy(win) - 1 - first_y + 1;
855 int wide = getmaxx(win) - first_x;
857 int new_y = first_y + getbegy(win);
858 int new_x = first_x + getbegx(win);
860 getyx(win, old_y, old_x);
861 if (high > 2 && wide > 2) {
862 WINDOW *wb = newwin(high, wide, new_y, new_x);
863 WINDOW *wi = newwin(high - 2, wide - 2, new_y + 1, new_x + 1);
868 remember_boxes(level, wi, wb);
869 wgetch_test(level + 1, wi, delay);
873 wgetch_help(win, flags);
874 wmove(win, old_y, old_x);
880 } else if (c == 'z') {
881 kill(getpid(), SIGTSTP);
884 wprintw(win, "Key pressed: %04o ", c);
885 #ifdef NCURSES_MOUSE_VERSION
886 if (c == KEY_MOUSE) {
889 #endif /* NCURSES_MOUSE_VERSION */
891 #if defined(NCURSES_VERSION) && defined(KEY_RESIZE) && HAVE_WRESIZE
892 if (c == KEY_RESIZE) {
893 resize_boxes(level, win);
896 (void) waddstr(win, keyname(c));
897 } else if (c >= 0x80) {
898 unsigned c2 = (unsigned) c;
899 #if !(defined(NCURSES_VERSION) || defined(_XOPEN_CURSES))
900 /* at least Solaris SVR4 curses breaks unctrl(128), etc. */
904 (void) wprintw(win, "%c", UChar(c));
905 else if (c2 != UChar(c))
906 (void) wprintw(win, "M-%s", unctrl(c2));
908 (void) wprintw(win, "%s", unctrl(c2));
909 waddstr(win, " (high-half character)");
912 (void) wprintw(win, "%c (ASCII printable character)", c);
914 (void) wprintw(win, "%s (ASCII control character)",
917 wgetch_wrap(win, first_y);
924 init_getch(win, flags);
928 begin_getch_test(void)
935 #ifdef NCURSES_MOUSE_VERSION
936 mousemask(ALL_MOUSE_EVENTS, (mmask_t *) 0);
939 (void) printw("Delay in 10ths of a second (<CR> for blocking input)? ");
941 getnstr(buf, sizeof(buf) - 1);
945 if (isdigit(UChar(buf[0]))) {
946 delay = atoi(buf) * 100;
956 finish_getch_test(void)
958 #ifdef NCURSES_MOUSE_VERSION
959 mousemask(0, (mmask_t *) 0);
970 int delay = begin_getch_test();
973 wgetch_test(0, stdscr, delay);
979 #if USE_WIDEC_SUPPORT
981 * For wget_wch_test(), we create pairs of windows - one for a box, one for text.
982 * Resize both and paint the box in the parent.
984 #if defined(KEY_RESIZE) && HAVE_WRESIZE
986 resize_wide_boxes(unsigned level, WINDOW *win)
990 int high = LINES - base;
994 wnoutrefresh(stdscr);
998 for (n = 0; n < level; ++n) {
999 wresize(winstack[n].frame, high, wide);
1000 wresize(winstack[n].text, high - 2, wide - 2);
1003 werase(winstack[n].text);
1004 box_set(winstack[n].frame, 0, 0);
1005 wnoutrefresh(winstack[n].frame);
1006 wprintw(winstack[n].text,
1008 getmaxy(winstack[n].text),
1009 getmaxx(winstack[n].text));
1010 wnoutrefresh(winstack[n].text);
1011 if (winstack[n].text == win)
1016 #endif /* KEY_RESIZE */
1019 wcstos(const wchar_t *src)
1023 const wchar_t *tmp = src;
1024 #ifndef state_unused
1028 reset_wchars(state);
1029 if ((need = (int) count_wchars(tmp, 0, &state)) > 0) {
1030 unsigned have = (unsigned) need;
1031 if ((result = typeCalloc(char, have + 1)) != 0) {
1033 if (trans_wchars(result, tmp, have, &state) != have) {
1043 wget_wch_test(unsigned level, WINDOW *win, int delay)
1045 wchar_t wchar_buf[BUFSIZ];
1046 wint_t wint_buf[BUFSIZ];
1047 int first_y, first_x;
1051 bool blocking = (delay < 0);
1055 init_getch(win, flags);
1056 wtimeout(win, delay);
1057 getyx(win, first_y, first_x);
1059 wgetch_help(win, flags);
1060 wsetscrreg(win, first_y, getmaxy(win) - 1);
1061 scrollok(win, TRUE);
1064 while ((code = wGet_wchar(win, &c)) == ERR) {
1067 (void) wprintw(win, "%05d: input error", incount);
1070 (void) wprintw(win, "%05d: input timed out", incount);
1072 wgetch_wrap(win, first_y);
1074 if (code == ERR && blocking) {
1075 wprintw(win, "ERR");
1076 wgetch_wrap(win, first_y);
1077 } else if (isQuit((int) c)) {
1079 } else if (c == 'e') {
1080 flags[UChar('e')] = !flags[UChar('e')];
1081 setup_getch(win, flags);
1082 wgetch_help(win, flags);
1083 } else if (c == 'g') {
1084 waddstr(win, "getstr test: ");
1086 code = wgetn_wstr(win, wint_buf, sizeof(wint_buf) - 1);
1089 wprintw(win, "wgetn_wstr returns an error.");
1092 for (n = 0; (wchar_buf[n] = (wchar_t) wint_buf[n]) != 0; ++n) {
1095 if ((temp = wcstos(wchar_buf)) != 0) {
1096 wprintw(win, "I saw %d characters:\n\t`%s'.",
1097 (int) wcslen(wchar_buf), temp);
1100 wprintw(win, "I saw %d characters (cannot convert).",
1101 (int) wcslen(wchar_buf));
1105 wgetch_wrap(win, first_y);
1106 } else if (c == 'k') {
1107 flags[UChar('k')] = !flags[UChar('k')];
1108 setup_getch(win, flags);
1109 wgetch_help(win, flags);
1110 } else if (c == 'm') {
1111 flags[UChar('m')] = !flags[UChar('m')];
1112 setup_getch(win, flags);
1113 wgetch_help(win, flags);
1114 } else if (c == 's') {
1116 } else if (c == 'w') {
1117 int high = getmaxy(win) - 1 - first_y + 1;
1118 int wide = getmaxx(win) - first_x;
1120 int new_y = first_y + getbegy(win);
1121 int new_x = first_x + getbegx(win);
1123 getyx(win, old_y, old_x);
1124 if (high > 2 && wide > 2) {
1125 WINDOW *wb = newwin(high, wide, new_y, new_x);
1126 WINDOW *wi = newwin(high - 2, wide - 2, new_y + 1, new_x + 1);
1131 remember_boxes(level, wi, wb);
1132 wget_wch_test(level + 1, wi, delay);
1136 wgetch_help(win, flags);
1137 wmove(win, old_y, old_x);
1142 } else if (c == 'z') {
1143 kill(getpid(), SIGTSTP);
1146 wprintw(win, "Key pressed: %04o ", (int) c);
1147 #ifdef NCURSES_MOUSE_VERSION
1148 if (c == KEY_MOUSE) {
1151 #endif /* NCURSES_MOUSE_VERSION */
1152 if (code == KEY_CODE_YES) {
1153 #if defined(KEY_RESIZE) && HAVE_WRESIZE
1154 if (c == KEY_RESIZE) {
1155 resize_wide_boxes(level, win);
1158 (void) waddstr(win, keyname((wchar_t) c));
1160 (void) waddstr(win, key_name((wchar_t) c));
1161 if (c < 256 && iscntrl(c)) {
1162 (void) wprintw(win, " (control character)");
1164 (void) wprintw(win, " = %#x (printable character)",
1168 wgetch_wrap(win, first_y);
1175 init_getch(win, flags);
1181 int delay = begin_getch_test();
1184 wget_wch_test(0, stdscr, delay);
1186 finish_getch_test();
1191 /****************************************************************************
1193 * Character attributes test
1195 ****************************************************************************/
1197 #if HAVE_SETUPTERM || HAVE_TGETENT
1198 #define get_ncv() TIGETNUM("ncv","NC")
1199 #define get_xmc() TIGETNUM("xmc","sg")
1201 #define get_ncv() -1
1202 #define get_xmc() -1
1209 static int first = TRUE;
1210 static chtype result = 0;
1216 char *area_pointer = parsed;
1218 tgetent(buffer, getenv("TERM"));
1221 if (TIGETSTR("smso", "so"))
1222 result |= A_STANDOUT;
1223 if (TIGETSTR("smul", "us"))
1224 result |= A_UNDERLINE;
1225 if (TIGETSTR("rev", "mr"))
1226 result |= A_REVERSE;
1227 if (TIGETSTR("blink", "mb"))
1229 if (TIGETSTR("dim", "mh"))
1231 if (TIGETSTR("bold", "md"))
1233 if (TIGETSTR("smacs", "ac"))
1234 result |= A_ALTCHARSET;
1240 #define termattrs() my_termattrs()
1243 #define MAX_ATTRSTRING 31
1244 #define LEN_ATTRSTRING 26
1246 static char attr_test_string[MAX_ATTRSTRING + 1];
1249 attr_legend(WINDOW *helpwin)
1254 MvWPrintw(helpwin, row++, col,
1256 MvWPrintw(helpwin, row++, col,
1259 MvWPrintw(helpwin, row++, col,
1260 "Modify the test strings:");
1261 MvWPrintw(helpwin, row++, col,
1262 " A digit sets gaps on each side of displayed attributes");
1263 MvWPrintw(helpwin, row++, col,
1264 " </> shifts the text left/right. ");
1266 MvWPrintw(helpwin, row++, col,
1269 MvWPrintw(helpwin, row++, col,
1270 " f/F/b/F toggle foreground/background background color");
1271 MvWPrintw(helpwin, row++, col,
1272 " t/T toggle text/background color attribute");
1274 MvWPrintw(helpwin, row++, col,
1275 " a/A toggle ACS (alternate character set) mapping");
1276 MvWPrintw(helpwin, row, col,
1277 " v/V toggle video attribute to combine with each line");
1281 show_color_attr(int fg, int bg, int tx)
1284 printw(" Colors (fg %d, bg %d", fg, bg);
1286 printw(", text %d", tx);
1292 cycle_color_attr(int ch, short *fg, short *bg, short *tx)
1299 *fg = (short) (*fg + 1);
1302 *fg = (short) (*fg - 1);
1305 *bg = (short) (*bg + 1);
1308 *bg = (short) (*bg - 1);
1311 *tx = (short) (*tx + 1);
1314 *tx = (short) (*tx - 1);
1322 *fg = (short) min_colors;
1323 if (*fg < min_colors)
1324 *fg = (short) (COLORS - 1);
1326 *bg = (short) min_colors;
1327 if (*bg < min_colors)
1328 *bg = (short) (COLORS - 1);
1332 *tx = (short) (COLORS - 1);
1341 adjust_attr_string(int adjust)
1343 int first = ((int) UChar(attr_test_string[0])) + adjust;
1344 int last = first + LEN_ATTRSTRING;
1346 if (first >= ' ' && last <= '~') { /* 32..126 */
1348 for (j = 0, k = first; j < MAX_ATTRSTRING && k <= last; ++j, ++k) {
1349 attr_test_string[j] = (char) k;
1350 if (((k + 1 - first) % 5) == 0) {
1351 if (++j >= MAX_ATTRSTRING)
1353 attr_test_string[j] = ' ';
1356 while (j < MAX_ATTRSTRING)
1357 attr_test_string[j++] = ' ';
1358 attr_test_string[j] = '\0';
1365 init_attr_string(void)
1367 attr_test_string[0] = 'a';
1368 adjust_attr_string(0);
1372 show_attr(int row, int skip, bool arrow, chtype attr, const char *name)
1374 int ncv = get_ncv();
1375 chtype test = attr & (chtype) (~A_ALTCHARSET);
1378 MvPrintw(row, 5, "-->");
1379 MvPrintw(row, 8, "%s mode:", name);
1380 MvPrintw(row, 24, "|");
1382 printw("%*s", skip, " ");
1384 * Just for testing, write text using the alternate character set one
1385 * character at a time (to pass its rendition directly), and use the
1386 * string operation for the other attributes.
1388 if (attr & A_ALTCHARSET) {
1392 for (s = attr_test_string; *s != '\0'; ++s) {
1397 (void) attrset(attr);
1398 addstr(attr_test_string);
1402 printw("%*s", skip, " ");
1404 if (test != A_NORMAL) {
1405 if (!(termattrs() & test)) {
1408 if (ncv > 0 && stdscr && (getbkgd(stdscr) & A_COLOR)) {
1409 static const chtype table[] =
1425 for (n = 0; n < SIZEOF(table); n++) {
1426 if ((table[n] & attr) != 0
1427 && ((1 << n) & ncv) != 0) {
1435 if ((termattrs() & test) != test)
1442 static const struct {
1444 NCURSES_CONST char * name;
1445 } attrs_to_test[] = {
1446 { A_STANDOUT, "STANDOUT" },
1447 { A_REVERSE, "REVERSE" },
1449 { A_UNDERLINE, "UNDERLINE" },
1451 { A_BLINK, "BLINK" },
1452 { A_PROTECT, "PROTECT" },
1454 { A_INVIS, "INVISIBLE" },
1456 { A_NORMAL, "NORMAL" },
1461 attr_getc(int *skip, short *fg, short *bg, short *tx, int *ac, unsigned *kc)
1471 if (ch < 256 && isdigit(ch)) {
1479 if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
1481 attr_legend(helpwin);
1494 *kc = SIZEOF(attrs_to_test) - 1;
1500 if (*kc >= SIZEOF(attrs_to_test))
1504 adjust_attr_string(-1);
1507 adjust_attr_string(1);
1513 error = cycle_color_attr(ch, fg, bg, tx);
1523 /* test text attributes */
1526 int skip = get_xmc();
1527 short fg = COLOR_BLACK; /* color pair 0 is special */
1528 short bg = COLOR_BLACK;
1536 n = skip; /* make it easy */
1537 k = SIZEOF(attrs_to_test) - 1;
1542 chtype normal = A_NORMAL | BLANK;
1543 chtype extras = (chtype) ac;
1546 short pair = (short) (fg != COLOR_BLACK || bg != COLOR_BLACK);
1549 if (init_pair(pair, fg, bg) == ERR) {
1552 normal |= (chtype) COLOR_PAIR(pair);
1557 if (init_pair(pair, tx, bg) == ERR) {
1560 extras |= (chtype) COLOR_PAIR(pair);
1569 MvAddStr(0, 20, "Character attribute test display");
1571 for (j = 0; j < SIZEOF(attrs_to_test); ++j) {
1572 bool arrow = (j == k);
1573 row = show_attr(row, n, arrow,
1575 attrs_to_test[j].attr |
1576 attrs_to_test[k].attr,
1577 attrs_to_test[j].name);
1581 "This terminal does %shave the magic-cookie glitch",
1582 get_xmc() > -1 ? "" : "not ");
1583 MvPrintw(row + 1, 8, "Enter '?' for help.");
1584 show_color_attr(fg, bg, tx);
1585 printw(" ACS (%d)", ac != 0);
1588 } while (attr_getc(&n, &fg, &bg, &tx, &ac, &k));
1590 bkgdset(A_NORMAL | BLANK);
1595 #if USE_WIDEC_SUPPORT
1596 static wchar_t wide_attr_test_string[MAX_ATTRSTRING + 1];
1599 wide_adjust_attr_string(int adjust)
1601 int first = ((int) UChar(wide_attr_test_string[0])) + adjust;
1602 int last = first + LEN_ATTRSTRING;
1604 if (first >= ' ' && last <= '~') { /* 32..126 */
1606 for (j = 0, k = first; j < MAX_ATTRSTRING && k <= last; ++j, ++k) {
1607 wide_attr_test_string[j] = k;
1608 if (((k + 1 - first) % 5) == 0) {
1609 if (++j >= MAX_ATTRSTRING)
1611 wide_attr_test_string[j] = ' ';
1614 while (j < MAX_ATTRSTRING)
1615 wide_attr_test_string[j++] = ' ';
1616 wide_attr_test_string[j] = '\0';
1623 wide_init_attr_string(void)
1625 wide_attr_test_string[0] = 'a';
1626 wide_adjust_attr_string(0);
1630 set_wide_background(short pair)
1637 setcchar(&normal, blank, A_NORMAL, pair, 0);
1643 get_wide_background(void)
1645 attr_t result = A_NORMAL;
1651 if (getbkgrnd(&ch) != ERR) {
1652 if (getcchar(&ch, wch, &attr, &pair, 0) != ERR) {
1660 wide_show_attr(int row, int skip, bool arrow, chtype attr, short pair, const char *name)
1662 int ncv = get_ncv();
1663 chtype test = attr & ~WA_ALTCHARSET;
1666 MvPrintw(row, 5, "-->");
1667 MvPrintw(row, 8, "%s mode:", name);
1668 MvPrintw(row, 24, "|");
1670 printw("%*s", skip, " ");
1673 * Just for testing, write text using the alternate character set one
1674 * character at a time (to pass its rendition directly), and use the
1675 * string operation for the other attributes.
1677 if (attr & WA_ALTCHARSET) {
1681 for (s = wide_attr_test_string; *s != L'\0'; ++s) {
1685 setcchar(&ch, fill, attr, pair, 0);
1689 attr_t old_attr = 0;
1692 (void) attr_get(&old_attr, &old_pair, 0);
1693 (void) attr_set(attr, pair, 0);
1694 addwstr(wide_attr_test_string);
1695 (void) attr_set(old_attr, old_pair, 0);
1698 printw("%*s", skip, " ");
1700 if (test != A_NORMAL) {
1701 if (!(term_attrs() & test)) {
1704 if (ncv > 0 && (get_wide_background() & A_COLOR)) {
1705 static const attr_t table[] =
1719 for (n = 0; n < SIZEOF(table); n++) {
1720 if ((table[n] & attr) != 0
1721 && ((1 << n) & ncv) != 0) {
1729 if ((term_attrs() & test) != test)
1737 wide_attr_getc(int *skip, short *fg, short *bg, short *tx, int *ac, unsigned *kc)
1747 if (ch < 256 && isdigit(ch)) {
1755 if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
1756 box_set(helpwin, 0, 0);
1757 attr_legend(helpwin);
1770 *kc = SIZEOF(attrs_to_test) - 1;
1776 if (*kc >= SIZEOF(attrs_to_test))
1780 wide_adjust_attr_string(-1);
1783 wide_adjust_attr_string(1);
1789 error = cycle_color_attr(ch, fg, bg, tx);
1798 wide_attr_test(void)
1799 /* test text attributes using wide-character calls */
1802 int skip = get_xmc();
1803 short fg = COLOR_BLACK; /* color pair 0 is special */
1804 short bg = COLOR_BLACK;
1812 n = skip; /* make it easy */
1813 k = SIZEOF(attrs_to_test) - 1;
1814 wide_init_attr_string();
1822 pair = (short) (fg != COLOR_BLACK || bg != COLOR_BLACK);
1825 if (init_pair(pair, fg, bg) == ERR) {
1832 if (init_pair(extras, tx, bg) == ERR) {
1837 set_wide_background(pair);
1840 box_set(stdscr, 0, 0);
1841 MvAddStr(0, 20, "Character attribute test display");
1843 for (j = 0; j < SIZEOF(attrs_to_test); ++j) {
1844 row = wide_show_attr(row, n, j == k,
1846 attrs_to_test[j].attr |
1847 attrs_to_test[k].attr),
1849 attrs_to_test[j].name);
1853 "This terminal does %shave the magic-cookie glitch",
1854 get_xmc() > -1 ? "" : "not ");
1855 MvPrintw(row + 1, 8, "Enter '?' for help.");
1856 show_color_attr(fg, bg, tx);
1857 printw(" ACS (%d)", ac != 0);
1860 } while (wide_attr_getc(&n, &fg, &bg, &tx, &ac, &k));
1862 set_wide_background(0);
1868 /****************************************************************************
1870 * Color support tests
1872 ****************************************************************************/
1874 static NCURSES_CONST char *the_color_names[] =
1895 show_color_name(int y, int x, int color, bool wide)
1897 if (move(y, x) != ERR) {
1902 sprintf(temp, "%02d", color);
1904 } else if (color >= 8) {
1905 sprintf(temp, "[%02d]", color);
1906 } else if (color < 0) {
1907 strcpy(temp, "default");
1909 strcpy(temp, the_color_names[color]);
1911 printw("%-*.*s", width, width, temp);
1916 color_legend(WINDOW *helpwin, bool wide)
1921 MvWPrintw(helpwin, row++, col,
1924 MvWPrintw(helpwin, row++, col,
1925 "Use up/down arrow to scroll through the display if it is");
1926 MvWPrintw(helpwin, row++, col,
1927 "longer than one screen. Control/N and Control/P can be used");
1928 MvWPrintw(helpwin, row++, col,
1929 "in place of up/down arrow. Use pageup/pagedown to scroll a");
1930 MvWPrintw(helpwin, row++, col,
1931 "full screen; control/B and control/F can be used here.");
1933 MvWPrintw(helpwin, row++, col,
1935 MvWPrintw(helpwin, row++, col,
1936 " a/A toggle altcharset off/on");
1937 MvWPrintw(helpwin, row++, col,
1938 " b/B toggle bold off/on");
1939 MvWPrintw(helpwin, row++, col,
1940 " n/N toggle text/number on/off");
1941 MvWPrintw(helpwin, row++, col,
1942 " r/R toggle reverse on/off");
1943 MvWPrintw(helpwin, row++, col,
1944 " w/W toggle width between 8/16 colors");
1945 #if USE_WIDEC_SUPPORT
1947 MvWPrintw(helpwin, row++, col,
1948 "Wide characters:");
1949 MvWPrintw(helpwin, row, col,
1950 " x/X toggle text between ASCII and wide-character");
1957 #define set_color_test(name, value) if (name != value) { name = value; base_row = 0; }
1959 /* generate a color test pattern */
1966 int grid_top = top + 3;
1967 int page_size = (LINES - grid_top);
1968 int pairs_max = PAIR_NUMBER(A_COLOR) + 1;
1974 bool opt_acsc = FALSE;
1975 bool opt_bold = FALSE;
1976 bool opt_revs = FALSE;
1977 bool opt_nums = FALSE;
1978 bool opt_wide = FALSE;
1981 if (COLORS * COLORS == COLOR_PAIRS) {
1982 int limit = (COLORS - min_colors) * (COLORS - min_colors);
1983 if (pairs_max > limit)
1986 if (pairs_max > COLOR_PAIRS)
1987 pairs_max = COLOR_PAIRS;
1993 /* this assumes an 80-column line */
1997 per_row = (COLORS > 8) ? 16 : 8;
2003 per_row -= min_colors;
2005 row_limit = (pairs_max + per_row - 1) / per_row;
2008 (void) printw("There are %d color pairs and %d colors%s\n",
2010 min_colors ? " besides 'default'" : "");
2013 MvPrintw(top + 1, 0,
2014 "%dx%d matrix of foreground/background colors, bold *%s*\n",
2017 opt_bold ? "on" : "off");
2019 /* show color names/numbers across the top */
2020 for (i = 0; i < per_row; i++)
2021 show_color_name(top + 2, (i + 1) * width, i + min_colors, opt_wide);
2023 /* show a grid of colors, with color names/ numbers on the left */
2024 for (i = (short) (base_row * per_row); i < pairs_max; i++) {
2025 int row = grid_top + (i / per_row) - base_row;
2026 int col = (i % per_row + 1) * width;
2029 #define InxToFG(i) (short) ((i % (COLORS - min_colors)) + min_colors)
2030 #define InxToBG(i) (short) ((i / (COLORS - min_colors)) + min_colors)
2031 if (row >= 0 && move(row, col) != ERR) {
2032 short fg = InxToFG(i);
2033 short bg = InxToBG(i);
2035 init_pair(pair, fg, bg);
2036 attron((attr_t) COLOR_PAIR(pair));
2038 attron((attr_t) A_ALTCHARSET);
2040 attron((attr_t) A_BOLD);
2042 attron((attr_t) A_REVERSE);
2045 sprintf(numbered, "{%02X}", i);
2048 printw("%-*.*s", width, width, hello);
2049 (void) attrset(A_NORMAL);
2051 if ((i % per_row) == 0 && InxToFG(i) == min_colors) {
2052 show_color_name(row, 0, InxToBG(i), opt_wide);
2060 switch (wGetchar(stdscr)) {
2089 set_color_test(opt_wide, FALSE);
2092 set_color_test(opt_wide, TRUE);
2096 if (base_row <= 0) {
2104 if (base_row + page_size >= row_limit) {
2113 if (base_row <= 0) {
2116 base_row -= (page_size - 1);
2124 if (base_row + page_size >= row_limit) {
2127 base_row += page_size - 1;
2128 if (base_row + page_size >= row_limit) {
2129 base_row = row_limit - page_size - 1;
2134 if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
2136 color_legend(helpwin, FALSE);
2151 #if USE_WIDEC_SUPPORT
2152 /* generate a color test pattern */
2154 wide_color_test(void)
2159 int grid_top = top + 3;
2160 int page_size = (LINES - grid_top);
2161 int pairs_max = (unsigned short) (-1);
2167 bool opt_acsc = FALSE;
2168 bool opt_bold = FALSE;
2169 bool opt_revs = FALSE;
2170 bool opt_wide = FALSE;
2171 bool opt_nums = FALSE;
2172 bool opt_xchr = FALSE;
2176 if (COLORS * COLORS == COLOR_PAIRS) {
2177 int limit = (COLORS - min_colors) * (COLORS - min_colors);
2178 if (pairs_max > limit)
2181 if (pairs_max > COLOR_PAIRS)
2182 pairs_max = COLOR_PAIRS;
2188 /* this assumes an 80-column line */
2192 per_row = (COLORS > 8) ? 16 : 8;
2198 per_row -= min_colors;
2201 make_fullwidth_text(buffer, hello);
2205 make_narrow_text(buffer, hello);
2208 row_limit = (pairs_max + per_row - 1) / per_row;
2211 (void) printw("There are %d color pairs and %d colors%s\n",
2213 min_colors ? " besides 'default'" : "");
2216 MvPrintw(top + 1, 0,
2217 "%dx%d matrix of foreground/background colors, bold *%s*\n",
2220 opt_bold ? "on" : "off");
2222 /* show color names/numbers across the top */
2223 for (i = 0; i < per_row; i++)
2224 show_color_name(top + 2, (i + 1) * width, i + min_colors, opt_wide);
2226 /* show a grid of colors, with color names/ numbers on the left */
2227 for (i = (base_row * per_row); i < pairs_max; i++) {
2228 int row = grid_top + (i / per_row) - base_row;
2229 int col = (i % per_row + 1) * width;
2230 short pair = (short) i;
2232 if (row >= 0 && move(row, col) != ERR) {
2233 init_pair(pair, InxToFG(i), InxToBG(i));
2234 color_set(pair, NULL);
2236 attr_on((attr_t) A_ALTCHARSET, NULL);
2238 attr_on((attr_t) A_BOLD, NULL);
2240 attr_on((attr_t) A_REVERSE, NULL);
2243 sprintf(numbered, "{%02X}", i);
2245 make_fullwidth_text(buffer, numbered);
2247 make_narrow_text(buffer, numbered);
2250 addnwstr(buffer, width);
2251 (void) attr_set(A_NORMAL, 0, NULL);
2253 if ((i % per_row) == 0 && InxToFG(i) == min_colors) {
2254 show_color_name(row, 0, InxToBG(i), opt_wide);
2262 switch (wGetchar(stdscr)) {
2291 set_color_test(opt_wide, FALSE);
2294 set_color_test(opt_wide, TRUE);
2304 if (base_row <= 0) {
2312 if (base_row + page_size >= row_limit) {
2321 if (base_row <= 0) {
2324 base_row -= (page_size - 1);
2332 if (base_row + page_size >= row_limit) {
2335 base_row += page_size - 1;
2336 if (base_row + page_size >= row_limit) {
2337 base_row = row_limit - page_size - 1;
2342 if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
2344 color_legend(helpwin, TRUE);
2358 #endif /* USE_WIDEC_SUPPORT */
2361 change_color(short current, int field, int value, int usebase)
2363 short red, green, blue;
2365 color_content(current, &red, &green, &blue);
2369 red = (short) (usebase ? (red + value) : value);
2372 green = (short) (usebase ? (green + value) : value);
2375 blue = (short) (usebase ? (blue + value) : value);
2379 if (init_color(current, red, green, blue) == ERR)
2384 init_all_colors(void)
2388 for (c = 0; c < COLORS; ++c)
2391 all_colors[c].green,
2392 all_colors[c].blue);
2395 #define scaled_rgb(n) ((255 * (n)) / 1000)
2399 /* display the color test pattern, without trying to edit colors */
2403 int this_c = 0, value = 0, field = 0;
2406 int page_size = (LINES - 6);
2411 for (i = 0; i < max_colors; i++)
2412 init_pair((short) i, (short) COLOR_WHITE, (short) i);
2414 MvPrintw(LINES - 2, 0, "Number: %d", value);
2417 short red, green, blue;
2420 MvAddStr(0, 20, "Color RGB Value Editing");
2423 for (i = (short) top_color;
2424 (i - top_color < page_size)
2425 && (i < max_colors); i++) {
2428 sprintf(numeric, "[%d]", i);
2429 MvPrintw(2 + i - top_color, 0, "%c %-8s:",
2430 (i == current ? '>' : ' '),
2431 (i < (int) SIZEOF(the_color_names)
2432 ? the_color_names[i] : numeric));
2433 (void) attrset((attr_t) COLOR_PAIR(i));
2435 (void) attrset(A_NORMAL);
2437 color_content((short) i, &red, &green, &blue);
2439 if (current == i && field == 0)
2441 printw("%04d", red);
2442 if (current == i && field == 0)
2443 (void) attrset(A_NORMAL);
2445 if (current == i && field == 1)
2447 printw("%04d", green);
2448 if (current == i && field == 1)
2449 (void) attrset(A_NORMAL);
2451 if (current == i && field == 2)
2453 printw("%04d", blue);
2454 if (current == i && field == 2)
2455 (void) attrset(A_NORMAL);
2456 (void) attrset(A_NORMAL);
2457 printw(" ( %3d %3d %3d )",
2463 MvAddStr(LINES - 3, 0,
2464 "Use up/down to select a color, left/right to change fields.");
2465 MvAddStr(LINES - 2, 0,
2466 "Modify field by typing nnn=, nnn-, or nnn+. ? for help.");
2468 move(2 + current - top_color, 0);
2472 if (this_c < 256 && isdigit(this_c) && !isdigit(last_c))
2479 current -= (page_size - 1);
2486 if (current < (max_colors - 1))
2487 current += (page_size - 1);
2494 current = (current == 0 ? (max_colors - 1) : current - 1);
2499 current = (current == (max_colors - 1) ? 0 : current + 1);
2503 field = (field == 2 ? 0 : field + 1);
2507 field = (field == 0 ? 2 : field - 1);
2520 value = value * 10 + (this_c - '0');
2524 change_color((short) current, field, value, 1);
2528 change_color((short) current, field, -value, 1);
2532 change_color((short) current, field, value, 0);
2537 P(" RGB Value Editing Help");
2539 P("You are in the RGB value editor. Use the arrow keys to select one of");
2540 P("the fields in one of the RGB triples of the current colors; the one");
2541 P("currently selected will be reverse-video highlighted.");
2543 P("To change a field, enter the digits of the new value; they are echoed");
2544 P("as entered. Finish by typing `='. The change will take effect instantly.");
2545 P("To increment or decrement a value, use the same procedure, but finish");
2546 P("with a `+' or `-'.");
2548 P("Press 'm' to invoke the top-level menu with the current color settings.");
2549 P("To quit, do ESC");
2558 for (i = 0; i < max_colors; i++)
2559 init_pair((short) i, (short) COLOR_WHITE, (short) i);
2573 if (current >= max_colors)
2574 current = max_colors - 1;
2575 if (current < top_color)
2576 top_color = current;
2577 if (current - top_color >= page_size)
2578 top_color = current - (page_size - 1);
2580 MvPrintw(LINES - 1, 0, "Number: %d", value);
2588 * ncurses does not reset each color individually when calling endwin().
2595 /****************************************************************************
2597 * Alternate character-set stuff
2599 ****************************************************************************/
2604 } attrs_to_cycle[] = {
2605 { A_NORMAL, "normal" },
2607 { A_BLINK, "blink" },
2608 { A_REVERSE, "reverse" },
2609 { A_UNDERLINE, "underline" },
2614 cycle_attr(int ch, unsigned *at_code, chtype *attr)
2620 if ((*at_code += 1) >= SIZEOF(attrs_to_cycle))
2625 *at_code = SIZEOF(attrs_to_cycle) - 1;
2634 *attr = attrs_to_cycle[*at_code].attr;
2639 cycle_colors(int ch, int *fg, int *bg, short *pair)
2641 bool result = FALSE;
2651 if ((*fg += 1) >= COLORS)
2659 if ((*bg += 1) >= COLORS)
2667 *pair = (short) (*fg != COLOR_BLACK || *bg != COLOR_BLACK);
2670 if (init_pair(*pair, (short) *fg, (short) *bg) == ERR) {
2679 /****************************************************************************
2681 * Soft-key label test
2683 ****************************************************************************/
2688 #define SLK_WORK (SLK_HELP + 3)
2693 static const char *table[] =
2695 "Available commands are:"
2697 ,"^L -- repaint this message and activate soft keys"
2698 ,"a/d -- activate/disable soft keys"
2699 ,"c -- set centered format for labels"
2700 ,"l -- set left-justified format for labels"
2701 ,"r -- set right-justified format for labels"
2702 ,"[12345678] -- set label; labels are numbered 1 through 8"
2703 ,"e -- erase stdscr (should not erase labels)"
2704 ,"s -- test scrolling of shortened screen"
2705 ,"v/V -- cycle through video attributes"
2707 ,"F/f/B/b -- cycle through foreground/background colors"
2709 ,"ESC -- return to main menu"
2711 ,"Note: if activating the soft keys causes your terminal to scroll up"
2712 ,"one line, your terminal auto-scrolls when anything is written to the"
2713 ,"last screen position. The ncurses code does not yet handle this"
2719 for (j = 0; j < SIZEOF(table); ++j) {
2727 call_slk_color(int fg, int bg)
2729 init_pair(1, (short) bg, (short) fg);
2731 MvPrintw(SLK_WORK, 0, "Colors %d/%d\n", fg, bg);
2741 /* exercise the soft keys */
2746 chtype attr = A_NORMAL;
2747 unsigned at_code = 0;
2749 int fg = COLOR_BLACK;
2750 int bg = COLOR_WHITE;
2757 call_slk_color(fg, bg);
2767 MvAddStr(0, 20, "Soft Key Exerciser");
2782 MvPrintw(SLK_WORK, 0, "Press Q to stop the scrolling-test: ");
2783 while ((c = Getchar()) != 'Q' && (c != ERR))
2811 MvAddStr(SLK_WORK, 0, "Please enter the label value: ");
2813 if ((s = slk_label(c - '0')) != 0) {
2816 wGetstring(stdscr, buf, 8);
2817 slk_set((c - '0'), buf, fmt);
2826 #if defined(NCURSES_VERSION) && defined(KEY_RESIZE) && HAVE_WRESIZE
2828 wnoutrefresh(stdscr);
2833 if (cycle_attr(c, &at_code, &attr)) {
2840 if (cycle_colors(c, &fg, &bg, &pair)) {
2842 call_slk_color(fg, bg);
2852 } while (!isQuit(c = Getchar()));
2860 #if USE_WIDEC_SUPPORT
2864 /* exercise the soft keys */
2867 wchar_t buf[SLKLEN + 1];
2869 chtype attr = A_NORMAL;
2870 unsigned at_code = 0;
2871 int fg = COLOR_BLACK;
2872 int bg = COLOR_WHITE;
2877 call_slk_color(fg, bg);
2884 attr_on(WA_BOLD, NULL);
2885 MvAddStr(0, 20, "Soft Key Exerciser");
2886 attr_off(WA_BOLD, NULL);
2900 MvPrintw(SLK_WORK, 0, "Press Q to stop the scrolling-test: ");
2901 while ((c = Getchar()) != 'Q' && (c != ERR))
2929 MvAddStr(SLK_WORK, 0, "Please enter the label value: ");
2931 if ((s = slk_label(c - '0')) != 0) {
2932 char *temp = strdup(s);
2933 size_t used = strlen(temp);
2934 size_t want = SLKLEN;
2936 #ifndef state_unused
2941 while (want > 0 && used != 0) {
2942 const char *base = s;
2943 reset_mbytes(state);
2944 test = count_mbytes(base, 0, &state);
2945 if (test == (size_t) -1) {
2947 } else if (test > want) {
2950 reset_mbytes(state);
2951 trans_mbytes(buf, base, want, &state);
2957 wGet_wstring(stdscr, buf, SLKLEN);
2958 slk_wset((c - '0'), buf, fmt);
2969 fg = (short) ((fg + 1) % COLORS);
2970 call_slk_color(fg, bg);
2975 bg = (short) ((bg + 1) % COLORS);
2976 call_slk_color(fg, bg);
2979 #if defined(NCURSES_VERSION) && defined(KEY_RESIZE) && HAVE_WRESIZE
2981 wnoutrefresh(stdscr);
2985 if (cycle_attr(c, &at_code, &attr)) {
2986 slk_attr_set(attr, (short) (fg || bg), NULL);
2992 if (cycle_colors(c, &fg, &bg, &pair)) {
2994 call_slk_color(fg, bg);
3004 } while (!isQuit(c = Getchar()));
3012 #endif /* SLK_INIT */
3014 /* ISO 6429: codes 0x80 to 0x9f may be control characters that cause the
3015 * terminal to perform functions. The remaining codes can be graphic.
3018 show_upper_chars(unsigned first, int repeat, attr_t attr, short pair)
3020 bool C1 = (first == 128);
3022 unsigned last = first + 31;
3027 MvPrintw(0, 20, "Display of %s Character Codes %d to %d",
3028 C1 ? "C1" : "GR", first, last);
3032 for (code = first; code <= last; code++) {
3034 int row = 2 + ((int) (code - first) % 16);
3035 int col = ((int) (code - first) / 16) * COLS / 2;
3037 sprintf(tmp, "%3u (0x%x)", code, code);
3038 MvPrintw(row, col, "%*s: ", COLS / 4, tmp);
3042 nodelay(stdscr, TRUE);
3043 echochar(colored_chtype(code, attr, pair));
3045 /* (yes, this _is_ crude) */
3046 while ((reply = Getchar()) != ERR) {
3047 addch(UChar(reply));
3050 nodelay(stdscr, FALSE);
3052 } while (--count > 0);
3059 show_pc_chars(int repeat, attr_t attr, short pair)
3065 MvPrintw(0, 20, "Display of PC Character Codes");
3069 for (code = 0; code < 16; ++code) {
3070 MvPrintw(2, (int) code * PC_COLS + 8, "%X", code);
3072 for (code = 0; code < 256; code++) {
3074 int row = 3 + (int) (code / 16) + (code >= 128);
3075 int col = 8 + (int) (code % 16) * PC_COLS;
3076 if ((code % 16) == 0)
3077 MvPrintw(row, 0, "0x%02x:", code);
3088 * Skip the ones that do not work.
3092 addch(colored_chtype(code, A_ALTCHARSET | attr, pair));
3095 } while (--count > 0);
3100 show_box_chars(int repeat, attr_t attr, short pair)
3104 attr |= (attr_t) COLOR_PAIR(pair);
3108 MvAddStr(0, 20, "Display of the ACS Line-Drawing Set");
3113 colored_chtype(ACS_VLINE, attr, pair),
3114 colored_chtype(ACS_VLINE, attr, pair),
3115 colored_chtype(ACS_HLINE, attr, pair),
3116 colored_chtype(ACS_HLINE, attr, pair),
3117 colored_chtype(ACS_ULCORNER, attr, pair),
3118 colored_chtype(ACS_URCORNER, attr, pair),
3119 colored_chtype(ACS_LLCORNER, attr, pair),
3120 colored_chtype(ACS_LRCORNER, attr, pair));
3121 MvHLine(LINES / 2, 0, colored_chtype(ACS_HLINE, attr, pair), COLS);
3122 MvVLine(0, COLS / 2, colored_chtype(ACS_VLINE, attr, pair), LINES);
3123 MvAddCh(0, COLS / 2, colored_chtype(ACS_TTEE, attr, pair));
3124 MvAddCh(LINES / 2, COLS / 2, colored_chtype(ACS_PLUS, attr, pair));
3125 MvAddCh(LINES - 1, COLS / 2, colored_chtype(ACS_BTEE, attr, pair));
3126 MvAddCh(LINES / 2, 0, colored_chtype(ACS_LTEE, attr, pair));
3127 MvAddCh(LINES / 2, COLS - 1, colored_chtype(ACS_RTEE, attr, pair));
3133 show_1_acs(int n, int repeat, const char *name, chtype code)
3135 const int height = 16;
3136 int row = 2 + (n % height);
3137 int col = (n / height) * COLS / 2;
3139 MvPrintw(row, col, "%*s : ", COLS / 4, name);
3142 } while (--repeat > 0);
3147 show_acs_chars(int repeat, attr_t attr, short pair)
3148 /* display the ACS character set */
3152 #define BOTH(name) #name, colored_chtype(name, attr, (chtype) pair)
3156 MvAddStr(0, 20, "Display of the ACS Character Set");
3160 n = show_1_acs(0, repeat, BOTH(ACS_ULCORNER));
3161 n = show_1_acs(n, repeat, BOTH(ACS_URCORNER));
3162 n = show_1_acs(n, repeat, BOTH(ACS_LLCORNER));
3163 n = show_1_acs(n, repeat, BOTH(ACS_LRCORNER));
3165 n = show_1_acs(n, repeat, BOTH(ACS_LTEE));
3166 n = show_1_acs(n, repeat, BOTH(ACS_RTEE));
3167 n = show_1_acs(n, repeat, BOTH(ACS_TTEE));
3168 n = show_1_acs(n, repeat, BOTH(ACS_BTEE));
3170 n = show_1_acs(n, repeat, BOTH(ACS_HLINE));
3171 n = show_1_acs(n, repeat, BOTH(ACS_VLINE));
3174 * HPUX's ACS definitions are broken here. Just give up.
3176 #if !(defined(__hpux) && !defined(NCURSES_VERSION))
3177 n = show_1_acs(n, repeat, BOTH(ACS_LARROW));
3178 n = show_1_acs(n, repeat, BOTH(ACS_RARROW));
3179 n = show_1_acs(n, repeat, BOTH(ACS_UARROW));
3180 n = show_1_acs(n, repeat, BOTH(ACS_DARROW));
3182 n = show_1_acs(n, repeat, BOTH(ACS_BLOCK));
3183 n = show_1_acs(n, repeat, BOTH(ACS_BOARD));
3184 n = show_1_acs(n, repeat, BOTH(ACS_LANTERN));
3185 n = show_1_acs(n, repeat, BOTH(ACS_BULLET));
3186 n = show_1_acs(n, repeat, BOTH(ACS_CKBOARD));
3187 n = show_1_acs(n, repeat, BOTH(ACS_DEGREE));
3188 n = show_1_acs(n, repeat, BOTH(ACS_DIAMOND));
3189 n = show_1_acs(n, repeat, BOTH(ACS_PLMINUS));
3190 n = show_1_acs(n, repeat, BOTH(ACS_PLUS));
3192 n = show_1_acs(n, repeat, BOTH(ACS_GEQUAL));
3193 n = show_1_acs(n, repeat, BOTH(ACS_NEQUAL));
3194 n = show_1_acs(n, repeat, BOTH(ACS_LEQUAL));
3196 n = show_1_acs(n, repeat, BOTH(ACS_STERLING));
3197 n = show_1_acs(n, repeat, BOTH(ACS_PI));
3198 n = show_1_acs(n, repeat, BOTH(ACS_S1));
3199 n = show_1_acs(n, repeat, BOTH(ACS_S3));
3200 n = show_1_acs(n, repeat, BOTH(ACS_S7));
3201 (void) show_1_acs(n, repeat, BOTH(ACS_S9));
3209 char *term = getenv("TERM");
3210 const char *pch_kludge = ((term != 0 && strstr(term, "linux"))
3213 chtype attr = A_NORMAL;
3216 int fg = COLOR_BLACK;
3217 int bg = COLOR_BLACK;
3218 unsigned at_code = 0;
3220 void (*last_show_acs) (int, attr_t, short) = 0;
3228 ToggleAcs(last_show_acs, show_acs_chars);
3232 ToggleAcs(last_show_acs, show_pc_chars);
3237 ToggleAcs(last_show_acs, show_box_chars);
3263 if (repeat < (COLS / 4))
3271 if (cycle_attr(c, &at_code, &attr)
3272 || cycle_colors(c, &fg, &bg, &pair)) {
3279 if (last_show_acs != 0)
3280 last_show_acs(repeat, attr, pair);
3282 show_upper_chars((unsigned) (digit * 32 + 128), repeat, attr, pair);
3284 MvPrintw(LINES - 3, 0,
3285 "Note: ANSI terminals may not display C1 characters.");
3286 MvPrintw(LINES - 2, 0,
3287 "Select: a=ACS, x=box, %s0=C1, 1-3,+/- non-ASCII, </> repeat, ESC=quit",
3290 MvPrintw(LINES - 1, 0,
3291 "v/V, f/F, b/B cycle through video attributes (%s) and color %d/%d.",
3292 attrs_to_cycle[at_code].name,
3295 MvPrintw(LINES - 1, 0,
3296 "v/V cycles through video attributes (%s).",
3297 attrs_to_cycle[at_code].name);
3300 } while (!isQuit(c = Getchar()));
3307 #if USE_WIDEC_SUPPORT
3309 merge_wide_attr(cchar_t *dst, const cchar_t *src, attr_t attr, short pair)
3315 TEST_CCHAR(src, count, {
3316 attr |= (test_attrs & A_ALTCHARSET);
3317 setcchar(dst, test_wch, attr, pair, NULL);
3327 show_upper_widechars(int first, int repeat, int space, attr_t attr, short pair)
3331 int last = first + 31;
3335 MvPrintw(0, 20, "Display of Character Codes %d to %d", first, last);
3338 for (code = first; (int) code <= last; code++) {
3339 int row = 2 + ((code - first) % 16);
3340 int col = ((code - first) / 16) * COLS / 2;
3346 memset(&codes, 0, sizeof(codes));
3348 sprintf(tmp, "%3ld (0x%lx)", (long) code, (long) code);
3349 MvPrintw(row, col, "%*s: ", COLS / 4, tmp);
3350 setcchar(&temp, codes, attr, pair, 0);
3353 * Give non-spacing characters something to combine with. If we
3354 * don't, they'll bunch up in a heap on the space after the ":".
3355 * Mark them with reverse-video to make them simpler to find on
3358 if (wcwidth(code) == 0) {
3359 addch((chtype) space |
3360 (A_REVERSE ^ attr) |
3361 (attr_t) COLOR_PAIR(pair));
3364 * This could use add_wch(), but is done for comparison with the
3365 * normal 'f' test (and to make a test-case for echo_wchar()).
3366 * The screen will flicker because the erase() at the top of the
3367 * function is met by the builtin refresh() in echo_wchar().
3371 * The repeat-count may make text wrap - avoid that.
3373 getyx(stdscr, y, x);
3375 if (x >= col + (COLS / 2) - 2)
3377 } while (--count > 0);
3382 show_1_wacs(int n, int repeat, const char *name, const cchar_t *code)
3384 const int height = 16;
3385 int row = 2 + (n % height);
3386 int col = (n / height) * COLS / 2;
3388 MvPrintw(row, col, "%*s : ", COLS / 4, name);
3389 while (--repeat >= 0) {
3395 #define MERGE_ATTR(wch) merge_wide_attr(&temp, wch, attr, pair)
3398 show_wacs_chars(int repeat, attr_t attr, short pair)
3399 /* display the wide-ACS character set */
3405 /*#define BOTH2(name) #name, &(name) */
3406 #define BOTH2(name) #name, MERGE_ATTR(name)
3410 MvAddStr(0, 20, "Display of the Wide-ACS Character Set");
3414 n = show_1_wacs(0, repeat, BOTH2(WACS_ULCORNER));
3415 n = show_1_wacs(n, repeat, BOTH2(WACS_URCORNER));
3416 n = show_1_wacs(n, repeat, BOTH2(WACS_LLCORNER));
3417 n = show_1_wacs(n, repeat, BOTH2(WACS_LRCORNER));
3419 n = show_1_wacs(n, repeat, BOTH2(WACS_LTEE));
3420 n = show_1_wacs(n, repeat, BOTH2(WACS_RTEE));
3421 n = show_1_wacs(n, repeat, BOTH2(WACS_TTEE));
3422 n = show_1_wacs(n, repeat, BOTH2(WACS_BTEE));
3424 n = show_1_wacs(n, repeat, BOTH2(WACS_HLINE));
3425 n = show_1_wacs(n, repeat, BOTH2(WACS_VLINE));
3427 n = show_1_wacs(n, repeat, BOTH2(WACS_LARROW));
3428 n = show_1_wacs(n, repeat, BOTH2(WACS_RARROW));
3429 n = show_1_wacs(n, repeat, BOTH2(WACS_UARROW));
3430 n = show_1_wacs(n, repeat, BOTH2(WACS_DARROW));
3432 n = show_1_wacs(n, repeat, BOTH2(WACS_BLOCK));
3433 n = show_1_wacs(n, repeat, BOTH2(WACS_BOARD));
3434 n = show_1_wacs(n, repeat, BOTH2(WACS_LANTERN));
3435 n = show_1_wacs(n, repeat, BOTH2(WACS_BULLET));
3436 n = show_1_wacs(n, repeat, BOTH2(WACS_CKBOARD));
3437 n = show_1_wacs(n, repeat, BOTH2(WACS_DEGREE));
3438 n = show_1_wacs(n, repeat, BOTH2(WACS_DIAMOND));
3439 n = show_1_wacs(n, repeat, BOTH2(WACS_PLMINUS));
3440 n = show_1_wacs(n, repeat, BOTH2(WACS_PLUS));
3442 #ifdef CURSES_WACS_ARRAY
3443 n = show_1_wacs(n, repeat, BOTH2(WACS_GEQUAL));
3444 n = show_1_wacs(n, repeat, BOTH2(WACS_NEQUAL));
3445 n = show_1_wacs(n, repeat, BOTH2(WACS_LEQUAL));
3447 n = show_1_wacs(n, repeat, BOTH2(WACS_STERLING));
3448 n = show_1_wacs(n, repeat, BOTH2(WACS_PI));
3449 n = show_1_wacs(n, repeat, BOTH2(WACS_S1));
3450 n = show_1_wacs(n, repeat, BOTH2(WACS_S3));
3451 n = show_1_wacs(n, repeat, BOTH2(WACS_S7));
3452 (void) show_1_wacs(n, repeat, BOTH2(WACS_S9));
3458 show_wacs_chars_double(int repeat, attr_t attr, short pair)
3459 /* display the wide-ACS character set */
3465 /*#define BOTH2(name) #name, &(name) */
3466 #define BOTH2(name) #name, MERGE_ATTR(name)
3470 MvAddStr(0, 20, "Display of the Wide-ACS Character Set");
3474 n = show_1_wacs(0, repeat, BOTH2(WACS_D_ULCORNER));
3475 n = show_1_wacs(n, repeat, BOTH2(WACS_D_URCORNER));
3476 n = show_1_wacs(n, repeat, BOTH2(WACS_D_LLCORNER));
3477 n = show_1_wacs(n, repeat, BOTH2(WACS_D_LRCORNER));
3479 n = show_1_wacs(n, repeat, BOTH2(WACS_D_LTEE));
3480 n = show_1_wacs(n, repeat, BOTH2(WACS_D_RTEE));
3481 n = show_1_wacs(n, repeat, BOTH2(WACS_D_TTEE));
3482 n = show_1_wacs(n, repeat, BOTH2(WACS_D_BTEE));
3484 n = show_1_wacs(n, repeat, BOTH2(WACS_D_HLINE));
3485 n = show_1_wacs(n, repeat, BOTH2(WACS_D_VLINE));
3487 n = show_1_wacs(n, repeat, BOTH2(WACS_LARROW));
3488 n = show_1_wacs(n, repeat, BOTH2(WACS_RARROW));
3489 n = show_1_wacs(n, repeat, BOTH2(WACS_UARROW));
3490 n = show_1_wacs(n, repeat, BOTH2(WACS_DARROW));
3492 n = show_1_wacs(n, repeat, BOTH2(WACS_BLOCK));
3493 n = show_1_wacs(n, repeat, BOTH2(WACS_BOARD));
3494 n = show_1_wacs(n, repeat, BOTH2(WACS_LANTERN));
3495 n = show_1_wacs(n, repeat, BOTH2(WACS_BULLET));
3496 n = show_1_wacs(n, repeat, BOTH2(WACS_CKBOARD));
3497 n = show_1_wacs(n, repeat, BOTH2(WACS_DEGREE));
3498 n = show_1_wacs(n, repeat, BOTH2(WACS_DIAMOND));
3499 n = show_1_wacs(n, repeat, BOTH2(WACS_PLMINUS));
3500 n = show_1_wacs(n, repeat, BOTH2(WACS_PLUS));
3502 #ifdef CURSES_WACS_ARRAY
3503 n = show_1_wacs(n, repeat, BOTH2(WACS_GEQUAL));
3504 n = show_1_wacs(n, repeat, BOTH2(WACS_NEQUAL));
3505 n = show_1_wacs(n, repeat, BOTH2(WACS_LEQUAL));
3507 n = show_1_wacs(n, repeat, BOTH2(WACS_STERLING));
3508 n = show_1_wacs(n, repeat, BOTH2(WACS_PI));
3509 n = show_1_wacs(n, repeat, BOTH2(WACS_S1));
3510 n = show_1_wacs(n, repeat, BOTH2(WACS_S3));
3511 n = show_1_wacs(n, repeat, BOTH2(WACS_S7));
3512 (void) show_1_wacs(n, repeat, BOTH2(WACS_S9));
3519 show_wacs_chars_thick(int repeat, attr_t attr, short pair)
3520 /* display the wide-ACS character set */
3526 /*#define BOTH2(name) #name, &(name) */
3527 #define BOTH2(name) #name, MERGE_ATTR(name)
3531 MvAddStr(0, 20, "Display of the Wide-ACS Character Set");
3535 n = show_1_wacs(0, repeat, BOTH2(WACS_T_ULCORNER));
3536 n = show_1_wacs(n, repeat, BOTH2(WACS_T_URCORNER));
3537 n = show_1_wacs(n, repeat, BOTH2(WACS_T_LLCORNER));
3538 n = show_1_wacs(n, repeat, BOTH2(WACS_T_LRCORNER));
3540 n = show_1_wacs(n, repeat, BOTH2(WACS_T_LTEE));
3541 n = show_1_wacs(n, repeat, BOTH2(WACS_T_RTEE));
3542 n = show_1_wacs(n, repeat, BOTH2(WACS_T_TTEE));
3543 n = show_1_wacs(n, repeat, BOTH2(WACS_T_BTEE));
3545 n = show_1_wacs(n, repeat, BOTH2(WACS_T_HLINE));
3546 n = show_1_wacs(n, repeat, BOTH2(WACS_T_VLINE));
3548 n = show_1_wacs(n, repeat, BOTH2(WACS_LARROW));
3549 n = show_1_wacs(n, repeat, BOTH2(WACS_RARROW));
3550 n = show_1_wacs(n, repeat, BOTH2(WACS_UARROW));
3551 n = show_1_wacs(n, repeat, BOTH2(WACS_DARROW));
3553 n = show_1_wacs(n, repeat, BOTH2(WACS_BLOCK));
3554 n = show_1_wacs(n, repeat, BOTH2(WACS_BOARD));
3555 n = show_1_wacs(n, repeat, BOTH2(WACS_LANTERN));
3556 n = show_1_wacs(n, repeat, BOTH2(WACS_BULLET));
3557 n = show_1_wacs(n, repeat, BOTH2(WACS_CKBOARD));
3558 n = show_1_wacs(n, repeat, BOTH2(WACS_DEGREE));
3559 n = show_1_wacs(n, repeat, BOTH2(WACS_DIAMOND));
3560 n = show_1_wacs(n, repeat, BOTH2(WACS_PLMINUS));
3561 n = show_1_wacs(n, repeat, BOTH2(WACS_PLUS));
3563 #ifdef CURSES_WACS_ARRAY
3564 n = show_1_wacs(n, repeat, BOTH2(WACS_GEQUAL));
3565 n = show_1_wacs(n, repeat, BOTH2(WACS_NEQUAL));
3566 n = show_1_wacs(n, repeat, BOTH2(WACS_LEQUAL));
3568 n = show_1_wacs(n, repeat, BOTH2(WACS_STERLING));
3569 n = show_1_wacs(n, repeat, BOTH2(WACS_PI));
3570 n = show_1_wacs(n, repeat, BOTH2(WACS_S1));
3571 n = show_1_wacs(n, repeat, BOTH2(WACS_S3));
3572 n = show_1_wacs(n, repeat, BOTH2(WACS_S7));
3573 (void) show_1_wacs(n, repeat, BOTH2(WACS_S9));
3580 #define MERGE_ATTR(n,wch) merge_wide_attr(&temp[n], wch, attr, pair)
3583 show_wbox_chars(int repeat, attr_t attr, short pair)
3590 MvAddStr(0, 20, "Display of the Wide-ACS Line-Drawing Set");
3595 MERGE_ATTR(0, WACS_VLINE),
3596 MERGE_ATTR(1, WACS_VLINE),
3597 MERGE_ATTR(2, WACS_HLINE),
3598 MERGE_ATTR(3, WACS_HLINE),
3599 MERGE_ATTR(4, WACS_ULCORNER),
3600 MERGE_ATTR(5, WACS_URCORNER),
3601 MERGE_ATTR(6, WACS_LLCORNER),
3602 MERGE_ATTR(7, WACS_LRCORNER));
3604 (void) mvhline_set(LINES / 2, 0, MERGE_ATTR(0, WACS_HLINE), COLS);
3605 (void) mvvline_set(0, COLS / 2, MERGE_ATTR(0, WACS_VLINE), LINES);
3606 (void) mvadd_wch(0, COLS / 2, MERGE_ATTR(0, WACS_TTEE));
3607 (void) mvadd_wch(LINES / 2, COLS / 2, MERGE_ATTR(0, WACS_PLUS));
3608 (void) mvadd_wch(LINES - 1, COLS / 2, MERGE_ATTR(0, WACS_BTEE));
3609 (void) mvadd_wch(LINES / 2, 0, MERGE_ATTR(0, WACS_LTEE));
3610 (void) mvadd_wch(LINES / 2, COLS - 1, MERGE_ATTR(0, WACS_RTEE));
3618 show_2_wacs(int n, const char *name, const char *code, attr_t attr, short pair)
3620 const int height = 16;
3621 int row = 2 + (n % height);
3622 int col = (n / height) * COLS / 2;
3625 MvPrintw(row, col, "%*s : ", COLS / 4, name);
3626 (void) attr_set(attr, pair, 0);
3627 addstr(strcpy(temp, code));
3628 (void) attr_set(A_NORMAL, 0, 0);
3632 #define SHOW_UTF8(n, name, code) show_2_wacs(n, name, code, attr, pair)
3635 show_utf8_chars(int repeat, attr_t attr, short pair)
3642 MvAddStr(0, 20, "Display of the Wide-ACS Character Set");
3646 n = SHOW_UTF8(0, "WACS_ULCORNER", "\342\224\214");
3647 n = SHOW_UTF8(n, "WACS_URCORNER", "\342\224\220");
3648 n = SHOW_UTF8(n, "WACS_LLCORNER", "\342\224\224");
3649 n = SHOW_UTF8(n, "WACS_LRCORNER", "\342\224\230");
3651 n = SHOW_UTF8(n, "WACS_LTEE", "\342\224\234");
3652 n = SHOW_UTF8(n, "WACS_RTEE", "\342\224\244");
3653 n = SHOW_UTF8(n, "WACS_TTEE", "\342\224\254");
3654 n = SHOW_UTF8(n, "WACS_BTEE", "\342\224\264");
3656 n = SHOW_UTF8(n, "WACS_HLINE", "\342\224\200");
3657 n = SHOW_UTF8(n, "WACS_VLINE", "\342\224\202");
3659 n = SHOW_UTF8(n, "WACS_LARROW", "\342\206\220");
3660 n = SHOW_UTF8(n, "WACS_RARROW", "\342\206\222");
3661 n = SHOW_UTF8(n, "WACS_UARROW", "\342\206\221");
3662 n = SHOW_UTF8(n, "WACS_DARROW", "\342\206\223");
3664 n = SHOW_UTF8(n, "WACS_BLOCK", "\342\226\256");
3665 n = SHOW_UTF8(n, "WACS_BOARD", "\342\226\222");
3666 n = SHOW_UTF8(n, "WACS_LANTERN", "\342\230\203");
3667 n = SHOW_UTF8(n, "WACS_BULLET", "\302\267");
3668 n = SHOW_UTF8(n, "WACS_CKBOARD", "\342\226\222");
3669 n = SHOW_UTF8(n, "WACS_DEGREE", "\302\260");
3670 n = SHOW_UTF8(n, "WACS_DIAMOND", "\342\227\206");
3671 n = SHOW_UTF8(n, "WACS_PLMINUS", "\302\261");
3672 n = SHOW_UTF8(n, "WACS_PLUS", "\342\224\274");
3673 n = SHOW_UTF8(n, "WACS_GEQUAL", "\342\211\245");
3674 n = SHOW_UTF8(n, "WACS_NEQUAL", "\342\211\240");
3675 n = SHOW_UTF8(n, "WACS_LEQUAL", "\342\211\244");
3677 n = SHOW_UTF8(n, "WACS_STERLING", "\302\243");
3678 n = SHOW_UTF8(n, "WACS_PI", "\317\200");
3679 n = SHOW_UTF8(n, "WACS_S1", "\342\216\272");
3680 n = SHOW_UTF8(n, "WACS_S3", "\342\216\273");
3681 n = SHOW_UTF8(n, "WACS_S7", "\342\216\274");
3682 (void) SHOW_UTF8(n, "WACS_S9", "\342\216\275");
3687 /* display the wide-ACS character set */
3689 wide_acs_display(void)
3695 chtype attr = A_NORMAL;
3696 int fg = COLOR_BLACK;
3697 int bg = COLOR_BLACK;
3698 unsigned at_code = 0;
3700 void (*last_show_wacs) (int, attr_t, short) = 0;
3708 ToggleAcs(last_show_wacs, show_wacs_chars);
3712 ToggleAcs(last_show_wacs, show_wacs_chars_double);
3717 ToggleAcs(last_show_wacs, show_wacs_chars_thick);
3721 ToggleAcs(last_show_wacs, show_wbox_chars);
3724 ToggleAcs(last_show_wacs, show_utf8_chars);
3727 if (c < 256 && isdigit(c)) {
3730 } else if (c == '+') {
3733 } else if (c == '-' && digit > 0) {
3736 } else if (c == '>' && repeat < (COLS / 4)) {
3738 } else if (c == '<' && repeat > 1) {
3740 } else if (c == '_') {
3741 space = (space == ' ') ? '_' : ' ';
3743 } else if (cycle_attr(c, &at_code, &attr)
3744 || cycle_colors(c, &fg, &bg, &pair)) {
3745 if (last_show_wacs != 0)
3753 if (last_show_wacs != 0)
3754 last_show_wacs(repeat, attr, pair);
3756 show_upper_widechars(digit * 32 + 128, repeat, space, attr, pair);
3758 MvPrintw(LINES - 3, 0,
3759 "Select: a/d/t WACS, x box, u UTF-8, 0-9,+/- non-ASCII, </> repeat, ESC=quit");
3761 MvPrintw(LINES - 2, 0,
3762 "v/V, f/F, b/B cycle through video attributes (%s) and color %d/%d.",
3763 attrs_to_cycle[at_code].name,
3766 MvPrintw(LINES - 2, 0,
3767 "v/V cycles through video attributes (%s).",
3768 attrs_to_cycle[at_code].name);
3771 } while (!isQuit(c = Getchar()));
3781 * Graphic-rendition test (adapted from vttest)
3784 test_sgr_attributes(void)
3788 for (pass = 0; pass < 2; pass++) {
3789 chtype normal = ((pass == 0 ? A_NORMAL : A_REVERSE)) | BLANK;
3791 /* Use non-default colors if possible to exercise bce a little */
3793 init_pair(1, COLOR_WHITE, COLOR_BLUE);
3794 normal |= COLOR_PAIR(1);
3798 MvPrintw(1, 20, "Graphic rendition test pattern:");
3800 MvPrintw(4, 1, "vanilla");
3802 #define set_sgr(mask) bkgdset((normal^(mask)));
3804 MvPrintw(4, 40, "bold");
3806 set_sgr(A_UNDERLINE);
3807 MvPrintw(6, 6, "underline");
3809 set_sgr(A_BOLD | A_UNDERLINE);
3810 MvPrintw(6, 45, "bold underline");
3813 MvPrintw(8, 1, "blink");
3815 set_sgr(A_BLINK | A_BOLD);
3816 MvPrintw(8, 40, "bold blink");
3818 set_sgr(A_UNDERLINE | A_BLINK);
3819 MvPrintw(10, 6, "underline blink");
3821 set_sgr(A_BOLD | A_UNDERLINE | A_BLINK);
3822 MvPrintw(10, 45, "bold underline blink");
3825 MvPrintw(12, 1, "negative");
3827 set_sgr(A_BOLD | A_REVERSE);
3828 MvPrintw(12, 40, "bold negative");
3830 set_sgr(A_UNDERLINE | A_REVERSE);
3831 MvPrintw(14, 6, "underline negative");
3833 set_sgr(A_BOLD | A_UNDERLINE | A_REVERSE);
3834 MvPrintw(14, 45, "bold underline negative");
3836 set_sgr(A_BLINK | A_REVERSE);
3837 MvPrintw(16, 1, "blink negative");
3839 set_sgr(A_BOLD | A_BLINK | A_REVERSE);
3840 MvPrintw(16, 40, "bold blink negative");
3842 set_sgr(A_UNDERLINE | A_BLINK | A_REVERSE);
3843 MvPrintw(18, 6, "underline blink negative");
3845 set_sgr(A_BOLD | A_UNDERLINE | A_BLINK | A_REVERSE);
3846 MvPrintw(18, 45, "bold underline blink negative");
3849 MvPrintw(LINES - 2, 1, "%s background. ", pass == 0 ? "Dark" :
3855 bkgdset(A_NORMAL | BLANK);
3860 /****************************************************************************
3862 * Windows and scrolling tester.
3864 ****************************************************************************/
3866 #define BOTLINES 4 /* number of line stolen from screen bottom */
3872 #define FRAME struct frame
3881 #if defined(NCURSES_VERSION)
3882 #if (NCURSES_VERSION_PATCH < 20070331) && NCURSES_EXT_FUNCS
3883 #define is_keypad(win) (win)->_use_keypad
3884 #define is_scrollok(win) (win)->_scroll
3885 #elif !defined(is_keypad)
3886 #define is_keypad(win) FALSE
3887 #define is_scrollok(win) FALSE
3890 #define is_keypad(win) FALSE
3891 #define is_scrollok(win) FALSE
3895 frame_win(FRAME * curp)
3897 return (curp != 0) ? curp->wind : stdscr;
3900 /* We need to know if these flags are actually set, so don't look in FRAME.
3901 * These names are known to work with SVr4 curses as well as ncurses. The
3902 * _use_keypad name does not work with Solaris 8.
3905 HaveKeypad(FRAME * curp)
3907 WINDOW *win = frame_win(curp);
3909 return is_keypad(win);
3913 HaveScroll(FRAME * curp)
3915 WINDOW *win = frame_win(curp);
3917 return is_scrollok(win);
3921 newwin_legend(FRAME * curp)
3923 static const struct {
3928 "^C = create window", 0
3931 "^N = next window", 0
3934 "^P = previous window", 0
3937 "^F = scroll forward", 0
3940 "^B = scroll backward", 0
3943 "^K = keypad(%s)", 1
3946 "^S = scrollok(%s)", 2
3949 "^W = save window to file", 0
3952 "^R = restore window", 0
3965 bool do_keypad = HaveKeypad(curp);
3966 bool do_scroll = HaveScroll(curp);
3970 for (n = 0; n < SIZEOF(legend); n++) {
3971 switch (legend[n].code) {
3973 strcpy(buf, legend[n].msg);
3976 sprintf(buf, legend[n].msg, do_keypad ? "yes" : "no");
3979 sprintf(buf, legend[n].msg, do_scroll ? "yes" : "no");
3982 sprintf(buf, legend[n].msg, do_keypad ? "/ESC" : "");
3985 x = getcurx(stdscr);
3986 addstr((COLS < (x + 3 + (int) strlen(buf))) ? "\n" : (n ? ", " : ""));
3993 transient(FRAME * curp, NCURSES_CONST char *msg)
3995 newwin_legend(curp);
3997 MvAddStr(LINES - 1, 0, msg);
4003 printw("%s characters are echoed, window should %sscroll.",
4004 HaveKeypad(curp) ? "Non-arrow" : "All other",
4005 HaveScroll(curp) ? "" : "not ");
4010 newwin_report(FRAME * curp)
4011 /* report on the cursor's current position, then restore it */
4013 WINDOW *win = frame_win(curp);
4017 transient(curp, (char *) 0);
4019 move(LINES - 1, COLS - 17);
4020 printw("Y = %2d X = %2d", y, x);
4028 selectcell(int uli, int ulj, int lri, int lrj)
4029 /* arrows keys move cursor, return location at current on non-arrow key */
4031 static pair res; /* result cell */
4032 int si = lri - uli + 1; /* depth of the select area */
4033 int sj = lrj - ulj + 1; /* width of the select area */
4034 int i = 0, j = 0; /* offsets into the select area */
4039 move(uli + i, ulj + j);
4040 newwin_report((FRAME *) 0);
4042 switch (Getchar()) {
4056 return ((pair *) 0);
4057 #ifdef NCURSES_MOUSE_VERSION
4063 if (event.y > uli && event.x > ulj) {
4084 outerbox(pair ul, pair lr, bool onoff)
4085 /* draw or erase a box *outside* the given pair of corners */
4087 MvAddCh(ul.y - 1, lr.x - 1, onoff ? ACS_ULCORNER : ' ');
4088 MvAddCh(ul.y - 1, lr.x + 1, onoff ? ACS_URCORNER : ' ');
4089 MvAddCh(lr.y + 1, lr.x + 1, onoff ? ACS_LRCORNER : ' ');
4090 MvAddCh(lr.y + 1, ul.x - 1, onoff ? ACS_LLCORNER : ' ');
4091 move(ul.y - 1, ul.x);
4092 hline(onoff ? ACS_HLINE : ' ', lr.x - ul.x + 1);
4093 move(ul.y, ul.x - 1);
4094 vline(onoff ? ACS_VLINE : ' ', lr.y - ul.y + 1);
4095 move(lr.y + 1, ul.x);
4096 hline(onoff ? ACS_HLINE : ' ', lr.x - ul.x + 1);
4097 move(ul.y, lr.x + 1);
4098 vline(onoff ? ACS_VLINE : ' ', lr.y - ul.y + 1);
4103 /* Ask user for a window definition */
4110 addstr("Use arrows to move cursor, anything else to mark corner 1");
4112 if ((tmp = selectcell(2, 1, LINES - BOTLINES - 2, COLS - 2)) == (pair *) 0)
4113 return ((WINDOW *) 0);
4114 memcpy(&ul, tmp, sizeof(pair));
4115 MvAddCh(ul.y - 1, ul.x - 1, ACS_ULCORNER);
4118 addstr("Use arrows to move cursor, anything else to mark corner 2");
4120 if ((tmp = selectcell(ul.y, ul.x, LINES - BOTLINES - 2, COLS - 2)) ==
4122 return ((WINDOW *) 0);
4123 memcpy(&lr, tmp, sizeof(pair));
4125 rwindow = subwin(stdscr, lr.y - ul.y + 1, lr.x - ul.x + 1, ul.y, ul.x);
4127 outerbox(ul, lr, TRUE);
4138 newwin_move(FRAME * curp, int dy, int dx)
4140 WINDOW *win = frame_win(curp);
4144 getyx(win, cur_y, cur_x);
4145 getmaxyx(win, max_y, max_x);
4146 if ((cur_x += dx) < 0)
4148 else if (cur_x >= max_x)
4150 if ((cur_y += dy) < 0)
4152 else if (cur_y >= max_y)
4154 wmove(win, cur_y, cur_x);
4158 delete_framed(FRAME * fp, bool showit)
4163 fp->last->next = fp->next;
4164 fp->next->last = fp->last;
4172 np = (fp == fp->next) ? 0 : fp->next;
4179 acs_and_scroll(void)
4180 /* Demonstrate windows */
4183 FRAME *current = (FRAME *) 0, *neww;
4185 #if HAVE_PUTWIN && HAVE_GETWIN
4189 #define DUMPFILE "screendump"
4191 #ifdef NCURSES_MOUSE_VERSION
4192 mousemask(BUTTON1_CLICKED, (mmask_t *) 0);
4197 transient((FRAME *) 0, (char *) 0);
4200 if ((neww = typeCalloc(FRAME, 1)) == 0) {
4203 if ((neww->wind = getwindow()) == (WINDOW *) 0) {
4208 if (current == 0) { /* First element, */
4209 neww->next = neww; /* so point it at itself */
4212 neww->next = current->next;
4213 neww->last = current;
4214 neww->last->next = neww;
4215 neww->next->last = neww;
4218 /* SVr4 curses sets the keypad on all newly-created windows to
4219 * false. Someone reported that PDCurses makes new windows inherit
4220 * this flag. Remove the following 'keypad()' call to test this
4222 keypad(current->wind, TRUE);
4223 current->do_keypad = HaveKeypad(current);
4224 current->do_scroll = HaveScroll(current);
4227 case CTRL('N'): /* go to next window */
4229 current = current->next;
4232 case CTRL('P'): /* go to previous window */
4234 current = current->last;
4237 case CTRL('F'): /* scroll current window forward */
4239 wscrl(frame_win(current), 1);
4242 case CTRL('B'): /* scroll current window backwards */
4244 wscrl(frame_win(current), -1);
4247 case CTRL('K'): /* toggle keypad mode for current */
4249 current->do_keypad = !current->do_keypad;
4250 keypad(current->wind, current->do_keypad);
4256 current->do_scroll = !current->do_scroll;
4257 scrollok(current->wind, current->do_scroll);
4261 #if HAVE_PUTWIN && HAVE_GETWIN
4262 case CTRL('W'): /* save and delete window */
4263 if ((current != 0) && (current == current->next)) {
4264 transient(current, "Will not save/delete ONLY window");
4266 } else if ((fp = fopen(DUMPFILE, "w")) == (FILE *) 0) {
4267 transient(current, "Can't open screen dump file");
4269 (void) putwin(frame_win(current), fp);
4272 current = delete_framed(current, TRUE);
4276 case CTRL('R'): /* restore window */
4277 if ((fp = fopen(DUMPFILE, "r")) == (FILE *) 0) {
4278 transient(current, "Can't open screen dump file");
4280 if ((neww = typeCalloc(FRAME, 1)) != 0) {
4282 neww->next = current ? current->next : 0;
4283 neww->last = current;
4284 if (neww->last != 0)
4285 neww->last->next = neww;
4286 if (neww->next != 0)
4287 neww->next->last = neww;
4289 neww->wind = getwin(fp);
4291 wrefresh(neww->wind);
4299 case CTRL('X'): /* resize window */
4306 addstr("Use arrows to move cursor, anything else to mark new corner");
4309 getbegyx(current->wind, ul.y, ul.x);
4311 tmp = selectcell(ul.y, ul.x, LINES - BOTLINES - 2, COLS - 2);
4312 if (tmp == (pair *) 0) {
4317 getmaxyx(current->wind, lr.y, lr.x);
4320 outerbox(ul, lr, FALSE);
4321 wnoutrefresh(stdscr);
4323 /* strictly cosmetic hack for the test */
4324 getmaxyx(current->wind, my, mx);
4325 if (my > tmp->y - ul.y) {
4326 getyx(current->wind, lr.y, lr.x);
4327 wmove(current->wind, tmp->y - ul.y + 1, 0);
4328 wclrtobot(current->wind);
4329 wmove(current->wind, lr.y, lr.x);
4331 if (mx > tmp->x - ul.x)
4332 for (i = 0; i < my; i++) {
4333 wmove(current->wind, i, tmp->x - ul.x + 1);
4334 wclrtoeol(current->wind);
4336 wnoutrefresh(current->wind);
4338 memcpy(&lr, tmp, sizeof(pair));
4339 (void) wresize(current->wind, lr.y - ul.y + 0, lr.x - ul.x + 0);
4341 getbegyx(current->wind, ul.y, ul.x);
4342 getmaxyx(current->wind, lr.y, lr.x);
4345 outerbox(ul, lr, TRUE);
4346 wnoutrefresh(stdscr);
4348 wnoutrefresh(current->wind);
4354 #endif /* HAVE_WRESIZE */
4356 case KEY_F(10): /* undocumented --- use this to test area clears */
4357 selectcell(0, 0, LINES - 1, COLS - 1);
4363 newwin_move(current, -1, 0);
4366 newwin_move(current, 1, 0);
4369 newwin_move(current, 0, -1);
4372 newwin_move(current, 0, 1);
4380 getyx(frame_win(current), y, x);
4384 x = getmaxx(frame_win(current)) - 1;
4386 (void) mvwdelch(frame_win(current), y, x);
4396 waddch(current->wind, (chtype) c);
4401 newwin_report(current);
4402 usescr = frame_win(current);
4405 (!isQuit(c = wGetchar(usescr))
4409 while (current != 0)
4410 current = delete_framed(current, FALSE);
4412 scrollok(stdscr, TRUE); /* reset to driver's default */
4413 #ifdef NCURSES_MOUSE_VERSION
4414 mousemask(0, (mmask_t *) 0);
4421 /****************************************************************************
4425 ****************************************************************************/
4428 static int nap_msec = 1;
4430 static NCURSES_CONST char *mod[] =
4440 /*+-------------------------------------------------------------------------
4442 --------------------------------------------------------------------------*/
4444 wait_a_while(int msec GCC_UNUSED)
4454 else if (msec > 1000)
4455 sleep((unsigned) msec / 1000);
4459 } /* end of wait_a_while */
4461 /*+-------------------------------------------------------------------------
4463 --------------------------------------------------------------------------*/
4465 saywhat(NCURSES_CONST char *text)
4467 wmove(stdscr, LINES - 1, 0);
4469 if (text != 0 && *text != '\0') {
4470 waddstr(stdscr, text);
4471 waddstr(stdscr, "; ");
4473 waddstr(stdscr, "press any key to continue");
4474 } /* end of saywhat */
4476 /*+-------------------------------------------------------------------------
4477 mkpanel(rows,cols,tly,tlx) - alloc a win and panel and associate them
4478 --------------------------------------------------------------------------*/
4480 mkpanel(short color, int rows, int cols, int tly, int tlx)
4485 if ((win = newwin(rows, cols, tly, tlx)) != 0) {
4486 if ((pan = new_panel(win)) == 0) {
4488 } else if (use_colors) {
4489 short fg = (short) ((color == COLOR_BLUE) ? COLOR_WHITE : COLOR_BLACK);
4492 init_pair(color, fg, bg);
4493 wbkgdset(win, (attr_t) (COLOR_PAIR(color) | ' '));