diff options
Diffstat (limited to 'scripts/kconfig/lxdialog')
-rw-r--r-- | scripts/kconfig/lxdialog/Makefile | 21 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/checklist.c | 136 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/dialog.h | 52 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/inputbox.c | 2 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/lxdialog.c | 204 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/menubox.c | 95 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/msgbox.c | 72 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/textbox.c | 298 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/util.c | 134 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/yesno.c | 2 |
10 files changed, 340 insertions, 676 deletions
diff --git a/scripts/kconfig/lxdialog/Makefile b/scripts/kconfig/lxdialog/Makefile deleted file mode 100644 index a8b026326247..000000000000 --- a/scripts/kconfig/lxdialog/Makefile +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | # Makefile to build lxdialog package | ||
2 | # | ||
3 | |||
4 | check-lxdialog := $(srctree)/$(src)/check-lxdialog.sh | ||
5 | |||
6 | # Use reursively expanded variables so we do not call gcc unless | ||
7 | # we really need to do so. (Do not call gcc as part of make mrproper) | ||
8 | HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) | ||
9 | HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) | ||
10 | |||
11 | HOST_EXTRACFLAGS += -DLOCALE | ||
12 | |||
13 | PHONY += dochecklxdialog | ||
14 | $(obj)/dochecklxdialog: | ||
15 | $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES) | ||
16 | |||
17 | hostprogs-y := lxdialog | ||
18 | always := $(hostprogs-y) dochecklxdialog | ||
19 | |||
20 | lxdialog-objs := checklist.o menubox.o textbox.o yesno.o inputbox.o \ | ||
21 | util.o lxdialog.o msgbox.o | ||
diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c index b90e888a2bc0..282511020bcb 100644 --- a/scripts/kconfig/lxdialog/checklist.c +++ b/scripts/kconfig/lxdialog/checklist.c | |||
@@ -28,8 +28,7 @@ static int list_width, check_x, item_x; | |||
28 | /* | 28 | /* |
29 | * Print list item | 29 | * Print list item |
30 | */ | 30 | */ |
31 | static void print_item(WINDOW * win, const char *item, int status, int choice, | 31 | static void print_item(WINDOW * win, int choice, int selected) |
32 | int selected) | ||
33 | { | 32 | { |
34 | int i; | 33 | int i; |
35 | 34 | ||
@@ -42,12 +41,12 @@ static void print_item(WINDOW * win, const char *item, int status, int choice, | |||
42 | wmove(win, choice, check_x); | 41 | wmove(win, choice, check_x); |
43 | wattrset(win, selected ? dlg.check_selected.atr | 42 | wattrset(win, selected ? dlg.check_selected.atr |
44 | : dlg.check.atr); | 43 | : dlg.check.atr); |
45 | wprintw(win, "(%c)", status ? 'X' : ' '); | 44 | wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' '); |
46 | 45 | ||
47 | wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr); | 46 | wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr); |
48 | mvwaddch(win, choice, item_x, item[0]); | 47 | mvwaddch(win, choice, item_x, item_str()[0]); |
49 | wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); | 48 | wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); |
50 | waddstr(win, (char *)item + 1); | 49 | waddstr(win, (char *)item_str() + 1); |
51 | if (selected) { | 50 | if (selected) { |
52 | wmove(win, choice, check_x + 1); | 51 | wmove(win, choice, check_x + 1); |
53 | wrefresh(win); | 52 | wrefresh(win); |
@@ -110,32 +109,23 @@ static void print_buttons(WINDOW * dialog, int height, int width, int selected) | |||
110 | * in the style of radiolist (only one option turned on at a time). | 109 | * in the style of radiolist (only one option turned on at a time). |
111 | */ | 110 | */ |
112 | int dialog_checklist(const char *title, const char *prompt, int height, | 111 | int dialog_checklist(const char *title, const char *prompt, int height, |
113 | int width, int list_height, int item_no, | 112 | int width, int list_height) |
114 | const char *const *items) | ||
115 | { | 113 | { |
116 | int i, x, y, box_x, box_y; | 114 | int i, x, y, box_x, box_y; |
117 | int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; | 115 | int key = 0, button = 0, choice = 0, scroll = 0, max_choice; |
118 | WINDOW *dialog, *list; | 116 | WINDOW *dialog, *list; |
119 | 117 | ||
120 | /* Allocate space for storing item on/off status */ | 118 | /* which item to highlight */ |
121 | if ((status = malloc(sizeof(int) * item_no)) == NULL) { | 119 | item_foreach() { |
122 | endwin(); | 120 | if (item_is_tag('X')) |
123 | fprintf(stderr, | 121 | choice = item_n(); |
124 | "\nCan't allocate memory in dialog_checklist().\n"); | 122 | if (item_is_selected()) { |
125 | exit(-1); | 123 | choice = item_n(); |
126 | } | 124 | break; |
127 | 125 | } | |
128 | /* Initializes status */ | ||
129 | for (i = 0; i < item_no; i++) { | ||
130 | status[i] = !strcasecmp(items[i * 3 + 2], "on"); | ||
131 | if ((!choice && status[i]) | ||
132 | || !strcasecmp(items[i * 3 + 2], "selected")) | ||
133 | choice = i + 1; | ||
134 | } | 126 | } |
135 | if (choice) | ||
136 | choice--; | ||
137 | 127 | ||
138 | max_choice = MIN(list_height, item_no); | 128 | max_choice = MIN(list_height, item_count()); |
139 | 129 | ||
140 | /* center dialog box on screen */ | 130 | /* center dialog box on screen */ |
141 | x = (COLS - width) / 2; | 131 | x = (COLS - width) / 2; |
@@ -176,8 +166,8 @@ int dialog_checklist(const char *title, const char *prompt, int height, | |||
176 | 166 | ||
177 | /* Find length of longest item in order to center checklist */ | 167 | /* Find length of longest item in order to center checklist */ |
178 | check_x = 0; | 168 | check_x = 0; |
179 | for (i = 0; i < item_no; i++) | 169 | item_foreach() |
180 | check_x = MAX(check_x, +strlen(items[i * 3 + 1]) + 4); | 170 | check_x = MAX(check_x, strlen(item_str()) + 4); |
181 | 171 | ||
182 | check_x = (list_width - check_x) / 2; | 172 | check_x = (list_width - check_x) / 2; |
183 | item_x = check_x + 4; | 173 | item_x = check_x + 4; |
@@ -189,14 +179,11 @@ int dialog_checklist(const char *title, const char *prompt, int height, | |||
189 | 179 | ||
190 | /* Print the list */ | 180 | /* Print the list */ |
191 | for (i = 0; i < max_choice; i++) { | 181 | for (i = 0; i < max_choice; i++) { |
192 | if (i != choice) | 182 | item_set(scroll + i); |
193 | print_item(list, items[(scroll + i) * 3 + 1], | 183 | print_item(list, i, i == choice); |
194 | status[i + scroll], i, 0); | ||
195 | } | 184 | } |
196 | print_item(list, items[(scroll + choice) * 3 + 1], | ||
197 | status[choice + scroll], choice, 1); | ||
198 | 185 | ||
199 | print_arrows(dialog, choice, item_no, scroll, | 186 | print_arrows(dialog, choice, item_count(), scroll, |
200 | box_y, box_x + check_x + 5, list_height); | 187 | box_y, box_x + check_x + 5, list_height); |
201 | 188 | ||
202 | print_buttons(dialog, height, width, 0); | 189 | print_buttons(dialog, height, width, 0); |
@@ -208,10 +195,11 @@ int dialog_checklist(const char *title, const char *prompt, int height, | |||
208 | while (key != ESC) { | 195 | while (key != ESC) { |
209 | key = wgetch(dialog); | 196 | key = wgetch(dialog); |
210 | 197 | ||
211 | for (i = 0; i < max_choice; i++) | 198 | for (i = 0; i < max_choice; i++) { |
212 | if (toupper(key) == | 199 | item_set(i + scroll); |
213 | toupper(items[(scroll + i) * 3 + 1][0])) | 200 | if (toupper(key) == toupper(item_str()[0])) |
214 | break; | 201 | break; |
202 | } | ||
215 | 203 | ||
216 | if (i < max_choice || key == KEY_UP || key == KEY_DOWN || | 204 | if (i < max_choice || key == KEY_UP || key == KEY_DOWN || |
217 | key == '+' || key == '-') { | 205 | key == '+' || key == '-') { |
@@ -222,15 +210,16 @@ int dialog_checklist(const char *title, const char *prompt, int height, | |||
222 | /* Scroll list down */ | 210 | /* Scroll list down */ |
223 | if (list_height > 1) { | 211 | if (list_height > 1) { |
224 | /* De-highlight current first item */ | 212 | /* De-highlight current first item */ |
225 | print_item(list, items[scroll * 3 + 1], | 213 | item_set(scroll); |
226 | status[scroll], 0, FALSE); | 214 | print_item(list, 0, FALSE); |
227 | scrollok(list, TRUE); | 215 | scrollok(list, TRUE); |
228 | wscrl(list, -1); | 216 | wscrl(list, -1); |
229 | scrollok(list, FALSE); | 217 | scrollok(list, FALSE); |
230 | } | 218 | } |
231 | scroll--; | 219 | scroll--; |
232 | print_item(list, items[scroll * 3 + 1], status[scroll], 0, TRUE); | 220 | item_set(scroll); |
233 | print_arrows(dialog, choice, item_no, | 221 | print_item(list, 0, TRUE); |
222 | print_arrows(dialog, choice, item_count(), | ||
234 | scroll, box_y, box_x + check_x + 5, list_height); | 223 | scroll, box_y, box_x + check_x + 5, list_height); |
235 | 224 | ||
236 | wnoutrefresh(dialog); | 225 | wnoutrefresh(dialog); |
@@ -241,23 +230,24 @@ int dialog_checklist(const char *title, const char *prompt, int height, | |||
241 | i = choice - 1; | 230 | i = choice - 1; |
242 | } else if (key == KEY_DOWN || key == '+') { | 231 | } else if (key == KEY_DOWN || key == '+') { |
243 | if (choice == max_choice - 1) { | 232 | if (choice == max_choice - 1) { |
244 | if (scroll + choice >= item_no - 1) | 233 | if (scroll + choice >= item_count() - 1) |
245 | continue; | 234 | continue; |
246 | /* Scroll list up */ | 235 | /* Scroll list up */ |
247 | if (list_height > 1) { | 236 | if (list_height > 1) { |
248 | /* De-highlight current last item before scrolling up */ | 237 | /* De-highlight current last item before scrolling up */ |
249 | print_item(list, items[(scroll + max_choice - 1) * 3 + 1], | 238 | item_set(scroll + max_choice - 1); |
250 | status[scroll + max_choice - 1], | 239 | print_item(list, |
251 | max_choice - 1, FALSE); | 240 | max_choice - 1, |
241 | FALSE); | ||
252 | scrollok(list, TRUE); | 242 | scrollok(list, TRUE); |
253 | wscrl(list, 1); | 243 | wscrl(list, 1); |
254 | scrollok(list, FALSE); | 244 | scrollok(list, FALSE); |
255 | } | 245 | } |
256 | scroll++; | 246 | scroll++; |
257 | print_item(list, items[(scroll + max_choice - 1) * 3 + 1], | 247 | item_set(scroll + max_choice - 1); |
258 | status[scroll + max_choice - 1], max_choice - 1, TRUE); | 248 | print_item(list, max_choice - 1, TRUE); |
259 | 249 | ||
260 | print_arrows(dialog, choice, item_no, | 250 | print_arrows(dialog, choice, item_count(), |
261 | scroll, box_y, box_x + check_x + 5, list_height); | 251 | scroll, box_y, box_x + check_x + 5, list_height); |
262 | 252 | ||
263 | wnoutrefresh(dialog); | 253 | wnoutrefresh(dialog); |
@@ -269,12 +259,12 @@ int dialog_checklist(const char *title, const char *prompt, int height, | |||
269 | } | 259 | } |
270 | if (i != choice) { | 260 | if (i != choice) { |
271 | /* De-highlight current item */ | 261 | /* De-highlight current item */ |
272 | print_item(list, items[(scroll + choice) * 3 + 1], | 262 | item_set(scroll + choice); |
273 | status[scroll + choice], choice, FALSE); | 263 | print_item(list, choice, FALSE); |
274 | /* Highlight new item */ | 264 | /* Highlight new item */ |
275 | choice = i; | 265 | choice = i; |
276 | print_item(list, items[(scroll + choice) * 3 + 1], | 266 | item_set(scroll + choice); |
277 | status[scroll + choice], choice, TRUE); | 267 | print_item(list, choice, TRUE); |
278 | wnoutrefresh(dialog); | 268 | wnoutrefresh(dialog); |
279 | wrefresh(list); | 269 | wrefresh(list); |
280 | } | 270 | } |
@@ -284,10 +274,19 @@ int dialog_checklist(const char *title, const char *prompt, int height, | |||
284 | case 'H': | 274 | case 'H': |
285 | case 'h': | 275 | case 'h': |
286 | case '?': | 276 | case '?': |
287 | fprintf(stderr, "%s", items[(scroll + choice) * 3]); | 277 | button = 1; |
278 | /* fall-through */ | ||
279 | case 'S': | ||
280 | case 's': | ||
281 | case ' ': | ||
282 | case '\n': | ||
283 | item_foreach() | ||
284 | item_set_selected(0); | ||
285 | item_set(scroll + choice); | ||
286 | item_set_selected(1); | ||
287 | delwin(list); | ||
288 | delwin(dialog); | 288 | delwin(dialog); |
289 | free(status); | 289 | return button; |
290 | return 1; | ||
291 | case TAB: | 290 | case TAB: |
292 | case KEY_LEFT: | 291 | case KEY_LEFT: |
293 | case KEY_RIGHT: | 292 | case KEY_RIGHT: |
@@ -297,30 +296,6 @@ int dialog_checklist(const char *title, const char *prompt, int height, | |||
297 | print_buttons(dialog, height, width, button); | 296 | print_buttons(dialog, height, width, button); |
298 | wrefresh(dialog); | 297 | wrefresh(dialog); |
299 | break; | 298 | break; |
300 | case 'S': | ||
301 | case 's': | ||
302 | case ' ': | ||
303 | case '\n': | ||
304 | if (!button) { | ||
305 | if (!status[scroll + choice]) { | ||
306 | for (i = 0; i < item_no; i++) | ||
307 | status[i] = 0; | ||
308 | status[scroll + choice] = 1; | ||
309 | for (i = 0; i < max_choice; i++) | ||
310 | print_item(list, items[(scroll + i) * 3 + 1], | ||
311 | status[scroll + i], i, i == choice); | ||
312 | } | ||
313 | wnoutrefresh(dialog); | ||
314 | wrefresh(list); | ||
315 | |||
316 | for (i = 0; i < item_no; i++) | ||
317 | if (status[i]) | ||
318 | fprintf(stderr, "%s", items[i * 3]); | ||
319 | } else | ||
320 | fprintf(stderr, "%s", items[(scroll + choice) * 3]); | ||
321 | delwin(dialog); | ||
322 | free(status); | ||
323 | return button; | ||
324 | case 'X': | 299 | case 'X': |
325 | case 'x': | 300 | case 'x': |
326 | key = ESC; | 301 | key = ESC; |
@@ -331,8 +306,7 @@ int dialog_checklist(const char *title, const char *prompt, int height, | |||
331 | /* Now, update everything... */ | 306 | /* Now, update everything... */ |
332 | doupdate(); | 307 | doupdate(); |
333 | } | 308 | } |
334 | 309 | delwin(list); | |
335 | delwin(dialog); | 310 | delwin(dialog); |
336 | free(status); | 311 | return 255; /* ESC pressed */ |
337 | return -1; /* ESC pressed */ | ||
338 | } | 312 | } |
diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index 2f4c19d710b2..065ded0a449f 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h | |||
@@ -133,11 +133,55 @@ struct dialog_info { | |||
133 | * Global variables | 133 | * Global variables |
134 | */ | 134 | */ |
135 | extern struct dialog_info dlg; | 135 | extern struct dialog_info dlg; |
136 | extern char dialog_input_result[]; | ||
136 | 137 | ||
137 | /* | 138 | /* |
138 | * Function prototypes | 139 | * Function prototypes |
139 | */ | 140 | */ |
140 | void init_dialog(void); | 141 | |
142 | /* item list as used by checklist and menubox */ | ||
143 | void item_reset(void); | ||
144 | void item_make(const char *fmt, ...); | ||
145 | void item_add_str(const char *fmt, ...); | ||
146 | void item_set_tag(char tag); | ||
147 | void item_set_data(void *p); | ||
148 | void item_set_selected(int val); | ||
149 | int item_activate_selected(void); | ||
150 | void *item_data(void); | ||
151 | char item_tag(void); | ||
152 | |||
153 | /* item list manipulation for lxdialog use */ | ||
154 | #define MAXITEMSTR 200 | ||
155 | struct dialog_item { | ||
156 | char str[MAXITEMSTR]; /* promtp displayed */ | ||
157 | char tag; | ||
158 | void *data; /* pointer to menu item - used by menubox+checklist */ | ||
159 | int selected; /* Set to 1 by dialog_*() function if selected. */ | ||
160 | }; | ||
161 | |||
162 | /* list of lialog_items */ | ||
163 | struct dialog_list { | ||
164 | struct dialog_item node; | ||
165 | struct dialog_list *next; | ||
166 | }; | ||
167 | |||
168 | extern struct dialog_list *item_cur; | ||
169 | extern struct dialog_list item_nil; | ||
170 | extern struct dialog_list *item_head; | ||
171 | |||
172 | int item_count(void); | ||
173 | void item_set(int n); | ||
174 | int item_n(void); | ||
175 | const char *item_str(void); | ||
176 | int item_is_selected(void); | ||
177 | int item_is_tag(char tag); | ||
178 | #define item_foreach() \ | ||
179 | for (item_cur = item_head ? item_head: item_cur; \ | ||
180 | item_cur && (item_cur != &item_nil); item_cur = item_cur->next) | ||
181 | |||
182 | |||
183 | void init_dialog(const char *backtitle); | ||
184 | void reset_dialog(void); | ||
141 | void end_dialog(void); | 185 | void end_dialog(void); |
142 | void attr_clear(WINDOW * win, int height, int width, chtype attr); | 186 | void attr_clear(WINDOW * win, int height, int width, chtype attr); |
143 | void dialog_clear(void); | 187 | void dialog_clear(void); |
@@ -154,11 +198,9 @@ int dialog_msgbox(const char *title, const char *prompt, int height, | |||
154 | int width, int pause); | 198 | int width, int pause); |
155 | int dialog_textbox(const char *title, const char *file, int height, int width); | 199 | int dialog_textbox(const char *title, const char *file, int height, int width); |
156 | int dialog_menu(const char *title, const char *prompt, int height, int width, | 200 | int dialog_menu(const char *title, const char *prompt, int height, int width, |
157 | int menu_height, const char *choice, int item_no, | 201 | int menu_height, const void *selected, int *s_scroll); |
158 | const char *const *items); | ||
159 | int dialog_checklist(const char *title, const char *prompt, int height, | 202 | int dialog_checklist(const char *title, const char *prompt, int height, |
160 | int width, int list_height, int item_no, | 203 | int width, int list_height); |
161 | const char *const *items); | ||
162 | extern char dialog_input_result[]; | 204 | extern char dialog_input_result[]; |
163 | int dialog_inputbox(const char *title, const char *prompt, int height, | 205 | int dialog_inputbox(const char *title, const char *prompt, int height, |
164 | int width, const char *init); | 206 | int width, const char *init); |
diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c index f75b51f8e636..9c53098d6b74 100644 --- a/scripts/kconfig/lxdialog/inputbox.c +++ b/scripts/kconfig/lxdialog/inputbox.c | |||
@@ -222,5 +222,5 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width | |||
222 | } | 222 | } |
223 | 223 | ||
224 | delwin(dialog); | 224 | delwin(dialog); |
225 | return -1; /* ESC pressed */ | 225 | return 255; /* ESC pressed */ |
226 | } | 226 | } |
diff --git a/scripts/kconfig/lxdialog/lxdialog.c b/scripts/kconfig/lxdialog/lxdialog.c deleted file mode 100644 index c264e024309e..000000000000 --- a/scripts/kconfig/lxdialog/lxdialog.c +++ /dev/null | |||
@@ -1,204 +0,0 @@ | |||
1 | /* | ||
2 | * dialog - Display simple dialog boxes from shell scripts | ||
3 | * | ||
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) | ||
6 | * | ||
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. | ||
11 | * | ||
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. | ||
16 | * | ||
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. | ||
20 | */ | ||
21 | |||
22 | #include "dialog.h" | ||
23 | |||
24 | static void Usage(const char *name); | ||
25 | |||
26 | typedef int (jumperFn) (const char *title, int argc, const char *const *argv); | ||
27 | |||
28 | struct Mode { | ||
29 | char *name; | ||
30 | int argmin, argmax, argmod; | ||
31 | jumperFn *jumper; | ||
32 | }; | ||
33 | |||
34 | jumperFn j_menu, j_radiolist, j_yesno, j_textbox, j_inputbox; | ||
35 | jumperFn j_msgbox, j_infobox; | ||
36 | |||
37 | static struct Mode modes[] = { | ||
38 | {"--menu", 9, 0, 3, j_menu}, | ||
39 | {"--radiolist", 9, 0, 3, j_radiolist}, | ||
40 | {"--yesno", 5, 5, 1, j_yesno}, | ||
41 | {"--textbox", 5, 5, 1, j_textbox}, | ||
42 | {"--inputbox", 5, 6, 1, j_inputbox}, | ||
43 | {"--msgbox", 5, 5, 1, j_msgbox}, | ||
44 | {"--infobox", 5, 5, 1, j_infobox}, | ||
45 | {NULL, 0, 0, 0, NULL} | ||
46 | }; | ||
47 | |||
48 | static struct Mode *modePtr; | ||
49 | |||
50 | #ifdef LOCALE | ||
51 | #include <locale.h> | ||
52 | #endif | ||
53 | |||
54 | int main(int argc, const char *const *argv) | ||
55 | { | ||
56 | int offset = 0, opt_clear = 0, end_common_opts = 0, retval; | ||
57 | const char *title = NULL; | ||
58 | |||
59 | #ifdef LOCALE | ||
60 | (void)setlocale(LC_ALL, ""); | ||
61 | #endif | ||
62 | |||
63 | #ifdef TRACE | ||
64 | trace(TRACE_CALLS | TRACE_UPDATE); | ||
65 | #endif | ||
66 | if (argc < 2) { | ||
67 | Usage(argv[0]); | ||
68 | exit(-1); | ||
69 | } | ||
70 | |||
71 | while (offset < argc - 1 && !end_common_opts) { /* Common options */ | ||
72 | if (!strcmp(argv[offset + 1], "--title")) { | ||
73 | if (argc - offset < 3 || title != NULL) { | ||
74 | Usage(argv[0]); | ||
75 | exit(-1); | ||
76 | } else { | ||
77 | title = argv[offset + 2]; | ||
78 | offset += 2; | ||
79 | } | ||
80 | } else if (!strcmp(argv[offset + 1], "--backtitle")) { | ||
81 | if (dlg.backtitle != NULL) { | ||
82 | Usage(argv[0]); | ||
83 | exit(-1); | ||
84 | } else { | ||
85 | dlg.backtitle = argv[offset + 2]; | ||
86 | offset += 2; | ||
87 | } | ||
88 | } else if (!strcmp(argv[offset + 1], "--clear")) { | ||
89 | if (opt_clear) { /* Hey, "--clear" can't appear twice! */ | ||
90 | Usage(argv[0]); | ||
91 | exit(-1); | ||
92 | } else if (argc == 2) { /* we only want to clear the screen */ | ||
93 | init_dialog(); | ||
94 | refresh(); /* init_dialog() will clear the screen for us */ | ||
95 | end_dialog(); | ||
96 | return 0; | ||
97 | } else { | ||
98 | opt_clear = 1; | ||
99 | offset++; | ||
100 | } | ||
101 | } else /* no more common options */ | ||
102 | end_common_opts = 1; | ||
103 | } | ||
104 | |||
105 | if (argc - 1 == offset) { /* no more options */ | ||
106 | Usage(argv[0]); | ||
107 | exit(-1); | ||
108 | } | ||
109 | /* use a table to look for the requested mode, to avoid code duplication */ | ||
110 | |||
111 | for (modePtr = modes; modePtr->name; modePtr++) /* look for the mode */ | ||
112 | if (!strcmp(argv[offset + 1], modePtr->name)) | ||
113 | break; | ||
114 | |||
115 | if (!modePtr->name) | ||
116 | Usage(argv[0]); | ||
117 | if (argc - offset < modePtr->argmin) | ||
118 | Usage(argv[0]); | ||
119 | if (modePtr->argmax && argc - offset > modePtr->argmax) | ||
120 | Usage(argv[0]); | ||
121 | |||
122 | init_dialog(); | ||
123 | retval = (*(modePtr->jumper)) (title, argc - offset, argv + offset); | ||
124 | |||
125 | if (opt_clear) { /* clear screen before exit */ | ||
126 | attr_clear(stdscr, LINES, COLS, dlg.screen.atr); | ||
127 | refresh(); | ||
128 | } | ||
129 | end_dialog(); | ||
130 | |||
131 | exit(retval); | ||
132 | } | ||
133 | |||
134 | /* | ||
135 | * Print program usage | ||
136 | */ | ||
137 | static void Usage(const char *name) | ||
138 | { | ||
139 | fprintf(stderr, "\ | ||
140 | \ndialog, by Savio Lam (lam836@cs.cuhk.hk).\ | ||
141 | \n patched by Stuart Herbert (S.Herbert@shef.ac.uk)\ | ||
142 | \n modified/gutted for use as a Linux kernel config tool by \ | ||
143 | \n William Roadcap (roadcapw@cfw.com)\ | ||
144 | \n\ | ||
145 | \n* Display dialog boxes from shell scripts *\ | ||
146 | \n\ | ||
147 | \nUsage: %s --clear\ | ||
148 | \n %s [--title <title>] [--backtitle <backtitle>] --clear <Box options>\ | ||
149 | \n\ | ||
150 | \nBox options:\ | ||
151 | \n\ | ||
152 | \n --menu <text> <height> <width> <menu height> <tag1> <item1>...\ | ||
153 | \n --radiolist <text> <height> <width> <list height> <tag1> <item1> <status1>...\ | ||
154 | \n --textbox <file> <height> <width>\ | ||
155 | \n --inputbox <text> <height> <width> [<init>]\ | ||
156 | \n --yesno <text> <height> <width>\ | ||
157 | \n", name, name); | ||
158 | exit(-1); | ||
159 | } | ||
160 | |||
161 | /* | ||
162 | * These are the program jumpers | ||
163 | */ | ||
164 | |||
165 | int j_menu(const char *t, int ac, const char *const *av) | ||
166 | { | ||
167 | return dialog_menu(t, av[2], atoi(av[3]), atoi(av[4]), | ||
168 | atoi(av[5]), av[6], (ac - 6) / 2, av + 7); | ||
169 | } | ||
170 | |||
171 | int j_radiolist(const char *t, int ac, const char *const *av) | ||
172 | { | ||
173 | return dialog_checklist(t, av[2], atoi(av[3]), atoi(av[4]), | ||
174 | atoi(av[5]), (ac - 6) / 3, av + 6); | ||
175 | } | ||
176 | |||
177 | int j_textbox(const char *t, int ac, const char *const *av) | ||
178 | { | ||
179 | return dialog_textbox(t, av[2], atoi(av[3]), atoi(av[4])); | ||
180 | } | ||
181 | |||
182 | int j_yesno(const char *t, int ac, const char *const *av) | ||
183 | { | ||
184 | return dialog_yesno(t, av[2], atoi(av[3]), atoi(av[4])); | ||
185 | } | ||
186 | |||
187 | int j_inputbox(const char *t, int ac, const char *const *av) | ||
188 | { | ||
189 | int ret = dialog_inputbox(t, av[2], atoi(av[3]), atoi(av[4]), | ||
190 | ac == 6 ? av[5] : (char *)NULL); | ||
191 | if (ret == 0) | ||
192 | fprintf(stderr, dialog_input_result); | ||
193 | return ret; | ||
194 | } | ||
195 | |||
196 | int j_msgbox(const char *t, int ac, const char *const *av) | ||
197 | { | ||
198 | return dialog_msgbox(t, av[2], atoi(av[3]), atoi(av[4]), 1); | ||
199 | } | ||
200 | |||
201 | int j_infobox(const char *t, int ac, const char *const *av) | ||
202 | { | ||
203 | return dialog_msgbox(t, av[2], atoi(av[3]), atoi(av[4]), 0); | ||
204 | } | ||
diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c index ff991db827bd..f39ae29f4fcc 100644 --- a/scripts/kconfig/lxdialog/menubox.c +++ b/scripts/kconfig/lxdialog/menubox.c | |||
@@ -99,10 +99,10 @@ static void do_print_item(WINDOW * win, const char *item, int choice, | |||
99 | wrefresh(win); | 99 | wrefresh(win); |
100 | } | 100 | } |
101 | 101 | ||
102 | #define print_item(index, choice, selected) \ | 102 | #define print_item(index, choice, selected) \ |
103 | do {\ | 103 | do { \ |
104 | int hotkey = (items[(index) * 2][0] != ':'); \ | 104 | item_set(index); \ |
105 | do_print_item(menu, items[(index) * 2 + 1], choice, selected, hotkey); \ | 105 | do_print_item(menu, item_str(), choice, selected, !item_is_tag(':')); \ |
106 | } while (0) | 106 | } while (0) |
107 | 107 | ||
108 | /* | 108 | /* |
@@ -180,16 +180,14 @@ static void do_scroll(WINDOW *win, int *scroll, int n) | |||
180 | * Display a menu for choosing among a number of options | 180 | * Display a menu for choosing among a number of options |
181 | */ | 181 | */ |
182 | int dialog_menu(const char *title, const char *prompt, int height, int width, | 182 | int dialog_menu(const char *title, const char *prompt, int height, int width, |
183 | int menu_height, const char *current, int item_no, | 183 | int menu_height, const void *selected, int *s_scroll) |
184 | const char *const *items) | ||
185 | { | 184 | { |
186 | int i, j, x, y, box_x, box_y; | 185 | int i, j, x, y, box_x, box_y; |
187 | int key = 0, button = 0, scroll = 0, choice = 0; | 186 | int key = 0, button = 0, scroll = 0, choice = 0; |
188 | int first_item = 0, max_choice; | 187 | int first_item = 0, max_choice; |
189 | WINDOW *dialog, *menu; | 188 | WINDOW *dialog, *menu; |
190 | FILE *f; | ||
191 | 189 | ||
192 | max_choice = MIN(menu_height, item_no); | 190 | max_choice = MIN(menu_height, item_count()); |
193 | 191 | ||
194 | /* center dialog box on screen */ | 192 | /* center dialog box on screen */ |
195 | x = (COLS - width) / 2; | 193 | x = (COLS - width) / 2; |
@@ -231,28 +229,21 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, | |||
231 | item_x = (menu_width - 70) / 2; | 229 | item_x = (menu_width - 70) / 2; |
232 | 230 | ||
233 | /* Set choice to default item */ | 231 | /* Set choice to default item */ |
234 | for (i = 0; i < item_no; i++) | 232 | item_foreach() |
235 | if (strcmp(current, items[i * 2]) == 0) | 233 | if (selected && (selected == item_data())) |
236 | choice = i; | 234 | choice = item_n(); |
237 | 235 | /* get the saved scroll info */ | |
238 | /* get the scroll info from the temp file */ | 236 | scroll = *s_scroll; |
239 | if ((f = fopen("lxdialog.scrltmp", "r")) != NULL) { | 237 | if ((scroll <= choice) && (scroll + max_choice > choice) && |
240 | if ((fscanf(f, "%d\n", &scroll) == 1) && (scroll <= choice) && | 238 | (scroll >= 0) && (scroll + max_choice <= item_count())) { |
241 | (scroll + max_choice > choice) && (scroll >= 0) && | 239 | first_item = scroll; |
242 | (scroll + max_choice <= item_no)) { | 240 | choice = choice - scroll; |
243 | first_item = scroll; | 241 | } else { |
244 | choice = choice - scroll; | 242 | scroll = 0; |
245 | fclose(f); | ||
246 | } else { | ||
247 | scroll = 0; | ||
248 | remove("lxdialog.scrltmp"); | ||
249 | fclose(f); | ||
250 | f = NULL; | ||
251 | } | ||
252 | } | 243 | } |
253 | if ((choice >= max_choice) || (f == NULL && choice >= max_choice / 2)) { | 244 | if ((choice >= max_choice)) { |
254 | if (choice >= item_no - max_choice / 2) | 245 | if (choice >= item_count() - max_choice / 2) |
255 | scroll = first_item = item_no - max_choice; | 246 | scroll = first_item = item_count() - max_choice; |
256 | else | 247 | else |
257 | scroll = first_item = choice - max_choice / 2; | 248 | scroll = first_item = choice - max_choice / 2; |
258 | choice = choice - scroll; | 249 | choice = choice - scroll; |
@@ -265,7 +256,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, | |||
265 | 256 | ||
266 | wnoutrefresh(menu); | 257 | wnoutrefresh(menu); |
267 | 258 | ||
268 | print_arrows(dialog, item_no, scroll, | 259 | print_arrows(dialog, item_count(), scroll, |
269 | box_y, box_x + item_x + 1, menu_height); | 260 | box_y, box_x + item_x + 1, menu_height); |
270 | 261 | ||
271 | print_buttons(dialog, height, width, 0); | 262 | print_buttons(dialog, height, width, 0); |
@@ -282,14 +273,16 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, | |||
282 | i = max_choice; | 273 | i = max_choice; |
283 | else { | 274 | else { |
284 | for (i = choice + 1; i < max_choice; i++) { | 275 | for (i = choice + 1; i < max_choice; i++) { |
285 | j = first_alpha(items[(scroll + i) * 2 + 1], "YyNnMmHh"); | 276 | item_set(scroll + i); |
286 | if (key == tolower(items[(scroll + i) * 2 + 1][j])) | 277 | j = first_alpha(item_str(), "YyNnMmHh"); |
278 | if (key == tolower(item_str()[j])) | ||
287 | break; | 279 | break; |
288 | } | 280 | } |
289 | if (i == max_choice) | 281 | if (i == max_choice) |
290 | for (i = 0; i < max_choice; i++) { | 282 | for (i = 0; i < max_choice; i++) { |
291 | j = first_alpha(items [(scroll + i) * 2 + 1], "YyNnMmHh"); | 283 | item_set(scroll + i); |
292 | if (key == tolower(items[(scroll + i) * 2 + 1][j])) | 284 | j = first_alpha(item_str(), "YyNnMmHh"); |
285 | if (key == tolower(item_str()[j])) | ||
293 | break; | 286 | break; |
294 | } | 287 | } |
295 | } | 288 | } |
@@ -314,7 +307,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, | |||
314 | print_item(scroll+choice, choice, FALSE); | 307 | print_item(scroll+choice, choice, FALSE); |
315 | 308 | ||
316 | if ((choice > max_choice - 3) && | 309 | if ((choice > max_choice - 3) && |
317 | (scroll + max_choice < item_no)) { | 310 | (scroll + max_choice < item_count())) { |
318 | /* Scroll menu up */ | 311 | /* Scroll menu up */ |
319 | do_scroll(menu, &scroll, 1); | 312 | do_scroll(menu, &scroll, 1); |
320 | 313 | ||
@@ -337,7 +330,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, | |||
337 | 330 | ||
338 | } else if (key == KEY_NPAGE) { | 331 | } else if (key == KEY_NPAGE) { |
339 | for (i = 0; (i < max_choice); i++) { | 332 | for (i = 0; (i < max_choice); i++) { |
340 | if (scroll + max_choice < item_no) { | 333 | if (scroll + max_choice < item_count()) { |
341 | do_scroll(menu, &scroll, 1); | 334 | do_scroll(menu, &scroll, 1); |
342 | print_item(scroll+max_choice-1, | 335 | print_item(scroll+max_choice-1, |
343 | max_choice - 1, FALSE); | 336 | max_choice - 1, FALSE); |
@@ -351,7 +344,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, | |||
351 | 344 | ||
352 | print_item(scroll + choice, choice, TRUE); | 345 | print_item(scroll + choice, choice, TRUE); |
353 | 346 | ||
354 | print_arrows(dialog, item_no, scroll, | 347 | print_arrows(dialog, item_count(), scroll, |
355 | box_y, box_x + item_x + 1, menu_height); | 348 | box_y, box_x + item_x + 1, menu_height); |
356 | 349 | ||
357 | wnoutrefresh(dialog); | 350 | wnoutrefresh(dialog); |
@@ -377,12 +370,11 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, | |||
377 | case 'm': | 370 | case 'm': |
378 | case '/': | 371 | case '/': |
379 | /* save scroll info */ | 372 | /* save scroll info */ |
380 | if ((f = fopen("lxdialog.scrltmp", "w")) != NULL) { | 373 | *s_scroll = scroll; |
381 | fprintf(f, "%d\n", scroll); | 374 | delwin(menu); |
382 | fclose(f); | ||
383 | } | ||
384 | delwin(dialog); | 375 | delwin(dialog); |
385 | fprintf(stderr, "%s\n", items[(scroll + choice) * 2]); | 376 | item_set(scroll + choice); |
377 | item_set_selected(1); | ||
386 | switch (key) { | 378 | switch (key) { |
387 | case 's': | 379 | case 's': |
388 | return 3; | 380 | return 3; |
@@ -402,17 +394,11 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, | |||
402 | case '?': | 394 | case '?': |
403 | button = 2; | 395 | button = 2; |
404 | case '\n': | 396 | case '\n': |
397 | *s_scroll = scroll; | ||
398 | delwin(menu); | ||
405 | delwin(dialog); | 399 | delwin(dialog); |
406 | if (button == 2) | 400 | item_set(scroll + choice); |
407 | fprintf(stderr, "%s \"%s\"\n", | 401 | item_set_selected(1); |
408 | items[(scroll + choice) * 2], | ||
409 | items[(scroll + choice) * 2 + 1] + | ||
410 | first_alpha(items [(scroll + choice) * 2 + 1], "")); | ||
411 | else | ||
412 | fprintf(stderr, "%s\n", | ||
413 | items[(scroll + choice) * 2]); | ||
414 | |||
415 | remove("lxdialog.scrltmp"); | ||
416 | return button; | 402 | return button; |
417 | case 'e': | 403 | case 'e': |
418 | case 'x': | 404 | case 'x': |
@@ -421,8 +407,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, | |||
421 | break; | 407 | break; |
422 | } | 408 | } |
423 | } | 409 | } |
424 | 410 | delwin(menu); | |
425 | delwin(dialog); | 411 | delwin(dialog); |
426 | remove("lxdialog.scrltmp"); | 412 | return 255; /* ESC pressed */ |
427 | return -1; /* ESC pressed */ | ||
428 | } | 413 | } |
diff --git a/scripts/kconfig/lxdialog/msgbox.c b/scripts/kconfig/lxdialog/msgbox.c deleted file mode 100644 index 236759ff3f4e..000000000000 --- a/scripts/kconfig/lxdialog/msgbox.c +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | /* | ||
2 | * msgbox.c -- implements the message box and info box | ||
3 | * | ||
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) | ||
6 | * | ||
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. | ||
11 | * | ||
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. | ||
16 | * | ||
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. | ||
20 | */ | ||
21 | |||
22 | #include "dialog.h" | ||
23 | |||
24 | /* | ||
25 | * Display a message box. Program will pause and display an "OK" button | ||
26 | * if the parameter 'pause' is non-zero. | ||
27 | */ | ||
28 | int 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 | /* center dialog box on screen */ | ||
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, | ||
44 | dlg.dialog.atr, dlg.border.atr); | ||
45 | |||
46 | print_title(dialog, title, width); | ||
47 | |||
48 | wattrset(dialog, dlg.dialog.atr); | ||
49 | print_autowrap(dialog, prompt, width - 2, 1, 2); | ||
50 | |||
51 | if (pause) { | ||
52 | wattrset(dialog, dlg.border.atr); | ||
53 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); | ||
54 | for (i = 0; i < width - 2; i++) | ||
55 | waddch(dialog, ACS_HLINE); | ||
56 | wattrset(dialog, dlg.dialog.atr); | ||
57 | waddch(dialog, ACS_RTEE); | ||
58 | |||
59 | print_button(dialog, " Ok ", height - 2, width / 2 - 4, TRUE); | ||
60 | |||
61 | wrefresh(dialog); | ||
62 | while (key != ESC && key != '\n' && key != ' ' && | ||
63 | key != 'O' && key != 'o' && key != 'X' && key != 'x') | ||
64 | key = wgetch(dialog); | ||
65 | } else { | ||
66 | key = '\n'; | ||
67 | wrefresh(dialog); | ||
68 | } | ||
69 | |||
70 | delwin(dialog); | ||
71 | return key == ESC ? -1 : 0; | ||
72 | } | ||
diff --git a/scripts/kconfig/lxdialog/textbox.c b/scripts/kconfig/lxdialog/textbox.c index 336793b03954..86b0770b0387 100644 --- a/scripts/kconfig/lxdialog/textbox.c +++ b/scripts/kconfig/lxdialog/textbox.c | |||
@@ -27,54 +27,27 @@ static void print_line(WINDOW * win, int row, int width); | |||
27 | static char *get_line(void); | 27 | static char *get_line(void); |
28 | static void print_position(WINDOW * win, int height, int width); | 28 | static void print_position(WINDOW * win, int height, int width); |
29 | 29 | ||
30 | static int hscroll, fd, file_size, bytes_read; | 30 | static int hscroll; |
31 | static int begin_reached = 1, end_reached, page_length; | 31 | static int begin_reached, end_reached, page_length; |
32 | static char *buf, *page; | 32 | static const char *buf; |
33 | static const char *page; | ||
33 | 34 | ||
34 | /* | 35 | /* |
35 | * Display text from a file in a dialog box. | 36 | * Display text from a file in a dialog box. |
36 | */ | 37 | */ |
37 | int dialog_textbox(const char *title, const char *file, int height, int width) | 38 | int dialog_textbox(const char *title, const char *tbuf, int height, int width) |
38 | { | 39 | { |
39 | int i, x, y, cur_x, cur_y, fpos, key = 0; | 40 | int i, x, y, cur_x, cur_y, key = 0; |
41 | int texth, textw; | ||
40 | int passed_end; | 42 | int passed_end; |
41 | char search_term[MAX_LEN + 1]; | ||
42 | WINDOW *dialog, *text; | 43 | WINDOW *dialog, *text; |
43 | 44 | ||
44 | search_term[0] = '\0'; /* no search term entered yet */ | 45 | begin_reached = 1; |
45 | 46 | end_reached = 0; | |
46 | /* Open input file for reading */ | 47 | page_length = 0; |
47 | if ((fd = open(file, O_RDONLY)) == -1) { | 48 | hscroll = 0; |
48 | endwin(); | 49 | buf = tbuf; |
49 | fprintf(stderr, "\nCan't open input file in dialog_textbox().\n"); | 50 | page = buf; /* page is pointer to start of page to be displayed */ |
50 | exit(-1); | ||
51 | } | ||
52 | /* Get file size. Actually, 'file_size' is the real file size - 1, | ||
53 | since it's only the last byte offset from the beginning */ | ||
54 | if ((file_size = lseek(fd, 0, SEEK_END)) == -1) { | ||
55 | endwin(); | ||
56 | fprintf(stderr, "\nError getting file size in dialog_textbox().\n"); | ||
57 | exit(-1); | ||
58 | } | ||
59 | /* Restore file pointer to beginning of file after getting file size */ | ||
60 | if (lseek(fd, 0, SEEK_SET) == -1) { | ||
61 | endwin(); | ||
62 | fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); | ||
63 | exit(-1); | ||
64 | } | ||
65 | /* Allocate space for read buffer */ | ||
66 | if ((buf = malloc(BUF_SIZE + 1)) == NULL) { | ||
67 | endwin(); | ||
68 | fprintf(stderr, "\nCan't allocate memory in dialog_textbox().\n"); | ||
69 | exit(-1); | ||
70 | } | ||
71 | if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) { | ||
72 | endwin(); | ||
73 | fprintf(stderr, "\nError reading file in dialog_textbox().\n"); | ||
74 | exit(-1); | ||
75 | } | ||
76 | buf[bytes_read] = '\0'; /* mark end of valid data */ | ||
77 | page = buf; /* page is pointer to start of page to be displayed */ | ||
78 | 51 | ||
79 | /* center dialog box on screen */ | 52 | /* center dialog box on screen */ |
80 | x = (COLS - width) / 2; | 53 | x = (COLS - width) / 2; |
@@ -86,7 +59,9 @@ int dialog_textbox(const char *title, const char *file, int height, int width) | |||
86 | keypad(dialog, TRUE); | 59 | keypad(dialog, TRUE); |
87 | 60 | ||
88 | /* Create window for text region, used for scrolling text */ | 61 | /* Create window for text region, used for scrolling text */ |
89 | text = subwin(dialog, height - 4, width - 2, y + 1, x + 1); | 62 | texth = height - 4; |
63 | textw = width - 2; | ||
64 | text = subwin(dialog, texth, textw, y + 1, x + 1); | ||
90 | wattrset(text, dlg.dialog.atr); | 65 | wattrset(text, dlg.dialog.atr); |
91 | wbkgdset(text, dlg.dialog.atr & A_COLOR); | 66 | wbkgdset(text, dlg.dialog.atr & A_COLOR); |
92 | 67 | ||
@@ -111,8 +86,8 @@ int dialog_textbox(const char *title, const char *file, int height, int width) | |||
111 | getyx(dialog, cur_y, cur_x); /* Save cursor position */ | 86 | getyx(dialog, cur_y, cur_x); /* Save cursor position */ |
112 | 87 | ||
113 | /* Print first page of text */ | 88 | /* Print first page of text */ |
114 | attr_clear(text, height - 4, width - 2, dlg.dialog.atr); | 89 | attr_clear(text, texth, textw, dlg.dialog.atr); |
115 | print_page(text, height - 4, width - 2); | 90 | print_page(text, texth, textw); |
116 | print_position(dialog, height, width); | 91 | print_position(dialog, height, width); |
117 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ | 92 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ |
118 | wrefresh(dialog); | 93 | wrefresh(dialog); |
@@ -124,37 +99,15 @@ int dialog_textbox(const char *title, const char *file, int height, int width) | |||
124 | case 'e': | 99 | case 'e': |
125 | case 'X': | 100 | case 'X': |
126 | case 'x': | 101 | case 'x': |
102 | delwin(text); | ||
127 | delwin(dialog); | 103 | delwin(dialog); |
128 | free(buf); | ||
129 | close(fd); | ||
130 | return 0; | 104 | return 0; |
131 | case 'g': /* First page */ | 105 | case 'g': /* First page */ |
132 | case KEY_HOME: | 106 | case KEY_HOME: |
133 | if (!begin_reached) { | 107 | if (!begin_reached) { |
134 | begin_reached = 1; | 108 | begin_reached = 1; |
135 | /* First page not in buffer? */ | ||
136 | if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { | ||
137 | endwin(); | ||
138 | fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); | ||
139 | exit(-1); | ||
140 | } | ||
141 | if (fpos > bytes_read) { /* Yes, we have to read it in */ | ||
142 | if (lseek(fd, 0, SEEK_SET) == -1) { | ||
143 | endwin(); | ||
144 | fprintf(stderr, "\nError moving file pointer in " | ||
145 | "dialog_textbox().\n"); | ||
146 | exit(-1); | ||
147 | } | ||
148 | if ((bytes_read = | ||
149 | read(fd, buf, BUF_SIZE)) == -1) { | ||
150 | endwin(); | ||
151 | fprintf(stderr, "\nError reading file in dialog_textbox().\n"); | ||
152 | exit(-1); | ||
153 | } | ||
154 | buf[bytes_read] = '\0'; | ||
155 | } | ||
156 | page = buf; | 109 | page = buf; |
157 | print_page(text, height - 4, width - 2); | 110 | print_page(text, texth, textw); |
158 | print_position(dialog, height, width); | 111 | print_position(dialog, height, width); |
159 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ | 112 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ |
160 | wrefresh(dialog); | 113 | wrefresh(dialog); |
@@ -164,29 +117,10 @@ int dialog_textbox(const char *title, const char *file, int height, int width) | |||
164 | case KEY_END: | 117 | case KEY_END: |
165 | 118 | ||
166 | end_reached = 1; | 119 | end_reached = 1; |
167 | /* Last page not in buffer? */ | 120 | /* point to last char in buf */ |
168 | if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { | 121 | page = buf + strlen(buf); |
169 | endwin(); | 122 | back_lines(texth); |
170 | fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); | 123 | print_page(text, texth, textw); |
171 | exit(-1); | ||
172 | } | ||
173 | if (fpos < file_size) { /* Yes, we have to read it in */ | ||
174 | if (lseek(fd, -BUF_SIZE, SEEK_END) == -1) { | ||
175 | endwin(); | ||
176 | fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); | ||
177 | exit(-1); | ||
178 | } | ||
179 | if ((bytes_read = | ||
180 | read(fd, buf, BUF_SIZE)) == -1) { | ||
181 | endwin(); | ||
182 | fprintf(stderr, "\nError reading file in dialog_textbox().\n"); | ||
183 | exit(-1); | ||
184 | } | ||
185 | buf[bytes_read] = '\0'; | ||
186 | } | ||
187 | page = buf + bytes_read; | ||
188 | back_lines(height - 4); | ||
189 | print_page(text, height - 4, width - 2); | ||
190 | print_position(dialog, height, width); | 124 | print_position(dialog, height, width); |
191 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ | 125 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ |
192 | wrefresh(dialog); | 126 | wrefresh(dialog); |
@@ -197,20 +131,22 @@ int dialog_textbox(const char *title, const char *file, int height, int width) | |||
197 | if (!begin_reached) { | 131 | if (!begin_reached) { |
198 | back_lines(page_length + 1); | 132 | back_lines(page_length + 1); |
199 | 133 | ||
200 | /* We don't call print_page() here but use scrolling to ensure | 134 | /* We don't call print_page() here but use |
201 | faster screen update. However, 'end_reached' and | 135 | * scrolling to ensure faster screen update. |
202 | 'page_length' should still be updated, and 'page' should | 136 | * However, 'end_reached' and 'page_length' |
203 | point to start of next page. This is done by calling | 137 | * should still be updated, and 'page' should |
204 | get_line() in the following 'for' loop. */ | 138 | * point to start of next page. This is done |
139 | * by calling get_line() in the following | ||
140 | * 'for' loop. */ | ||
205 | scrollok(text, TRUE); | 141 | scrollok(text, TRUE); |
206 | wscrl(text, -1); /* Scroll text region down one line */ | 142 | wscrl(text, -1); /* Scroll text region down one line */ |
207 | scrollok(text, FALSE); | 143 | scrollok(text, FALSE); |
208 | page_length = 0; | 144 | page_length = 0; |
209 | passed_end = 0; | 145 | passed_end = 0; |
210 | for (i = 0; i < height - 4; i++) { | 146 | for (i = 0; i < texth; i++) { |
211 | if (!i) { | 147 | if (!i) { |
212 | /* print first line of page */ | 148 | /* print first line of page */ |
213 | print_line(text, 0, width - 2); | 149 | print_line(text, 0, textw); |
214 | wnoutrefresh(text); | 150 | wnoutrefresh(text); |
215 | } else | 151 | } else |
216 | /* Called to update 'end_reached' and 'page' */ | 152 | /* Called to update 'end_reached' and 'page' */ |
@@ -231,8 +167,8 @@ int dialog_textbox(const char *title, const char *file, int height, int width) | |||
231 | case KEY_PPAGE: | 167 | case KEY_PPAGE: |
232 | if (begin_reached) | 168 | if (begin_reached) |
233 | break; | 169 | break; |
234 | back_lines(page_length + height - 4); | 170 | back_lines(page_length + texth); |
235 | print_page(text, height - 4, width - 2); | 171 | print_page(text, texth, textw); |
236 | print_position(dialog, height, width); | 172 | print_position(dialog, height, width); |
237 | wmove(dialog, cur_y, cur_x); | 173 | wmove(dialog, cur_y, cur_x); |
238 | wrefresh(dialog); | 174 | wrefresh(dialog); |
@@ -245,7 +181,7 @@ int dialog_textbox(const char *title, const char *file, int height, int width) | |||
245 | scrollok(text, TRUE); | 181 | scrollok(text, TRUE); |
246 | scroll(text); /* Scroll text region up one line */ | 182 | scroll(text); /* Scroll text region up one line */ |
247 | scrollok(text, FALSE); | 183 | scrollok(text, FALSE); |
248 | print_line(text, height - 5, width - 2); | 184 | print_line(text, texth - 1, textw); |
249 | wnoutrefresh(text); | 185 | wnoutrefresh(text); |
250 | print_position(dialog, height, width); | 186 | print_position(dialog, height, width); |
251 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ | 187 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ |
@@ -258,7 +194,7 @@ int dialog_textbox(const char *title, const char *file, int height, int width) | |||
258 | break; | 194 | break; |
259 | 195 | ||
260 | begin_reached = 0; | 196 | begin_reached = 0; |
261 | print_page(text, height - 4, width - 2); | 197 | print_page(text, texth, textw); |
262 | print_position(dialog, height, width); | 198 | print_position(dialog, height, width); |
263 | wmove(dialog, cur_y, cur_x); | 199 | wmove(dialog, cur_y, cur_x); |
264 | wrefresh(dialog); | 200 | wrefresh(dialog); |
@@ -276,7 +212,7 @@ int dialog_textbox(const char *title, const char *file, int height, int width) | |||
276 | hscroll--; | 212 | hscroll--; |
277 | /* Reprint current page to scroll horizontally */ | 213 | /* Reprint current page to scroll horizontally */ |
278 | back_lines(page_length); | 214 | back_lines(page_length); |
279 | print_page(text, height - 4, width - 2); | 215 | print_page(text, texth, textw); |
280 | wmove(dialog, cur_y, cur_x); | 216 | wmove(dialog, cur_y, cur_x); |
281 | wrefresh(dialog); | 217 | wrefresh(dialog); |
282 | break; | 218 | break; |
@@ -288,7 +224,7 @@ int dialog_textbox(const char *title, const char *file, int height, int width) | |||
288 | hscroll++; | 224 | hscroll++; |
289 | /* Reprint current page to scroll horizontally */ | 225 | /* Reprint current page to scroll horizontally */ |
290 | back_lines(page_length); | 226 | back_lines(page_length); |
291 | print_page(text, height - 4, width - 2); | 227 | print_page(text, texth, textw); |
292 | wmove(dialog, cur_y, cur_x); | 228 | wmove(dialog, cur_y, cur_x); |
293 | wrefresh(dialog); | 229 | wrefresh(dialog); |
294 | break; | 230 | break; |
@@ -296,123 +232,42 @@ int dialog_textbox(const char *title, const char *file, int height, int width) | |||
296 | break; | 232 | break; |
297 | } | 233 | } |
298 | } | 234 | } |
299 | 235 | delwin(text); | |
300 | delwin(dialog); | 236 | delwin(dialog); |
301 | free(buf); | 237 | return 255; /* ESC pressed */ |
302 | close(fd); | ||
303 | return -1; /* ESC pressed */ | ||
304 | } | 238 | } |
305 | 239 | ||
306 | /* | 240 | /* |
307 | * Go back 'n' lines in text file. Called by dialog_textbox(). | 241 | * Go back 'n' lines in text. Called by dialog_textbox(). |
308 | * 'page' will be updated to point to the desired line in 'buf'. | 242 | * 'page' will be updated to point to the desired line in 'buf'. |
309 | */ | 243 | */ |
310 | static void back_lines(int n) | 244 | static void back_lines(int n) |
311 | { | 245 | { |
312 | int i, fpos; | 246 | int i; |
313 | 247 | ||
314 | begin_reached = 0; | 248 | begin_reached = 0; |
315 | /* We have to distinguish between end_reached and !end_reached | 249 | /* Go back 'n' lines */ |
316 | since at end of file, the line is not ended by a '\n'. | 250 | for (i = 0; i < n; i++) { |
317 | The code inside 'if' basically does a '--page' to move one | 251 | if (*page == '\0') { |
318 | character backward so as to skip '\n' of the previous line */ | 252 | if (end_reached) { |
319 | if (!end_reached) { | 253 | end_reached = 0; |
320 | /* Either beginning of buffer or beginning of file reached? */ | 254 | continue; |
321 | if (page == buf) { | ||
322 | if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { | ||
323 | endwin(); | ||
324 | fprintf(stderr, "\nError moving file pointer in " | ||
325 | "back_lines().\n"); | ||
326 | exit(-1); | ||
327 | } | ||
328 | if (fpos > bytes_read) { /* Not beginning of file yet */ | ||
329 | /* We've reached beginning of buffer, but not beginning of | ||
330 | file yet, so read previous part of file into buffer. | ||
331 | Note that we only move backward for BUF_SIZE/2 bytes, | ||
332 | but not BUF_SIZE bytes to avoid re-reading again in | ||
333 | print_page() later */ | ||
334 | /* Really possible to move backward BUF_SIZE/2 bytes? */ | ||
335 | if (fpos < BUF_SIZE / 2 + bytes_read) { | ||
336 | /* No, move less then */ | ||
337 | if (lseek(fd, 0, SEEK_SET) == -1) { | ||
338 | endwin(); | ||
339 | fprintf(stderr, "\nError moving file pointer in " | ||
340 | "back_lines().\n"); | ||
341 | exit(-1); | ||
342 | } | ||
343 | page = buf + fpos - bytes_read; | ||
344 | } else { /* Move backward BUF_SIZE/2 bytes */ | ||
345 | if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR) == -1) { | ||
346 | endwin(); | ||
347 | fprintf(stderr, "\nError moving file pointer " | ||
348 | "in back_lines().\n"); | ||
349 | exit(-1); | ||
350 | } | ||
351 | page = buf + BUF_SIZE / 2; | ||
352 | } | ||
353 | if ((bytes_read = | ||
354 | read(fd, buf, BUF_SIZE)) == -1) { | ||
355 | endwin(); | ||
356 | fprintf(stderr, "\nError reading file in back_lines().\n"); | ||
357 | exit(-1); | ||
358 | } | ||
359 | buf[bytes_read] = '\0'; | ||
360 | } else { /* Beginning of file reached */ | ||
361 | begin_reached = 1; | ||
362 | return; | ||
363 | } | 255 | } |
364 | } | 256 | } |
365 | if (*(--page) != '\n') { /* '--page' here */ | 257 | if (page == buf) { |
366 | /* Something's wrong... */ | 258 | begin_reached = 1; |
367 | endwin(); | 259 | return; |
368 | fprintf(stderr, "\nInternal error in back_lines().\n"); | ||
369 | exit(-1); | ||
370 | } | 260 | } |
371 | } | 261 | page--; |
372 | /* Go back 'n' lines */ | ||
373 | for (i = 0; i < n; i++) | ||
374 | do { | 262 | do { |
375 | if (page == buf) { | 263 | if (page == buf) { |
376 | if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { | 264 | begin_reached = 1; |
377 | endwin(); | 265 | return; |
378 | fprintf(stderr, "\nError moving file pointer in back_lines().\n"); | ||
379 | exit(-1); | ||
380 | } | ||
381 | if (fpos > bytes_read) { | ||
382 | /* Really possible to move backward BUF_SIZE/2 bytes? */ | ||
383 | if (fpos < BUF_SIZE / 2 + bytes_read) { | ||
384 | /* No, move less then */ | ||
385 | if (lseek(fd, 0, SEEK_SET) == -1) { | ||
386 | endwin(); | ||
387 | fprintf(stderr, "\nError moving file pointer " | ||
388 | "in back_lines().\n"); | ||
389 | exit(-1); | ||
390 | } | ||
391 | page = buf + fpos - bytes_read; | ||
392 | } else { /* Move backward BUF_SIZE/2 bytes */ | ||
393 | if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR) == -1) { | ||
394 | endwin(); | ||
395 | fprintf(stderr, "\nError moving file pointer" | ||
396 | " in back_lines().\n"); | ||
397 | exit(-1); | ||
398 | } | ||
399 | page = buf + BUF_SIZE / 2; | ||
400 | } | ||
401 | if ((bytes_read = | ||
402 | read(fd, buf, BUF_SIZE)) == -1) { | ||
403 | endwin(); | ||
404 | fprintf(stderr, "\nError reading file in " | ||
405 | "back_lines().\n"); | ||
406 | exit(-1); | ||
407 | } | ||
408 | buf[bytes_read] = '\0'; | ||
409 | } else { /* Beginning of file reached */ | ||
410 | begin_reached = 1; | ||
411 | return; | ||
412 | } | ||
413 | } | 266 | } |
414 | } while (*(--page) != '\n'); | 267 | page--; |
415 | page++; | 268 | } while (*page != '\n'); |
269 | page++; | ||
270 | } | ||
416 | } | 271 | } |
417 | 272 | ||
418 | /* | 273 | /* |
@@ -467,33 +322,14 @@ static void print_line(WINDOW * win, int row, int width) | |||
467 | */ | 322 | */ |
468 | static char *get_line(void) | 323 | static char *get_line(void) |
469 | { | 324 | { |
470 | int i = 0, fpos; | 325 | int i = 0; |
471 | static char line[MAX_LEN + 1]; | 326 | static char line[MAX_LEN + 1]; |
472 | 327 | ||
473 | end_reached = 0; | 328 | end_reached = 0; |
474 | while (*page != '\n') { | 329 | while (*page != '\n') { |
475 | if (*page == '\0') { | 330 | if (*page == '\0') { |
476 | /* Either end of file or end of buffer reached */ | 331 | if (!end_reached) { |
477 | if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { | 332 | end_reached = 1; |
478 | endwin(); | ||
479 | fprintf(stderr, "\nError moving file pointer in " | ||
480 | "get_line().\n"); | ||
481 | exit(-1); | ||
482 | } | ||
483 | if (fpos < file_size) { /* Not end of file yet */ | ||
484 | /* We've reached end of buffer, but not end of file yet, | ||
485 | so read next part of file into buffer */ | ||
486 | if ((bytes_read = | ||
487 | read(fd, buf, BUF_SIZE)) == -1) { | ||
488 | endwin(); | ||
489 | fprintf(stderr, "\nError reading file in get_line().\n"); | ||
490 | exit(-1); | ||
491 | } | ||
492 | buf[bytes_read] = '\0'; | ||
493 | page = buf; | ||
494 | } else { | ||
495 | if (!end_reached) | ||
496 | end_reached = 1; | ||
497 | break; | 333 | break; |
498 | } | 334 | } |
499 | } else if (i < MAX_LEN) | 335 | } else if (i < MAX_LEN) |
@@ -518,17 +354,11 @@ static char *get_line(void) | |||
518 | */ | 354 | */ |
519 | static void print_position(WINDOW * win, int height, int width) | 355 | static void print_position(WINDOW * win, int height, int width) |
520 | { | 356 | { |
521 | int fpos, percent; | 357 | int percent; |
522 | 358 | ||
523 | if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { | ||
524 | endwin(); | ||
525 | fprintf(stderr, "\nError moving file pointer in print_position().\n"); | ||
526 | exit(-1); | ||
527 | } | ||
528 | wattrset(win, dlg.position_indicator.atr); | 359 | wattrset(win, dlg.position_indicator.atr); |
529 | wbkgdset(win, dlg.position_indicator.atr & A_COLOR); | 360 | wbkgdset(win, dlg.position_indicator.atr & A_COLOR); |
530 | percent = !file_size ? | 361 | percent = (page - buf) * 100 / strlen(buf); |
531 | 100 : ((fpos - bytes_read + page - buf) * 100) / file_size; | ||
532 | wmove(win, height - 3, width - 9); | 362 | wmove(win, height - 3, width - 9); |
533 | wprintw(win, "(%3d%%)", percent); | 363 | wprintw(win, "(%3d%%)", percent); |
534 | } | 364 | } |
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c index e73a36df93b4..0b3118df50df 100644 --- a/scripts/kconfig/lxdialog/util.c +++ b/scripts/kconfig/lxdialog/util.c | |||
@@ -268,13 +268,18 @@ void dialog_clear(void) | |||
268 | /* | 268 | /* |
269 | * Do some initialization for dialog | 269 | * Do some initialization for dialog |
270 | */ | 270 | */ |
271 | void init_dialog(void) | 271 | void init_dialog(const char *backtitle) |
272 | { | ||
273 | dlg.backtitle = backtitle; | ||
274 | color_setup(getenv("MENUCONFIG_COLOR")); | ||
275 | } | ||
276 | |||
277 | void reset_dialog(void) | ||
272 | { | 278 | { |
273 | initscr(); /* Init curses */ | 279 | initscr(); /* Init curses */ |
274 | keypad(stdscr, TRUE); | 280 | keypad(stdscr, TRUE); |
275 | cbreak(); | 281 | cbreak(); |
276 | noecho(); | 282 | noecho(); |
277 | color_setup(getenv("MENUCONFIG_COLOR")); | ||
278 | dialog_clear(); | 283 | dialog_clear(); |
279 | } | 284 | } |
280 | 285 | ||
@@ -471,3 +476,128 @@ int first_alpha(const char *string, const char *exempt) | |||
471 | 476 | ||
472 | return 0; | 477 | return 0; |
473 | } | 478 | } |
479 | |||
480 | struct dialog_list *item_cur; | ||
481 | struct dialog_list item_nil; | ||
482 | struct dialog_list *item_head; | ||
483 | |||
484 | void item_reset(void) | ||
485 | { | ||
486 | struct dialog_list *p, *next; | ||
487 | |||
488 | for (p = item_head; p; p = next) { | ||
489 | next = p->next; | ||
490 | free(p); | ||
491 | } | ||
492 | item_head = NULL; | ||
493 | item_cur = &item_nil; | ||
494 | } | ||
495 | |||
496 | void item_make(const char *fmt, ...) | ||
497 | { | ||
498 | va_list ap; | ||
499 | struct dialog_list *p = malloc(sizeof(*p)); | ||
500 | |||
501 | if (item_head) | ||
502 | item_cur->next = p; | ||
503 | else | ||
504 | item_head = p; | ||
505 | item_cur = p; | ||
506 | memset(p, 0, sizeof(*p)); | ||
507 | |||
508 | va_start(ap, fmt); | ||
509 | vsnprintf(item_cur->node.str, sizeof(item_cur->node.str), fmt, ap); | ||
510 | va_end(ap); | ||
511 | } | ||
512 | |||
513 | void item_add_str(const char *fmt, ...) | ||
514 | { | ||
515 | va_list ap; | ||
516 | size_t avail; | ||
517 | |||
518 | avail = sizeof(item_cur->node.str) - strlen(item_cur->node.str); | ||
519 | |||
520 | va_start(ap, fmt); | ||
521 | vsnprintf(item_cur->node.str + strlen(item_cur->node.str), | ||
522 | avail, fmt, ap); | ||
523 | item_cur->node.str[sizeof(item_cur->node.str) - 1] = '\0'; | ||
524 | va_end(ap); | ||
525 | } | ||
526 | |||
527 | void item_set_tag(char tag) | ||
528 | { | ||
529 | item_cur->node.tag = tag; | ||
530 | } | ||
531 | void item_set_data(void *ptr) | ||
532 | { | ||
533 | item_cur->node.data = ptr; | ||
534 | } | ||
535 | |||
536 | void item_set_selected(int val) | ||
537 | { | ||
538 | item_cur->node.selected = val; | ||
539 | } | ||
540 | |||
541 | int item_activate_selected(void) | ||
542 | { | ||
543 | item_foreach() | ||
544 | if (item_is_selected()) | ||
545 | return 1; | ||
546 | return 0; | ||
547 | } | ||
548 | |||
549 | void *item_data(void) | ||
550 | { | ||
551 | return item_cur->node.data; | ||
552 | } | ||
553 | |||
554 | char item_tag(void) | ||
555 | { | ||
556 | return item_cur->node.tag; | ||
557 | } | ||
558 | |||
559 | int item_count(void) | ||
560 | { | ||
561 | int n = 0; | ||
562 | struct dialog_list *p; | ||
563 | |||
564 | for (p = item_head; p; p = p->next) | ||
565 | n++; | ||
566 | return n; | ||
567 | } | ||
568 | |||
569 | void item_set(int n) | ||
570 | { | ||
571 | int i = 0; | ||
572 | item_foreach() | ||
573 | if (i++ == n) | ||
574 | return; | ||
575 | } | ||
576 | |||
577 | int item_n(void) | ||
578 | { | ||
579 | int n = 0; | ||
580 | struct dialog_list *p; | ||
581 | |||
582 | for (p = item_head; p; p = p->next) { | ||
583 | if (p == item_cur) | ||
584 | return n; | ||
585 | n++; | ||
586 | } | ||
587 | return 0; | ||
588 | } | ||
589 | |||
590 | const char *item_str(void) | ||
591 | { | ||
592 | return item_cur->node.str; | ||
593 | } | ||
594 | |||
595 | int item_is_selected(void) | ||
596 | { | ||
597 | return (item_cur->node.selected != 0); | ||
598 | } | ||
599 | |||
600 | int item_is_tag(char tag) | ||
601 | { | ||
602 | return (item_cur->node.tag == tag); | ||
603 | } | ||
diff --git a/scripts/kconfig/lxdialog/yesno.c b/scripts/kconfig/lxdialog/yesno.c index e938037c8020..9fc24492c52f 100644 --- a/scripts/kconfig/lxdialog/yesno.c +++ b/scripts/kconfig/lxdialog/yesno.c | |||
@@ -99,5 +99,5 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width) | |||
99 | } | 99 | } |
100 | 100 | ||
101 | delwin(dialog); | 101 | delwin(dialog); |
102 | return -1; /* ESC pressed */ | 102 | return 255; /* ESC pressed */ |
103 | } | 103 | } |