1 /****************************************************************************
2 * Copyright (c) 2006-2010,2011 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 ****************************************************************************/
29 * $Id: redraw.c,v 1.7 2011/05/21 18:38:35 tom Exp $
31 * Demonstrate the redrawwin() and wredrawln() functions.
32 * Thomas Dickey - 2006/11/4
35 #include <test.priv.h>
38 trash(int beg_x, int max_x, int cur_x)
42 for (x = cur_x; x > beg_x; --x) {
45 for (x = beg_x; x < max_x; ++x) {
53 for (x = max_x; x > cur_x; --x) {
59 test_redraw(WINDOW *win)
72 getmaxyx(win, max_y, max_x);
73 getbegyx(win, beg_y, beg_x);
74 while (!done && win != 0) {
84 win1 = newwin(max_y, max_x,
86 win2 = newwin(max_y - 2, max_x - 2,
87 beg_y + 1, beg_x + 1);
101 * redrawwin() and wredrawln() do not take into account the
102 * possibility that the cursor may have moved. That makes them
103 * cumbersome for using with a shell command. So we simply
104 * trash the current line of the window using backspace/overwrite.
106 trash(beg_x, max_x, x + beg_x);
109 #ifdef NCURSES_VERSION
112 * For a shell command, we can work around the problem noted above
113 * using mvcur(). It is ifdef'd for NCURSES, since X/Open does
114 * not define the case where the old location is unknown.
116 IGNORE_RC(system("date"));
126 wredrawln(win, y, 1);
131 wmove(win, y - 1, x);
136 wmove(win, y + 1, x);
141 wmove(win, y, x - 1);
146 wmove(win, y, x + 1);
151 waddstr(win, keyname(ch));
153 waddstr(win, unctrl(UChar(ch)));
163 main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
170 ExitProgram(EXIT_SUCCESS);