1 /****************************************************************************
2 * Copyright 2020-2021,2022 Thomas E. Dickey *
3 * Copyright 2013-2014,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 ****************************************************************************/
30 * $Id: test_vid_puts.c,v 1.17 2022/12/10 22:28:50 tom Exp $
32 * Demonstrate the vid_puts and vid_attr functions.
33 * Thomas Dickey - 2013/01/12
37 #include <test.priv.h>
39 #if USE_WIDEC_SUPPORT && HAVE_SETUPTERM && HAVE_VID_PUTS
42 static bool p_opt = FALSE;
56 if (VALID_STRING(s)) {
67 outs(exit_attribute_mode);
68 if (!outs(orig_colors))
75 change_attr(chtype attr)
78 vid_puts(attr, (short) 0, (void *) 0, outc);
80 vid_attr(attr, (short) 0, (void *) 0);
87 fprintf(my_fp, "Name: ");
90 change_attr(A_REVERSE);
91 fputs(" Reverse", my_fp);
92 change_attr(A_NORMAL);
99 static const char *tbl[] =
101 "Usage: test_vid_puts [options]"
105 ," -e use stderr (default stdout)"
106 ," -n do not initialize terminal"
107 ," -p use vid_puts (default vid_attr)"
110 for (n = 0; n < SIZEOF(tbl); ++n)
111 fprintf(stderr, "%s\n", tbl[n]);
112 ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
119 main(int argc, char *argv[])
122 bool no_init = FALSE;
126 while ((ch = getopt(argc, argv, OPTS_COMMON "enp")) != -1) {
139 ExitProgram(EXIT_SUCCESS);
141 usage(ch == OPTS_USAGE);
148 setlocale(LC_ALL, "");
152 setupterm((char *) 0, fileno(my_fp), (int *) 0);
156 ExitProgram(EXIT_SUCCESS);
163 printf("This program requires the wide-ncurses terminfo library\n");
164 ExitProgram(EXIT_FAILURE);