1 /****************************************************************************
2 * Copyright 2019-2020,2022 Thomas E. Dickey *
3 * Copyright 1998-2010,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 * Test lower-right-hand corner access
32 * originally by Eric S. Raymond <esr@thyrsus.com>, written for animation
33 * and resizing -T.Dickey
35 * This can't be part of the ncurses test-program, because ncurses rips off the
36 * bottom line to do labels.
38 * $Id: lrtest.c,v 1.29 2022/12/10 23:44:18 tom Exp $
41 #include <test.priv.h>
44 int y, x, mode, dir, inc;
49 * Make a couple of markers go 'round the border to demonstrate that we can
50 * really write to all positions properly.
55 MvAddCh(m->y, m->x, m->value);
56 if (m->mode == 0) { /* along the x-direction */
60 m->inc = -m->dir * m->inc;
63 } else if (m->x < 0) {
65 m->inc = -m->dir * m->inc;
69 } else { /* along the y-direction */
73 m->inc = m->dir * m->inc;
76 } else if (m->y < 0) {
78 m->inc = m->dir * m->inc;
88 static const char *msg[] =
90 "Usage: lrtest [options]"
96 for (n = 0; n < SIZEOF(msg); n++)
97 fprintf(stderr, "%s\n", msg[n]);
99 ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
106 main(int argc, char *argv[])
108 static MARK marks[] =
110 {0, 0, 0, -1, 1, '+' | A_BOLD},
111 {0, 0, 1, 1, 2, 'X'},
112 {0, 0, 1, -1, 3, 'Y'},
113 {0, 8, 0, -1, 1, '+' | A_BOLD},
114 {0, 9, 0, -1, 1, '+' | A_BOLD},
115 {1, 0, 1, 1, 1, '*' | A_REVERSE},
116 {2, 0, 1, 1, 1, '*' | A_REVERSE}
120 while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
124 ExitProgram(EXIT_SUCCESS);
126 usage(ch == OPTS_USAGE);
133 setlocale(LC_ALL, "");
138 nodelay(stdscr, TRUE);
142 keypad(stdscr, TRUE);
145 move(LINES / 2 - 1, 4);
148 /* see PutCharLR() */
150 || (enter_am_mode && exit_am_mode)
153 addstr("Your terminal lacks the capabilities needed to address the\n");
155 addstr("lower-right-hand corner of the screen.\n");
157 addstr("This is a test of access to the lower right corner.\n");
159 addstr("If the top of the box is missing, the test failed.\n");
160 move(LINES / 2 + 1, 4);
161 addstr("Please report this (with a copy of your terminfo entry).\n");
162 move(LINES / 2 + 2, 4);
163 addstr("to the ncurses maintainers, at bug-ncurses@gnu.org.\n");
171 for (n = 0; n < SIZEOF(marks); n++) {
175 if ((c2 = getch()) > 0) {
179 nodelay(stdscr, FALSE);
181 nodelay(stdscr, TRUE);
186 curses_trace(TRACE_CALLS | TRACE_ICALLS | TRACE_UPDATE);
189 else if (c2 == KEY_RESIZE) {
190 for (n = 0; n < SIZEOF(marks); n++) {
191 if (marks[n].mode == 0) { /* moving along x-direction */
193 marks[n].y = LINES - 1;
196 marks[n].x = COLS - 1;
211 ExitProgram(EXIT_SUCCESS);
214 /* lrtest.c ends here */