1 /* vi: set sw=4 ts=4: */
3 * msgbox.c -- implements the message box and info box
5 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
6 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com)
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 * Display a message box. Program will pause and display an "OK" button
27 * if the parameter 'pause' is non-zero.
30 dialog_msgbox (const char *title, const char *prompt, int height, int width,
36 /* center dialog box on screen */
37 x = (COLS - width) / 2;
38 y = (LINES - height) / 2;
40 draw_shadow (stdscr, y, x, height, width);
42 dialog = newwin (height, width, y, x);
43 keypad (dialog, TRUE);
45 draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
47 if (title != NULL && strlen(title) >= width-2 ) {
48 /* truncate long title -- mec */
49 char * title2 = malloc(width-2+1);
50 memcpy( title2, title, width-2 );
51 title2[width-2] = '\0';
56 wattrset (dialog, title_attr);
57 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
58 waddstr (dialog, (char *)title);
61 wattrset (dialog, dialog_attr);
62 print_autowrap (dialog, prompt, width - 2, 1, 2);
65 wattrset (dialog, border_attr);
66 mvwaddch (dialog, height - 3, 0, ACS_LTEE);
67 for (i = 0; i < width - 2; i++)
68 waddch (dialog, ACS_HLINE);
69 wattrset (dialog, dialog_attr);
70 waddch (dialog, ACS_RTEE);
72 print_button (dialog, " Ok ",
73 height - 2, width / 2 - 4, TRUE);
76 while (key != ESC && key != '\n' && key != ' ' &&
77 key != 'O' && key != 'o' && key != 'X' && key != 'x')
78 key = wgetch (dialog);
85 return key == ESC ? -1 : 0;