/****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2014,2015 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.412 2014/07/27 00:24:00 tom Exp $
+$Id: ncurses.c,v 1.420 2015/05/23 23:41:25 tom Exp $
***************************************************************************/
static wchar_t
fullwidth_digit(int ch)
{
- return (ch + 0xff10 - '0');
+ return (wchar_t) (ch + 0xff10 - '0');
}
static void
{
int ch;
while ((ch = *source++) != 0) {
- *target++ = ch;
+ *target++ = (wchar_t) ch;
}
*target = 0;
}
refresh();
#ifdef NCURSES_MOUSE_VERSION
- mousemask(ALL_MOUSE_EVENTS, (mmask_t *) 0);
+ mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, (mmask_t *) 0);
#endif
(void) printw("Delay in 10ths of a second (<CR> for blocking input)? ");
(void) waddch(win, ch | attr);
}
} else {
- (void) wattrset(win, (int) attr);
+ (void) wattrset(win, AttrArg(attr, 0));
(void) waddstr(win, attr_test_string);
(void) wattroff(win, (int) attr);
}
beep();
} else {
extras |= (chtype) COLOR_PAIR(pair);
+ normal &= ~A_COLOR;
}
}
}
for (j = 0; j < my_size; ++j) {
bool arrow = (j == k);
row = show_attr(my_wins[j], row, n, arrow,
+ normal |
extras |
my_list[j].attr |
my_list[k].attr,
#define FULL_HI 0xff5e
#define HALF_LO 0x20
-#define isFullWidth(ch) ((ch) >= FULL_LO && (ch) <= FULL_HI)
-#define ToNormalWidth(ch) (((ch) - FULL_LO) + HALF_LO)
-#define ToFullWidth(ch) (((ch) - HALF_LO) + FULL_LO)
+#define isFullWidth(ch) ((int)(ch) >= FULL_LO && (int)(ch) <= FULL_HI)
+#define ToNormalWidth(ch) (wchar_t) (((int)(ch) - FULL_LO) + HALF_LO)
+#define ToFullWidth(ch) (wchar_t) (((int)(ch) - HALF_LO) + FULL_LO)
/*
* Returns an ASCII code in [32..126]
static wchar_t
normal_wchar(int ch)
{
- wchar_t result = ch;
+ wchar_t result = (wchar_t) ch;
if (isFullWidth(ch))
result = ToNormalWidth(ch);
return result;
static wchar_t
target_wchar(int ch)
{
- wchar_t result = ch;
+ wchar_t result = (wchar_t) ch;
if (use_fullwidth) {
if (!isFullWidth(ch))
result = ToFullWidth(ch);
wide_init_attr_string(void)
{
use_fullwidth = FALSE;
- wide_attr_test_string[0] = default_attr_string();
+ wide_attr_test_string[0] = (wchar_t) default_attr_string();
wide_adjust_attr_string(0);
}
NCURSES_COLOR_T bg = InxToBG(i);
init_pair(pair, fg, bg);
- attron((attr_t) COLOR_PAIR(pair));
+ attron(COLOR_PAIR(pair));
if (opt_acsc)
- attron((attr_t) A_ALTCHARSET);
+ attron(A_ALTCHARSET);
if (opt_bold)
- attron((attr_t) A_BOLD);
+ attron(A_BOLD);
if (opt_revs)
- attron((attr_t) A_REVERSE);
+ attron(A_REVERSE);
if (opt_nums) {
sprintf(numbered, "{%02X}", (int) i);
init_pair(pair, InxToFG(i), InxToBG(i));
(void) color_set(pair, NULL);
if (opt_acsc)
- attr_on((attr_t) A_ALTCHARSET, NULL);
+ attr_on(A_ALTCHARSET, NULL);
if (opt_bold)
- attr_on((attr_t) A_BOLD, NULL);
+ attr_on(A_BOLD, NULL);
if (opt_revs)
- attr_on((attr_t) A_REVERSE, NULL);
+ attr_on(A_REVERSE, NULL);
if (opt_nums) {
sprintf(numbered, "{%02X}", i);
(i == current ? '>' : ' '),
(i < (int) SIZEOF(the_color_names)
? the_color_names[i] : numeric));
- (void) attrset((attr_t) COLOR_PAIR(i));
+ (void) attrset(AttrArg(COLOR_PAIR(i), 0));
addstr(" ");
(void) attrset(A_NORMAL);
MvPrintw(0, 20, "Display of Character Codes %#x to %#x", first, last);
attroff(A_BOLD);
- for (code = first; (int) code <= last; code++) {
+ for (code = (wchar_t) first; (int) code <= last; code++) {
int row = (2 + ((int) code - first) / per_line);
int col = 5 * ((int) code % per_line);
int count;
MvPrintw(0, 20, "Display of Character Codes %d to %d", first, last);
attroff(A_BOLD);
- for (code = first; (int) code <= last; code++) {
+ for (code = (wchar_t) first; (int) code <= last; code++) {
int row = 2 + ((code - first) % 16);
int col = ((code - first) / 16) * COLS / 2;
wchar_t codes[10];
}
static void
-fill_pad(WINDOW *panpad, bool pan_lines)
+fill_pad(WINDOW *panpad, bool pan_lines, bool colored)
{
int y, x;
unsigned gridcount = 0;
+ chtype fill = 0;
+#ifdef A_COLOR
+ if (colored)
+ fill = (chtype) COLOR_PAIR(1);
+#endif
wmove(panpad, 0, 0);
for (y = 0; y < getmaxy(panpad); y++) {
waddch(panpad, pan_lines ? ACS_LTEE : '+');
else
waddch(panpad, (chtype) ((pan_lines ? 'a' : 'A') +
- (int) (gridcount++ % 26)));
+ (int) (gridcount++ % 26)) | fill);
} else if (y % GRIDSIZE == 0)
waddch(panpad, pan_lines ? ACS_HLINE : '-');
else if (x % GRIDSIZE == 0)
static void
panner(WINDOW *pad,
int top_x, int top_y, int porty, int portx,
- int (*pgetc) (WINDOW *))
+ int (*pgetc) (WINDOW *),
+ bool colored)
{
#if HAVE_GETTIMEOFDAY
struct timeval before, after;
break;
case 'a':
pan_lines = !pan_lines;
- fill_pad(pad, pan_lines);
+ fill_pad(pad, pan_lines, colored);
pending_pan = FALSE;
break;
#define PAD_WIDE 200
static void
-demo_pad(void)
+demo_pad(bool colored)
/* Demonstrate pads. */
{
WINDOW *panpad = newpad(PAD_HIGH, PAD_WIDE);
return;
}
- fill_pad(panpad, FALSE);
+#ifdef A_COLOR
+ if (colored && use_colors) {
+ init_pair(1, COLOR_BLACK, COLOR_GREEN);
+ init_pair(2, COLOR_CYAN, COLOR_BLUE);
+ wbkgd(panpad, (chtype) (COLOR_PAIR(2) | ' '));
+ }
+#endif
+ fill_pad(panpad, FALSE, colored);
panner_legend(LINES - 4);
panner_legend(LINES - 3);
* We'll still be able to widen it during a test, since that's required
* for testing boundaries.
*/
- panner(panpad, 2, 2, LINES - 5, COLS - 15, padgetch);
+ panner(panpad, 2, 2, LINES - 5, COLS - 15, padgetch, colored);
delwin(panpad);
endwin();
break;
case 2:
init_pair(cpair, COLOR_BLUE, COLOR_WHITE);
- (void) wattrset(win, (int) ((chtype) COLOR_PAIR(cpair) | A_NORMAL));
+ (void) wattrset(win, AttrArg(COLOR_PAIR(cpair), A_NORMAL));
break;
case 3:
init_pair(cpair, COLOR_WHITE, COLOR_BLUE);
- (void) wattrset(win, (int) ((chtype) COLOR_PAIR(cpair) | A_BOLD));
+ (void) wattrset(win, AttrArg(COLOR_PAIR(cpair), A_BOLD));
break;
}
}
#endif
case 'p':
- demo_pad();
+ demo_pad(FALSE);
+ break;
+
+ case 'P':
+ demo_pad(TRUE);
break;
#if USE_LIBFORM
#endif
#endif
(void) puts("p = exercise pad features");
+ (void) puts("P = exercise pad features, using color");
(void) puts("q = quit");
#if USE_LIBFORM
(void) puts("r = exercise forms code");