]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/ncurses.c
ncurses 6.0 - patch 20150822
[ncurses.git] / test / ncurses.c
index a6a87d7f79d21c4fe62a4729a99b1d91f405c7c4..59a88c457402cc0a4ab43325e750246a0634ee56 100644 (file)
@@ -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            *
  *                                                                          *
  * 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 <esr@snark.thyrsus.com> 1993
            Thomas E. Dickey (beginning revision 1.27 in 1996).
 
    Author: Eric S. Raymond <esr@snark.thyrsus.com> 1993
            Thomas E. Dickey (beginning revision 1.27 in 1996).
 
-$Id: ncurses.c,v 1.414 2014/08/02 23:10:26 tom Exp $
+$Id: ncurses.c,v 1.420 2015/05/23 23:41:25 tom Exp $
 
 ***************************************************************************/
 
 
 ***************************************************************************/
 
@@ -943,7 +943,7 @@ begin_getch_test(void)
     refresh();
 
 #ifdef NCURSES_MOUSE_VERSION
     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)? ");
 #endif
 
     (void) printw("Delay in 10ths of a second (<CR> for blocking input)? ");
@@ -1640,6 +1640,7 @@ attr_test(void)
                        beep();
                    } else {
                        extras |= (chtype) COLOR_PAIR(pair);
                        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,
            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,
                                extras |
                                my_list[j].attr |
                                my_list[k].attr,
@@ -2235,13 +2237,13 @@ color_test(void)
                NCURSES_COLOR_T bg = InxToBG(i);
 
                init_pair(pair, fg, bg);
                NCURSES_COLOR_T bg = InxToBG(i);
 
                init_pair(pair, fg, bg);
-               attron((attr_t) COLOR_PAIR(pair));
+               attron(COLOR_PAIR(pair));
                if (opt_acsc)
                if (opt_acsc)
-                   attron((attr_t) A_ALTCHARSET);
+                   attron(A_ALTCHARSET);
                if (opt_bold)
                if (opt_bold)
-                   attron((attr_t) A_BOLD);
+                   attron(A_BOLD);
                if (opt_revs)
                if (opt_revs)
-                   attron((attr_t) A_REVERSE);
+                   attron(A_REVERSE);
 
                if (opt_nums) {
                    sprintf(numbered, "{%02X}", (int) i);
 
                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)
                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)
                if (opt_bold)
-                   attr_on((attr_t) A_BOLD, NULL);
+                   attr_on(A_BOLD, NULL);
                if (opt_revs)
                if (opt_revs)
-                   attr_on((attr_t) A_REVERSE, NULL);
+                   attr_on(A_REVERSE, NULL);
 
                if (opt_nums) {
                    sprintf(numbered, "{%02X}", i);
 
                if (opt_nums) {
                    sprintf(numbered, "{%02X}", i);
@@ -5141,10 +5143,15 @@ panner_v_cleanup(int from_y, int from_x, int to_y)
 }
 
 static void
 }
 
 static void
-fill_pad(WINDOW *panpad, bool pan_lines)
+fill_pad(WINDOW *panpad, bool pan_lines, bool colored)
 {
     int y, x;
     unsigned gridcount = 0;
 {
     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++) {
 
     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') +
                    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)
            } 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,
 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;
 {
 #if HAVE_GETTIMEOFDAY
     struct timeval before, after;
@@ -5219,7 +5227,7 @@ panner(WINDOW *pad,
            break;
        case 'a':
            pan_lines = !pan_lines;
            break;
        case 'a':
            pan_lines = !pan_lines;
-           fill_pad(pad, pan_lines);
+           fill_pad(pad, pan_lines, colored);
            pending_pan = FALSE;
            break;
 
            pending_pan = FALSE;
            break;
 
@@ -5506,7 +5514,7 @@ padgetch(WINDOW *win)
 #define PAD_WIDE 200
 
 static void
 #define PAD_WIDE 200
 
 static void
-demo_pad(void)
+demo_pad(bool colored)
 /* Demonstrate pads. */
 {
     WINDOW *panpad = newpad(PAD_HIGH, PAD_WIDE);
 /* Demonstrate pads. */
 {
     WINDOW *panpad = newpad(PAD_HIGH, PAD_WIDE);
@@ -5516,7 +5524,14 @@ demo_pad(void)
        return;
     }
 
        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);
 
     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.
      */
      * 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();
 
     delwin(panpad);
     endwin();
@@ -6793,7 +6808,11 @@ do_single_test(const char c)
 #endif
 
     case 'p':
 #endif
 
     case 'p':
-       demo_pad();
+       demo_pad(FALSE);
+       break;
+
+    case 'P':
+       demo_pad(TRUE);
        break;
 
 #if USE_LIBFORM
        break;
 
 #if USE_LIBFORM
@@ -6949,6 +6968,7 @@ main_menu(bool top)
 #endif
 #endif
        (void) puts("p = exercise pad features");
 #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");
        (void) puts("q = quit");
 #if USE_LIBFORM
        (void) puts("r = exercise forms code");