]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/test_opaque.c
ncurses 6.2 - patch 20210306
[ncurses.git] / test / test_opaque.c
index bb7a6b0afc05c9f9d7e264682c44dfe756da920f..eeea2302284c12df8d1e7d65eed9237d079920b7 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2007,2008 Free Software Foundation, Inc.                   *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 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 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_opaque.c,v 1.5 2008/01/19 21:01:36 tom Exp $
+ * $Id: test_opaque.c,v 1.12 2021/03/06 23:53:34 tom Exp $
  *
  * Author: Thomas E Dickey
  *
@@ -44,6 +45,9 @@
        bool is_scrollok(const WINDOW *win);
        bool is_syncok(const WINDOW *win);
        int wgetscrreg (const WINDOW *, int *, int *);
+       bool is_pad(const WINDOW *win);
+       bool is_subwin(const WINDOW *win);
+       int wgetdelay(const WINDOW *win);
  */
 
 #include <test.priv.h>
@@ -51,7 +55,7 @@
 #define BASE_Y 6
 #define MAX_COLS 1024
 
-#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH >= 20070818) && NCURSES_EXT_FUNCS
+#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH >= 20080119) && NCURSES_EXT_FUNCS
 
 static bool
 Quit(int ch)
@@ -185,10 +189,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 {
@@ -208,6 +212,8 @@ static struct {
 };
 /* *INDENT-ON* */
 
+#define bool2c(c) ((c) ? 'T' : 'F')
+
 /*
  * Display and/or allow update for the properties accessed in the opaque
  * window.  Some may change state after refreshing the window, so we
@@ -226,18 +232,35 @@ show_opaque(WINDOW *stswin, WINDOW *txtwin, bool before, int active)
        show_keyword(stswin, n, active, bool_funcs[n].name);
 
        to_result(stswin, n, before);
-       wprintw(stswin, "%c", bool_funcs[n].func(txtwin, -1) ? 'T' : 'F');
+       wprintw(stswin, "%c", bool2c(bool_funcs[n].func(txtwin, -1)));
     }
 
+    show_keyword(stswin, n, active, "is_pad");
+    to_result(stswin, n, TRUE);
+    wprintw(stswin, "%c", bool2c(is_pad(txtwin)));
+
+    ++n;
+    show_keyword(stswin, n, active, "is_subwin");
+    to_result(stswin, n, TRUE);
+    wprintw(stswin, "%c", bool2c(is_subwin(txtwin)));
+
+    ++n;
     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, "wgetdelay");
+    to_result(stswin, n, TRUE);
+    wprintw(stswin, "%d", wgetdelay(txtwin));
 
     ++n;
     show_keyword(stswin, n, active, "wgetscrreg");
     to_result(stswin, n, TRUE);
     if (wgetscrreg(txtwin, &top, &bottom) == OK)
        wprintw(stswin, "%d,%d", top, bottom);
+    else
+       wprintw(stswin, "none");
 
     wnoutrefresh(stswin);
     return active;
@@ -394,6 +417,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[])
 {
@@ -409,6 +469,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);