]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/ncurses.c
ncurses 6.0 - patch 20170909
[ncurses.git] / test / ncurses.c
index 728fdcd0841c0d24ff94855ceb006abe953e51b1..24a2f8779330c06b13c775ad233376b3c4d796ae 100644 (file)
@@ -40,7 +40,7 @@ AUTHOR
    Author: Eric S. Raymond <esr@snark.thyrsus.com> 1993
            Thomas E. Dickey (beginning revision 1.27 in 1996).
 
-$Id: ncurses.c,v 1.450 2017/05/05 14:58:47 tom Exp $
+$Id: ncurses.c,v 1.460 2017/09/09 22:52:38 tom Exp $
 
 ***************************************************************************/
 
@@ -77,7 +77,6 @@ $Id: ncurses.c,v 1.450 2017/05/05 14:58:47 tom Exp $
 
 #ifdef TRACE
 static unsigned save_trace = TRACE_ORDINARY | TRACE_ICALLS | TRACE_CALLS;
-extern unsigned _nc_tracing;
 #endif
 
 #else
@@ -142,7 +141,7 @@ extern unsigned _nc_tracing;
 #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)
 
@@ -156,6 +155,7 @@ static bool use_colors;             /* true if we use colors */
 #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;
@@ -163,6 +163,7 @@ typedef struct {
 } RGB_DATA;
 
 static RGB_DATA *all_colors;
+#endif
 
 static void main_menu(bool);
 static void failed(const char *s) GCC_NORETURN;
@@ -175,29 +176,16 @@ failed(const char *s)
     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
@@ -2645,6 +2633,7 @@ wide_color_test(void)
 }
 #endif /* USE_WIDEC_SUPPORT */
 
+#if HAVE_COLOR_CONTENT
 static void
 change_color(NCURSES_PAIRS_T current, int field, int value, int usebase)
 {
@@ -2991,6 +2980,7 @@ color_edit(void)
 
     endwin();
 }
+#endif /* HAVE_COLOR_CONTENT */
 
 /****************************************************************************
  *
@@ -4551,8 +4541,8 @@ selectcell(int uli, int ulj, int lri, int lrj)
                    break;
                }
            }
-           /* FALLTHRU */
 #endif
+           /* FALLTHRU */
        default:
            res.y = uli + i;
            res.x = ulj + j;
@@ -4653,7 +4643,7 @@ delete_framed(FRAME * fp, bool showit)
        }
        delwin(fp->wind);
 
-       np = (fp == fp->next) ? 0 : fp->next;
+       np = (fp == fp->next) ? NULL : fp->next;
        free(fp);
     }
     return np;
@@ -4990,7 +4980,7 @@ mkpanel(NCURSES_COLOR_T color, int rows, int cols, int tly, int tlx)
        rmpanel(pan)
 --------------------------------------------------------------------------*/
 static void
-rmpanel(PANEL * pan)
+rmpanel(PANEL *pan)
 {
     WINDOW *win = panel_window(pan);
     del_panel(pan);
@@ -5022,7 +5012,7 @@ init_panel(WINDOW *win)
 }
 
 static void
-fill_panel(PANEL * pan)
+fill_panel(PANEL *pan)
 {
     WINDOW *win = panel_window(pan);
     const char *userptr = (const char *) panel_userptr(pan);
@@ -5059,7 +5049,7 @@ init_wide_panel(WINDOW *win)
 }
 
 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);
@@ -5082,7 +5072,7 @@ fill_wide_panel(PANEL * 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';
 
@@ -5256,6 +5246,25 @@ demo_panels(void (*InitPanel) (WINDOW *), void (*FillPanel) (PANEL *))
  *
  ****************************************************************************/
 
+#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;
@@ -5704,6 +5713,7 @@ demo_pad(bool colored)
     endwin();
     erase();
 }
