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