1 /****************************************************************************
2 * Copyright 2019,2020 Thomas E. Dickey *
3 * Copyright 2000-2013,2017 Free Software Foundation, Inc. *
5 * Permission is hereby granted, free of charge, to any person obtaining a *
6 * copy of this software and associated documentation files (the *
7 * "Software"), to deal in the Software without restriction, including *
8 * without limitation the rights to use, copy, modify, merge, publish, *
9 * distribute, distribute with modifications, sublicense, and/or sell *
10 * copies of the Software, and to permit persons to whom the Software is *
11 * furnished to do so, subject to the following conditions: *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 * Except as contained in this notice, the name(s) of the above copyright *
25 * holders shall not be used in advertising or otherwise to promote the *
26 * sale, use or other dealings in this Software without prior written *
28 ****************************************************************************/
31 * Author: Thomas E. Dickey - 2000
33 * $Id: railroad.c,v 1.25 2020/09/05 21:43:37 tom Exp $
35 * A simple demo of the termcap interface.
38 #include <test.priv.h>
57 static bool interrupted = FALSE;
66 if (write(STDOUT_FILENO, &tmp, (size_t) 1) == -1)
69 if (putc(c, stdout) == EOF)
80 napms(moveit ? 10 : 50); /* not really termcap... */
86 tputs(backup != 0 ? backup : "\b", 1, outc);
90 MyShowCursor(int flag)
92 if (startC != 0 && finisC != 0) {
93 tputs(flag ? startC : finisC, 1, outc);
100 if (startS != 0 && finisS != 0) {
101 tputs(flag ? startS : finisS, 1, outc);
108 if (startU != 0 && finisU != 0) {
109 tputs(flag ? startU : finisU, 1, outc);
114 ShowSign(char *string)
120 tputs(tgoto(moveit, 0, height - 1), 1, outc);
121 tputs(wipeit, 1, outc);
124 while (*string != 0) {
128 for (first = length - 2; first >= (string - base); first--) {
129 if (first < length - 1) {
130 tputs(tgoto(moveit, first + 1, height - 1), 1, outc);
133 tputs(tgoto(moveit, first, height - 1), 1, outc);
139 first = isupper(ch) ? 'A' : 'a';
140 } else if (isdigit(ch)) {
147 while (first < last) {
165 tputs(wipeit, 1, outc);
178 onsig(int n GCC_UNUSED)
182 ExitProgram(EXIT_FAILURE);
186 railroad(char **args)
188 NCURSES_CONST char *name = getenv("TERM");
190 char area[1024], *ap = area;
194 #ifdef EXP_WIN32_DRIVER
195 name = "ms-terminal";
200 InitAndCatch(z = tgetent(buffer, name), onsig);
203 wipeit = tgetstr("ce", &ap);
204 height = tgetnum("li");
205 length = tgetnum("co");
206 moveit = tgetstr("cm", &ap);
218 startS = tgetstr("so", &ap);
219 finisS = tgetstr("se", &ap);
221 startU = tgetstr("us", &ap);
222 finisU = tgetstr("ue", &ap);
224 backup = tgetstr("le", &ap);
226 startC = tgetstr("ve", &ap);
227 finisC = tgetstr("vi", &ap);
239 main(int argc, char *argv[])
244 static char world[] = "Hello World";
245 static char *hello[] =
249 ExitProgram(EXIT_SUCCESS);
254 main(int argc GCC_UNUSED,
255 char *argv[]GCC_UNUSED)
257 printf("This program requires termcap\n");