+#endif /* HAVE_NEWPAD */
 
 /****************************************************************************
  *
@@ -6128,7 +6138,7 @@ make_field(int frow, int fcol, int rows, int cols, bool secure)
 }
 
 static void
-display_form(FORM * f)
+display_form(FORM *f)
 {
     WINDOW *w;
     int rows, cols;
@@ -6146,7 +6156,7 @@ display_form(FORM * f)
 }
 
 static void
-erase_form(FORM * f)
+erase_form(FORM *f)
 {
     WINDOW *w = form_win(f);
     WINDOW *s = form_sub(f);
@@ -6159,7 +6169,7 @@ erase_form(FORM * f)
 }
 
 static int
-edit_secure(FIELD * me, int c)
+edit_secure(FIELD *me, int c)
 {
     int rows, cols, frow, fcol, nrow, nbuf;
 
@@ -6225,7 +6235,7 @@ edit_secure(FIELD * me, int c)
 }
 
 static int
-form_virtualize(FORM * f, WINDOW *w)
+form_virtualize(FORM *f, WINDOW *w)
 {
     /* *INDENT-OFF* */
     static const struct {
@@ -6332,7 +6342,7 @@ form_virtualize(FORM * f, WINDOW *w)
 }
 
 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)
@@ -6520,6 +6530,7 @@ demo_forms(void)
  *
  ****************************************************************************/
 
+#if HAVE_COPYWIN               /* ...and overlay, overwrite */
 static void
 fillwin(WINDOW *win, char ch)
 {
@@ -6862,10 +6873,11 @@ overlap_test(void)
     delwin(win2);
     delwin(win1);
     erase();
-    curs_set(1);
-    endwin();
+    exit_curses();
 }
 
+#endif /* HAVE_COPYWIN */
+
 static void
 show_setting_name(const char *name)
 {
@@ -6945,7 +6957,7 @@ show_settings(void)
     show_boolean_setting("has_il", has_il());
     Pause();
     erase();
-    endwin();
+    exit_curses();
 }
 
 /****************************************************************************
@@ -6995,6 +7007,7 @@ do_single_test(const char c)
        break;
 #endif
 
+#if HAVE_COLOR_CONTENT
     case 'd':
        if (!use_colors)
            Cannot("does not support color.");
@@ -7003,6 +7016,7 @@ do_single_test(const char c)
        else
            color_edit();
        break;
+#endif
 
 #if USE_SOFTKEYS
     case 'e':
@@ -7056,6 +7070,7 @@ do_single_test(const char c)
        break;
 #endif
 
+#if HAVE_NEWPAD
     case 'p':
        demo_pad(FALSE);
        break;
@@ -7063,6 +7078,7 @@ do_single_test(const char c)
     case 'P':
        demo_pad(TRUE);
        break;
+#endif
 
 #if USE_LIBFORM
     case 'r':
@@ -7070,9 +7086,11 @@ do_single_test(const char c)
        break;
 #endif
 
+#if HAVE_COPYWIN
     case 's':
        overlap_test();
        break;
+#endif
 
 #if USE_LIBMENU && defined(TRACE)
     case 't':
@@ -7117,7 +7135,9 @@ usage(void)
        ,"  -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
@@ -7127,7 +7147,9 @@ usage(void)
 #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++)
@@ -7197,8 +7219,10 @@ main_menu(bool top)
 #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
@@ -7221,13 +7245,17 @@ main_menu(bool top)
        (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
@@ -7305,9 +7333,11 @@ main(int argc, char *argv[])
     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, "");
 
@@ -7355,9 +7385,11 @@ main(int argc, char *argv[])
        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);
@@ -7373,9 +7405,11 @@ main(int argc, char *argv[])
            save_trace = (unsigned) strtol(optarg, 0, 0);
            break;
 #endif
+#if HAVE_COLOR_CONTENT
        case 'x':
            xterm_colors = TRUE;
            break;
+#endif
        default:
            usage();
        }
@@ -7435,9 +7469,11 @@ main(int argc, char *argv[])
 #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
     }
 
     /*