diff options
author | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2005-04-19 09:55:06 +0000 |
---|---|---|
committer | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2005-04-19 09:55:06 +0000 |
commit | bae38db8e42b2d09b920d9430d18ee41bdcc0b17 (patch) | |
tree | 3e1ebb993c7c1979858d58dfd5a923e60a67ec5d | |
parent | 2bf88a891fb9359951bab83b74296ce036a50ae0 (diff) | |
download | busybox-w32-bae38db8e42b2d09b920d9430d18ee41bdcc0b17.tar.gz busybox-w32-bae38db8e42b2d09b920d9430d18ee41bdcc0b17.tar.bz2 busybox-w32-bae38db8e42b2d09b920d9430d18ee41bdcc0b17.zip |
Updated to match trunk/uClibc/extra/config as of r10132, and thus
Linux 2.6.11.
23 files changed, 887 insertions, 472 deletions
diff --git a/scripts/config/Makefile b/scripts/config/Makefile index c0b5b9d35..3c4669f8c 100644 --- a/scripts/config/Makefile +++ b/scripts/config/Makefile | |||
@@ -9,7 +9,11 @@ include $(top_builddir)/Rules.mak | |||
9 | 9 | ||
10 | all: ncurses conf mconf | 10 | all: ncurses conf mconf |
11 | 11 | ||
12 | ifeq ($(shell uname),SunOS) | ||
13 | LIBS = -lcurses | ||
14 | else | ||
12 | LIBS = -lncurses | 15 | LIBS = -lncurses |
16 | endif | ||
13 | ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h)) | 17 | ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h)) |
14 | HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" | 18 | HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" |
15 | else | 19 | else |
@@ -32,14 +36,17 @@ endif | |||
32 | endif | 36 | endif |
33 | endif | 37 | endif |
34 | 38 | ||
35 | CONF_SRC =conf.c | 39 | CONF_SRC = conf.c |
36 | MCONF_SRC =mconf.c checklist.c menubox.c textbox.c yesno.c inputbox.c util.c msgbox.c | 40 | MCONF_SRC = mconf.c |
37 | SHARED_SRC=zconf.tab.c | 41 | LXD_SRC = lxdialog/checklist.c lxdialog/menubox.c lxdialog/textbox.c \ |
38 | SHARED_DEPS:=$(srcdir)/lkc.h $(srcdir)/lkc_proto.h \ | 42 | lxdialog/yesno.c lxdialog/inputbox.c lxdialog/util.c \ |
39 | lkc_defs.h $(srcdir)/expr.h zconf.tab.h | 43 | lxdialog/msgbox.c |
40 | CONF_OBJS =$(patsubst %.c,%.o, $(CONF_SRC)) | 44 | SHARED_SRC = zconf.tab.c |
41 | MCONF_OBJS=$(patsubst %.c,%.o, $(MCONF_SRC)) | 45 | SHARED_DEPS := $(srcdir)/lkc.h $(srcdir)/lkc_proto.h \ |
42 | SHARED_OBJS=$(patsubst %.c,%.o, $(SHARED_SRC)) | 46 | lkc_defs.h $(srcdir)/expr.h zconf.tab.h |
47 | CONF_OBJS = $(patsubst %.c,%.o, $(CONF_SRC)) | ||
48 | MCONF_OBJS = $(patsubst %.c,%.o, $(MCONF_SRC) $(LXD_SRC)) | ||
49 | SHARED_OBJS = $(patsubst %.c,%.o, $(SHARED_SRC)) | ||
43 | 50 | ||
44 | conf: $(CONF_OBJS) $(SHARED_OBJS) | 51 | conf: $(CONF_OBJS) $(SHARED_OBJS) |
45 | $(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ | 52 | $(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ |
diff --git a/scripts/config/conf.c b/scripts/config/conf.c index 3b0c1c1b5..78c1af596 100644 --- a/scripts/config/conf.c +++ b/scripts/config/conf.c | |||
@@ -31,14 +31,14 @@ char *defconfig_file; | |||
31 | static int indent = 1; | 31 | static int indent = 1; |
32 | static int valid_stdin = 1; | 32 | static int valid_stdin = 1; |
33 | static int conf_cnt; | 33 | static int conf_cnt; |
34 | static char line[128]; | 34 | static signed char line[128]; |
35 | static struct menu *rootEntry; | 35 | static struct menu *rootEntry; |
36 | 36 | ||
37 | static char nohelp_text[] = "Sorry, no help available for this option yet.\n"; | 37 | static char nohelp_text[] = "Sorry, no help available for this option yet.\n"; |
38 | 38 | ||
39 | static void strip(char *str) | 39 | static void strip(signed char *str) |
40 | { | 40 | { |
41 | char *p = str; | 41 | signed char *p = str; |
42 | int l; | 42 | int l; |
43 | 43 | ||
44 | while ((isspace(*p))) | 44 | while ((isspace(*p))) |
diff --git a/scripts/config/confdata.c b/scripts/config/confdata.c index fd3a345e2..7b9000e84 100644 --- a/scripts/config/confdata.c +++ b/scripts/config/confdata.c | |||
@@ -23,10 +23,10 @@ const char *conf_confnames[] = { | |||
23 | NULL, | 23 | NULL, |
24 | }; | 24 | }; |
25 | 25 | ||
26 | static char *conf_expand_value(const char *in) | 26 | static char *conf_expand_value(const signed char *in) |
27 | { | 27 | { |
28 | struct symbol *sym; | 28 | struct symbol *sym; |
29 | const char *src; | 29 | const signed char *src; |
30 | static char res_value[SYMBOL_MAXLENGTH]; | 30 | static char res_value[SYMBOL_MAXLENGTH]; |
31 | char *dst, name[SYMBOL_MAXLENGTH]; | 31 | char *dst, name[SYMBOL_MAXLENGTH]; |
32 | 32 | ||
@@ -287,7 +287,7 @@ int conf_write(const char *name) | |||
287 | } else | 287 | } else |
288 | basename = conf_def_filename; | 288 | basename = conf_def_filename; |
289 | 289 | ||
290 | sprintf(newname, "%s.tmpconfig.%d", dirname, getpid()); | 290 | sprintf(newname, "%s.tmpconfig.%d", dirname, (int)getpid()); |
291 | out = fopen(newname, "w"); | 291 | out = fopen(newname, "w"); |
292 | if (!out) | 292 | if (!out) |
293 | return 1; | 293 | return 1; |
diff --git a/scripts/config/expr.c b/scripts/config/expr.c index 10f45232b..30e4f9d69 100644 --- a/scripts/config/expr.c +++ b/scripts/config/expr.c | |||
@@ -1087,3 +1087,13 @@ void expr_fprint(struct expr *e, FILE *out) | |||
1087 | { | 1087 | { |
1088 | expr_print(e, expr_print_file_helper, out, E_NONE); | 1088 | expr_print(e, expr_print_file_helper, out, E_NONE); |
1089 | } | 1089 | } |
1090 | |||
1091 | static void expr_print_gstr_helper(void *data, const char *str) | ||
1092 | { | ||
1093 | str_append((struct gstr*)data, str); | ||
1094 | } | ||
1095 | |||
1096 | void expr_gstr_print(struct expr *e, struct gstr *gs) | ||
1097 | { | ||
1098 | expr_print(e, expr_print_gstr_helper, gs, E_NONE); | ||
1099 | } | ||
diff --git a/scripts/config/expr.h b/scripts/config/expr.h index cac51f6a8..7d39ff43e 100644 --- a/scripts/config/expr.h +++ b/scripts/config/expr.h | |||
@@ -174,6 +174,8 @@ void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, s | |||
174 | struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); | 174 | struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); |
175 | 175 | ||
176 | void expr_fprint(struct expr *e, FILE *out); | 176 | void expr_fprint(struct expr *e, FILE *out); |
177 | struct gstr; /* forward */ | ||
178 | void expr_gstr_print(struct expr *e, struct gstr *gs); | ||
177 | 179 | ||
178 | static inline int expr_is_yes(struct expr *e) | 180 | static inline int expr_is_yes(struct expr *e) |
179 | { | 181 | { |
diff --git a/scripts/config/lkc.h b/scripts/config/lkc.h index dd040f7a8..b8a67fc9d 100644 --- a/scripts/config/lkc.h +++ b/scripts/config/lkc.h | |||
@@ -56,11 +56,21 @@ void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); | |||
56 | void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); | 56 | void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); |
57 | void menu_finalize(struct menu *parent); | 57 | void menu_finalize(struct menu *parent); |
58 | void menu_set_type(int type); | 58 | void menu_set_type(int type); |
59 | |||
60 | /* util.c */ | ||
59 | struct file *file_lookup(const char *name); | 61 | struct file *file_lookup(const char *name); |
60 | int file_write_dep(const char *name); | 62 | int file_write_dep(const char *name); |
61 | 63 | ||
62 | extern struct menu *current_entry; | 64 | struct gstr { |
63 | extern struct menu *current_menu; | 65 | size_t len; |
66 | char *s; | ||
67 | }; | ||
68 | struct gstr str_new(void); | ||
69 | struct gstr str_assign(const char *s); | ||
70 | void str_free(struct gstr *gs); | ||
71 | void str_append(struct gstr *gs, const char *s); | ||
72 | void str_printf(struct gstr *gs, const char *fmt, ...); | ||
73 | const char *str_get(struct gstr *gs); | ||
64 | 74 | ||
65 | /* symbol.c */ | 75 | /* symbol.c */ |
66 | void sym_init(void); | 76 | void sym_init(void); |
diff --git a/scripts/config/lkc_proto.h b/scripts/config/lkc_proto.h index 97c79178e..6dc6d0c48 100644 --- a/scripts/config/lkc_proto.h +++ b/scripts/config/lkc_proto.h | |||
@@ -18,6 +18,7 @@ P(sym_change_count,int,); | |||
18 | 18 | ||
19 | P(sym_lookup,struct symbol *,(const char *name, int isconst)); | 19 | P(sym_lookup,struct symbol *,(const char *name, int isconst)); |
20 | P(sym_find,struct symbol *,(const char *name)); | 20 | P(sym_find,struct symbol *,(const char *name)); |
21 | P(sym_re_search,struct symbol **,(const char *pattern)); | ||
21 | P(sym_type_name,const char *,(enum symbol_type type)); | 22 | P(sym_type_name,const char *,(enum symbol_type type)); |
22 | P(sym_calc_value,void,(struct symbol *sym)); | 23 | P(sym_calc_value,void,(struct symbol *sym)); |
23 | P(sym_get_type,enum symbol_type,(struct symbol *sym)); | 24 | P(sym_get_type,enum symbol_type,(struct symbol *sym)); |
diff --git a/scripts/config/lxdialog/BIG.FAT.WARNING b/scripts/config/lxdialog/BIG.FAT.WARNING new file mode 100644 index 000000000..a8999d82b --- /dev/null +++ b/scripts/config/lxdialog/BIG.FAT.WARNING | |||
@@ -0,0 +1,4 @@ | |||
1 | This is NOT the official version of dialog. This version has been | ||
2 | significantly modified from the original. It is for use by the Linux | ||
3 | kernel configuration script. Please do not bother Savio Lam with | ||
4 | questions about this program. | ||
diff --git a/scripts/config/checklist.c b/scripts/config/lxdialog/checklist.c index 4dbd16616..71de4a191 100644 --- a/scripts/config/checklist.c +++ b/scripts/config/lxdialog/checklist.c | |||
@@ -120,7 +120,7 @@ int | |||
120 | dialog_checklist (const char *title, const char *prompt, int height, int width, | 120 | dialog_checklist (const char *title, const char *prompt, int height, int width, |
121 | int list_height, int item_no, struct dialog_list_item ** items, | 121 | int list_height, int item_no, struct dialog_list_item ** items, |
122 | int flag) | 122 | int flag) |
123 | 123 | ||
124 | { | 124 | { |
125 | int i, x, y, box_x, box_y; | 125 | int i, x, y, box_x, box_y; |
126 | int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; | 126 | int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; |
@@ -197,7 +197,7 @@ dialog_checklist (const char *title, const char *prompt, int height, int width, | |||
197 | 197 | ||
198 | /* Find length of longest item in order to center checklist */ | 198 | /* Find length of longest item in order to center checklist */ |
199 | check_x = 0; | 199 | check_x = 0; |
200 | for (i = 0; i < item_no; i++) | 200 | for (i = 0; i < item_no; i++) |
201 | check_x = MAX (check_x, + strlen (items[i]->name) + 4); | 201 | check_x = MAX (check_x, + strlen (items[i]->name) + 4); |
202 | 202 | ||
203 | check_x = (list_width - check_x) / 2; | 203 | check_x = (list_width - check_x) / 2; |
@@ -231,7 +231,7 @@ dialog_checklist (const char *title, const char *prompt, int height, int width, | |||
231 | break; | 231 | break; |
232 | 232 | ||
233 | 233 | ||
234 | if ( i < max_choice || key == KEY_UP || key == KEY_DOWN || | 234 | if ( i < max_choice || key == KEY_UP || key == KEY_DOWN || |
235 | key == '+' || key == '-' ) { | 235 | key == '+' || key == '-' ) { |
236 | if (key == KEY_UP || key == '-') { | 236 | if (key == KEY_UP || key == '-') { |
237 | if (!choice) { | 237 | if (!choice) { |
@@ -342,7 +342,7 @@ dialog_checklist (const char *title, const char *prompt, int height, int width, | |||
342 | } | 342 | } |
343 | wnoutrefresh (list); | 343 | wnoutrefresh (list); |
344 | wrefresh (dialog); | 344 | wrefresh (dialog); |
345 | 345 | ||
346 | for (i = 0; i < item_no; i++) { | 346 | for (i = 0; i < item_no; i++) { |
347 | items[i]->selected = status[i]; | 347 | items[i]->selected = status[i]; |
348 | } | 348 | } |
@@ -364,7 +364,7 @@ dialog_checklist (const char *title, const char *prompt, int height, int width, | |||
364 | /* Now, update everything... */ | 364 | /* Now, update everything... */ |
365 | doupdate (); | 365 | doupdate (); |
366 | } | 366 | } |
367 | 367 | ||
368 | 368 | ||
369 | delwin (dialog); | 369 | delwin (dialog); |
370 | free (status); | 370 | free (status); |
diff --git a/scripts/config/colors.h b/scripts/config/lxdialog/colors.h index d34dd37c6..d34dd37c6 100644 --- a/scripts/config/colors.h +++ b/scripts/config/lxdialog/colors.h | |||
diff --git a/scripts/config/dialog.h b/scripts/config/lxdialog/dialog.h index 6486cc8f7..7bab3ad0e 100644 --- a/scripts/config/dialog.h +++ b/scripts/config/lxdialog/dialog.h | |||
@@ -27,6 +27,9 @@ | |||
27 | #include <string.h> | 27 | #include <string.h> |
28 | 28 | ||
29 | #ifdef CURSES_LOC | 29 | #ifdef CURSES_LOC |
30 | #ifdef __sun__ | ||
31 | #define CURS_MACROS | ||
32 | #endif | ||
30 | #include CURSES_LOC | 33 | #include CURSES_LOC |
31 | 34 | ||
32 | /* | 35 | /* |
@@ -86,7 +89,7 @@ | |||
86 | #define ACS_DARROW 'v' | 89 | #define ACS_DARROW 'v' |
87 | #endif | 90 | #endif |
88 | 91 | ||
89 | /* | 92 | /* |
90 | * Attribute names | 93 | * Attribute names |
91 | */ | 94 | */ |
92 | #define screen_attr attributes[0] | 95 | #define screen_attr attributes[0] |
@@ -130,7 +133,7 @@ extern bool use_colors; | |||
130 | extern chtype attributes[]; | 133 | extern chtype attributes[]; |
131 | #endif | 134 | #endif |
132 | 135 | ||
133 | extern char *backtitle; | 136 | extern const char *backtitle; |
134 | 137 | ||
135 | struct dialog_list_item { | 138 | struct dialog_list_item { |
136 | char *name; | 139 | char *name; |
@@ -162,7 +165,7 @@ int dialog_msgbox (const char *title, const char *prompt, int height, | |||
162 | int width, int pause); | 165 | int width, int pause); |
163 | int dialog_textbox (const char *title, const char *file, int height, int width); | 166 | int dialog_textbox (const char *title, const char *file, int height, int width); |
164 | int dialog_menu (const char *title, const char *prompt, int height, int width, | 167 | int dialog_menu (const char *title, const char *prompt, int height, int width, |
165 | int menu_height, const char *choice, int item_no, | 168 | int menu_height, const char *choice, int item_no, |
166 | struct dialog_list_item ** items); | 169 | struct dialog_list_item ** items); |
167 | int dialog_checklist (const char *title, const char *prompt, int height, | 170 | int dialog_checklist (const char *title, const char *prompt, int height, |
168 | int width, int list_height, int item_no, | 171 | int width, int list_height, int item_no, |
diff --git a/scripts/config/inputbox.c b/scripts/config/lxdialog/inputbox.c index fa7bebc69..fa7bebc69 100644 --- a/scripts/config/inputbox.c +++ b/scripts/config/lxdialog/inputbox.c | |||
diff --git a/scripts/config/menubox.c b/scripts/config/lxdialog/menubox.c index 431f09fc9..873dc587b 100644 --- a/scripts/config/menubox.c +++ b/scripts/config/lxdialog/menubox.c | |||
@@ -26,7 +26,7 @@ | |||
26 | * | 26 | * |
27 | * *) A bugfix for the Page-Down problem | 27 | * *) A bugfix for the Page-Down problem |
28 | * | 28 | * |
29 | * *) Formerly when I used Page Down and Page Up, the cursor would be set | 29 | * *) Formerly when I used Page Down and Page Up, the cursor would be set |
30 | * to the first position in the menu box. Now lxdialog is a bit | 30 | * to the first position in the menu box. Now lxdialog is a bit |
31 | * smarter and works more like other menu systems (just have a look at | 31 | * smarter and works more like other menu systems (just have a look at |
32 | * it). | 32 | * it). |
@@ -71,7 +71,7 @@ print_item (WINDOW * win, const char *item, int choice, int selected, int hotkey | |||
71 | 71 | ||
72 | strncpy(menu_item, item, menu_width); | 72 | strncpy(menu_item, item, menu_width); |
73 | menu_item[menu_width] = 0; | 73 | menu_item[menu_width] = 0; |
74 | j = first_alpha(menu_item, "YyNnMm"); | 74 | j = first_alpha(menu_item, "YyNnMmHh"); |
75 | 75 | ||
76 | /* Clear 'residue' of last item */ | 76 | /* Clear 'residue' of last item */ |
77 | wattrset (win, menubox_attr); | 77 | wattrset (win, menubox_attr); |
@@ -225,7 +225,7 @@ dialog_menu (const char *title, const char *prompt, int height, int width, | |||
225 | 225 | ||
226 | /* | 226 | /* |
227 | * Find length of longest item in order to center menu. | 227 | * Find length of longest item in order to center menu. |
228 | * Set 'choice' to default item. | 228 | * Set 'choice' to default item. |
229 | */ | 229 | */ |
230 | item_x = 0; | 230 | item_x = 0; |
231 | for (i = 0; i < item_no; i++) { | 231 | for (i = 0; i < item_no; i++) { |
@@ -278,23 +278,23 @@ dialog_menu (const char *title, const char *prompt, int height, int width, | |||
278 | 278 | ||
279 | if (key < 256 && isalpha(key)) key = tolower(key); | 279 | if (key < 256 && isalpha(key)) key = tolower(key); |
280 | 280 | ||
281 | if (strchr("ynm", key)) | 281 | if (strchr("ynmh", key)) |
282 | i = max_choice; | 282 | i = max_choice; |
283 | else { | 283 | else { |
284 | for (i = choice+1; i < max_choice; i++) { | 284 | for (i = choice+1; i < max_choice; i++) { |
285 | j = first_alpha(items[scroll + i]->name, "YyNnMm>"); | 285 | j = first_alpha(items[scroll + i]->name, "YyNnMmHh"); |
286 | if (key == tolower(items[scroll + i]->name[j])) | 286 | if (key == tolower(items[scroll + i]->name[j])) |
287 | break; | 287 | break; |
288 | } | 288 | } |
289 | if (i == max_choice) | 289 | if (i == max_choice) |
290 | for (i = 0; i < max_choice; i++) { | 290 | for (i = 0; i < max_choice; i++) { |
291 | j = first_alpha(items[scroll + i]->name, "YyNnMm>"); | 291 | j = first_alpha(items[scroll + i]->name, "YyNnMmHh"); |
292 | if (key == tolower(items[scroll + i]->name[j])) | 292 | if (key == tolower(items[scroll + i]->name[j])) |
293 | break; | 293 | break; |
294 | } | 294 | } |
295 | } | 295 | } |
296 | 296 | ||
297 | if (i < max_choice || | 297 | if (i < max_choice || |
298 | key == KEY_UP || key == KEY_DOWN || | 298 | key == KEY_UP || key == KEY_DOWN || |
299 | key == '-' || key == '+' || | 299 | key == '-' || key == '+' || |
300 | key == KEY_PPAGE || key == KEY_NPAGE) { | 300 | key == KEY_PPAGE || key == KEY_NPAGE) { |
@@ -398,6 +398,7 @@ dialog_menu (const char *title, const char *prompt, int height, int width, | |||
398 | case 'y': | 398 | case 'y': |
399 | case 'n': | 399 | case 'n': |
400 | case 'm': | 400 | case 'm': |
401 | case '/': | ||
401 | /* save scroll info */ | 402 | /* save scroll info */ |
402 | if ( (f=fopen("lxdialog.scrltmp","w")) != NULL ) { | 403 | if ( (f=fopen("lxdialog.scrltmp","w")) != NULL ) { |
403 | fprintf(f,"%d\n",scroll); | 404 | fprintf(f,"%d\n",scroll); |
@@ -411,6 +412,7 @@ dialog_menu (const char *title, const char *prompt, int height, int width, | |||
411 | case 'n': return 4; | 412 | case 'n': return 4; |
412 | case 'm': return 5; | 413 | case 'm': return 5; |
413 | case ' ': return 6; | 414 | case ' ': return 6; |
415 | case '/': return 7; | ||
414 | } | 416 | } |
415 | return 0; | 417 | return 0; |
416 | case 'h': | 418 | case 'h': |
diff --git a/scripts/config/msgbox.c b/scripts/config/lxdialog/msgbox.c index 93692e1fb..93692e1fb 100644 --- a/scripts/config/msgbox.c +++ b/scripts/config/lxdialog/msgbox.c | |||
diff --git a/scripts/config/textbox.c b/scripts/config/lxdialog/textbox.c index a5a460b5c..a5a460b5c 100644 --- a/scripts/config/textbox.c +++ b/scripts/config/lxdialog/textbox.c | |||
diff --git a/scripts/config/lxdialog/util.c b/scripts/config/lxdialog/util.c new file mode 100644 index 000000000..6f83951b9 --- /dev/null +++ b/scripts/config/lxdialog/util.c | |||
@@ -0,0 +1,375 @@ | |||
1 | /* | ||
2 | * util.c | ||
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 | |||
25 | /* use colors by default? */ | ||
26 | bool use_colors = 1; | ||
27 | |||
28 | const char *backtitle = NULL; | ||
29 | |||
30 | const char *dialog_result; | ||
31 | |||
32 | /* | ||
33 | * Attribute values, default is for mono display | ||
34 | */ | ||
35 | chtype attributes[] = | ||
36 | { | ||
37 | A_NORMAL, /* screen_attr */ | ||
38 | A_NORMAL, /* shadow_attr */ | ||
39 | A_NORMAL, /* dialog_attr */ | ||
40 | A_BOLD, /* title_attr */ | ||
41 | A_NORMAL, /* border_attr */ | ||
42 | A_REVERSE, /* button_active_attr */ | ||
43 | A_DIM, /* button_inactive_attr */ | ||
44 | A_REVERSE, /* button_key_active_attr */ | ||
45 | A_BOLD, /* button_key_inactive_attr */ | ||
46 | A_REVERSE, /* button_label_active_attr */ | ||
47 | A_NORMAL, /* button_label_inactive_attr */ | ||
48 | A_NORMAL, /* inputbox_attr */ | ||
49 | A_NORMAL, /* inputbox_border_attr */ | ||
50 | A_NORMAL, /* searchbox_attr */ | ||
51 | A_BOLD, /* searchbox_title_attr */ | ||
52 | A_NORMAL, /* searchbox_border_attr */ | ||
53 | A_BOLD, /* position_indicator_attr */ | ||
54 | A_NORMAL, /* menubox_attr */ | ||
55 | A_NORMAL, /* menubox_border_attr */ | ||
56 | A_NORMAL, /* item_attr */ | ||
57 | A_REVERSE, /* item_selected_attr */ | ||
58 | A_BOLD, /* tag_attr */ | ||
59 | A_REVERSE, /* tag_selected_attr */ | ||
60 | A_BOLD, /* tag_key_attr */ | ||
61 | A_REVERSE, /* tag_key_selected_attr */ | ||
62 | A_BOLD, /* check_attr */ | ||
63 | A_REVERSE, /* check_selected_attr */ | ||
64 | A_BOLD, /* uarrow_attr */ | ||
65 | A_BOLD /* darrow_attr */ | ||
66 | }; | ||
67 | |||
68 | |||
69 | #include "colors.h" | ||
70 | |||
71 | /* | ||
72 | * Table of color values | ||
73 | */ | ||
74 | int color_table[][3] = | ||
75 | { | ||
76 | {SCREEN_FG, SCREEN_BG, SCREEN_HL}, | ||
77 | {SHADOW_FG, SHADOW_BG, SHADOW_HL}, | ||
78 | {DIALOG_FG, DIALOG_BG, DIALOG_HL}, | ||
79 | {TITLE_FG, TITLE_BG, TITLE_HL}, | ||
80 | {BORDER_FG, BORDER_BG, BORDER_HL}, | ||
81 | {BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL}, | ||
82 | {BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL}, | ||
83 | {BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL}, | ||
84 | {BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG, BUTTON_KEY_INACTIVE_HL}, | ||
85 | {BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG, BUTTON_LABEL_ACTIVE_HL}, | ||
86 | {BUTTON_LABEL_INACTIVE_FG, BUTTON_LABEL_INACTIVE_BG, | ||
87 | BUTTON_LABEL_INACTIVE_HL}, | ||
88 | {INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL}, | ||
89 | {INPUTBOX_BORDER_FG, INPUTBOX_BORDER_BG, INPUTBOX_BORDER_HL}, | ||
90 | {SEARCHBOX_FG, SEARCHBOX_BG, SEARCHBOX_HL}, | ||
91 | {SEARCHBOX_TITLE_FG, SEARCHBOX_TITLE_BG, SEARCHBOX_TITLE_HL}, | ||
92 | {SEARCHBOX_BORDER_FG, SEARCHBOX_BORDER_BG, SEARCHBOX_BORDER_HL}, | ||
93 | {POSITION_INDICATOR_FG, POSITION_INDICATOR_BG, POSITION_INDICATOR_HL}, | ||
94 | {MENUBOX_FG, MENUBOX_BG, MENUBOX_HL}, | ||
95 | {MENUBOX_BORDER_FG, MENUBOX_BORDER_BG, MENUBOX_BORDER_HL}, | ||
96 | {ITEM_FG, ITEM_BG, ITEM_HL}, | ||
97 | {ITEM_SELECTED_FG, ITEM_SELECTED_BG, ITEM_SELECTED_HL}, | ||
98 | {TAG_FG, TAG_BG, TAG_HL}, | ||
99 | {TAG_SELECTED_FG, TAG_SELECTED_BG, TAG_SELECTED_HL}, | ||
100 | {TAG_KEY_FG, TAG_KEY_BG, TAG_KEY_HL}, | ||
101 | {TAG_KEY_SELECTED_FG, TAG_KEY_SELECTED_BG, TAG_KEY_SELECTED_HL}, | ||
102 | {CHECK_FG, CHECK_BG, CHECK_HL}, | ||
103 | {CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL}, | ||
104 | {UARROW_FG, UARROW_BG, UARROW_HL}, | ||
105 | {DARROW_FG, DARROW_BG, DARROW_HL}, | ||
106 | }; /* color_table */ | ||
107 | |||
108 | /* | ||
109 | * Set window to attribute 'attr' | ||
110 | */ | ||
111 | void | ||
112 | attr_clear (WINDOW * win, int height, int width, chtype attr) | ||
113 | { | ||
114 | int i, j; | ||
115 | |||
116 | wattrset (win, attr); | ||
117 | for (i = 0; i < height; i++) { | ||
118 | wmove (win, i, 0); | ||
119 | for (j = 0; j < width; j++) | ||
120 | waddch (win, ' '); | ||
121 | } | ||
122 | touchwin (win); | ||
123 | } | ||
124 | |||
125 | void dialog_clear (void) | ||
126 | { | ||
127 | attr_clear (stdscr, LINES, COLS, screen_attr); | ||
128 | /* Display background title if it exists ... - SLH */ | ||
129 | if (backtitle != NULL) { | ||
130 | int i; | ||
131 | |||
132 | wattrset (stdscr, screen_attr); | ||
133 | mvwaddstr (stdscr, 0, 1, (char *)backtitle); | ||
134 | wmove (stdscr, 1, 1); | ||
135 | for (i = 1; i < COLS - 1; i++) | ||
136 | waddch (stdscr, ACS_HLINE); | ||
137 | } | ||
138 | wnoutrefresh (stdscr); | ||
139 | } | ||
140 | |||
141 | /* | ||
142 | * Do some initialization for dialog | ||
143 | */ | ||
144 | void | ||
145 | init_dialog (void) | ||
146 | { | ||
147 | initscr (); /* Init curses */ | ||
148 | keypad (stdscr, TRUE); | ||
149 | cbreak (); | ||
150 | noecho (); | ||
151 | |||
152 | |||
153 | if (use_colors) /* Set up colors */ | ||
154 | color_setup (); | ||
155 | |||
156 | |||
157 | dialog_clear (); | ||
158 | } | ||
159 | |||
160 | /* | ||
161 | * Setup for color display | ||
162 | */ | ||
163 | void | ||
164 | color_setup (void) | ||
165 | { | ||
166 | int i; | ||
167 | |||
168 | if (has_colors ()) { /* Terminal supports color? */ | ||
169 | start_color (); | ||
170 | |||
171 | /* Initialize color pairs */ | ||
172 | for (i = 0; i < ATTRIBUTE_COUNT; i++) | ||
173 | init_pair (i + 1, color_table[i][0], color_table[i][1]); | ||
174 | |||
175 | /* Setup color attributes */ | ||
176 | for (i = 0; i < ATTRIBUTE_COUNT; i++) | ||
177 | attributes[i] = C_ATTR (color_table[i][2], i + 1); | ||
178 | } | ||
179 | } | ||
180 | |||
181 | /* | ||
182 | * End using dialog functions. | ||
183 | */ | ||
184 | void | ||
185 | end_dialog (void) | ||
186 | { | ||
187 | endwin (); | ||
188 | } | ||
189 | |||
190 | |||
191 | /* | ||
192 | * Print a string of text in a window, automatically wrap around to the | ||
193 | * next line if the string is too long to fit on one line. Newline | ||
194 | * characters '\n' are replaced by spaces. We start on a new line | ||
195 | * if there is no room for at least 4 nonblanks following a double-space. | ||
196 | */ | ||
197 | void | ||
198 | print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x) | ||
199 | { | ||
200 | int newl, cur_x, cur_y; | ||
201 | int i, prompt_len, room, wlen; | ||
202 | char tempstr[MAX_LEN + 1], *word, *sp, *sp2; | ||
203 | |||
204 | strcpy (tempstr, prompt); | ||
205 | |||
206 | prompt_len = strlen(tempstr); | ||
207 | |||
208 | /* | ||
209 | * Remove newlines | ||
210 | */ | ||
211 | for(i=0; i<prompt_len; i++) { | ||
212 | if(tempstr[i] == '\n') tempstr[i] = ' '; | ||
213 | } | ||
214 | |||
215 | if (prompt_len <= width - x * 2) { /* If prompt is short */ | ||
216 | wmove (win, y, (width - prompt_len) / 2); | ||
217 | waddstr (win, tempstr); | ||
218 | } else { | ||
219 | cur_x = x; | ||
220 | cur_y = y; | ||
221 | newl = 1; | ||
222 | word = tempstr; | ||
223 | while (word && *word) { | ||
224 | sp = index(word, ' '); | ||
225 | if (sp) | ||
226 | *sp++ = 0; | ||
227 | |||
228 | /* Wrap to next line if either the word does not fit, | ||
229 | or it is the first word of a new sentence, and it is | ||
230 | short, and the next word does not fit. */ | ||
231 | room = width - cur_x; | ||
232 | wlen = strlen(word); | ||
233 | if (wlen > room || | ||
234 | (newl && wlen < 4 && sp && wlen+1+strlen(sp) > room | ||
235 | && (!(sp2 = index(sp, ' ')) || wlen+1+(sp2-sp) > room))) { | ||
236 | cur_y++; | ||
237 | cur_x = x; | ||
238 | } | ||
239 | wmove (win, cur_y, cur_x); | ||
240 | waddstr (win, word); | ||
241 | getyx (win, cur_y, cur_x); | ||
242 | cur_x++; | ||
243 | if (sp && *sp == ' ') { | ||
244 | cur_x++; /* double space */ | ||
245 | while (*++sp == ' '); | ||
246 | newl = 1; | ||
247 | } else | ||
248 | newl = 0; | ||
249 | word = sp; | ||
250 | } | ||
251 | } | ||
252 | } | ||
253 | |||
254 | /* | ||
255 | * Print a button | ||
256 | */ | ||
257 | void | ||
258 | print_button (WINDOW * win, const char *label, int y, int x, int selected) | ||
259 | { | ||
260 | int i, temp; | ||
261 | |||
262 | wmove (win, y, x); | ||
263 | wattrset (win, selected ? button_active_attr : button_inactive_attr); | ||
264 | waddstr (win, "<"); | ||
265 | temp = strspn (label, " "); | ||
266 | label += temp; | ||
267 | wattrset (win, selected ? button_label_active_attr | ||
268 | : button_label_inactive_attr); | ||
269 | for (i = 0; i < temp; i++) | ||
270 | waddch (win, ' '); | ||
271 | wattrset (win, selected ? button_key_active_attr | ||
272 | : button_key_inactive_attr); | ||
273 | waddch (win, label[0]); | ||
274 | wattrset (win, selected ? button_label_active_attr | ||
275 | : button_label_inactive_attr); | ||
276 | waddstr (win, (char *)label + 1); | ||
277 | wattrset (win, selected ? button_active_attr : button_inactive_attr); | ||
278 | waddstr (win, ">"); | ||
279 | wmove (win, y, x + temp + 1); | ||
280 | } | ||
281 | |||
282 | /* | ||
283 | * Draw a rectangular box with line drawing characters | ||
284 | */ | ||
285 | void | ||
286 | draw_box (WINDOW * win, int y, int x, int height, int width, | ||
287 | chtype box, chtype border) | ||
288 | { | ||
289 | int i, j; | ||
290 | |||
291 | wattrset (win, 0); | ||
292 | for (i = 0; i < height; i++) { | ||
293 | wmove (win, y + i, x); | ||
294 | for (j = 0; j < width; j++) | ||
295 | if (!i && !j) | ||
296 | waddch (win, border | ACS_ULCORNER); | ||
297 | else if (i == height - 1 && !j) | ||
298 | waddch (win, border | ACS_LLCORNER); | ||
299 | else if (!i && j == width - 1) | ||
300 | waddch (win, box | ACS_URCORNER); | ||
301 | else if (i == height - 1 && j == width - 1) | ||
302 | waddch (win, box | ACS_LRCORNER); | ||
303 | else if (!i) | ||
304 | waddch (win, border | ACS_HLINE); | ||
305 | else if (i == height - 1) | ||
306 | waddch (win, box | ACS_HLINE); | ||
307 | else if (!j) | ||
308 | waddch (win, border | ACS_VLINE); | ||
309 | else if (j == width - 1) | ||
310 | waddch (win, box | ACS_VLINE); | ||
311 | else | ||
312 | waddch (win, box | ' '); | ||
313 | } | ||
314 | } | ||
315 | |||
316 | /* | ||
317 | * Draw shadows along the right and bottom edge to give a more 3D look | ||
318 | * to the boxes | ||
319 | */ | ||
320 | void | ||
321 | draw_shadow (WINDOW * win, int y, int x, int height, int width) | ||
322 | { | ||
323 | int i; | ||
324 | |||
325 | if (has_colors ()) { /* Whether terminal supports color? */ | ||
326 | wattrset (win, shadow_attr); | ||
327 | wmove (win, y + height, x + 2); | ||
328 | for (i = 0; i < width; i++) | ||
329 | waddch (win, winch (win) & A_CHARTEXT); | ||
330 | for (i = y + 1; i < y + height + 1; i++) { | ||
331 | wmove (win, i, x + width); | ||
332 | waddch (win, winch (win) & A_CHARTEXT); | ||
333 | waddch (win, winch (win) & A_CHARTEXT); | ||
334 | } | ||
335 | wnoutrefresh (win); | ||
336 | } | ||
337 | } | ||
338 | |||
339 | /* | ||
340 | * Return the position of the first alphabetic character in a string. | ||
341 | */ | ||
342 | int | ||
343 | first_alpha(const char *string, const char *exempt) | ||
344 | { | ||
345 | int i, in_paren=0, c; | ||
346 | |||
347 | for (i = 0; i < strlen(string); i++) { | ||
348 | c = tolower(string[i]); | ||
349 | |||
350 | if (strchr("<[(", c)) ++in_paren; | ||
351 | if (strchr(">])", c) && in_paren > 0) --in_paren; | ||
352 | |||
353 | if ((! in_paren) && isalpha(c) && | ||
354 | strchr(exempt, c) == 0) | ||
355 | return i; | ||
356 | } | ||
357 | |||
358 | return 0; | ||
359 | } | ||
360 | |||
361 | /* | ||
362 | * Get the first selected item in the dialog_list_item list. | ||
363 | */ | ||
364 | struct dialog_list_item * | ||
365 | first_sel_item(int item_no, struct dialog_list_item ** items) | ||
366 | { | ||
367 | int i; | ||
368 | |||
369 | for (i = 0; i < item_no; i++) { | ||
370 | if (items[i]->selected) | ||
371 | return items[i]; | ||
372 | } | ||
373 | |||
374 | return NULL; | ||
375 | } | ||
diff --git a/scripts/config/yesno.c b/scripts/config/lxdialog/yesno.c index 11fcc25f5..11fcc25f5 100644 --- a/scripts/config/yesno.c +++ b/scripts/config/lxdialog/yesno.c | |||
diff --git a/scripts/config/mconf.c b/scripts/config/mconf.c index 63b4ff72f..5bc2abdd8 100644 --- a/scripts/config/mconf.c +++ b/scripts/config/mconf.c | |||
@@ -23,18 +23,150 @@ | |||
23 | #include <termios.h> | 23 | #include <termios.h> |
24 | #include <unistd.h> | 24 | #include <unistd.h> |
25 | 25 | ||
26 | #include "dialog.h" | 26 | #include "lxdialog/dialog.h" |
27 | 27 | ||
28 | #define LKC_DIRECT_LINK | 28 | #define LKC_DIRECT_LINK |
29 | #include "lkc.h" | 29 | #include "lkc.h" |
30 | 30 | ||
31 | static char menu_backtitle[128]; | 31 | static char menu_backtitle[128]; |
32 | static const char menu_instructions[] = | 32 | static const char mconf_readme[] = |
33 | "Overview\n" | ||
34 | "--------\n" | ||
35 | "Some features may be built directly into BusyBox. Some features\n" | ||
36 | "may be completely removed altogether. There are also certain\n" | ||
37 | "parameters which are not really features, but must be\n" | ||
38 | "entered in as decimal or hexadecimal numbers or possibly text.\n" | ||
39 | "\n" | ||
40 | "Menu items beginning with [*] or [ ] represent features\n" | ||
41 | "configured to be built in or removed respectively.\n" | ||
42 | "\n" | ||
43 | "To change any of these features, highlight it with the cursor\n" | ||
44 | "keys and press <Y> to build it in or <N> to removed it.\n" | ||
45 | "You may also press the <Space Bar> to cycle\n" | ||
46 | "through the available options (ie. Y->N->Y).\n" | ||
47 | "\n" | ||
48 | "Some additional keyboard hints:\n" | ||
49 | "\n" | ||
50 | "Menus\n" | ||
51 | "----------\n" | ||
52 | "o Use the Up/Down arrow keys (cursor keys) to highlight the item\n" | ||
53 | " you wish to change or submenu wish to select and press <Enter>.\n" | ||
54 | " Submenus are designated by \"--->\".\n" | ||
55 | "\n" | ||
56 | " Shortcut: Press the option's highlighted letter (hotkey).\n" | ||
57 | " Pressing a hotkey more than once will sequence\n" | ||
58 | " through all visible items which use that hotkey.\n" | ||
59 | "\n" | ||
60 | " You may also use the <PAGE UP> and <PAGE DOWN> keys to scroll\n" | ||
61 | " unseen options into view.\n" | ||
62 | "\n" | ||
63 | "o To exit a menu use the cursor keys to highlight the <Exit> button\n" | ||
64 | " and press <ENTER>.\n" | ||
65 | "\n" | ||
66 | " Shortcut: Press <ESC><ESC> or <E> or <X> if there is no hotkey\n" | ||
67 | " using those letters. You may press a single <ESC>, but\n" | ||
68 | " there is a delayed response which you may find annoying.\n" | ||
69 | "\n" | ||
70 | " Also, the <TAB> and cursor keys will cycle between <Select>,\n" | ||
71 | " <Exit> and <Help>\n" | ||
72 | "\n" | ||
73 | "o To get help with an item, use the cursor keys to highlight <Help>\n" | ||
74 | " and Press <ENTER>.\n" | ||
75 | "\n" | ||
76 | " Shortcut: Press <H> or <?>.\n" | ||
77 | "\n" | ||
78 | "\n" | ||
79 | "Radiolists (Choice lists)\n" | ||
80 | "-----------\n" | ||
81 | "o Use the cursor keys to select the option you wish to set and press\n" | ||
82 | " <S> or the <SPACE BAR>.\n" | ||
83 | "\n" | ||
84 | " Shortcut: Press the first letter of the option you wish to set then\n" | ||
85 | " press <S> or <SPACE BAR>.\n" | ||
86 | "\n" | ||
87 | "o To see available help for the item, use the cursor keys to highlight\n" | ||
88 | " <Help> and Press <ENTER>.\n" | ||
89 | "\n" | ||
90 | " Shortcut: Press <H> or <?>.\n" | ||
91 | "\n" | ||
92 | " Also, the <TAB> and cursor keys will cycle between <Select> and\n" | ||
93 | " <Help>\n" | ||
94 | "\n" | ||
95 | "\n" | ||
96 | "Data Entry\n" | ||
97 | "-----------\n" | ||
98 | "o Enter the requested information and press <ENTER>\n" | ||
99 | " If you are entering hexadecimal values, it is not necessary to\n" | ||
100 | " add the '0x' prefix to the entry.\n" | ||
101 | "\n" | ||
102 | "o For help, use the <TAB> or cursor keys to highlight the help option\n" | ||
103 | " and press <ENTER>. You can try <TAB><H> as well.\n" | ||
104 | "\n" | ||
105 | "\n" | ||
106 | "Text Box (Help Window)\n" | ||
107 | "--------\n" | ||
108 | "o Use the cursor keys to scroll up/down/left/right. The VI editor\n" | ||
109 | " keys h,j,k,l function here as do <SPACE BAR> and <B> for those\n" | ||
110 | " who are familiar with less and lynx.\n" | ||
111 | "\n" | ||
112 | "o Press <E>, <X>, <Enter> or <Esc><Esc> to exit.\n" | ||
113 | "\n" | ||
114 | "\n" | ||
115 | "Alternate Configuration Files\n" | ||
116 | "-----------------------------\n" | ||
117 | "Menuconfig supports the use of alternate configuration files for\n" | ||
118 | "those who, for various reasons, find it necessary to switch\n" | ||
119 | "between different configurations.\n" | ||
120 | "\n" | ||
121 | "At the end of the main menu you will find two options. One is\n" | ||
122 | "for saving the current configuration to a file of your choosing.\n" | ||
123 | "The other option is for loading a previously saved alternate\n" | ||
124 | "configuration.\n" | ||
125 | "\n" | ||
126 | "Even if you don't use alternate configuration files, but you\n" | ||
127 | "find during a Menuconfig session that you have completely messed\n" | ||
128 | "up your settings, you may use the \"Load Alternate...\" option to\n" | ||
129 | "restore your previously saved settings from \".config\" without\n" | ||
130 | "restarting Menuconfig.\n" | ||
131 | "\n" | ||
132 | "Other information\n" | ||
133 | "-----------------\n" | ||
134 | "If you use Menuconfig in an XTERM window make sure you have your\n" | ||
135 | "$TERM variable set to point to a xterm definition which supports color.\n" | ||
136 | "Otherwise, Menuconfig will look rather bad. Menuconfig will not\n" | ||
137 | "display correctly in a RXVT window because rxvt displays only one\n" | ||
138 | "intensity of color, bright.\n" | ||
139 | "\n" | ||
140 | "Menuconfig will display larger menus on screens or xterms which are\n" | ||
141 | "set to display more than the standard 25 row by 80 column geometry.\n" | ||
142 | "In order for this to work, the \"stty size\" command must be able to\n" | ||
143 | "display the screen's current row and column geometry. I STRONGLY\n" | ||
144 | "RECOMMEND that you make sure you do NOT have the shell variables\n" | ||
145 | "LINES and COLUMNS exported into your environment. Some distributions\n" | ||
146 | "export those variables via /etc/profile. Some ncurses programs can\n" | ||
147 | "become confused when those variables (LINES & COLUMNS) don't reflect\n" | ||
148 | "the true screen size.\n" | ||
149 | "\n" | ||
150 | "Optional personality available\n" | ||
151 | "------------------------------\n" | ||
152 | "If you prefer to have all of the options listed in a single\n" | ||
153 | "menu, rather than the default multimenu hierarchy, run the menuconfig\n" | ||
154 | "with MENUCONFIG_MODE environment variable set to single_menu. Example:\n" | ||
155 | "\n" | ||
156 | "make MENUCONFIG_MODE=single_menu menuconfig\n" | ||
157 | "\n" | ||
158 | "<Enter> will then unroll the appropriate category, or enfold it if it\n" | ||
159 | "is already unrolled.\n" | ||
160 | "\n" | ||
161 | "Note that this mode can eventually be a little more CPU expensive\n" | ||
162 | "(especially with a larger number of unrolled categories) than the\n" | ||
163 | "default mode.\n", | ||
164 | menu_instructions[] = | ||
33 | "Arrow keys navigate the menu. " | 165 | "Arrow keys navigate the menu. " |
34 | "<Enter> selects submenus --->. " | 166 | "<Enter> selects submenus --->. " |
35 | "Highlighted letters are hotkeys. " | 167 | "Highlighted letters are hotkeys. " |
36 | "Pressing <Y> selectes a feature, while <N> will exclude a feature. " | 168 | "Pressing <Y> selectes a feature, while <N> will exclude a feature. " |
37 | "Press <Esc><Esc> to exit, <?> for Help. " | 169 | "Press <Esc><Esc> to exit, <?> for Help, </> for Search. " |
38 | "Legend: [*] feature is selected [ ] feature is excluded", | 170 | "Legend: [*] feature is selected [ ] feature is excluded", |
39 | radiolist_instructions[] = | 171 | radiolist_instructions[] = |
40 | "Use the arrow keys to navigate this window or " | 172 | "Use the arrow keys to navigate this window or " |
@@ -85,23 +217,50 @@ save_config_help[] = | |||
85 | "\n" | 217 | "\n" |
86 | "If you are uncertain what all this means then you should probably\n" | 218 | "If you are uncertain what all this means then you should probably\n" |
87 | "leave this blank.\n", | 219 | "leave this blank.\n", |
88 | top_menu_help[] = | 220 | search_help[] = |
89 | "\n" | 221 | "\n" |
90 | "Use the Up/Down arrow keys (cursor keys) to highlight the item\n" | 222 | "Search for CONFIG_ symbols and display their relations.\n" |
91 | "you wish to change or submenu wish to select and press <Enter>.\n" | 223 | "Example: search for \"^FOO\"\n" |
92 | "Submenus are designated by \"--->\".\n" | 224 | "Result:\n" |
225 | "-----------------------------------------------------------------\n" | ||
226 | "Symbol: FOO [=m]\n" | ||
227 | "Prompt: Foo bus is used to drive the bar HW\n" | ||
228 | "Defined at drivers/pci/Kconfig:47\n" | ||
229 | "Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n" | ||
230 | "Location:\n" | ||
231 | " -> Bus options (PCI, PCMCIA, EISA, MCA, ISA)\n" | ||
232 | " -> PCI support (PCI [=y])\n" | ||
233 | " -> PCI access mode (<choice> [=y])\n" | ||
234 | "Selects: LIBCRC32\n" | ||
235 | "Selected by: BAR\n" | ||
236 | "-----------------------------------------------------------------\n" | ||
237 | "o The line 'Prompt:' shows the text used in the menu structure for\n" | ||
238 | " this CONFIG_ symbol\n" | ||
239 | "o The 'Defined at' line tell at what file / line number the symbol\n" | ||
240 | " is defined\n" | ||
241 | "o The 'Depends on:' line tell what symbols needs to be defined for\n" | ||
242 | " this symbol to be visible in the menu (selectable)\n" | ||
243 | "o The 'Location:' lines tell where in the menu structure this symbol\n" | ||
244 | " is located\n" | ||
245 | " A location followed by a [=y] indicate that this is a selectable\n" | ||
246 | " menu item - and current value is displayed inside brackets.\n" | ||
247 | "o The 'Selects:' line tell what symbol will be automatically\n" | ||
248 | " selected if this symbol is selected (y or m)\n" | ||
249 | "o The 'Selected by' line tell what symbol has selected this symbol\n" | ||
93 | "\n" | 250 | "\n" |
94 | "Shortcut: Press the option's highlighted letter (hotkey).\n" | 251 | "Only relevant lines are shown.\n" |
95 | "\n" | 252 | "\n\n" |
96 | "You may also use the <PAGE UP> and <PAGE DOWN> keys to scroll\n" | 253 | "Search examples:\n" |
97 | "unseen options into view.\n" | 254 | "Examples: USB => find all CONFIG_ symbols containing USB\n" |
98 | ; | 255 | " ^USB => find all CONFIG_ symbols starting with USB\n" |
256 | " USB$ => find all CONFIG_ symbols ending with USB\n" | ||
257 | "\n"; | ||
99 | 258 | ||
100 | static char filename[PATH_MAX+1] = ".config"; | 259 | static char filename[PATH_MAX+1] = ".config"; |
101 | static int indent = 0; | 260 | static int indent; |
102 | static struct termios ios_org; | 261 | static struct termios ios_org; |
103 | static int rows, cols; | 262 | static int rows = 0, cols = 0; |
104 | struct menu *current_menu; | 263 | static struct menu *current_menu; |
105 | static int child_count; | 264 | static int child_count; |
106 | static int single_menu_mode; | 265 | static int single_menu_mode; |
107 | 266 | ||
@@ -116,33 +275,31 @@ static void conf_save(void); | |||
116 | static void show_textbox(const char *title, const char *text, int r, int c); | 275 | static void show_textbox(const char *title, const char *text, int r, int c); |
117 | static void show_helptext(const char *title, const char *text); | 276 | static void show_helptext(const char *title, const char *text); |
118 | static void show_help(struct menu *menu); | 277 | static void show_help(struct menu *menu); |
119 | static void show_readme(void); | 278 | static void show_file(const char *filename, const char *title, int r, int c); |
120 | 279 | ||
121 | static void init_wsize(void) | 280 | static void init_wsize(void) |
122 | { | 281 | { |
123 | struct winsize ws; | 282 | struct winsize ws; |
124 | char *env; | 283 | char *env; |
125 | 284 | ||
126 | if (ioctl(1, TIOCGWINSZ, &ws) == -1) { | 285 | if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &ws)) { |
127 | rows = 24; | ||
128 | cols = 80; | ||
129 | } else { | ||
130 | rows = ws.ws_row; | 286 | rows = ws.ws_row; |
131 | cols = ws.ws_col; | 287 | cols = ws.ws_col; |
132 | if (!rows) { | 288 | } |
133 | env = getenv("LINES"); | 289 | |
134 | if (env) | 290 | if (!rows) { |
135 | rows = atoi(env); | 291 | env = getenv("LINES"); |
136 | if (!rows) | 292 | if (env) |
137 | rows = 24; | 293 | rows = atoi(env); |
138 | } | 294 | if (!rows) |
139 | if (!cols) { | 295 | rows = 24; |
140 | env = getenv("COLUMNS"); | 296 | } |
141 | if (env) | 297 | if (!cols) { |
142 | cols = atoi(env); | 298 | env = getenv("COLUMNS"); |
143 | if (!cols) | 299 | if (env) |
144 | cols = 80; | 300 | cols = atoi(env); |
145 | } | 301 | if (!cols) |
302 | cols = 80; | ||
146 | } | 303 | } |
147 | 304 | ||
148 | if (rows < 19 || cols < 80) { | 305 | if (rows < 19 || cols < 80) { |
@@ -214,6 +371,103 @@ static void cdone(void) | |||
214 | item_no = 0; | 371 | item_no = 0; |
215 | } | 372 | } |
216 | 373 | ||
374 | static void get_prompt_str(struct gstr *r, struct property *prop) | ||
375 | { | ||
376 | int i, j; | ||
377 | struct menu *submenu[8], *menu; | ||
378 | |||
379 | str_printf(r, "Prompt: %s\n", prop->text); | ||
380 | str_printf(r, " Defined at %s:%d\n", prop->menu->file->name, | ||
381 | prop->menu->lineno); | ||
382 | if (!expr_is_yes(prop->visible.expr)) { | ||
383 | str_append(r, " Depends on: "); | ||
384 | expr_gstr_print(prop->visible.expr, r); | ||
385 | str_append(r, "\n"); | ||
386 | } | ||
387 | menu = prop->menu->parent; | ||
388 | for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) | ||
389 | submenu[i++] = menu; | ||
390 | if (i > 0) { | ||
391 | str_printf(r, " Location:\n"); | ||
392 | for (j = 4; --i >= 0; j += 2) { | ||
393 | menu = submenu[i]; | ||
394 | str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu)); | ||
395 | if (menu->sym) { | ||
396 | str_printf(r, " (%s [=%s])", menu->sym->name ? | ||
397 | menu->sym->name : "<choice>", | ||
398 | sym_get_string_value(menu->sym)); | ||
399 | } | ||
400 | str_append(r, "\n"); | ||
401 | } | ||
402 | } | ||
403 | } | ||
404 | |||
405 | static void get_symbol_str(struct gstr *r, struct symbol *sym) | ||
406 | { | ||
407 | bool hit; | ||
408 | struct property *prop; | ||
409 | |||
410 | str_printf(r, "Symbol: %s [=%s]\n", sym->name, | ||
411 | sym_get_string_value(sym)); | ||
412 | for_all_prompts(sym, prop) | ||
413 | get_prompt_str(r, prop); | ||
414 | hit = false; | ||
415 | for_all_properties(sym, prop, P_SELECT) { | ||
416 | if (!hit) { | ||
417 | str_append(r, " Selects: "); | ||
418 | hit = true; | ||
419 | } else | ||
420 | str_printf(r, " && "); | ||
421 | expr_gstr_print(prop->expr, r); | ||
422 | } | ||
423 | if (hit) | ||
424 | str_append(r, "\n"); | ||
425 | if (sym->rev_dep.expr) { | ||
426 | str_append(r, " Selected by: "); | ||
427 | expr_gstr_print(sym->rev_dep.expr, r); | ||
428 | str_append(r, "\n"); | ||
429 | } | ||
430 | str_append(r, "\n\n"); | ||
431 | } | ||
432 | |||
433 | static struct gstr get_relations_str(struct symbol **sym_arr) | ||
434 | { | ||
435 | struct symbol *sym; | ||
436 | struct gstr res = str_new(); | ||
437 | int i; | ||
438 | |||
439 | for (i = 0; sym_arr && (sym = sym_arr[i]); i++) | ||
440 | get_symbol_str(&res, sym); | ||
441 | if (!i) | ||
442 | str_append(&res, "No matches found.\n"); | ||
443 | return res; | ||
444 | } | ||
445 | |||
446 | static void search_conf(void) | ||
447 | { | ||
448 | struct symbol **sym_arr; | ||
449 | struct gstr res; | ||
450 | |||
451 | again: | ||
452 | switch (dialog_inputbox("Search Configuration Parameter", | ||
453 | "Enter Keyword", 10, 75, | ||
454 | NULL)) { | ||
455 | case 0: | ||
456 | break; | ||
457 | case 1: | ||
458 | show_helptext("Search Configuration", search_help); | ||
459 | goto again; | ||
460 | default: | ||
461 | return; | ||
462 | } | ||
463 | |||
464 | sym_arr = sym_re_search(dialog_input_result); | ||
465 | res = get_relations_str(sym_arr); | ||
466 | free(sym_arr); | ||
467 | show_textbox("Search Results", str_get(&res), 0, 0); | ||
468 | str_free(&res); | ||
469 | } | ||
470 | |||
217 | static void build_conf(struct menu *menu) | 471 | static void build_conf(struct menu *menu) |
218 | { | 472 | { |
219 | struct symbol *sym; | 473 | struct symbol *sym; |
@@ -308,6 +562,11 @@ static void build_conf(struct menu *menu) | |||
308 | return; | 562 | return; |
309 | } | 563 | } |
310 | } else { | 564 | } else { |
565 | if (menu == current_menu) { | ||
566 | cprint_tag(":%p", menu); | ||
567 | cprint_name("---%*c%s", indent + 1, ' ', menu_get_prompt(menu)); | ||
568 | goto conf_childs; | ||
569 | } | ||
311 | child_count++; | 570 | child_count++; |
312 | val = sym_get_tristate_value(sym); | 571 | val = sym_get_tristate_value(sym); |
313 | if (sym_is_choice_value(sym) && val == yes) { | 572 | if (sym_is_choice_value(sym) && val == yes) { |
@@ -376,7 +635,7 @@ static void conf(struct menu *menu) | |||
376 | while (1) { | 635 | while (1) { |
377 | indent = 0; | 636 | indent = 0; |
378 | child_count = 0; | 637 | child_count = 0; |
379 | current_menu = menu; | 638 | current_menu = menu; |
380 | cdone(); cinit(); | 639 | cdone(); cinit(); |
381 | build_conf(menu); | 640 | build_conf(menu); |
382 | if (!child_count) | 641 | if (!child_count) |
@@ -441,7 +700,7 @@ static void conf(struct menu *menu) | |||
441 | if (sym) | 700 | if (sym) |
442 | show_help(submenu); | 701 | show_help(submenu); |
443 | else | 702 | else |
444 | show_readme(); | 703 | show_helptext("README", mconf_readme); |
445 | break; | 704 | break; |
446 | case 3: | 705 | case 3: |
447 | if (type == 't') { | 706 | if (type == 't') { |
@@ -465,6 +724,9 @@ static void conf(struct menu *menu) | |||
465 | else if (type == 'm') | 724 | else if (type == 'm') |
466 | conf(submenu); | 725 | conf(submenu); |
467 | break; | 726 | break; |
727 | case 7: | ||
728 | search_conf(); | ||
729 | break; | ||
468 | } | 730 | } |
469 | } | 731 | } |
470 | } | 732 | } |
@@ -476,37 +738,39 @@ static void show_textbox(const char *title, const char *text, int r, int c) | |||
476 | fd = creat(".help.tmp", 0777); | 738 | fd = creat(".help.tmp", 0777); |
477 | write(fd, text, strlen(text)); | 739 | write(fd, text, strlen(text)); |
478 | close(fd); | 740 | close(fd); |
479 | while (dialog_textbox(title, ".help.tmp", r, c) < 0) | 741 | show_file(".help.tmp", title, r, c); |
480 | ; | ||
481 | unlink(".help.tmp"); | 742 | unlink(".help.tmp"); |
482 | } | 743 | } |
483 | 744 | ||
484 | static void show_helptext(const char *title, const char *text) | 745 | static void show_helptext(const char *title, const char *text) |
485 | { | 746 | { |
486 | show_textbox(title, text, rows, cols); | 747 | show_textbox(title, text, 0, 0); |
487 | } | 748 | } |
488 | 749 | ||
489 | static void show_help(struct menu *menu) | 750 | static void show_help(struct menu *menu) |
490 | { | 751 | { |
491 | const char *help; | 752 | struct gstr help = str_new(); |
492 | char *helptext; | ||
493 | struct symbol *sym = menu->sym; | 753 | struct symbol *sym = menu->sym; |
494 | 754 | ||
495 | help = sym->help; | 755 | if (sym->help) |
496 | if (!help) | 756 | { |
497 | help = nohelp_text; | 757 | if (sym->name) { |
498 | if (sym->name) { | 758 | str_printf(&help, "%s:\n\n", sym->name); |
499 | helptext = malloc(strlen(sym->name) + strlen(help) + 16); | 759 | str_append(&help, sym->help); |
500 | sprintf(helptext, "%s:\n\n%s", sym->name, help); | 760 | str_append(&help, "\n"); |
501 | show_helptext(menu_get_prompt(menu), helptext); | 761 | } |
502 | free(helptext); | 762 | } else { |
503 | } else | 763 | str_append(&help, nohelp_text); |
504 | show_helptext(menu_get_prompt(menu), help); | 764 | } |
765 | get_symbol_str(&help, sym); | ||
766 | show_helptext(menu_get_prompt(menu), str_get(&help)); | ||
767 | str_free(&help); | ||
505 | } | 768 | } |
506 | 769 | ||
507 | static void show_readme(void) | 770 | static void show_file(const char *filename, const char *title, int r, int c) |
508 | { | 771 | { |
509 | show_helptext("Help", top_menu_help); | 772 | while (dialog_textbox(title, filename, r ? r : rows, c ? c : cols) < 0) |
773 | ; | ||
510 | } | 774 | } |
511 | 775 | ||
512 | static void conf_choice(struct menu *menu) | 776 | static void conf_choice(struct menu *menu) |
@@ -667,9 +931,9 @@ static void winch_handler(int sig) | |||
667 | 931 | ||
668 | int main(int ac, char **av) | 932 | int main(int ac, char **av) |
669 | { | 933 | { |
670 | int stat; | ||
671 | char *mode; | ||
672 | struct symbol *sym; | 934 | struct symbol *sym; |
935 | char *mode; | ||
936 | int stat; | ||
673 | 937 | ||
674 | conf_parse(av[1]); | 938 | conf_parse(av[1]); |
675 | conf_read(NULL); | 939 | conf_read(NULL); |
@@ -697,7 +961,7 @@ int main(int ac, char **av) | |||
697 | init_dialog(); | 961 | init_dialog(); |
698 | do { | 962 | do { |
699 | stat = dialog_yesno(NULL, | 963 | stat = dialog_yesno(NULL, |
700 | "Do you wish to save your new BusyBox configuration?", 5, 60); | 964 | "Do you wish to save your new BusyBox configuration?", 5, 60); |
701 | } while (stat < 0); | 965 | } while (stat < 0); |
702 | end_dialog(); | 966 | end_dialog(); |
703 | 967 | ||
diff --git a/scripts/config/menu.c b/scripts/config/menu.c index 6425296fc..0c13156f3 100644 --- a/scripts/config/menu.c +++ b/scripts/config/menu.c | |||
@@ -10,7 +10,6 @@ | |||
10 | #include "lkc.h" | 10 | #include "lkc.h" |
11 | 11 | ||
12 | struct menu rootmenu; | 12 | struct menu rootmenu; |
13 | struct menu *current_menu, *current_entry; | ||
14 | static struct menu **last_entry_ptr; | 13 | static struct menu **last_entry_ptr; |
15 | 14 | ||
16 | struct file *file_list; | 15 | struct file *file_list; |
@@ -389,43 +388,3 @@ struct menu *menu_get_parent_menu(struct menu *menu) | |||
389 | return menu; | 388 | return menu; |
390 | } | 389 | } |
391 | 390 | ||
392 | struct file *file_lookup(const char *name) | ||
393 | { | ||
394 | struct file *file; | ||
395 | |||
396 | for (file = file_list; file; file = file->next) { | ||
397 | if (!strcmp(name, file->name)) | ||
398 | return file; | ||
399 | } | ||
400 | |||
401 | file = malloc(sizeof(*file)); | ||
402 | memset(file, 0, sizeof(*file)); | ||
403 | file->name = strdup(name); | ||
404 | file->next = file_list; | ||
405 | file_list = file; | ||
406 | return file; | ||
407 | } | ||
408 | |||
409 | int file_write_dep(const char *name) | ||
410 | { | ||
411 | struct file *file; | ||
412 | FILE *out; | ||
413 | |||
414 | if (!name) | ||
415 | name = ".config.cmd"; | ||
416 | out = fopen(".config.tmp", "w"); | ||
417 | if (!out) | ||
418 | return 1; | ||
419 | fprintf(out, "deps_config := \\\n"); | ||
420 | for (file = file_list; file; file = file->next) { | ||
421 | if (file->next) | ||
422 | fprintf(out, "\t%s \\\n", file->name); | ||
423 | else | ||
424 | fprintf(out, "\t%s\n", file->name); | ||
425 | } | ||
426 | fprintf(out, "\n.config include/config.h: $(deps_config)\n\n$(deps_config):\n"); | ||
427 | fclose(out); | ||
428 | rename(".config.tmp", name); | ||
429 | return 0; | ||
430 | } | ||
431 | |||
diff --git a/scripts/config/symbol.c b/scripts/config/symbol.c index a9fae9c13..ea629728a 100644 --- a/scripts/config/symbol.c +++ b/scripts/config/symbol.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <ctype.h> | 6 | #include <ctype.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <string.h> | 8 | #include <string.h> |
9 | #include <regex.h> | ||
9 | #include <sys/utsname.h> | 10 | #include <sys/utsname.h> |
10 | 11 | ||
11 | #define LKC_DIRECT_LINK | 12 | #define LKC_DIRECT_LINK |
@@ -414,7 +415,7 @@ tristate sym_toggle_tristate_value(struct symbol *sym) | |||
414 | 415 | ||
415 | bool sym_string_valid(struct symbol *sym, const char *str) | 416 | bool sym_string_valid(struct symbol *sym, const char *str) |
416 | { | 417 | { |
417 | char ch; | 418 | signed char ch; |
418 | 419 | ||
419 | switch (sym->type) { | 420 | switch (sym->type) { |
420 | case S_STRING: | 421 | case S_STRING: |
@@ -649,6 +650,43 @@ struct symbol *sym_find(const char *name) | |||
649 | return symbol; | 650 | return symbol; |
650 | } | 651 | } |
651 | 652 | ||
653 | struct symbol **sym_re_search(const char *pattern) | ||
654 | { | ||
655 | struct symbol *sym, **sym_arr = NULL; | ||
656 | int i, cnt, size; | ||
657 | regex_t re; | ||
658 | |||
659 | cnt = size = 0; | ||
660 | /* Skip if empty */ | ||
661 | if (strlen(pattern) == 0) | ||
662 | return NULL; | ||
663 | if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE)) | ||
664 | return NULL; | ||
665 | |||
666 | for_all_symbols(i, sym) { | ||
667 | if (sym->flags & SYMBOL_CONST || !sym->name) | ||
668 | continue; | ||
669 | if (regexec(&re, sym->name, 0, NULL, 0)) | ||
670 | continue; | ||
671 | if (cnt + 1 >= size) { | ||
672 | void *tmp = sym_arr; | ||
673 | size += 16; | ||
674 | sym_arr = realloc(sym_arr, size * sizeof(struct symbol *)); | ||
675 | if (!sym_arr) { | ||
676 | free(tmp); | ||
677 | return NULL; | ||
678 | } | ||
679 | } | ||
680 | sym_arr[cnt++] = sym; | ||
681 | } | ||
682 | if (sym_arr) | ||
683 | sym_arr[cnt] = NULL; | ||
684 | regfree(&re); | ||
685 | |||
686 | return sym_arr; | ||
687 | } | ||
688 | |||
689 | |||
652 | struct symbol *sym_check_deps(struct symbol *sym); | 690 | struct symbol *sym_check_deps(struct symbol *sym); |
653 | 691 | ||
654 | static struct symbol *sym_check_expr_deps(struct expr *e) | 692 | static struct symbol *sym_check_expr_deps(struct expr *e) |
diff --git a/scripts/config/util.c b/scripts/config/util.c index 0a2f82757..a72f5ea66 100644 --- a/scripts/config/util.c +++ b/scripts/config/util.c | |||
@@ -1,375 +1,109 @@ | |||
1 | /* | 1 | /* |
2 | * util.c | 2 | * Copyright (C) 2002-2005 Roman Zippel <zippel@linux-m68k.org> |
3 | * Copyright (C) 2002-2005 Sam Ravnborg <sam@ravnborg.org> | ||
3 | * | 4 | * |
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | 5 | * Released under the terms of the GNU GPL v2.0. |
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 | |||
25 | /* use colors by default? */ | ||
26 | bool use_colors = 1; | ||
27 | |||
28 | char *backtitle = NULL; | ||
29 | |||
30 | const char *dialog_result; | ||
31 | |||
32 | /* | ||
33 | * Attribute values, default is for mono display | ||
34 | */ | ||
35 | chtype attributes[] = | ||
36 | { | ||
37 | A_NORMAL, /* screen_attr */ | ||
38 | A_NORMAL, /* shadow_attr */ | ||
39 | A_NORMAL, /* dialog_attr */ | ||
40 | A_BOLD, /* title_attr */ | ||
41 | A_NORMAL, /* border_attr */ | ||
42 | A_REVERSE, /* button_active_attr */ | ||
43 | A_DIM, /* button_inactive_attr */ | ||
44 | A_REVERSE, /* button_key_active_attr */ | ||
45 | A_BOLD, /* button_key_inactive_attr */ | ||
46 | A_REVERSE, /* button_label_active_attr */ | ||
47 | A_NORMAL, /* button_label_inactive_attr */ | ||
48 | A_NORMAL, /* inputbox_attr */ | ||
49 | A_NORMAL, /* inputbox_border_attr */ | ||
50 | A_NORMAL, /* searchbox_attr */ | ||
51 | A_BOLD, /* searchbox_title_attr */ | ||
52 | A_NORMAL, /* searchbox_border_attr */ | ||
53 | A_BOLD, /* position_indicator_attr */ | ||
54 | A_NORMAL, /* menubox_attr */ | ||
55 | A_NORMAL, /* menubox_border_attr */ | ||
56 | A_NORMAL, /* item_attr */ | ||
57 | A_REVERSE, /* item_selected_attr */ | ||
58 | A_BOLD, /* tag_attr */ | ||
59 | A_REVERSE, /* tag_selected_attr */ | ||
60 | A_BOLD, /* tag_key_attr */ | ||
61 | A_REVERSE, /* tag_key_selected_attr */ | ||
62 | A_BOLD, /* check_attr */ | ||
63 | A_REVERSE, /* check_selected_attr */ | ||
64 | A_BOLD, /* uarrow_attr */ | ||
65 | A_BOLD /* darrow_attr */ | ||
66 | }; | ||
67 | |||
68 | |||
69 | #include "colors.h" | ||
70 | |||
71 | /* | ||
72 | * Table of color values | ||
73 | */ | ||
74 | int color_table[][3] = | ||
75 | { | ||
76 | {SCREEN_FG, SCREEN_BG, SCREEN_HL}, | ||
77 | {SHADOW_FG, SHADOW_BG, SHADOW_HL}, | ||
78 | {DIALOG_FG, DIALOG_BG, DIALOG_HL}, | ||
79 | {TITLE_FG, TITLE_BG, TITLE_HL}, | ||
80 | {BORDER_FG, BORDER_BG, BORDER_HL}, | ||
81 | {BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL}, | ||
82 | {BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL}, | ||
83 | {BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL}, | ||
84 | {BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG, BUTTON_KEY_INACTIVE_HL}, | ||
85 | {BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG, BUTTON_LABEL_ACTIVE_HL}, | ||
86 | {BUTTON_LABEL_INACTIVE_FG, BUTTON_LABEL_INACTIVE_BG, | ||
87 | BUTTON_LABEL_INACTIVE_HL}, | ||
88 | {INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL}, | ||
89 | {INPUTBOX_BORDER_FG, INPUTBOX_BORDER_BG, INPUTBOX_BORDER_HL}, | ||
90 | {SEARCHBOX_FG, SEARCHBOX_BG, SEARCHBOX_HL}, | ||
91 | {SEARCHBOX_TITLE_FG, SEARCHBOX_TITLE_BG, SEARCHBOX_TITLE_HL}, | ||
92 | {SEARCHBOX_BORDER_FG, SEARCHBOX_BORDER_BG, SEARCHBOX_BORDER_HL}, | ||
93 | {POSITION_INDICATOR_FG, POSITION_INDICATOR_BG, POSITION_INDICATOR_HL}, | ||
94 | {MENUBOX_FG, MENUBOX_BG, MENUBOX_HL}, | ||
95 | {MENUBOX_BORDER_FG, MENUBOX_BORDER_BG, MENUBOX_BORDER_HL}, | ||
96 | {ITEM_FG, ITEM_BG, ITEM_HL}, | ||
97 | {ITEM_SELECTED_FG, ITEM_SELECTED_BG, ITEM_SELECTED_HL}, | ||
98 | {TAG_FG, TAG_BG, TAG_HL}, | ||
99 | {TAG_SELECTED_FG, TAG_SELECTED_BG, TAG_SELECTED_HL}, | ||
100 | {TAG_KEY_FG, TAG_KEY_BG, TAG_KEY_HL}, | ||
101 | {TAG_KEY_SELECTED_FG, TAG_KEY_SELECTED_BG, TAG_KEY_SELECTED_HL}, | ||
102 | {CHECK_FG, CHECK_BG, CHECK_HL}, | ||
103 | {CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL}, | ||
104 | {UARROW_FG, UARROW_BG, UARROW_HL}, | ||
105 | {DARROW_FG, DARROW_BG, DARROW_HL}, | ||
106 | }; /* color_table */ | ||
107 | |||
108 | /* | ||
109 | * Set window to attribute 'attr' | ||
110 | */ | 6 | */ |
111 | void | ||
112 | attr_clear (WINDOW * win, int height, int width, chtype attr) | ||
113 | { | ||
114 | int i, j; | ||
115 | |||
116 | wattrset (win, attr); | ||
117 | for (i = 0; i < height; i++) { | ||
118 | wmove (win, i, 0); | ||
119 | for (j = 0; j < width; j++) | ||
120 | waddch (win, ' '); | ||
121 | } | ||
122 | touchwin (win); | ||
123 | } | ||
124 | 7 | ||
125 | void dialog_clear (void) | 8 | #include <string.h> |
126 | { | 9 | #include "lkc.h" |
127 | attr_clear (stdscr, LINES, COLS, screen_attr); | ||
128 | /* Display background title if it exists ... - SLH */ | ||
129 | if (backtitle != NULL) { | ||
130 | int i; | ||
131 | |||
132 | wattrset (stdscr, screen_attr); | ||
133 | mvwaddstr (stdscr, 0, 1, (char *)backtitle); | ||
134 | wmove (stdscr, 1, 1); | ||
135 | for (i = 1; i < COLS - 1; i++) | ||
136 | waddch (stdscr, ACS_HLINE); | ||
137 | } | ||
138 | wnoutrefresh (stdscr); | ||
139 | } | ||
140 | 10 | ||
141 | /* | 11 | /* file already present in list? If not add it */ |
142 | * Do some initialization for dialog | 12 | struct file *file_lookup(const char *name) |
143 | */ | ||
144 | void | ||
145 | init_dialog (void) | ||
146 | { | ||
147 | initscr (); /* Init curses */ | ||
148 | keypad (stdscr, TRUE); | ||
149 | cbreak (); | ||
150 | noecho (); | ||
151 | |||
152 | |||
153 | if (use_colors) /* Set up colors */ | ||
154 | color_setup (); | ||
155 | |||
156 | |||
157 | dialog_clear (); | ||
158 | } | ||
159 | |||
160 | /* | ||
161 | * Setup for color display | ||
162 | */ | ||
163 | void | ||
164 | color_setup (void) | ||
165 | { | 13 | { |
166 | int i; | 14 | struct file *file; |
167 | 15 | ||
168 | if (has_colors ()) { /* Terminal supports color? */ | 16 | for (file = file_list; file; file = file->next) { |
169 | start_color (); | 17 | if (!strcmp(name, file->name)) |
170 | 18 | return file; | |
171 | /* Initialize color pairs */ | 19 | } |
172 | for (i = 0; i < ATTRIBUTE_COUNT; i++) | ||
173 | init_pair (i + 1, color_table[i][0], color_table[i][1]); | ||
174 | 20 | ||
175 | /* Setup color attributes */ | 21 | file = malloc(sizeof(*file)); |
176 | for (i = 0; i < ATTRIBUTE_COUNT; i++) | 22 | memset(file, 0, sizeof(*file)); |
177 | attributes[i] = C_ATTR (color_table[i][2], i + 1); | 23 | file->name = strdup(name); |
178 | } | 24 | file->next = file_list; |
25 | file_list = file; | ||
26 | return file; | ||
179 | } | 27 | } |
180 | 28 | ||
181 | /* | 29 | /* write a dependency file as used by kbuild to track dependencies */ |
182 | * End using dialog functions. | 30 | int file_write_dep(const char *name) |
183 | */ | ||
184 | void | ||
185 | end_dialog (void) | ||
186 | { | 31 | { |
187 | endwin (); | 32 | struct file *file; |
33 | FILE *out; | ||
34 | |||
35 | if (!name) | ||
36 | name = ".config.cmd"; | ||
37 | out = fopen(".config.tmp", "w"); | ||
38 | if (!out) | ||
39 | return 1; | ||
40 | fprintf(out, "deps_config := \\\n"); | ||
41 | for (file = file_list; file; file = file->next) { | ||
42 | if (file->next) | ||
43 | fprintf(out, "\t%s \\\n", file->name); | ||
44 | else | ||
45 | fprintf(out, "\t%s\n", file->name); | ||
46 | } | ||
47 | fprintf(out, "\n.config include/config.h: $(deps_config)\n\n$(deps_config):\n"); | ||
48 | fclose(out); | ||
49 | rename(".config.tmp", name); | ||
50 | return 0; | ||
188 | } | 51 | } |
189 | 52 | ||
190 | 53 | ||
191 | /* | 54 | /* Allocate initial growable sting */ |
192 | * Print a string of text in a window, automatically wrap around to the | 55 | struct gstr str_new(void) |
193 | * next line if the string is too long to fit on one line. Newline | ||
194 | * characters '\n' are replaced by spaces. We start on a new line | ||
195 | * if there is no room for at least 4 nonblanks following a double-space. | ||
196 | */ | ||
197 | void | ||
198 | print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x) | ||
199 | { | 56 | { |
200 | int newl, cur_x, cur_y; | 57 | struct gstr gs; |
201 | int i, prompt_len, room, wlen; | 58 | gs.s = malloc(sizeof(char) * 64); |
202 | char tempstr[MAX_LEN + 1], *word, *sp, *sp2; | 59 | gs.len = 16; |
203 | 60 | strcpy(gs.s, "\0"); | |
204 | strcpy (tempstr, prompt); | 61 | return gs; |
205 | |||
206 | prompt_len = strlen(tempstr); | ||
207 | |||
208 | /* | ||
209 | * Remove newlines | ||
210 | */ | ||
211 | for(i=0; i<prompt_len; i++) { | ||
212 | if(tempstr[i] == '\n') tempstr[i] = ' '; | ||
213 | } | ||
214 | |||
215 | if (prompt_len <= width - x * 2) { /* If prompt is short */ | ||
216 | wmove (win, y, (width - prompt_len) / 2); | ||
217 | waddstr (win, tempstr); | ||
218 | } else { | ||
219 | cur_x = x; | ||
220 | cur_y = y; | ||
221 | newl = 1; | ||
222 | word = tempstr; | ||
223 | while (word && *word) { | ||
224 | sp = index(word, ' '); | ||
225 | if (sp) | ||
226 | *sp++ = 0; | ||
227 | |||
228 | /* Wrap to next line if either the word does not fit, | ||
229 | or it is the first word of a new sentence, and it is | ||
230 | short, and the next word does not fit. */ | ||
231 | room = width - cur_x; | ||
232 | wlen = strlen(word); | ||
233 | if (wlen > room || | ||
234 | (newl && wlen < 4 && sp && wlen+1+strlen(sp) > room | ||
235 | && (!(sp2 = index(sp, ' ')) || wlen+1+(sp2-sp) > room))) { | ||
236 | cur_y++; | ||
237 | cur_x = x; | ||
238 | } | ||
239 | wmove (win, cur_y, cur_x); | ||
240 | waddstr (win, word); | ||
241 | getyx (win, cur_y, cur_x); | ||
242 | cur_x++; | ||
243 | if (sp && *sp == ' ') { | ||
244 | cur_x++; /* double space */ | ||
245 | while (*++sp == ' '); | ||
246 | newl = 1; | ||
247 | } else | ||
248 | newl = 0; | ||
249 | word = sp; | ||
250 | } | ||
251 | } | ||
252 | } | 62 | } |
253 | 63 | ||
254 | /* | 64 | /* Allocate and assign growable string */ |
255 | * Print a button | 65 | struct gstr str_assign(const char *s) |
256 | */ | ||
257 | void | ||
258 | print_button (WINDOW * win, const char *label, int y, int x, int selected) | ||
259 | { | 66 | { |
260 | int i, temp; | 67 | struct gstr gs; |
261 | 68 | gs.s = strdup(s); | |
262 | wmove (win, y, x); | 69 | gs.len = strlen(s) + 1; |
263 | wattrset (win, selected ? button_active_attr : button_inactive_attr); | 70 | return gs; |
264 | waddstr (win, "<"); | ||
265 | temp = strspn (label, " "); | ||
266 | label += temp; | ||
267 | wattrset (win, selected ? button_label_active_attr | ||
268 | : button_label_inactive_attr); | ||
269 | for (i = 0; i < temp; i++) | ||
270 | waddch (win, ' '); | ||
271 | wattrset (win, selected ? button_key_active_attr | ||
272 | : button_key_inactive_attr); | ||
273 | waddch (win, label[0]); | ||
274 | wattrset (win, selected ? button_label_active_attr | ||
275 | : button_label_inactive_attr); | ||
276 | waddstr (win, (char *)label + 1); | ||
277 | wattrset (win, selected ? button_active_attr : button_inactive_attr); | ||
278 | waddstr (win, ">"); | ||
279 | wmove (win, y, x + temp + 1); | ||
280 | } | 71 | } |
281 | 72 | ||
282 | /* | 73 | /* Free storage for growable string */ |
283 | * Draw a rectangular box with line drawing characters | 74 | void str_free(struct gstr *gs) |
284 | */ | ||
285 | void | ||
286 | draw_box (WINDOW * win, int y, int x, int height, int width, | ||
287 | chtype box, chtype border) | ||
288 | { | 75 | { |
289 | int i, j; | 76 | if (gs->s) |
290 | 77 | free(gs->s); | |
291 | wattrset (win, 0); | 78 | gs->s = NULL; |
292 | for (i = 0; i < height; i++) { | 79 | gs->len = 0; |
293 | wmove (win, y + i, x); | ||
294 | for (j = 0; j < width; j++) | ||
295 | if (!i && !j) | ||
296 | waddch (win, border | ACS_ULCORNER); | ||
297 | else if (i == height - 1 && !j) | ||
298 | waddch (win, border | ACS_LLCORNER); | ||
299 | else if (!i && j == width - 1) | ||
300 | waddch (win, box | ACS_URCORNER); | ||
301 | else if (i == height - 1 && j == width - 1) | ||
302 | waddch (win, box | ACS_LRCORNER); | ||
303 | else if (!i) | ||
304 | waddch (win, border | ACS_HLINE); | ||
305 | else if (i == height - 1) | ||
306 | waddch (win, box | ACS_HLINE); | ||
307 | else if (!j) | ||
308 | waddch (win, border | ACS_VLINE); | ||
309 | else if (j == width - 1) | ||
310 | waddch (win, box | ACS_VLINE); | ||
311 | else | ||
312 | waddch (win, box | ' '); | ||
313 | } | ||
314 | } | 80 | } |
315 | 81 | ||
316 | /* | 82 | /* Append to growable string */ |
317 | * Draw shadows along the right and bottom edge to give a more 3D look | 83 | void str_append(struct gstr *gs, const char *s) |
318 | * to the boxes | ||
319 | */ | ||
320 | void | ||
321 | draw_shadow (WINDOW * win, int y, int x, int height, int width) | ||
322 | { | 84 | { |
323 | int i; | 85 | size_t l = strlen(gs->s) + strlen(s) + 1; |
324 | 86 | if (l > gs->len) { | |
325 | if (has_colors ()) { /* Whether terminal supports color? */ | 87 | gs->s = realloc(gs->s, l); |
326 | wattrset (win, shadow_attr); | 88 | gs->len = l; |
327 | wmove (win, y + height, x + 2); | ||
328 | for (i = 0; i < width; i++) | ||
329 | waddch (win, winch (win) & A_CHARTEXT); | ||
330 | for (i = y + 1; i < y + height + 1; i++) { | ||
331 | wmove (win, i, x + width); | ||
332 | waddch (win, winch (win) & A_CHARTEXT); | ||
333 | waddch (win, winch (win) & A_CHARTEXT); | ||
334 | } | 89 | } |
335 | wnoutrefresh (win); | 90 | strcat(gs->s, s); |
336 | } | ||
337 | } | 91 | } |
338 | 92 | ||
339 | /* | 93 | /* Append printf formatted string to growable string */ |
340 | * Return the position of the first alphabetic character in a string. | 94 | void str_printf(struct gstr *gs, const char *fmt, ...) |
341 | */ | ||
342 | int | ||
343 | first_alpha(const char *string, const char *exempt) | ||
344 | { | 95 | { |
345 | int i, in_paren=0, c; | 96 | va_list ap; |
346 | 97 | char s[10000]; /* big enough... */ | |
347 | for (i = 0; i < strlen(string); i++) { | 98 | va_start(ap, fmt); |
348 | c = tolower(string[i]); | 99 | vsnprintf(s, sizeof(s), fmt, ap); |
349 | 100 | str_append(gs, s); | |
350 | if (strchr("<[(", c)) ++in_paren; | 101 | va_end(ap); |
351 | if (strchr(">])", c) && in_paren > 0) --in_paren; | ||
352 | |||
353 | if ((! in_paren) && isalpha(c) && | ||
354 | strchr(exempt, c) == 0) | ||
355 | return i; | ||
356 | } | ||
357 | |||
358 | return 0; | ||
359 | } | 102 | } |
360 | 103 | ||
361 | /* | 104 | /* Retreive value of growable string */ |
362 | * Get the first selected item in the dialog_list_item list. | 105 | const char *str_get(struct gstr *gs) |
363 | */ | ||
364 | struct dialog_list_item * | ||
365 | first_sel_item(int item_no, struct dialog_list_item ** items) | ||
366 | { | 106 | { |
367 | int i; | 107 | return gs->s; |
368 | |||
369 | for (i = 0; i < item_no; i++) { | ||
370 | if (items[i]->selected) | ||
371 | return items[i]; | ||
372 | } | ||
373 | |||
374 | return NULL; | ||
375 | } | 108 | } |
109 | |||
diff --git a/scripts/config/zconf.tab.c_shipped b/scripts/config/zconf.tab.c_shipped index bc2225fb4..be6bd4c0d 100644 --- a/scripts/config/zconf.tab.c_shipped +++ b/scripts/config/zconf.tab.c_shipped | |||
@@ -175,6 +175,8 @@ static bool zconf_endtoken(int token, int starttoken, int endtoken); | |||
175 | 175 | ||
176 | struct symbol *symbol_hash[257]; | 176 | struct symbol *symbol_hash[257]; |
177 | 177 | ||
178 | static struct menu *current_menu, *current_entry; | ||
179 | |||
178 | #define YYERROR_VERBOSE | 180 | #define YYERROR_VERBOSE |
179 | 181 | ||
180 | 182 | ||
@@ -2119,6 +2121,7 @@ void zconfdump(FILE *out) | |||
2119 | } | 2121 | } |
2120 | 2122 | ||
2121 | #include "lex.zconf.c" | 2123 | #include "lex.zconf.c" |
2124 | #include "util.c" | ||
2122 | #include "confdata.c" | 2125 | #include "confdata.c" |
2123 | #include "expr.c" | 2126 | #include "expr.c" |
2124 | #include "symbol.c" | 2127 | #include "symbol.c" |
diff --git a/scripts/config/zconf.y b/scripts/config/zconf.y index 658495cda..5ebaf0a78 100644 --- a/scripts/config/zconf.y +++ b/scripts/config/zconf.y | |||
@@ -25,6 +25,8 @@ static bool zconf_endtoken(int token, int starttoken, int endtoken); | |||
25 | 25 | ||
26 | struct symbol *symbol_hash[257]; | 26 | struct symbol *symbol_hash[257]; |
27 | 27 | ||
28 | static struct menu *current_menu, *current_entry; | ||
29 | |||
28 | #define YYERROR_VERBOSE | 30 | #define YYERROR_VERBOSE |
29 | %} | 31 | %} |
30 | %expect 40 | 32 | %expect 40 |
@@ -681,6 +683,7 @@ void zconfdump(FILE *out) | |||
681 | } | 683 | } |
682 | 684 | ||
683 | #include "lex.zconf.c" | 685 | #include "lex.zconf.c" |
686 | #include "util.c" | ||
684 | #include "confdata.c" | 687 | #include "confdata.c" |
685 | #include "expr.c" | 688 | #include "expr.c" |
686 | #include "symbol.c" | 689 | #include "symbol.c" |