1 /****************************************************************************
2 * Copyright (c) 2000-2007,2008 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.17 2008/12/07 02:07:41 juergen Exp $
34 * A simple demo of the termcap interface.
37 #include <test.priv.h>
56 static bool interrupted = FALSE;
63 write(STDOUT_FILENO, &tmp, 1);
75 napms(moveit ? 10 : 50); /* not really termcap... */
81 tputs(backup != 0 ? backup : "\b", 1, outc);
85 MyShowCursor(int flag)
87 if (startC != 0 && finisC != 0) {
88 tputs(flag ? startC : finisC, 1, outc);
95 if (startS != 0 && finisS != 0) {
96 tputs(flag ? startS : finisS, 1, outc);
103 if (startU != 0 && finisU != 0) {
104 tputs(flag ? startU : finisU, 1, outc);
109 ShowSign(char *string)
115 tputs(tgoto(moveit, 0, height - 1), 1, outc);
116 tputs(wipeit, 1, outc);
119 while (*string != 0) {
123 for (first = length - 2; first >= (string - base); first--) {
124 if (first < length - 1) {
125 tputs(tgoto(moveit, first + 1, height - 1), 1, outc);
128 tputs(tgoto(moveit, first, height - 1), 1, outc);
134 first = isupper(ch) ? 'A' : 'a';
135 } else if (isdigit(ch)) {
142 while (first < last) {
160 tputs(wipeit, 1, outc);
173 onsig(int n GCC_UNUSED)
177 ExitProgram(EXIT_FAILURE);
181 railroad(char **args)
183 NCURSES_CONST char *name = getenv("TERM");
185 char area[1024], *ap = area;
189 if (tgetent(buffer, name) >= 0) {
191 wipeit = tgetstr("ce", &ap);
192 height = tgetnum("li");
193 length = tgetnum("co");
194 moveit = tgetstr("cm", &ap);
206 startS = tgetstr("so", &ap);
207 finisS = tgetstr("se", &ap);
209 startU = tgetstr("us", &ap);
210 finisU = tgetstr("ue", &ap);
212 backup = tgetstr("le", &ap);
214 startC = tgetstr("ve", &ap);
215 finisC = tgetstr("vi", &ap);
229 main(int argc, char *argv[])
234 static char world[] = "Hello World";
235 static char *hello[] =
239 ExitProgram(EXIT_SUCCESS);
244 main(int argc GCC_UNUSED,
245 char *argv[]GCC_UNUSED)
247 printf("This program requires termcap\n");