]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/dots_curses.c
ncurses 6.0 - patch 20171014
[ncurses.git] / test / dots_curses.c
index dc767116d33055666d859559f55c406ee815c09d..477c4a14ef116b60854324901ce83b86c725d7be 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2014 Free Software Foundation, Inc.                        *
+ * Copyright (c) 2014,2017 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            *
@@ -29,7 +29,7 @@
 /*
  * Author: Thomas E. Dickey
  *
- * $Id: dots_curses.c,v 1.2 2014/06/28 20:33:24 tom Exp $
+ * $Id: dots_curses.c,v 1.7 2017/10/11 08:16:33 tom Exp $
  *
  * A simple demo of the curses interface used for comparison with termcap.
  */
@@ -41,8 +41,6 @@
 
 #include <time.h>
 
-#define valid(s) ((s != 0) && s != (char *)-1)
-
 static bool interrupted = FALSE;
 static long total_chars = 0;
 static time_t started;
@@ -52,7 +50,7 @@ cleanup(void)
 {
     endwin();
 
-    printf("\n\n%ld total chars, rate %.2f/sec\n",
+    printf("\n\n%ld total cells, rate %.2f/sec\n",
           total_chars,
           ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
 }
@@ -82,7 +80,7 @@ set_colors(int fg, int bg)
 {
     int pair = mypair(fg, bg);
     if (pair > 0) {
-       attron((attr_t) COLOR_PAIR(mypair(fg, bg)));
+       attron(COLOR_PAIR(mypair(fg, bg)));
     }
 }
 
@@ -95,11 +93,9 @@ main(int argc GCC_UNUSED,
     double r;
     double c;
 
-    CATCHALL(onsig);
-
     srand((unsigned) time(0));
 
-    initscr();
+    InitAndCatch(initscr(), onsig);
     if (has_colors()) {
        start_color();
        for (fg = 0; fg < COLORS; fg++) {
@@ -127,7 +123,7 @@ main(int argc GCC_UNUSED,
            z = (int) (ranf() * COLORS);
            if (ranf() > 0.01) {
                set_colors(fg = z, bg);
-               attron((attr_t) COLOR_PAIR(mypair(fg, bg)));
+               attron(COLOR_PAIR(mypair(fg, bg)));
            } else {
                set_colors(fg, bg = z);
                napms(1);
@@ -142,7 +138,7 @@ main(int argc GCC_UNUSED,
                napms(1);
            }
        }
-       addch((chtype) p);
+       AddCh(p);
        refresh();
        ++total_chars;
     }