1 /****************************************************************************
2 * Copyright 2018-2020,2021 Thomas E. Dickey *
3 * Copyright 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: popup_msg.c,v 1.11 2021/12/18 21:19:19 tom Exp $
32 * Show a multi-line message in a window which may extend beyond the screen.
34 * Thomas Dickey - 2017/4/15.
37 #include <test.priv.h>
39 #include <popup_msg.h>
43 static WINDOW *old_window;
49 old_window = dupwin(curscr);
56 wnoutrefresh(old_window);
62 * Display a temporary window, e.g., to display a help-message.
65 popup_msg(WINDOW *parent, const char *const *msg)
71 int wide = getmaxx(parent) - ((x0 + 1) * 2);
72 int high = getmaxy(parent) - ((y0 + 1) * 2);
81 for (n = 0; msg[n] != 0; ++n) {
82 int check = (int) strlen(msg[n]);
88 if ((help = newwin(high, wide, y0, x0)) == 0)
90 if ((data = newpad(length + 1, width + 1)) == 0) {
99 for (n = 0; n < length; ++n) {
100 waddstr(data, msg[n]);
101 if ((n + 1) < length) {
106 last_y = (y2 - (high - 3));
159 pnoutrefresh(data, y1, 0, y0 + 1, x0 + 1, high, wide);
161 } while ((ch = wgetch(data)) != ERR && ch != QUIT && ch != ESCAPE);
171 popup_msg2(WINDOW *parent, char **msg)
173 popup_msg(parent, (const char *const *) msg);
178 popup_msg(WINDOW *parent, const char *const *msg)