1 /****************************************************************************
2 * Copyright (c) 1999-2001,2002 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.8 2002/04/06 21:33:42 tom Exp $
34 * A simple demo of the terminfo interface.
38 #include <test.priv.h>
40 #define valid(s) ((s != 0) && s != (char *)-1)
42 static bool interrupted = FALSE;
49 write(STDOUT_FILENO, &tmp, 1);
69 outs(exit_attribute_mode);
70 if (!outs(orig_colors))
77 onsig(int n GCC_UNUSED)
81 ExitProgram(EXIT_FAILURE);
87 long r = (rand() & 077777);
88 return ((float) r / 32768.);
94 char *argv[]GCC_UNUSED)
100 for (j = SIGHUP; j <= SIGTERM; j++)
101 if (signal(j, SIG_IGN) != SIG_IGN)
105 setupterm((char *) 0, 1, (int *) 0);
107 outs(cursor_invisible);
108 if (max_colors > 1) {
109 if (!valid(set_a_foreground)
110 || !valid(set_a_background)
111 || (!valid(orig_colors) && !valid(orig_pair)))
115 r = (float) (lines - 4);
116 c = (float) (columns - 4);
119 x = (int) (c * ranf()) + 2;
120 y = (int) (r * ranf()) + 2;
121 p = (ranf() > 0.9) ? '*' : ' ';
123 tputs(tparm3(cursor_address, y, x), 1, outc);
124 if (max_colors > 0) {
125 z = (int) (ranf() * max_colors);
127 tputs(tparm2(set_a_foreground, z), 1, outc);
129 tputs(tparm2(set_a_background, z), 1, outc);
131 } else if (valid(exit_attribute_mode)
132 && valid(enter_reverse_mode)) {
134 outs((ranf() > 0.6) ? enter_reverse_mode :
135 exit_attribute_mode);