1 /****************************************************************************
2 * Copyright 2021 Thomas E. Dickey *
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 ****************************************************************************/
29 * $Id: combine.c,v 1.7 2021/12/12 01:10:28 tom Exp $
32 #include <test.priv.h>
44 } while (!iswprint((wint_t) value));
49 do_row(int row, int base_ch, int over_ch)
53 bool reverse = (r_opt && !(row % 2));
56 printw("[U+%04X]", over_ch);
61 attr_t attr = reverse ? A_REVERSE : A_NORMAL;
66 setcchar(&target, source, attr, 0, NULL);
70 setcchar(&target, source, attr, 0, NULL);
79 attr_on(A_REVERSE, NULL);
82 attr_off(A_REVERSE, NULL);
84 col = getcurx(stdscr);
85 base_ch = next_char(base_ch);
86 done = (col + 1 >= COLS);
90 #define LAST_OVER 0x6f
95 if (++value > LAST_OVER)
113 for (row = 0; row < LINES; ++row) {
114 do_row(row, ' ', 0x300 + over_it);
115 over_it = next_over(over_it);
122 static const char *msg[] =
124 "Usage: combine [options]",
126 "Demonstrate combining-characters.",
129 " -c use cchar_t data rather than wchar_t string",
130 " -r draw even-numbered rows in reverse-video",
133 for (n = 0; n < SIZEOF(msg); ++n) {
134 fprintf(stderr, "%s\n", msg[n]);
136 ExitProgram(EXIT_FAILURE);
140 main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
146 while ((n = getopt(argc, argv, "cr")) != -1) {
160 setlocale(LC_ALL, "");
164 keypad(stdscr, TRUE);
184 over_it = prev_over(over_it);
188 over_it = next_over(over_it);
195 ExitProgram(EXIT_SUCCESS);
201 printf("This program requires wide-curses functions\n");
202 ExitProgram(EXIT_FAILURE);