1 /****************************************************************************
2 * Copyright (c) 2000-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> 2000
32 * $Id: railroad.c,v 1.11 2002/10/19 22:11:24 tom Exp $
34 * A simple demo of the termcap interface.
36 #include <test.priv.h>
53 static bool interrupted = FALSE;
60 write(STDOUT_FILENO, &tmp, 1);
72 napms(moveit ? 10 : 50); /* not really termcap... */
78 tputs(backup != 0 ? backup : "\b", 1, outc);
84 if (startC != 0 && finisC != 0) {
85 tputs(flag ? startC : finisC, 1, outc);
92 if (startS != 0 && finisS != 0) {
93 tputs(flag ? startS : finisS, 1, outc);
100 if (startU != 0 && finisU != 0) {
101 tputs(flag ? startU : finisU, 1, outc);
106 ShowSign(char *string)
112 tputs(tgoto(moveit, 0, height - 1), 1, outc);
113 tputs(wipeit, 1, outc);
116 while (*string != 0) {
120 for (first = length - 2; first >= (string - base); first--) {
121 if (first < length - 1) {
122 tputs(tgoto(moveit, first + 1, height - 1), 1, outc);
125 tputs(tgoto(moveit, first, height - 1), 1, outc);
131 first = isupper(ch) ? 'A' : 'a';
132 } else if (isdigit(ch)) {
139 while (first < last) {
157 tputs(wipeit, 1, outc);
170 onsig(int n GCC_UNUSED)
174 ExitProgram(EXIT_FAILURE);
178 railroad(char **args)
180 NCURSES_CONST char *name = getenv("TERM");
182 char area[1024], *ap = area;
187 if (tgetent(buffer, name)) {
189 wipeit = tgetstr("ce", &ap);
190 height = tgetnum("li");
191 length = tgetnum("co");
192 moveit = tgetstr("cm", &ap);
204 startS = tgetstr("so", &ap);
205 finisS = tgetstr("se", &ap);
207 startU = tgetstr("us", &ap);
208 finisU = tgetstr("ue", &ap);
210 backup = tgetstr("le", &ap);
212 startC = tgetstr("ve", &ap);
213 finisC = tgetstr("vi", &ap);
217 for (j = SIGHUP; j <= SIGTERM; j++)
218 if (signal(j, SIG_IGN) != SIG_IGN)
229 main(int argc, char *argv[])
234 static char world[] = "Hello World";
235 static char *hello[] =
239 ExitProgram(EXIT_SUCCESS);