1 /****************************************************************************
2 * Copyright (c) 1999,2000 Free Software Foundation, Inc. *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
27 ****************************************************************************/
30 * Author: Thomas E. Dickey <dickey@clark.net> 1999
32 * $Id: dots.c,v 1.4 2000/02/13 01:05:13 tom Exp $
34 * A simple demo of the terminfo interface.
36 #include <test.priv.h>
38 #include <term.h> /* for tparm() */
43 #define valid(s) ((s != 0) && s != (char *)-1)
45 static bool interrupted = FALSE;
52 write(STDOUT_FILENO, &tmp, 1);
72 outs(exit_attribute_mode);
73 if (!outs(orig_colors))
80 onsig(int n GCC_UNUSED)
90 long r = (rand() & 077777);
91 return ((float) r / 32768.);
97 char *argv[]GCC_UNUSED)
103 for (j = SIGHUP; j <= SIGTERM; j++)
104 if (signal(j, SIG_IGN) != SIG_IGN)
108 setupterm((char *) 0, 1, (int *) 0);
110 outs(cursor_invisible);
111 if (max_colors > 1) {
112 if (!valid(set_a_foreground)
113 || !valid(set_a_background)
114 || (!valid(orig_colors) && !valid(orig_pair)))
118 r = (float) (lines - 4);
119 c = (float) (columns - 4);
122 x = (int) (c * ranf()) + 2;
123 y = (int) (r * ranf()) + 2;
124 p = (ranf() > 0.9) ? '*' : ' ';
126 tputs(tparm(cursor_address, y, x), 1, outc);
127 if (max_colors > 0) {
128 z = (int)(ranf() * max_colors);
130 tputs(tparm(set_a_foreground, z), 1, outc);
132 tputs(tparm(set_a_background, z), 1, outc);
134 } else if (valid(exit_attribute_mode)
135 && valid(enter_reverse_mode)) {
137 outs((ranf() > 0.6) ? enter_reverse_mode :
138 exit_attribute_mode);