]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/ncurses.c
ncurses 5.6 - patch 20080209
[ncurses.git] / test / ncurses.c
index 204de46db8006f2f3eba94c7b60335f02212b05a..aa1c970305b911434eeb8e78213e4b842a2e7606 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 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 <esr@snark.thyrsus.com> 1993
            Thomas E. Dickey (beginning revision 1.27 in 1996).
 
-$Id: ncurses.c,v 1.289 2007/06/02 23:04:12 tom Exp $
+$Id: ncurses.c,v 1.301 2008/02/09 17:19:55 tom Exp $
 
 ***************************************************************************/
 
@@ -76,7 +76,7 @@ $Id: ncurses.c,v 1.289 2007/06/02 23:04:12 tom Exp $
 #define NCURSES_CONST_PARAM const void
 
 #ifdef TRACE
-static unsigned save_trace = TRACE_ORDINARY | TRACE_CALLS;
+static unsigned save_trace = TRACE_ORDINARY | TRACE_ICALLS | TRACE_CALLS;
 extern unsigned _nc_tracing;
 #endif
 
@@ -608,6 +608,20 @@ remember_boxes(unsigned level, WINDOW *txt_win, WINDOW *box_win)
     winstack[level].frame = box_win;
 }
 
+#if USE_SOFTKEYS && (NCURSES_VERSION_PATCH < 20071229) && NCURSES_EXT_FUNCS
+static void
+slk_repaint(void)
+{
+    /* this chunk is now done in resize_term() */
+    slk_touch();
+    slk_clear();
+    slk_noutrefresh();
+}
+
+#else
+#define slk_repaint()          /* nothing */
+#endif
+
 /*
  * For wgetch_test(), we create pairs of windows - one for a box, one for text.
  * Resize both and paint the box in the parent.
@@ -623,12 +637,7 @@ resize_boxes(unsigned level, WINDOW *win)
     touchwin(stdscr);
     wnoutrefresh(stdscr);
 
-#if USE_SOFTKEYS
-    /* FIXME: this chunk should be done in resizeterm() */
-    slk_touch();
-    slk_clear();
-    slk_noutrefresh();
-#endif
+    slk_repaint();
 
     for (n = 0; n < level; ++n) {
        wresize(winstack[n].frame, high, wide);
@@ -829,6 +838,8 @@ static void
 getch_test(void)
 {
     int delay = begin_getch_test();
+
+    slk_restore();
     wgetch_test(0, stdscr, delay);
     forget_boxes();
     finish_getch_test();
@@ -836,10 +847,10 @@ getch_test(void)
 
 #if USE_WIDEC_SUPPORT
 /*
- * For wgetch_test(), we create pairs of windows - one for a box, one for text.
+ * For wget_wch_test(), we create pairs of windows - one for a box, one for text.
  * Resize both and paint the box in the parent.
  */
-#ifdef KEY_RESIZE
+#if defined(KEY_RESIZE) && HAVE_WRESIZE
 static void
 resize_wide_boxes(unsigned level, WINDOW *win)
 {
@@ -851,12 +862,7 @@ resize_wide_boxes(unsigned level, WINDOW *win)
     touchwin(stdscr);
     wnoutrefresh(stdscr);
 
-#if USE_SOFTKEYS
-    /* FIXME: this chunk should be done in resizeterm() */
-    slk_touch();
-    slk_clear();
-    slk_noutrefresh();
-#endif
+    slk_repaint();
 
     for (n = 0; n < level; ++n) {
        wresize(winstack[n].frame, high, wide);
@@ -1018,7 +1024,7 @@ wget_wch_test(unsigned level, WINDOW *win, int delay)
            } else
 #endif /* NCURSES_MOUSE_VERSION */
            if (code == KEY_CODE_YES) {
-#ifdef KEY_RESIZE
+#if defined(KEY_RESIZE) && HAVE_WRESIZE
                if (c == KEY_RESIZE) {
                    resize_wide_boxes(level, win);
                }
@@ -1044,6 +1050,8 @@ static void
 get_wch_test(void)
 {
     int delay = begin_getch_test();
+
+    slk_restore();
     wget_wch_test(0, stdscr, delay);
     forget_boxes();
     finish_getch_test();
@@ -1302,7 +1310,7 @@ show_attr(int row, int skip, bool arrow, chtype attr, const char *name)
 }
 /* *INDENT-OFF* */
 static const struct {
-    attr_t                     attr;
+    chtype                     attr;
     NCURSES_CONST char *       name;
 } attrs_to_test[] = {
     { A_STANDOUT,      "STANDOUT" },
@@ -2515,12 +2523,16 @@ slk_test(void)
            }
            break;
 #endif
+#if defined(NCURSES_VERSION) && defined(KEY_RESIZE) && HAVE_WRESIZE
+       case KEY_RESIZE:
+           wnoutrefresh(stdscr);
+           break;
+#endif
 
        default:
            beep();
        }
-    } while
-       ((c = Getchar()) != EOF);
+    } while (!isQuit(c = Getchar()));
 
   done:
     slk_clear();
@@ -2642,12 +2654,15 @@ wide_slk_test(void)
                call_slk_color(fg, bg);
            }
            break;
