aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/lxdialog/msgbox.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lxdialog/msgbox.c')
-rw-r--r--scripts/lxdialog/msgbox.c89
1 files changed, 44 insertions, 45 deletions
diff --git a/scripts/lxdialog/msgbox.c b/scripts/lxdialog/msgbox.c
index 93692e1fbcc2..76f358ca1fda 100644
--- a/scripts/lxdialog/msgbox.c
+++ b/scripts/lxdialog/msgbox.c
@@ -26,60 +26,59 @@
26 * if the parameter 'pause' is non-zero. 26 * if the parameter 'pause' is non-zero.
27 */ 27 */
28int 28int
29dialog_msgbox (const char *title, const char *prompt, int height, int width, 29dialog_msgbox(const char *title, const char *prompt, int height, int width,
30 int pause) 30 int pause)
31{ 31{
32 int i, x, y, key = 0; 32 int i, x, y, key = 0;
33 WINDOW *dialog; 33 WINDOW *dialog;
34 34
35 /* center dialog box on screen */ 35 /* center dialog box on screen */
36 x = (COLS - width) / 2; 36 x = (COLS - width) / 2;
37 y = (LINES - height) / 2; 37 y = (LINES - height) / 2;
38 38
39 draw_shadow (stdscr, y, x, height, width); 39 draw_shadow(stdscr, y, x, height, width);
40 40
41 dialog = newwin (height, width, y, x); 41 dialog = newwin(height, width, y, x);
42 keypad (dialog, TRUE); 42 keypad(dialog, TRUE);
43 43
44 draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); 44 draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
45 45
46 if (title != NULL && strlen(title) >= width-2 ) { 46 if (title != NULL && strlen(title) >= width - 2) {
47 /* truncate long title -- mec */ 47 /* truncate long title -- mec */
48 char * title2 = malloc(width-2+1); 48 char *title2 = malloc(width - 2 + 1);
49 memcpy( title2, title, width-2 ); 49 memcpy(title2, title, width - 2);
50 title2[width-2] = '\0'; 50 title2[width - 2] = '\0';
51 title = title2; 51 title = title2;
52 } 52 }
53 53
54 if (title != NULL) { 54 if (title != NULL) {
55 wattrset (dialog, title_attr); 55 wattrset(dialog, title_attr);
56 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); 56 mvwaddch(dialog, 0, (width - strlen(title)) / 2 - 1, ' ');
57 waddstr (dialog, (char *)title); 57 waddstr(dialog, (char *)title);
58 waddch (dialog, ' '); 58 waddch(dialog, ' ');
59 } 59 }
60 wattrset (dialog, dialog_attr); 60 wattrset(dialog, dialog_attr);
61 print_autowrap (dialog, prompt, width - 2, 1, 2); 61 print_autowrap(dialog, prompt, width - 2, 1, 2);
62 62
63 if (pause) { 63 if (pause) {
64 wattrset (dialog, border_attr); 64 wattrset(dialog, border_attr);
65 mvwaddch (dialog, height - 3, 0, ACS_LTEE); 65 mvwaddch(dialog, height - 3, 0, ACS_LTEE);
66 for (i = 0; i < width - 2; i++) 66 for (i = 0; i < width - 2; i++)
67 waddch (dialog, ACS_HLINE); 67 waddch(dialog, ACS_HLINE);
68 wattrset (dialog, dialog_attr); 68 wattrset(dialog, dialog_attr);
69 waddch (dialog, ACS_RTEE); 69 waddch(dialog, ACS_RTEE);
70 70
71 print_button (dialog, " Ok ", 71 print_button(dialog, " Ok ", height - 2, width / 2 - 4, TRUE);
72 height - 2, width / 2 - 4, TRUE);
73 72
74 wrefresh (dialog); 73 wrefresh(dialog);
75 while (key != ESC && key != '\n' && key != ' ' && 74 while (key != ESC && key != '\n' && key != ' ' &&
76 key != 'O' && key != 'o' && key != 'X' && key != 'x') 75 key != 'O' && key != 'o' && key != 'X' && key != 'x')
77 key = wgetch (dialog); 76 key = wgetch(dialog);
78 } else { 77 } else {
79 key = '\n'; 78 key = '\n';
80 wrefresh (dialog); 79 wrefresh(dialog);
81 } 80 }
82 81
83 delwin (dialog); 82 delwin(dialog);
84 return key == ESC ? -1 : 0; 83 return key == ESC ? -1 : 0;
85} 84}