]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/test_opaque.c
ncurses 6.1 - patch 20181027
[ncurses.git] / test / test_opaque.c
index 63b7f586a714e22cbed41163d0cecdc5983b001c..6ec75fa11a20602c6c85cf5b1a9d177aa6a12460 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2007 Free Software Foundation, Inc.                        *
+ * Copyright (c) 2007-2008,2009 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            *
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_opaque.c,v 1.4 2007/08/18 17:51:51 tom Exp $
+ * $Id: test_opaque.c,v 1.9 2009/10/24 21:21:29 tom Exp $
  *
  * Author: Thomas E Dickey
  *
@@ -51,6 +51,8 @@
 #define BASE_Y 6
 #define MAX_COLS 1024
 
+#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH >= 20080119) && NCURSES_EXT_FUNCS
+
 static bool
 Quit(int ch)
 {
@@ -183,10 +185,10 @@ show_keyword(WINDOW *stswin, int cell, int active, const char *name)
 {
     to_keyword(stswin, cell);
     if (active == cell)
-       wstandout(stswin);
+       (void) wstandout(stswin);
     wprintw(stswin, "%s:", name);
     if (active == cell)
-       wstandend(stswin);
+       (void) wstandend(stswin);
 }
 /* *INDENT-OFF* */
 static struct {
@@ -229,7 +231,7 @@ show_opaque(WINDOW *stswin, WINDOW *txtwin, bool before, int active)
 
     show_keyword(stswin, n, active, "wgetparent");
     to_result(stswin, n, TRUE);
-    wprintw(stswin, "%p", wgetparent(txtwin));
+    wprintw(stswin, "%p", (void *) wgetparent(txtwin));
 
     ++n;
     show_keyword(stswin, n, active, "wgetscrreg");
@@ -321,7 +323,7 @@ test_opaque(int level, char **argv, WINDOW *stswin)
                break;
            case ' ':
                bool_funcs[active].func(txtwin,
-                                                                        !bool_funcs[active].func(txtwin, -1));
+                                       !bool_funcs[active].func(txtwin, -1));
                break;
            default:
                beep();
@@ -392,6 +394,43 @@ test_opaque(int level, char **argv, WINDOW *stswin)
     return TRUE;
 }
 
+static void
+test_set_escdelay(void)
+{
+    set_escdelay((100 + ESCDELAY) / 2);
+}
+
+static void
+test_set_tabsize(void)
+{
+    int y0, x0;
+    int y, x;
+    int save_tabsize = TABSIZE;
+
+    (void) cbreak();           /* take input chars one at a time, no wait for \n */
+    (void) noecho();           /* don't echo input */
+
+    for (y = 0; y < LINES; ++y) {
+       set_tabsize(y + 1);
+       if (move(y, 0) == ERR)
+           break;
+       for (x = 0; x < COLS;) {
+           addch('\t');
+           if (addch('*') == ERR) {
+               break;
+           }
+           getyx(stdscr, y0, x0);
+           if (y0 != y || x0 == x) {
+               break;
+           }
+       }
+    }
+    getch();
+    erase();
+
+    set_tabsize(save_tabsize);
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -407,6 +446,9 @@ main(int argc, char *argv[])
 
     initscr();
 
+    test_set_escdelay();
+    test_set_tabsize();
+
     stsbox = derwin(stdscr, BASE_Y, COLS, 0, 0);
     box(stsbox, 0, 0);
     wnoutrefresh(stsbox);
@@ -419,3 +461,11 @@ main(int argc, char *argv[])
     endwin();
     ExitProgram(EXIT_SUCCESS);
 }
+#else
+int
+main(void)
+{
+    printf("This program requires the ncurses library\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif