X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fncurses.c;h=bb7f77c690541e80f8ab95824827e66da14818fb;hp=ef75b42587780cc6894b427f86aaeeb35af25d6c;hb=a0b91dc27f0c411e343161b0a4b5459d15a43f85;hpb=0948e2c7ac34642a1f8a3a85000933bcbb258cff diff --git a/test/ncurses.c b/test/ncurses.c index ef75b425..bb7f77c6 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.416 2014/08/16 23:30:20 tom Exp $ +$Id: ncurses.c,v 1.421 2015/10/24 23:32:57 tom Exp $ ***************************************************************************/ @@ -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)? "); @@ -1255,9 +1255,10 @@ my_termattrs(void) #define ATTRSTRING_1ST 32 /* ' ' */ #define ATTRSTRING_END 126 /* '~' */ -#define COL_ATTRSTRING 25 -#define MARGIN_4_ATTRS (COL_ATTRSTRING + 8) -#define LEN_ATTRSTRING (COLS - MARGIN_4_ATTRS) +#define COLS_PRE_ATTRS 5 +#define COLS_AFT_ATTRS 15 +#define COL_ATTRSTRING (COLS_PRE_ATTRS + 17) +#define LEN_ATTRSTRING (COLS - (COL_ATTRSTRING + COLS_AFT_ATTRS)) #define MAX_ATTRSTRING (ATTRSTRING_END + 1 - ATTRSTRING_1ST) static char attr_test_string[MAX_ATTRSTRING + 1]; @@ -1415,8 +1416,8 @@ show_attr(WINDOW *win, int row, int skip, bool arrow, chtype attr, const char *n chtype test = attr & (chtype) (~A_ALTCHARSET); if (arrow) - MvPrintw(row, 5, "-->"); - MvPrintw(row, 8, "%s mode:", name); + MvPrintw(row, COLS_PRE_ATTRS - 3, "-->"); + MvPrintw(row, COLS_PRE_ATTRS, "%s mode:", name); MvPrintw(row, COL_ATTRSTRING - 1, "|"); if (skip) printw("%*s", skip, " "); @@ -1661,10 +1662,10 @@ attr_test(void) my_list[j].name); } - MvPrintw(row, 8, + MvPrintw(row, COLS_PRE_ATTRS, "This terminal does %shave the magic-cookie glitch", get_xmc() > -1 ? "" : "not "); - MvPrintw(row + 1, 8, "Enter '?' for help."); + MvPrintw(row + 1, COLS_PRE_ATTRS, "Enter '?' for help."); show_color_attr(fg, bg, tx); printw(" ACS (%d)", ac != 0); @@ -1802,8 +1803,8 @@ wide_show_attr(WINDOW *win, chtype test = attr & ~WA_ALTCHARSET; if (arrow) - MvPrintw(row, 5, "-->"); - MvPrintw(row, 8, "%s mode:", name); + MvPrintw(row, COLS_PRE_ATTRS - 3, "-->"); + MvPrintw(row, COLS_PRE_ATTRS, "%s mode:", name); MvPrintw(row, COL_ATTRSTRING - 1, "|"); if (skip) printw("%*s", skip, " "); @@ -2012,10 +2013,10 @@ wide_attr_test(void) my_list[j].name); } - MvPrintw(row, 8, + MvPrintw(row, COLS_PRE_ATTRS, "This terminal does %shave the magic-cookie glitch", get_xmc() > -1 ? "" : "not "); - MvPrintw(row + 1, 8, "Enter '?' for help."); + MvPrintw(row + 1, COLS_PRE_ATTRS, "Enter '?' for help."); show_color_attr(fg, bg, tx); printw(" ACS (%d)", ac != 0); @@ -5143,10 +5144,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++) { @@ -5160,7 +5166,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) @@ -5174,7 +5180,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; @@ -5221,7 +5228,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; @@ -5508,7 +5515,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); @@ -5517,8 +5524,14 @@ demo_pad(void) Cannot("cannot create requested pad"); 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); @@ -5531,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(); @@ -6795,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 @@ -6951,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");