X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fncurses.c;h=59a88c457402cc0a4ab43325e750246a0634ee56;hp=2eb18ec12cb2d615be76304977443e7114463ffb;hb=21c8ffa0edf2e389f3f674f0c08009002c6f357d;hpb=0dc2639645b2cc67271247405709161df24a771f diff --git a/test/ncurses.c b/test/ncurses.c index 2eb18ec1..59a88c45 100644 --- a/test/ncurses.c +++ b/test/ncurses.c @@ -1,5 +1,5 @@ /**************************************************************************** - * 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 * @@ -40,7 +40,7 @@ AUTHOR Author: Eric S. Raymond 1993 Thomas E. Dickey (beginning revision 1.27 in 1996). -$Id: ncurses.c,v 1.411 2014/07/19 22:56:40 tom Exp $ +$Id: ncurses.c,v 1.420 2015/05/23 23:41:25 tom Exp $ ***************************************************************************/ @@ -305,7 +305,7 @@ wGetstring(WINDOW *win, char *buffer, int limit) static wchar_t fullwidth_digit(int ch) { - return (ch + 0xff10 - '0'); + return (wchar_t) (ch + 0xff10 - '0'); } static void @@ -323,7 +323,7 @@ make_narrow_text(wchar_t *target, const char *source) { int ch; while ((ch = *source++) != 0) { - *target++ = ch; + *target++ = (wchar_t) ch; } *target = 0; } @@ -943,7 +943,7 @@ begin_getch_test(void) 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 ( for blocking input)? "); @@ -1436,9 +1436,9 @@ show_attr(WINDOW *win, int row, int skip, bool arrow, chtype attr, const char *n (void) waddch(win, ch | attr); } } else { - (void) wattrset(win, attr); + (void) wattrset(win, AttrArg(attr, 0)); (void) waddstr(win, attr_test_string); - (void) wattroff(win, attr); + (void) wattroff(win, (int) attr); } if (skip) printw("%*s", skip, " "); @@ -1640,6 +1640,7 @@ attr_test(void) beep(); } else { extras |= (chtype) COLOR_PAIR(pair); + normal &= ~A_COLOR; } } } @@ -1653,6 +1654,7 @@ attr_test(void) 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, @@ -1685,9 +1687,9 @@ static wchar_t wide_attr_test_string[MAX_ATTRSTRING + 1]; #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] @@ -1695,7 +1697,7 @@ static wchar_t wide_attr_test_string[MAX_ATTRSTRING + 1]; 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; @@ -1708,7 +1710,7 @@ normal_wchar(int ch) 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); @@ -1752,7 +1754,7 @@ static void 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); } @@ -2235,13 +2237,13 @@ color_test(void) 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); @@ -2446,11 +2448,11 @@ wide_color_test(void) 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); @@ -2651,7 +2653,7 @@ color_edit(void) (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); @@ -3609,7 +3611,7 @@ show_paged_widechars(int base, 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; @@ -3642,7 +3644,7 @@ show_upper_widechars(int first, int repeat, int space, attr_t attr, NCURSES_PAIR 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]; @@ -5141,10 +5143,15 @@ panner_v_cleanup(int from_y, int from_x, int to_y) } 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++) { @@ -5158,7 +5165,7 @@ fill_pad(WINDOW *panpad, bool pan_lines) 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) @@ -5172,7 +5179,8 @@ fill_pad(WINDOW *panpad, bool pan_lines) 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; @@ -5219,7 +5227,7 @@ panner(WINDOW *pad, break; case 'a': pan_lines = !pan_lines; - fill_pad(pad, pan_lines); + fill_pad(pad, pan_lines, colored); pending_pan = FALSE; break; @@ -5506,7 +5514,7 @@ padgetch(WINDOW *win) #define PAD_WIDE 200 static void -demo_pad(void) +demo_pad(bool colored) /* Demonstrate pads. */ { WINDOW *panpad = newpad(PAD_HIGH, PAD_WIDE); @@ -5516,7 +5524,14 @@ demo_pad(void) 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); @@ -5529,7 +5544,7 @@ demo_pad(void) * 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(); @@ -6407,11 +6422,11 @@ overlap_test_1_attr(WINDOW *win, int flavor, int col) break; case 2: init_pair(cpair, COLOR_BLUE, COLOR_WHITE); - (void) wattrset(win, (int) (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) (COLOR_PAIR(cpair) | A_BOLD)); + (void) wattrset(win, AttrArg(COLOR_PAIR(cpair), A_BOLD)); break; } } @@ -6793,7 +6808,11 @@ do_single_test(const char c) #endif case 'p': - demo_pad(); + demo_pad(FALSE); + break; + + case 'P': + demo_pad(TRUE); break; #if USE_LIBFORM @@ -6949,6 +6968,7 @@ main_menu(bool top) #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");