1
1
/****************************************************************************
2
* Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. *
2
* Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
4
4
* Permission is hereby granted, free of charge, to any person obtaining a *
5
5
* copy of this software and associated documentation files (the *
574
570
****************************************************************************/
576
#define NUM_GETCH_FLAGS 256
577
typedef bool GetchFlags[NUM_GETCH_FLAGS];
580
setup_getch(WINDOW *win, GetchFlags flags)
573
setup_getch(WINDOW *win, bool flags[])
582
575
keypad(win, flags['k']); /* should be redundant, but for testing */
583
576
meta(win, flags['m']); /* force this to a known state */
591
init_getch(WINDOW *win, GetchFlags flags)
593
memset(flags, FALSE, NUM_GETCH_FLAGS);
594
flags[UChar('k')] = (win == stdscr);
595
flags[UChar('m')] = TRUE;
597
setup_getch(win, flags);
601
wgetch_help(WINDOW *win, GetchFlags flags)
584
wgetch_help(WINDOW *win, bool flags[])
603
586
static const char *help[] =
851
837
(void) waddstr(win, keyname(c));
852
} else if (c >= 0x80) {
853
unsigned c2 = (unsigned) c;
854
#if !(defined(NCURSES_VERSION) || defined(_XOPEN_CURSES))
855
/* at least Solaris SVR4 curses breaks unctrl(128), etc. */
859
(void) wprintw(win, "%c", UChar(c));
860
else if (c2 != UChar(c))
838
} else if (c > 0x80) {
839
unsigned c2 = (unsigned) (c & 0x7f);
841
(void) wprintw(win, "M-%c", UChar(c2));
861
843
(void) wprintw(win, "M-%s", unctrl(c2));
863
(void) wprintw(win, "%s", unctrl(c2));
864
844
waddstr(win, " (high-half character)");
1117
1096
resize_wide_boxes(level, win);
1120
(void) waddstr(win, keyname((wchar_t) c));
1122
1099
(void) waddstr(win, key_name((wchar_t) c));
1123
1101
if (c < 256 && iscntrl(c)) {
1124
(void) wprintw(win, " (control character)");
1102
(void) wprintw(win, "%s (control character)", unctrl(c));
1126
(void) wprintw(win, " = %#x (printable character)",
1104
wchar_t c2 = (wchar_t) c;
1105
waddnwstr(win, &c2, 1);
1106
(void) wprintw(win, " = %#x (printable character)", (unsigned) c);
1130
1109
wgetch_wrap(win, first_y);
1901
1874
mvwprintw(helpwin, row++, col,
1902
1875
" n/N toggle text/number on/off");
1903
1876
mvwprintw(helpwin, row++, col,
1904
" r/R toggle reverse on/off");
1905
mvwprintw(helpwin, row++, col,
1906
1877
" w/W toggle width between 8/16 colors");
1907
1878
#if USE_WIDEC_SUPPORT
1981
1943
/* show color names/numbers across the top */
1982
1944
for (i = 0; i < per_row; i++)
1983
show_color_name(top + 2, (i + 1) * width, i + min_colors, opt_wide);
1945
show_color_name(top + 2, (i + 1) * width, i, opt_wide);
1985
1947
/* show a grid of colors, with color names/ numbers on the left */
1986
1948
for (i = (short) (base_row * per_row); i < pairs_max; i++) {
1988
1950
int col = (i % per_row + 1) * width;
1989
1951
short pair = i;
1991
#define InxToFG(i) (short) ((i % (COLORS - min_colors)) + min_colors)
1992
#define InxToBG(i) (short) ((i / (COLORS - min_colors)) + min_colors)
1993
1953
if (row >= 0 && move(row, col) != ERR) {
1994
short fg = InxToFG(i);
1995
short bg = InxToBG(i);
1954
short fg = (short) (i % COLORS);
1955
short bg = (short) (i / COLORS);
1997
1957
init_pair(pair, fg, bg);
1998
1958
attron((attr_t) COLOR_PAIR(pair));
2010
1968
printw("%-*.*s", width, width, hello);
2011
1969
attrset(A_NORMAL);
2013
if ((i % per_row) == 0 && InxToFG(i) == min_colors) {
2014
show_color_name(row, 0, InxToBG(i), opt_wide);
1971
if ((i % per_row) == 0 && (i % COLORS) == 0) {
1972
show_color_name(row, 0, i / COLORS, opt_wide);
2017
1975
} else if (shown) {
2185
2124
/* show color names/numbers across the top */
2186
2125
for (i = 0; i < per_row; i++)
2187
show_color_name(top + 2, (i + 1) * width, i + min_colors, opt_wide);
2126
show_color_name(top + 2, (i + 1) * width, i, opt_wide);
2189
2128
/* show a grid of colors, with color names/ numbers on the left */
2190
2129
for (i = (base_row * per_row); i < pairs_max; i++) {
2193
2132
short pair = (short) i;
2195
2134
if (row >= 0 && move(row, col) != ERR) {
2196
init_pair(pair, InxToFG(i), InxToBG(i));
2135
init_pair(pair, (short) (i % COLORS), (short) (i / COLORS));
2197
2136
color_set(pair, NULL);
2199
2138
attr_on((attr_t) A_ALTCHARSET, NULL);
2201
2140
attr_on((attr_t) A_BOLD, NULL);
2203
attr_on((attr_t) A_REVERSE, NULL);
2205
2142
if (opt_nums) {
2206
2143
sprintf(numbered, "{%02X}", i);
2213
2150
addnwstr(buffer, width);
2214
2151
attr_set(A_NORMAL, 0, NULL);
2216
if ((i % per_row) == 0 && InxToFG(i) == min_colors) {
2217
show_color_name(row, 0, InxToBG(i), opt_wide);
2153
if ((i % per_row) == 0 && (i % COLORS) == 0) {
2154
show_color_name(row, 0, i / COLORS, opt_wide);
2220
2157
} else if (shown) {
3039
2969
mvaddstr(0, 20, "Display of the ACS Line-Drawing Set");
3040
2970
attroff(A_BOLD);
3042
2973
/* *INDENT-OFF* */
3044
colored_chtype(ACS_VLINE, attr, pair),
3045
colored_chtype(ACS_VLINE, attr, pair),
3046
colored_chtype(ACS_HLINE, attr, pair),
3047
colored_chtype(ACS_HLINE, attr, pair),
3048
colored_chtype(ACS_ULCORNER, attr, pair),
3049
colored_chtype(ACS_URCORNER, attr, pair),
3050
colored_chtype(ACS_LLCORNER, attr, pair),
3051
colored_chtype(ACS_LRCORNER, attr, pair));
3052
mvhline(LINES / 2, 0, colored_chtype(ACS_HLINE, attr, pair), COLS);
3053
mvvline(0, COLS / 2, colored_chtype(ACS_VLINE, attr, pair), LINES);
3054
mvaddch(0, COLS / 2, colored_chtype(ACS_TTEE, attr, pair));
3055
mvaddch(LINES / 2, COLS / 2, colored_chtype(ACS_PLUS, attr, pair));
3056
mvaddch(LINES - 1, COLS / 2, colored_chtype(ACS_BTEE, attr, pair));
3057
mvaddch(LINES / 2, 0, colored_chtype(ACS_LTEE, attr, pair));
3058
mvaddch(LINES / 2, COLS - 1, colored_chtype(ACS_RTEE, attr, pair));
2974
mvhline(LINES / 2, 0, ACS_HLINE | attr, COLS);
2975
mvvline(0, COLS / 2, ACS_VLINE | attr, LINES);
2976
mvaddch(0, COLS / 2, ACS_TTEE | attr);
2977
mvaddch(LINES / 2, COLS / 2, ACS_PLUS | attr);
2978
mvaddch(LINES - 1, COLS / 2, ACS_BTEE | attr);
2979
mvaddch(LINES / 2, 0, ACS_LTEE | attr);
2980
mvaddch(LINES / 2, COLS - 1, ACS_RTEE | attr);
3059
2981
/* *INDENT-ON* */
3399
3321
attroff(A_BOLD);
3403
MERGE_ATTR(0, WACS_VLINE),
3404
MERGE_ATTR(1, WACS_VLINE),
3405
MERGE_ATTR(2, WACS_HLINE),
3406
MERGE_ATTR(3, WACS_HLINE),
3407
MERGE_ATTR(4, WACS_ULCORNER),
3408
MERGE_ATTR(5, WACS_URCORNER),
3409
MERGE_ATTR(6, WACS_LLCORNER),
3410
MERGE_ATTR(7, WACS_LRCORNER));
3324
attr_set(attr, pair, 0);
3325
box_set(stdscr, 0, 0);
3326
attr_set(A_NORMAL, 0, 0);
3411
3327
/* *INDENT-OFF* */
3412
mvhline_set(LINES / 2, 0, MERGE_ATTR(0, WACS_HLINE), COLS);
3413
mvvline_set(0, COLS / 2, MERGE_ATTR(0, WACS_VLINE), LINES);
3414
mvadd_wch(0, COLS / 2, MERGE_ATTR(0, WACS_TTEE));
3415
mvadd_wch(LINES / 2, COLS / 2, MERGE_ATTR(0, WACS_PLUS));
3416
mvadd_wch(LINES - 1, COLS / 2, MERGE_ATTR(0, WACS_BTEE));
3417
mvadd_wch(LINES / 2, 0, MERGE_ATTR(0, WACS_LTEE));
3418
mvadd_wch(LINES / 2, COLS - 1, MERGE_ATTR(0, WACS_RTEE));
3328
mvhline_set(LINES / 2, 0, MERGE_ATTR(WACS_HLINE), COLS);
3329
mvvline_set(0, COLS / 2, MERGE_ATTR(WACS_VLINE), LINES);
3330
mvadd_wch(0, COLS / 2, MERGE_ATTR(WACS_TTEE));
3331
mvadd_wch(LINES / 2, COLS / 2, MERGE_ATTR(WACS_PLUS));
3332
mvadd_wch(LINES - 1, COLS / 2, MERGE_ATTR(WACS_BTEE));
3333
mvadd_wch(LINES / 2, 0, MERGE_ATTR(WACS_LTEE));
3334
mvadd_wch(LINES / 2, COLS - 1, MERGE_ATTR(WACS_RTEE));
3419
3335
/* *INDENT-ON* */