-
+#if defined(NCURSES_VERSION) && defined(KEY_RESIZE) && HAVE_WRESIZE
+       case KEY_RESIZE:
+           wnoutrefresh(stdscr);
+           break;
+#endif
        default:
            beep();
        }
-    } while
-       ((c = Getchar()) != EOF);
+    } while (!isQuit(c = Getchar()));
 
   done:
     slk_clear();
@@ -2878,7 +2893,7 @@ acs_display(void)
 
 #if USE_WIDEC_SUPPORT
 static cchar_t *
-merge_wide_attr(cchar_t *dst, cchar_t *src, attr_t attr, short pair)
+merge_wide_attr(cchar_t *dst, const cchar_t *src, attr_t attr, short pair)
 {
     int count = getcchar(src, NULL, NULL, NULL, 0);
     wchar_t *wch = 0;
@@ -3123,7 +3138,7 @@ show_utf8_chars(attr_t attr, short pair)
 }
 /* *INDENT-OFF* */
 static struct {
-    attr_t attr;
+    chtype attr;
     const char *name;
 } attrs_to_cycle[] = {
     { A_NORMAL,                "normal" },
@@ -3379,12 +3394,17 @@ FRAME
     WINDOW *wind;
 };
 
-#if defined(NCURSES_VERSION) && !NCURSES_OPAQUE
-#define keypad_active(win) (win)->_use_keypad
-#define scroll_active(win) (win)->_scroll
+#if defined(NCURSES_VERSION)
+#if (NCURSES_VERSION_PATCH < 20070331) && NCURSES_EXT_FUNCS
+#define is_keypad(win)   (win)->_use_keypad
+#define is_scrollok(win) (win)->_scroll
+#elif !defined(is_keypad)
+#define is_keypad(win)   FALSE
+#define is_scrollok(win) FALSE
+#endif
 #else
-#define keypad_active(win) FALSE
-#define scroll_active(win) FALSE
+#define is_keypad(win)   FALSE
+#define is_scrollok(win) FALSE
 #endif
 
 /* We need to know if these flags are actually set, so don't look in FRAME.
@@ -3396,7 +3416,7 @@ HaveKeypad(FRAME * curp)
 {
     WINDOW *win = (curp ? curp->wind : stdscr);
     (void) win;
-    return keypad_active(win);
+    return is_keypad(win);
 }
 
 static bool
@@ -3404,7 +3424,7 @@ HaveScroll(FRAME * curp)
 {
     WINDOW *win = (curp ? curp->wind : stdscr);
     (void) win;
-    return scroll_active(win);
+    return is_scrollok(win);
 }
 
 static void
@@ -3667,7 +3687,7 @@ static void
 acs_and_scroll(void)
 /* Demonstrate windows */
 {
-    int c, i;
+    int c;
     FRAME *current = (FRAME *) 0, *neww;
     WINDOW *usescr = stdscr;
 #if HAVE_PUTWIN && HAVE_GETWIN
@@ -3780,7 +3800,7 @@ acs_and_scroll(void)
        case CTRL('X'): /* resize window */
            if (current) {
                pair *tmp, ul, lr;
-               int mx, my;
+               int i, mx, my;
 
                move(0, 0);
                clrtoeol();
@@ -4829,7 +4849,7 @@ menu_virtualize(int c)
     }
 }
 
-static const char *animals[] =
+static CONST_MENUS char *animals[] =
 {
     "Lions",
     "Tigers",
@@ -4853,7 +4873,7 @@ menu_test(void)
     MENU *m;
     ITEM *items[SIZEOF(animals)];
     ITEM **ip = items;
-    const char **ap;
+    CONST_MENUS char **ap;
     int mrows, mcols, c;
     WINDOW *menuwin;
 
@@ -5910,7 +5930,7 @@ do_single_test(const char c)
        break;
 #endif
 
-#if USE_WIDEC_SUPPORT
+#if USE_WIDEC_SUPPORT && USE_LIBPANEL
     case 'O':
        demo_panels(init_wide_panel, fill_wide_panel);
        break;
@@ -6024,7 +6044,7 @@ rip_footer(WINDOW *win, int cols)
     wbkgd(win, A_REVERSE);
     werase(win);
     wmove(win, 0, 0);
-    wprintw(win, "footer: %d columns", cols);
+    wprintw(win, "footer: window %p, %d columns", win, cols);
     wnoutrefresh(win);
     return OK;
 }
@@ -6035,7 +6055,7 @@ rip_header(WINDOW *win, int cols)
     wbkgd(win, A_REVERSE);
     werase(win);
     wmove(win, 0, 0);
-    wprintw(win, "header: %d columns", cols);
+    wprintw(win, "header: window %p, %d columns", win, cols);
     wnoutrefresh(win);
     return OK;
 }
@@ -6174,7 +6194,7 @@ main(int argc, char *argv[])
 
     setlocale(LC_ALL, "");
 
-    while ((c = getopt(argc, argv, "a:de:fhmp:s:t:")) != EOF) {
+    while ((c = getopt(argc, argv, "a:de:fhmp:s:t:")) != -1) {
        switch (c) {
 #ifdef NCURSES_VERSION
        case 'a':