1 /****************************************************************************
2 * Copyright (c) 2000-2005,2006 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 - 2000
32 * $Id: railroad.c,v 1.14 2006/05/20 16:02:04 tom Exp $
34 * A simple demo of the termcap interface.
36 #include <test.priv.h>
55 static bool interrupted = FALSE;
62 write(STDOUT_FILENO, &tmp, 1);
74 napms(moveit ? 10 : 50); /* not really termcap... */
80 tputs(backup != 0 ? backup : "\b", 1, outc);
86 if (startC != 0 && finisC != 0) {
87 tputs(flag ? startC : finisC, 1, outc);
94 if (startS != 0 && finisS != 0) {
95 tputs(flag ? startS : finisS, 1, outc);
102 if (startU != 0 && finisU != 0) {
103 tputs(flag ? startU : finisU, 1, outc);
108 ShowSign(char *string)
114 tputs(tgoto(moveit, 0, height - 1), 1, outc);
115 tputs(wipeit, 1, outc);
118 while (*string != 0) {
122 for (first = length - 2; first >= (string - base); first--) {
123 if (first < length - 1) {
124 tputs(tgoto(moveit, first + 1, height - 1), 1, outc);
127 tputs(tgoto(moveit, first, height - 1), 1, outc);
133 first = isupper(ch) ? 'A' : 'a';
134 } else if (isdigit(ch)) {
141 while (first < last) {
159 tputs(wipeit, 1, outc);
172 onsig(int n GCC_UNUSED)
176 ExitProgram(EXIT_FAILURE);
180 railroad(char **args)
182 NCURSES_CONST char *name = getenv("TERM");
184 char area[1024], *ap = area;
188 if (tgetent(buffer, name) >= 0) {
190 wipeit = tgetstr("ce", &ap);
191 height = tgetnum("li");
192 length = tgetnum("co");
193 moveit = tgetstr("cm", &ap);
205 startS = tgetstr("so", &ap);
206 finisS = tgetstr("se", &ap);
208 startU = tgetstr("us", &ap);
209 finisU = tgetstr("ue", &ap);
211 backup = tgetstr("le", &ap);
213 startC = tgetstr("ve", &ap);
214 finisC = tgetstr("vi", &ap);
228 main(int argc, char *argv[])
233 static char world[] = "Hello World";
234 static char *hello[] =
238 ExitProgram(EXIT_SUCCESS);
243 main(int argc GCC_UNUSED,
244 char *argv[]GCC_UNUSED)
246 printf("This program requires termcap\n");