aboutsummaryrefslogtreecommitdiff
path: root/scripts/config/lxdialog/yesno.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/config/lxdialog/yesno.c')
-rw-r--r--scripts/config/lxdialog/yesno.c119
1 files changed, 0 insertions, 119 deletions
diff --git a/scripts/config/lxdialog/yesno.c b/scripts/config/lxdialog/yesno.c
deleted file mode 100644
index 98562d8a9..000000000
--- a/scripts/config/lxdialog/yesno.c
+++ /dev/null
@@ -1,119 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * yesno.c -- implements the yes/no box
4 *
5 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
6 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
7 *
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.
12 *
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.
17 *
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.
21 */
22
23#include "dialog.h"
24
25/*
26 * Display termination buttons
27 */
28static void
29print_buttons(WINDOW *dialog, int height, int width, int selected)
30{
31 int x = width / 2 - 10;
32 int y = height - 2;
33
34 print_button (dialog, " Yes ", y, x, selected == 0);
35 print_button (dialog, " No ", y, x + 13, selected == 1);
36
37 wmove(dialog, y, x+1 + 13*selected );
38 wrefresh (dialog);
39}
40
41/*
42 * Display a dialog box with two buttons - Yes and No
43 */
44int
45dialog_yesno (const char *title, const char *prompt, int height, int width)
46{
47 int i, x, y, key = 0, button = 0;
48 WINDOW *dialog;
49
50 /* center dialog box on screen */
51 x = (COLS - width) / 2;
52 y = (LINES - height) / 2;
53
54 draw_shadow (stdscr, y, x, height, width);
55
56 dialog = newwin (height, width, y, x);
57 keypad (dialog, TRUE);
58
59 draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
60 wattrset (dialog, border_attr);
61 mvwaddch (dialog, height-3, 0, ACS_LTEE);
62 for (i = 0; i < width - 2; i++)
63 waddch (dialog, ACS_HLINE);
64 wattrset (dialog, dialog_attr);
65 waddch (dialog, ACS_RTEE);
66
67 if (title != NULL && strlen(title) >= width-2 ) {
68 /* truncate long title -- mec */
69 char * title2 = malloc(width-2+1);
70 memcpy( title2, title, width-2 );
71 title2[width-2] = '\0';
72 title = title2;
73 }
74
75 if (title != NULL) {
76 wattrset (dialog, title_attr);
77 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
78 waddstr (dialog, (char *)title);
79 waddch (dialog, ' ');
80 }
81
82 wattrset (dialog, dialog_attr);
83 print_autowrap (dialog, prompt, width - 2, 1, 3);
84
85 print_buttons(dialog, height, width, 0);
86
87 while (key != ESC) {
88 key = wgetch (dialog);
89 switch (key) {
90 case 'Y':
91 case 'y':
92 delwin (dialog);
93 return 0;
94 case 'N':
95 case 'n':
96 delwin (dialog);
97 return 1;
98
99 case TAB:
100 case KEY_LEFT:
101 case KEY_RIGHT:
102 button = ((key == KEY_LEFT ? --button : ++button) < 0)
103 ? 1 : (button > 1 ? 0 : button);
104
105 print_buttons(dialog, height, width, button);
106 wrefresh (dialog);
107 break;
108 case ' ':
109 case '\n':
110 delwin (dialog);
111 return button;
112 case ESC:
113 break;
114 }
115 }
116
117 delwin (dialog);
118 return -1; /* ESC pressed */
119}