1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#include "dialog.h"
23
24
25
26
27
28int dialog_msgbox(const char *title, const char *prompt, int height, int width,
29 int pause)
30{
31 int i, x, y, key = 0;
32 WINDOW *dialog;
33
34
35 x = (COLS - width) / 2;
36 y = (LINES - height) / 2;
37
38 draw_shadow(stdscr, y, x, height, width);
39
40 dialog = newwin(height, width, y, x);
41 keypad(dialog, TRUE);
42
43 draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
44
45 print_title(dialog, title, width);
46
47 wattrset(dialog, dialog_attr);
48 print_autowrap(dialog, prompt, width - 2, 1, 2);
49
50 if (pause) {
51 wattrset(dialog, border_attr);
52 mvwaddch(dialog, height - 3, 0, ACS_LTEE);
53 for (i = 0; i < width - 2; i++)
54 waddch(dialog, ACS_HLINE);
55 wattrset(dialog, dialog_attr);
56 waddch(dialog, ACS_RTEE);
57
58 print_button(dialog, " Ok ", height - 2, width / 2 - 4, TRUE);
59
60 wrefresh(dialog);
61 while (key != ESC && key != '\n' && key != ' ' &&
62 key != 'O' && key != 'o' && key != 'X' && key != 'x')
63 key = wgetch(dialog);
64 } else {
65 key = '\n';
66 wrefresh(dialog);
67 }
68
69 delwin(dialog);
70 return key == ESC ? -1 : 0;
71}
72