/****************************************************************************
- * Copyright (c) 1998-2015,2016 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
Author: Eric S. Raymond <esr@snark.thyrsus.com> 1993
Thomas E. Dickey (beginning revision 1.27 in 1996).
-$Id: ncurses.c,v 1.446 2016/09/17 21:12:04 tom Exp $
+$Id: ncurses.c,v 1.460 2017/09/09 22:52:38 tom Exp $
***************************************************************************/
#ifdef TRACE
static unsigned save_trace = TRACE_ORDINARY | TRACE_ICALLS | TRACE_CALLS;
-extern unsigned _nc_tracing;
#endif
#else
#define state_unused
#endif
-#define ToggleAcs(temp,real) temp = ((temp == real) ? 0 : real)
+#define ToggleAcs(temp,real) temp = ((temp == real) ? NULL : real)
#define P(string) printw("%s\n", string)
#undef max_pairs
static int max_pairs; /* ...and the number of color pairs */
+#if HAVE_COLOR_CONTENT
typedef struct {
NCURSES_COLOR_T red;
NCURSES_COLOR_T green;
} RGB_DATA;
static RGB_DATA *all_colors;
+#endif
static void main_menu(bool);
static void failed(const char *s) GCC_NORETURN;
ExitProgram(EXIT_FAILURE);
}
-/* The behavior of mvhline, mvvline for negative/zero length is unspecified,
- * though we can rely on negative x/y values to stop the macro.
- */
-static void
-do_h_line(int y, int x, chtype c, int to)
-{
- if ((to) > (x))
- MvHLine(y, x, c, (to) - (x));
-}
-
-static void
-do_v_line(int y, int x, chtype c, int to)
-{
- if ((to) > (y))
- MvVLine(y, x, c, (to) - (y));
-}
-
static void
Repaint(void)
{
touchwin(stdscr);
+#if HAVE_CURSCR
touchwin(curscr);
wrefresh(curscr);
+#else
+ wrefresh(stdscr);
+#endif
}
static bool
"Toggles:");
if (use_colors) {
MvWPrintw(helpwin, row++, col,
- " f/F/b/F toggle foreground/background background color");
+ " f/F/b/B toggle foreground/background background color");
MvWPrintw(helpwin, row++, col,
" t/T toggle text/background color attribute");
}
case CTRL('L'):
Repaint();
break;
- case '?':
+ case HELP_KEY_1:
if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
box(helpwin, 0, 0);
attr_legend(helpwin);
case CTRL('L'):
Repaint();
break;
- case '?':
+ case HELP_KEY_1:
if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
box_set(helpwin, 0, 0);
attr_legend(helpwin);
}
}
break;
- case '?':
+ case HELP_KEY_1:
if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
box(helpwin, 0, 0);
color_legend(helpwin, FALSE);
}
}
break;
- case '?':
+ case HELP_KEY_1:
if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
box(helpwin, 0, 0);
color_legend(helpwin, TRUE);
}
#endif /* USE_WIDEC_SUPPORT */
+#if HAVE_COLOR_CONTENT
static void
change_color(NCURSES_PAIRS_T current, int field, int value, int usebase)
{
change_color((NCURSES_PAIRS_T) current, field, value, 0);
break;
- case '?':
+ case HELP_KEY_1:
erase();
P(" RGB Value Editing Help");
P("");
endwin();
}
+#endif /* HAVE_COLOR_CONTENT */
/****************************************************************************
*
case 's':
MvPrintw(SLK_WORK, 0, "Press Q to stop the scrolling-test: ");
while ((c = Getchar()) != 'Q' && (c != ERR))
- addch((chtype) c);
+ AddCh(c);
break;
case 'd':
case 's':
MvPrintw(SLK_WORK, 0, "Press Q to stop the scrolling-test: ");
while ((c = Getchar()) != 'Q' && (c != ERR))
- addch((chtype) c);
+ AddCh(c);
break;
case 'd':
int col = (int) (5 * (code % 16));
IGNORE_RC(mvaddch(row, col, colored_chtype(code, attr, pair)));
for (count = 1; count < repeat; ++count) {
- addch(colored_chtype(code, attr, pair));
+ AddCh(colored_chtype(code, attr, pair));
}
}
if (C1) {
/* (yes, this _is_ crude) */
while ((reply = Getchar()) != ERR) {
- addch(UChar(reply));
+ AddCh(UChar(reply));
napms(10);
}
nodelay(stdscr, FALSE);
*/
break;
default:
- addch(colored_chtype(code, A_ALTCHARSET | attr, pair));
+ AddCh(colored_chtype(code, A_ALTCHARSET | attr, pair));
break;
}
} while (--count > 0);
MvPrintw(row, col, "%*s : ", COLS / 4, name);
do {
- addch(code);
+ AddCh(code);
} while (--repeat > 0);
return n + 1;
}
setcchar(&temp, codes, attr, pair, 0);
move(row, col);
if (wcwidth(code) == 0 && code != 0) {
- addch((chtype) space |
+ AddCh((chtype) space |
(A_REVERSE ^ attr) |
(attr_t) COLOR_PAIR(pair));
}
* the display.
*/
if (wcwidth(code) == 0) {
- addch((chtype) space |
+ AddCh((chtype) space |
(A_REVERSE ^ attr) |
(attr_t) COLOR_PAIR(pair));
}
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));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_D_PLUS));
#ifdef CURSES_WACS_ARRAY
n = show_1_wacs(n, repeat, BOTH2(WACS_GEQUAL));
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));
+ n = show_1_wacs(n, repeat, BOTH2(WACS_T_PLUS));
#ifdef CURSES_WACS_ARRAY
n = show_1_wacs(n, repeat, BOTH2(WACS_GEQUAL));
break;
}
}
- /* FALLTHRU */
#endif
+ /* FALLTHRU */
default:
res.y = uli + i;
res.x = ulj + j;
}
delwin(fp->wind);
- np = (fp == fp->next) ? 0 : fp->next;
+ np = (fp == fp->next) ? NULL : fp->next;
free(fp);
}
return np;
rmpanel(pan)
--------------------------------------------------------------------------*/
static void
-rmpanel(PANEL * pan)
+rmpanel(PANEL *pan)
{
WINDOW *win = panel_window(pan);
del_panel(pan);
}
static void
-fill_panel(PANEL * pan)
+fill_panel(PANEL *pan)
{
WINDOW *win = panel_window(pan);
const char *userptr = (const char *) panel_userptr(pan);
}
static void
-fill_wide_panel(PANEL * pan)
+fill_wide_panel(PANEL *pan)
{
WINDOW *win = panel_window(pan);
const char *userptr = (const char *) panel_userptr(pan);
#define MAX_PANELS 5
static void
-canned_panel(PANEL * px[MAX_PANELS + 1], NCURSES_CONST char *cmd)
+canned_panel(PANEL *px[MAX_PANELS + 1], NCURSES_CONST char *cmd)
{
int which = cmd[1] - '0';
*
****************************************************************************/
+#if HAVE_NEWPAD
+
+/* The behavior of mvhline, mvvline for negative/zero length is unspecified,
+ * though we can rely on negative x/y values to stop the macro.
+ */
+static void
+do_h_line(int y, int x, chtype c, int to)
+{
+ if ((to) > (x))
+ MvHLine(y, x, c, (to) - (x));
+}
+
+static void
+do_v_line(int y, int x, chtype c, int to)
+{
+ if ((to) > (y))
+ MvVLine(y, x, c, (to) - (y));
+}
+
#define GRIDSIZE 3
static bool pending_pan = FALSE;
erase();
/* FALLTHRU */
- case '?':
- if (c == '?')
+ case HELP_KEY_1:
+ if (c == HELP_KEY_1)
show_panner_legend = !show_panner_legend;
panner_legend(LINES - 4);
panner_legend(LINES - 3);
endwin();
erase();
}
+#endif /* HAVE_NEWPAD */
/****************************************************************************
*
}
static void
-display_form(FORM * f)
+display_form(FORM *f)
{
WINDOW *w;
int rows, cols;
}
static void
-erase_form(FORM * f)
+erase_form(FORM *f)
{
WINDOW *w = form_win(f);
WINDOW *s = form_sub(f);
}
static int
-edit_secure(FIELD * me, int c)
+edit_secure(FIELD *me, int c)
{
int rows, cols, frow, fcol, nrow, nbuf;
}
static int
-form_virtualize(FORM * f, WINDOW *w)
+form_virtualize(FORM *f, WINDOW *w)
{
/* *INDENT-OFF* */
static const struct {
}
static int
-my_form_driver(FORM * form, int c)
+my_form_driver(FORM *form, int c)
{
if (c == (MAX_FORM_COMMAND + 1)
&& form_driver(form, REQ_VALIDATION) == E_OK)
*
****************************************************************************/
+#if HAVE_COPYWIN /* ...and overlay, overwrite */
static void
fillwin(WINDOW *win, char ch)
{
state = overlap_help(state, flavor);
break;
- case '?':
+ case HELP_KEY_1:
state = overlap_help(state, flavor);
break;
delwin(win2);
delwin(win1);
erase();
- curs_set(1);
- endwin();
+ exit_curses();
}
+#endif /* HAVE_COPYWIN */
+
static void
show_setting_name(const char *name)
{
addstr("<NULL>");
attroff(A_REVERSE);
}
- addch('\n');
+ AddCh('\n');
}
static void
printw("%d", value);
attroff(A_REVERSE);
}
- addch('\n');
+ AddCh('\n');
}
static void
printw("%d", value);
attroff(A_REVERSE);
}
- addch('\n');
+ AddCh('\n');
}
static void
show_boolean_setting("has_il", has_il());
Pause();
erase();
- endwin();
+ exit_curses();
}
/****************************************************************************
break;
#endif
+#if HAVE_COLOR_CONTENT
case 'd':
if (!use_colors)
Cannot("does not support color.");
else
color_edit();
break;
+#endif
#if USE_SOFTKEYS
case 'e':
break;
#endif
+#if HAVE_NEWPAD
case 'p':
demo_pad(FALSE);
break;
case 'P':
demo_pad(TRUE);
break;
+#endif
#if USE_LIBFORM
case 'r':
break;
#endif
+#if HAVE_COPYWIN
case 's':
overlap_test();
break;
+#endif
#if USE_LIBMENU && defined(TRACE)
case 't':
," -h rip-off header line (can repeat)"
#endif
," -m do not use colors"
+#if HAVE_COLOR_CONTENT
," -p file rgb values to use in 'd' rather than ncurses's builtin"
+#endif
#if USE_LIBPANEL
," -s msec specify nominal time for panel-demo (default: 1, to hold)"
#endif
#ifdef TRACE
," -t mask specify default trace-level (may toggle with ^T)"
#endif
+#if HAVE_COLOR_CONTENT
," -x use xterm-compatible control for reading color palette"
+#endif
};
size_t n;
for (n = 0; n < SIZEOF(tbl); n++)
#if USE_WIDEC_SUPPORT
(void) puts("C = color test pattern using wide-character calls");
#endif
+#if HAVE_COLOR_CONTENT
if (top)
(void) puts("d = edit RGB color values");
+#endif
#if USE_SOFTKEYS
(void) puts("e = exercise soft keys");
#if USE_WIDEC_SUPPORT
(void) puts("O = exercise panels with wide-characters");
#endif
#endif
+#if HAVE_NEWPAD
(void) puts("p = exercise pad features");
(void) puts("P = exercise pad features, using color");
+#endif
(void) puts("q = quit");
#if USE_LIBFORM
(void) puts("r = exercise forms code");
#endif
+#if HAVE_COPYWIN
(void) puts("s = overlapping-refresh test");
+#endif
#if USE_LIBMENU && defined(TRACE)
(void) puts("t = set trace level");
#endif
bool assumed_colors = FALSE;
bool default_colors = FALSE;
#endif
- char *palette_file = 0;
bool monochrome = FALSE;
+#if HAVE_COLOR_CONTENT
bool xterm_colors = FALSE;
+ char *palette_file = 0;
+#endif
setlocale(LC_ALL, "");
case 'm':
monochrome = TRUE;
break;
+#if HAVE_COLOR_CONTENT
case 'p':
palette_file = optarg;
break;
+#endif
#if USE_LIBPANEL
case 's':
nap_msec = (int) atol(optarg);
save_trace = (unsigned) strtol(optarg, 0, 0);
break;
#endif
+#if HAVE_COLOR_CONTENT
case 'x':
xterm_colors = TRUE;
break;
+#endif
default:
usage();
}
#endif
max_pairs = COLOR_PAIRS; /* was > 256 ? 256 : COLOR_PAIRS */
+#if HAVE_COLOR_CONTENT
if (can_change_color()) {
init_all_colors(xterm_colors, palette_file);
}
+#endif
}
/*