aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/mconf.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig/mconf.c')
-rw-r--r--scripts/kconfig/mconf.c123
1 files changed, 96 insertions, 27 deletions
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index f584a281bb4c..48f67448af7b 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -236,16 +236,19 @@ search_help[] = N_(
236 "Result:\n" 236 "Result:\n"
237 "-----------------------------------------------------------------\n" 237 "-----------------------------------------------------------------\n"
238 "Symbol: FOO [=m]\n" 238 "Symbol: FOO [=m]\n"
239 "Type : tristate\n"
239 "Prompt: Foo bus is used to drive the bar HW\n" 240 "Prompt: Foo bus is used to drive the bar HW\n"
240 "Defined at drivers/pci/Kconfig:47\n" 241 " Defined at drivers/pci/Kconfig:47\n"
241 "Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n" 242 " Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
242 "Location:\n" 243 " Location:\n"
243 " -> Bus options (PCI, PCMCIA, EISA, ISA)\n" 244 " -> Bus options (PCI, PCMCIA, EISA, ISA)\n"
244 " -> PCI support (PCI [=y])\n" 245 " -> PCI support (PCI [=y])\n"
245 " -> PCI access mode (<choice> [=y])\n" 246 "(1) -> PCI access mode (<choice> [=y])\n"
246 "Selects: LIBCRC32\n" 247 " Selects: LIBCRC32\n"
247 "Selected by: BAR\n" 248 " Selected by: BAR\n"
248 "-----------------------------------------------------------------\n" 249 "-----------------------------------------------------------------\n"
250 "o The line 'Type:' shows the type of the configuration option for\n"
251 " this symbol (boolean, tristate, string, ...)\n"
249 "o The line 'Prompt:' shows the text used in the menu structure for\n" 252 "o The line 'Prompt:' shows the text used in the menu structure for\n"
250 " this symbol\n" 253 " this symbol\n"
251 "o The 'Defined at' line tell at what file / line number the symbol\n" 254 "o The 'Defined at' line tell at what file / line number the symbol\n"
@@ -254,8 +257,12 @@ search_help[] = N_(
254 " this symbol to be visible in the menu (selectable)\n" 257 " this symbol to be visible in the menu (selectable)\n"
255 "o The 'Location:' lines tell where in the menu structure this symbol\n" 258 "o The 'Location:' lines tell where in the menu structure this symbol\n"
256 " is located\n" 259 " is located\n"
257 " A location followed by a [=y] indicate that this is a selectable\n" 260 " A location followed by a [=y] indicates that this is a\n"
258 " menu item - and current value is displayed inside brackets.\n" 261 " selectable menu item - and the current value is displayed inside\n"
262 " brackets.\n"
263 " Press the key in the (#) prefix to jump directly to that\n"
264 " location. You will be returned to the current search results\n"
265 " after exiting this new menu.\n"
259 "o The 'Selects:' line tell what symbol will be automatically\n" 266 "o The 'Selects:' line tell what symbol will be automatically\n"
260 " selected if this symbol is selected (y or m)\n" 267 " selected if this symbol is selected (y or m)\n"
261 "o The 'Selected by' line tell what symbol has selected this symbol\n" 268 "o The 'Selected by' line tell what symbol has selected this symbol\n"
@@ -273,13 +280,15 @@ static struct menu *current_menu;
273static int child_count; 280static int child_count;
274static int single_menu_mode; 281static int single_menu_mode;
275static int show_all_options; 282static int show_all_options;
276static int saved_x, saved_y;
277 283
278static void conf(struct menu *menu); 284static void conf(struct menu *menu, struct menu *active_menu);
279static void conf_choice(struct menu *menu); 285static void conf_choice(struct menu *menu);
280static void conf_string(struct menu *menu); 286static void conf_string(struct menu *menu);
281static void conf_load(void); 287static void conf_load(void);
282static void conf_save(void); 288static void conf_save(void);
289static int show_textbox_ext(const char *title, char *text, int r, int c,
290 int *keys, int *vscroll, int *hscroll,
291 update_text_fn update_text, void *data);
283static void show_textbox(const char *title, const char *text, int r, int c); 292static void show_textbox(const char *title, const char *text, int r, int c);
284static void show_helptext(const char *title, const char *text); 293static void show_helptext(const char *title, const char *text);
285static void show_help(struct menu *menu); 294static void show_help(struct menu *menu);
@@ -302,12 +311,47 @@ static void set_config_filename(const char *config_filename)
302} 311}
303 312
304 313
314struct search_data {
315 struct jk_head *head;
316 struct menu **targets;
317 int *keys;
318};
319
320static void update_text(char *buf, size_t start, size_t end, void *_data)
321{
322 struct search_data *data = _data;
323 struct jump_key *pos;
324 int k = 0;
325
326 CIRCLEQ_FOREACH(pos, data->head, entries) {
327 if (pos->offset >= start && pos->offset < end) {
328 char header[4];
329
330 if (k < JUMP_NB) {
331 int key = '0' + (pos->index % JUMP_NB) + 1;
332
333 sprintf(header, "(%c)", key);
334 data->keys[k] = key;
335 data->targets[k] = pos->target;
336 k++;
337 } else {
338 sprintf(header, " ");
339 }
340
341 memcpy(buf + pos->offset, header, sizeof(header) - 1);
342 }
343 }
344 data->keys[k] = 0;
345}
346
305static void search_conf(void) 347static void search_conf(void)
306{ 348{
307 struct symbol **sym_arr; 349 struct symbol **sym_arr;
308 struct gstr res; 350 struct gstr res;
309 char *dialog_input; 351 char *dialog_input;
310 int dres; 352 int dres, vscroll = 0, hscroll = 0;
353 bool again;
354
311again: 355again:
312 dialog_clear(); 356 dialog_clear();
313 dres = dialog_inputbox(_("Search Configuration Parameter"), 357 dres = dialog_inputbox(_("Search Configuration Parameter"),
@@ -330,10 +374,30 @@ again:
330 dialog_input += strlen(CONFIG_); 374 dialog_input += strlen(CONFIG_);
331 375
332 sym_arr = sym_re_search(dialog_input); 376 sym_arr = sym_re_search(dialog_input);
333 res = get_relations_str(sym_arr); 377 do {
378 struct jk_head head = CIRCLEQ_HEAD_INITIALIZER(head);
379 struct menu *targets[JUMP_NB];
380 int keys[JUMP_NB + 1], i;
381 struct search_data data = {
382 .head = &head,
383 .targets = targets,
384 .keys = keys,
385 };
386
387 res = get_relations_str(sym_arr, &head);
388 dres = show_textbox_ext(_("Search Results"), (char *)
389 str_get(&res), 0, 0, keys, &vscroll,
390 &hscroll, &update_text, (void *)
391 &data);
392 again = false;
393 for (i = 0; i < JUMP_NB && keys[i]; i++)
394 if (dres == keys[i]) {
395 conf(targets[i]->parent, targets[i]);
396 again = true;
397 }
398 str_free(&res);
399 } while (again);
334 free(sym_arr); 400 free(sym_arr);
335 show_textbox(_("Search Results"), str_get(&res), 0, 0);
336 str_free(&res);
337} 401}
338 402
339static void build_conf(struct menu *menu) 403static void build_conf(struct menu *menu)
@@ -514,12 +578,11 @@ conf_childs:
514 indent -= doint; 578 indent -= doint;
515} 579}
516 580
517static void conf(struct menu *menu) 581static void conf(struct menu *menu, struct menu *active_menu)
518{ 582{
519 struct menu *submenu; 583 struct menu *submenu;
520 const char *prompt = menu_get_prompt(menu); 584 const char *prompt = menu_get_prompt(menu);
521 struct symbol *sym; 585 struct symbol *sym;
522 struct menu *active_menu = NULL;
523 int res; 586 int res;
524 int s_scroll = 0; 587 int s_scroll = 0;
525 588
@@ -562,13 +625,13 @@ static void conf(struct menu *menu)
562 if (single_menu_mode) 625 if (single_menu_mode)
563 submenu->data = (void *) (long) !submenu->data; 626 submenu->data = (void *) (long) !submenu->data;
564 else 627 else
565 conf(submenu); 628 conf(submenu, NULL);
566 break; 629 break;
567 case 't': 630 case 't':
568 if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) 631 if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)
569 conf_choice(submenu); 632 conf_choice(submenu);
570 else if (submenu->prompt->type == P_MENU) 633 else if (submenu->prompt->type == P_MENU)
571 conf(submenu); 634 conf(submenu, NULL);
572 break; 635 break;
573 case 's': 636 case 's':
574 conf_string(submenu); 637 conf_string(submenu);
@@ -607,7 +670,7 @@ static void conf(struct menu *menu)
607 if (item_is_tag('t')) 670 if (item_is_tag('t'))
608 sym_toggle_tristate_value(sym); 671 sym_toggle_tristate_value(sym);
609 else if (item_is_tag('m')) 672 else if (item_is_tag('m'))
610 conf(submenu); 673 conf(submenu, NULL);
611 break; 674 break;
612 case 7: 675 case 7:
613 search_conf(); 676 search_conf();
@@ -619,10 +682,19 @@ static void conf(struct menu *menu)
619 } 682 }
620} 683}
621 684
622static void show_textbox(const char *title, const char *text, int r, int c) 685static int show_textbox_ext(const char *title, char *text, int r, int c, int
686 *keys, int *vscroll, int *hscroll, update_text_fn
687 update_text, void *data)
623{ 688{
624 dialog_clear(); 689 dialog_clear();
625 dialog_textbox(title, text, r, c); 690 return dialog_textbox(title, text, r, c, keys, vscroll, hscroll,
691 update_text, data);
692}
693
694static void show_textbox(const char *title, const char *text, int r, int c)
695{
696 show_textbox_ext(title, (char *) text, r, c, (int []) {0}, NULL, NULL,
697 NULL, NULL);
626} 698}
627 699
628static void show_helptext(const char *title, const char *text) 700static void show_helptext(const char *title, const char *text)
@@ -862,9 +934,6 @@ int main(int ac, char **av)
862 single_menu_mode = 1; 934 single_menu_mode = 1;
863 } 935 }
864 936
865 initscr();
866
867 getyx(stdscr, saved_y, saved_x);
868 if (init_dialog(NULL)) { 937 if (init_dialog(NULL)) {
869 fprintf(stderr, N_("Your display is too small to run Menuconfig!\n")); 938 fprintf(stderr, N_("Your display is too small to run Menuconfig!\n"));
870 fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n")); 939 fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n"));
@@ -873,7 +942,7 @@ int main(int ac, char **av)
873 942
874 set_config_filename(conf_get_configname()); 943 set_config_filename(conf_get_configname());
875 do { 944 do {
876 conf(&rootmenu); 945 conf(&rootmenu, NULL);
877 res = handle_exit(); 946 res = handle_exit();
878 } while (res == KEY_ESC); 947 } while (res == KEY_ESC);
879 948