Blame view
scripts/kconfig/mconf.c
23.7 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 |
/* * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> * Released under the terms of the GNU GPL v2.0. * * Introduced single menu mode (show all sub-menus in one large tree). * 2002-11-06 Petr Baudis <pasky@ucw.cz> |
3b9fa0931 [PATCH] Kconfig i... |
7 8 |
* * i18n, 2005, Arnaldo Carvalho de Melo <acme@conectiva.com.br> |
1da177e4c Linux-2.6.12-rc2 |
9 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
10 11 12 13 |
#include <ctype.h> #include <errno.h> #include <fcntl.h> #include <limits.h> |
1da177e4c Linux-2.6.12-rc2 |
14 15 16 |
#include <stdarg.h> #include <stdlib.h> #include <string.h> |
564899f9f kconfig: handle S... |
17 |
#include <signal.h> |
1da177e4c Linux-2.6.12-rc2 |
18 |
#include <unistd.h> |
442ff7022 [PATCH] mconf.c n... |
19 |
#include <locale.h> |
1da177e4c Linux-2.6.12-rc2 |
20 |
|
1da177e4c Linux-2.6.12-rc2 |
21 |
#include "lkc.h" |
2982de699 kconfig/menuconfi... |
22 |
#include "lxdialog/dialog.h" |
1da177e4c Linux-2.6.12-rc2 |
23 |
|
3b9fa0931 [PATCH] Kconfig i... |
24 |
static const char mconf_readme[] = N_( |
1da177e4c Linux-2.6.12-rc2 |
25 26 27 28 |
"Overview " "-------- " |
652cf9821 kconfig: rephrase... |
29 30 31 32 33 34 |
"This interface let you select features and parameters for the build. " "Features can either be built-in, modularized, or ignored. Parameters " "must be entered in as decimal or hexadecimal numbers or text. " |
1da177e4c Linux-2.6.12-rc2 |
35 36 |
" " |
b5d609dbf kconfig/menuconfi... |
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
"Menu items beginning with following braces represent features that " " [ ] can be built in or removed " " < > can be built in, modularized or removed " " { } can be built in or modularized (selected by other feature) " " - - are selected by other feature, " "while *, M or whitespace inside braces means to build in, build as " "a module or to exclude the feature respectively. " |
1da177e4c Linux-2.6.12-rc2 |
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
" " "To change any of these features, highlight it with the cursor " "keys and press <Y> to build it in, <M> to make it a module or " "<N> to removed it. You may also press the <Space Bar> to cycle " "through the available options (ie. Y->N->M->Y). " " " "Some additional keyboard hints: " " " "Menus " "---------- " "o Use the Up/Down arrow keys (cursor keys) to highlight the item " " you wish to change or submenu wish to select and press <Enter>. " " Submenus are designated by \"--->\". " " " " Shortcut: Press the option's highlighted letter (hotkey). " " Pressing a hotkey more than once will sequence " " through all visible items which use that hotkey. " " " " You may also use the <PAGE UP> and <PAGE DOWN> keys to scroll " " unseen options into view. " " " "o To exit a menu use the cursor keys to highlight the <Exit> button " " and press <ENTER>. " " " " Shortcut: Press <ESC><ESC> or <E> or <X> if there is no hotkey " " using those letters. You may press a single <ESC>, but " " there is a delayed response which you may find annoying. " " " " Also, the <TAB> and cursor keys will cycle between <Select>, " |
22c7eca61 menuconfig: add s... |
109 110 |
" <Exit> and <Help>. " |
1da177e4c Linux-2.6.12-rc2 |
111 112 113 114 |
" " "o To get help with an item, use the cursor keys to highlight <Help> " |
22c7eca61 menuconfig: add s... |
115 116 |
" and press <ENTER>. " |
1da177e4c Linux-2.6.12-rc2 |
117 118 119 120 121 122 |
" " " Shortcut: Press <H> or <?>. " " " |
f9447c493 menuconfig: impro... |
123 124 |
"o To toggle the display of hidden options, press <Z>. " |
22c7eca61 menuconfig: add s... |
125 126 |
" " |
1da177e4c Linux-2.6.12-rc2 |
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
" " "Radiolists (Choice lists) " "----------- " "o Use the cursor keys to select the option you wish to set and press " " <S> or the <SPACE BAR>. " " " " Shortcut: Press the first letter of the option you wish to set then " " press <S> or <SPACE BAR>. " " " "o To see available help for the item, use the cursor keys to highlight " " <Help> and Press <ENTER>. " " " " Shortcut: Press <H> or <?>. " " " " Also, the <TAB> and cursor keys will cycle between <Select> and " " <Help> " " " " " "Data Entry " "----------- " "o Enter the requested information and press <ENTER> " " If you are entering hexadecimal values, it is not necessary to " " add the '0x' prefix to the entry. " " " "o For help, use the <TAB> or cursor keys to highlight the help option " " and press <ENTER>. You can try <TAB><H> as well. " " " " " "Text Box (Help Window) " "-------- " "o Use the cursor keys to scroll up/down/left/right. The VI editor " " keys h,j,k,l function here as do <SPACE BAR> and <B> for those " " who are familiar with less and lynx. " " " "o Press <E>, <X>, <Enter> or <Esc><Esc> to exit. " " " " " "Alternate Configuration Files " "----------------------------- " "Menuconfig supports the use of alternate configuration files for " "those who, for various reasons, find it necessary to switch " |
652cf9821 kconfig: rephrase... |
209 210 |
"between different configurations. " |
1da177e4c Linux-2.6.12-rc2 |
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
" " "At the end of the main menu you will find two options. One is " "for saving the current configuration to a file of your choosing. " "The other option is for loading a previously saved alternate " "configuration. " " " "Even if you don't use alternate configuration files, but you " "find during a Menuconfig session that you have completely messed " "up your settings, you may use the \"Load Alternate...\" option to " "restore your previously saved settings from \".config\" without " "restarting Menuconfig. " " " "Other information " "----------------- " "If you use Menuconfig in an XTERM window make sure you have your " "$TERM variable set to point to a xterm definition which supports color. " "Otherwise, Menuconfig will look rather bad. Menuconfig will not " "display correctly in a RXVT window because rxvt displays only one " "intensity of color, bright. " " " "Menuconfig will display larger menus on screens or xterms which are " "set to display more than the standard 25 row by 80 column geometry. " "In order for this to work, the \"stty size\" command must be able to " "display the screen's current row and column geometry. I STRONGLY " "RECOMMEND that you make sure you do NOT have the shell variables " "LINES and COLUMNS exported into your environment. Some distributions " "export those variables via /etc/profile. Some ncurses programs can " "become confused when those variables (LINES & COLUMNS) don't reflect " "the true screen size. " " " "Optional personality available " "------------------------------ " |
652cf9821 kconfig: rephrase... |
275 276 277 278 279 280 |
"If you prefer to have all of the options listed in a single menu, rather " "than the default multimenu hierarchy, run the menuconfig with " "MENUCONFIG_MODE environment variable set to single_menu. Example: " |
1da177e4c Linux-2.6.12-rc2 |
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
" " "make MENUCONFIG_MODE=single_menu menuconfig " " " "<Enter> will then unroll the appropriate category, or enfold it if it " "is already unrolled. " " " "Note that this mode can eventually be a little more CPU expensive " "(especially with a larger number of unrolled categories) than the " |
458972132 kconfig/lxdialog:... |
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
"default mode. " " " "Different color themes available " "-------------------------------- " "It is possible to select different color themes using the variable " "MENUCONFIG_COLOR. To select a theme use: " " " "make MENUCONFIG_COLOR=<theme> menuconfig " " " "Available themes are " " mono => selects colors suitable for monochrome displays " " blackbg => selects a color scheme with black background " |
350b5b763 kconfig/lxdialog:... |
321 322 323 324 |
" classic => theme with blue background. The classic look " " bluetitle => a LCD friendly version of classic. (default) " |
458972132 kconfig/lxdialog:... |
325 326 |
" "), |
3b9fa0931 [PATCH] Kconfig i... |
327 |
menu_instructions[] = N_( |
1da177e4c Linux-2.6.12-rc2 |
328 329 330 331 332 |
"Arrow keys navigate the menu. " "<Enter> selects submenus --->. " "Highlighted letters are hotkeys. " "Pressing <Y> includes, <N> excludes, <M> modularizes features. " "Press <Esc><Esc> to exit, <?> for Help, </> for Search. " |
3b9fa0931 [PATCH] Kconfig i... |
333 334 |
"Legend: [*] built-in [ ] excluded <M> module < > module capable"), radiolist_instructions[] = N_( |
1da177e4c Linux-2.6.12-rc2 |
335 336 337 |
"Use the arrow keys to navigate this window or " "press the hotkey of the item you wish to select " "followed by the <SPACE BAR>. " |
3b9fa0931 [PATCH] Kconfig i... |
338 339 |
"Press <?> for additional information about this option."), inputbox_instructions_int[] = N_( |
1da177e4c Linux-2.6.12-rc2 |
340 341 |
"Please enter a decimal value. " "Fractions will not be accepted. " |
3b9fa0931 [PATCH] Kconfig i... |
342 343 |
"Use the <TAB> key to move from the input field to the buttons below it."), inputbox_instructions_hex[] = N_( |
1da177e4c Linux-2.6.12-rc2 |
344 |
"Please enter a hexadecimal value. " |
3b9fa0931 [PATCH] Kconfig i... |
345 346 |
"Use the <TAB> key to move from the input field to the buttons below it."), inputbox_instructions_string[] = N_( |
1da177e4c Linux-2.6.12-rc2 |
347 |
"Please enter a string value. " |
3b9fa0931 [PATCH] Kconfig i... |
348 349 |
"Use the <TAB> key to move from the input field to the buttons below it."), setmod_text[] = N_( |
1da177e4c Linux-2.6.12-rc2 |
350 351 |
"This feature depends on another which has been configured as a module. " |
3b9fa0931 [PATCH] Kconfig i... |
352 |
"As a result, this feature will be built as a module."), |
3b9fa0931 [PATCH] Kconfig i... |
353 |
load_config_text[] = N_( |
1da177e4c Linux-2.6.12-rc2 |
354 355 |
"Enter the name of the configuration file you wish to load. " "Accept the name shown to restore the configuration you " |
3b9fa0931 [PATCH] Kconfig i... |
356 357 |
"last retrieved. Leave blank to abort."), load_config_help[] = N_( |
1da177e4c Linux-2.6.12-rc2 |
358 359 |
" " |
652cf9821 kconfig: rephrase... |
360 361 |
"For various reasons, one may wish to keep several different " |
1da177e4c Linux-2.6.12-rc2 |
362 363 364 365 366 367 |
"configurations available on a single machine. " " " "If you have saved a previous configuration in a file other than the " |
652cf9821 kconfig: rephrase... |
368 369 370 371 |
"default one, entering its name here will allow you to modify that " "configuration. " |
1da177e4c Linux-2.6.12-rc2 |
372 373 374 375 |
" " "If you are uncertain, then you have probably never used alternate " |
af901ca18 tree-wide: fix as... |
376 377 |
"configuration files. You should therefore leave this blank to abort. "), |
3b9fa0931 [PATCH] Kconfig i... |
378 |
save_config_text[] = N_( |
1da177e4c Linux-2.6.12-rc2 |
379 |
"Enter a filename to which this configuration should be saved " |
3b9fa0931 [PATCH] Kconfig i... |
380 381 |
"as an alternate. Leave blank to abort."), save_config_help[] = N_( |
1da177e4c Linux-2.6.12-rc2 |
382 383 |
" " |
652cf9821 kconfig: rephrase... |
384 385 386 387 |
"For various reasons, one may wish to keep different configurations " "available on a single machine. " |
1da177e4c Linux-2.6.12-rc2 |
388 389 390 391 392 393 394 395 396 397 398 399 |
" " "Entering a file name here will allow you to later retrieve, modify " "and use the current configuration as an alternate to whatever " "configuration options you have selected at that time. " " " "If you are uncertain what all this means then you should probably " |
3b9fa0931 [PATCH] Kconfig i... |
400 401 402 |
"leave this blank. "), search_help[] = N_( |
1da177e4c Linux-2.6.12-rc2 |
403 404 |
" " |
59dfa24da kconfig: rephrase... |
405 406 |
"Search for symbols and display their relations. " |
503af334e [PATCH] clarify m... |
407 408 |
"Regular expressions are allowed. " |
1da177e4c Linux-2.6.12-rc2 |
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
"Example: search for \"^FOO\" " "Result: " "----------------------------------------------------------------- " "Symbol: FOO [=m] " "Prompt: Foo bus is used to drive the bar HW " "Defined at drivers/pci/Kconfig:47 " "Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64 " "Location: " " -> Bus options (PCI, PCMCIA, EISA, MCA, ISA) " " -> PCI support (PCI [=y]) " " -> PCI access mode (<choice> [=y]) " "Selects: LIBCRC32 " "Selected by: BAR " "----------------------------------------------------------------- " "o The line 'Prompt:' shows the text used in the menu structure for " |
59dfa24da kconfig: rephrase... |
439 440 |
" this symbol " |
1da177e4c Linux-2.6.12-rc2 |
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 |
"o The 'Defined at' line tell at what file / line number the symbol " " is defined " "o The 'Depends on:' line tell what symbols needs to be defined for " " this symbol to be visible in the menu (selectable) " "o The 'Location:' lines tell where in the menu structure this symbol " " is located " " A location followed by a [=y] indicate that this is a selectable " " menu item - and current value is displayed inside brackets. " "o The 'Selects:' line tell what symbol will be automatically " " selected if this symbol is selected (y or m) " "o The 'Selected by' line tell what symbol has selected this symbol " " " "Only relevant lines are shown. " " " "Search examples: " |
59dfa24da kconfig: rephrase... |
472 473 474 475 476 477 |
"Examples: USB => find all symbols containing USB " " ^USB => find all symbols starting with USB " " USB$ => find all symbols ending with USB " |
3b9fa0931 [PATCH] Kconfig i... |
478 479 |
" "); |
1da177e4c Linux-2.6.12-rc2 |
480 |
|
1da177e4c Linux-2.6.12-rc2 |
481 |
static int indent; |
1da177e4c Linux-2.6.12-rc2 |
482 483 |
static struct menu *current_menu; static int child_count; |
1da177e4c Linux-2.6.12-rc2 |
484 |
static int single_menu_mode; |
22c7eca61 menuconfig: add s... |
485 |
static int show_all_options; |
564899f9f kconfig: handle S... |
486 |
static int saved_x, saved_y; |
1da177e4c Linux-2.6.12-rc2 |
487 488 489 490 491 492 493 494 495 |
static void conf(struct menu *menu); static void conf_choice(struct menu *menu); static void conf_string(struct menu *menu); static void conf_load(void); static void conf_save(void); static void show_textbox(const char *title, const char *text, int r, int c); static void show_helptext(const char *title, const char *text); static void show_help(struct menu *menu); |
1da177e4c Linux-2.6.12-rc2 |
496 |
|
95e30f959 menuconfig: remem... |
497 498 499 500 501 |
static char filename[PATH_MAX+1]; static void set_config_filename(const char *config_filename) { static char menu_backtitle[PATH_MAX+128]; int size; |
95e30f959 menuconfig: remem... |
502 |
|
95e30f959 menuconfig: remem... |
503 |
size = snprintf(menu_backtitle, sizeof(menu_backtitle), |
0954828fc kconfig: replace ... |
504 |
"%s - %s", config_filename, rootmenu.prompt->text); |
95e30f959 menuconfig: remem... |
505 506 507 508 509 510 511 512 |
if (size >= sizeof(menu_backtitle)) menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; set_dialog_backtitle(menu_backtitle); size = snprintf(filename, sizeof(filename), "%s", config_filename); if (size >= sizeof(filename)) filename[sizeof(filename)-1] = '\0'; } |
1da177e4c Linux-2.6.12-rc2 |
513 514 515 |
static void search_conf(void) { struct symbol **sym_arr; |
1da177e4c Linux-2.6.12-rc2 |
516 |
struct gstr res; |
0584f9f9c kconfig: strip 'C... |
517 |
char *dialog_input; |
2982de699 kconfig/menuconfi... |
518 |
int dres; |
1da177e4c Linux-2.6.12-rc2 |
519 |
again: |
e94c5bde7 kconfig/menuconfi... |
520 |
dialog_clear(); |
2982de699 kconfig/menuconfi... |
521 |
dres = dialog_inputbox(_("Search Configuration Parameter"), |
ffb5957bc kconfig: allow bu... |
522 523 |
_("Enter " CONFIG_ " (sub)string to search for " "(with or without \"" CONFIG_ "\")"), |
2982de699 kconfig/menuconfi... |
524 525 |
10, 75, ""); switch (dres) { |
1da177e4c Linux-2.6.12-rc2 |
526 527 528 |
case 0: break; case 1: |
3b9fa0931 [PATCH] Kconfig i... |
529 |
show_helptext(_("Search Configuration"), search_help); |
1da177e4c Linux-2.6.12-rc2 |
530 531 532 533 |
goto again; default: return; } |
ffb5957bc kconfig: allow bu... |
534 |
/* strip the prefix if necessary */ |
0584f9f9c kconfig: strip 'C... |
535 |
dialog_input = dialog_input_result; |
ffb5957bc kconfig: allow bu... |
536 537 |
if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0) dialog_input += strlen(CONFIG_); |
0584f9f9c kconfig: strip 'C... |
538 539 |
sym_arr = sym_re_search(dialog_input); |
1da177e4c Linux-2.6.12-rc2 |
540 541 |
res = get_relations_str(sym_arr); free(sym_arr); |
3b9fa0931 [PATCH] Kconfig i... |
542 |
show_textbox(_("Search Results"), str_get(&res), 0, 0); |
1da177e4c Linux-2.6.12-rc2 |
543 544 545 546 547 548 549 550 551 552 553 |
str_free(&res); } static void build_conf(struct menu *menu) { struct symbol *sym; struct property *prop; struct menu *child; int type, tmp, doint = 2; tristate val; char ch; |
22c7eca61 menuconfig: add s... |
554 555 556 557 558 559 560 561 562 563 |
bool visible; /* * note: menu_is_visible() has side effect that it will * recalc the value of the symbol. */ visible = menu_is_visible(menu); if (show_all_options && !menu_has_prompt(menu)) return; else if (!show_all_options && !visible) |
1da177e4c Linux-2.6.12-rc2 |
564 565 566 567 568 569 570 571 572 573 |
return; sym = menu->sym; prop = menu->prompt; if (!sym) { if (prop && menu != current_menu) { const char *prompt = menu_get_prompt(menu); switch (prop->type) { case P_MENU: child_count++; |
413f006ba kconfig: gettext ... |
574 |
prompt = _(prompt); |
1da177e4c Linux-2.6.12-rc2 |
575 |
if (single_menu_mode) { |
2982de699 kconfig/menuconfi... |
576 577 578 |
item_make("%s%*c%s", menu->data ? "-->" : "++>", indent + 1, ' ', prompt); |
1da177e4c Linux-2.6.12-rc2 |
579 |
} else |
2982de699 kconfig/menuconfi... |
580 |
item_make(" %*c%s --->", indent + 1, ' ', prompt); |
1da177e4c Linux-2.6.12-rc2 |
581 |
|
2982de699 kconfig/menuconfi... |
582 583 |
item_set_tag('m'); item_set_data(menu); |
1da177e4c Linux-2.6.12-rc2 |
584 585 586 |
if (single_menu_mode && menu->data) goto conf_childs; return; |
48874077d kconfig: make com... |
587 588 589 |
case P_COMMENT: if (prompt) { child_count++; |
413f006ba kconfig: gettext ... |
590 |
item_make(" %*c*** %s ***", indent + 1, ' ', _(prompt)); |
48874077d kconfig: make com... |
591 592 593 594 |
item_set_tag(':'); item_set_data(menu); } break; |
1da177e4c Linux-2.6.12-rc2 |
595 596 597 |
default: if (prompt) { child_count++; |
413f006ba kconfig: gettext ... |
598 |
item_make("---%*c%s", indent + 1, ' ', _(prompt)); |
2982de699 kconfig/menuconfi... |
599 600 |
item_set_tag(':'); item_set_data(menu); |
1da177e4c Linux-2.6.12-rc2 |
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 |
} } } else doint = 0; goto conf_childs; } type = sym_get_type(sym); if (sym_is_choice(sym)) { struct symbol *def_sym = sym_get_choice_value(sym); struct menu *def_menu = NULL; child_count++; for (child = menu->list; child; child = child->next) { if (menu_is_visible(child) && child->sym == def_sym) def_menu = child; } val = sym_get_tristate_value(sym); if (sym_is_changable(sym)) { |
1da177e4c Linux-2.6.12-rc2 |
621 622 |
switch (type) { case S_BOOLEAN: |
2982de699 kconfig/menuconfi... |
623 |
item_make("[%c]", val == no ? ' ' : '*'); |
1da177e4c Linux-2.6.12-rc2 |
624 625 626 627 628 629 630 |
break; case S_TRISTATE: switch (val) { case yes: ch = '*'; break; case mod: ch = 'M'; break; default: ch = ' '; break; } |
2982de699 kconfig/menuconfi... |
631 |
item_make("<%c>", ch); |
1da177e4c Linux-2.6.12-rc2 |
632 633 |
break; } |
2982de699 kconfig/menuconfi... |
634 635 |
item_set_tag('t'); item_set_data(menu); |
1da177e4c Linux-2.6.12-rc2 |
636 |
} else { |
2982de699 kconfig/menuconfi... |
637 638 639 |
item_make(" "); item_set_tag(def_menu ? 't' : ':'); item_set_data(menu); |
1da177e4c Linux-2.6.12-rc2 |
640 |
} |
413f006ba kconfig: gettext ... |
641 |
item_add_str("%*c%s", indent + 1, ' ', _(menu_get_prompt(menu))); |
1da177e4c Linux-2.6.12-rc2 |
642 643 |
if (val == yes) { if (def_menu) { |
413f006ba kconfig: gettext ... |
644 |
item_add_str(" (%s)", _(menu_get_prompt(def_menu))); |
2982de699 kconfig/menuconfi... |
645 |
item_add_str(" --->"); |
1da177e4c Linux-2.6.12-rc2 |
646 647 648 649 650 |
if (def_menu->list) { indent += 2; build_conf(def_menu); indent -= 2; } |
2982de699 kconfig/menuconfi... |
651 |
} |
1da177e4c Linux-2.6.12-rc2 |
652 653 |
return; } |
1da177e4c Linux-2.6.12-rc2 |
654 655 |
} else { if (menu == current_menu) { |
413f006ba kconfig: gettext ... |
656 |
item_make("---%*c%s", indent + 1, ' ', _(menu_get_prompt(menu))); |
2982de699 kconfig/menuconfi... |
657 658 |
item_set_tag(':'); item_set_data(menu); |
1da177e4c Linux-2.6.12-rc2 |
659 660 661 662 663 |
goto conf_childs; } child_count++; val = sym_get_tristate_value(sym); if (sym_is_choice_value(sym) && val == yes) { |
2982de699 kconfig/menuconfi... |
664 665 666 |
item_make(" "); item_set_tag(':'); item_set_data(menu); |
1da177e4c Linux-2.6.12-rc2 |
667 668 669 |
} else { switch (type) { case S_BOOLEAN: |
1da177e4c Linux-2.6.12-rc2 |
670 |
if (sym_is_changable(sym)) |
2982de699 kconfig/menuconfi... |
671 |
item_make("[%c]", val == no ? ' ' : '*'); |
1da177e4c Linux-2.6.12-rc2 |
672 |
else |
b5d609dbf kconfig/menuconfi... |
673 |
item_make("-%c-", val == no ? ' ' : '*'); |
2982de699 kconfig/menuconfi... |
674 675 |
item_set_tag('t'); item_set_data(menu); |
1da177e4c Linux-2.6.12-rc2 |
676 677 |
break; case S_TRISTATE: |
1da177e4c Linux-2.6.12-rc2 |
678 679 680 681 682 |
switch (val) { case yes: ch = '*'; break; case mod: ch = 'M'; break; default: ch = ' '; break; } |
b5d609dbf kconfig/menuconfi... |
683 684 685 686 687 688 689 |
if (sym_is_changable(sym)) { if (sym->rev_dep.tri == mod) item_make("{%c}", ch); else item_make("<%c>", ch); } else item_make("-%c-", ch); |
2982de699 kconfig/menuconfi... |
690 691 |
item_set_tag('t'); item_set_data(menu); |
1da177e4c Linux-2.6.12-rc2 |
692 693 |
break; default: |
2982de699 kconfig/menuconfi... |
694 695 |
tmp = 2 + strlen(sym_get_string_value(sym)); /* () = 2 */ item_make("(%s)", sym_get_string_value(sym)); |
1da177e4c Linux-2.6.12-rc2 |
696 697 698 |
tmp = indent - tmp + 4; if (tmp < 0) tmp = 0; |
413f006ba kconfig: gettext ... |
699 |
item_add_str("%*c%s%s", tmp, ' ', _(menu_get_prompt(menu)), |
2982de699 kconfig/menuconfi... |
700 |
(sym_has_value(sym) || !sym_is_changable(sym)) ? |
413f006ba kconfig: gettext ... |
701 |
"" : _(" (NEW)")); |
2982de699 kconfig/menuconfi... |
702 703 |
item_set_tag('s'); item_set_data(menu); |
1da177e4c Linux-2.6.12-rc2 |
704 705 706 |
goto conf_childs; } } |
413f006ba kconfig: gettext ... |
707 |
item_add_str("%*c%s%s", indent + 1, ' ', _(menu_get_prompt(menu)), |
2982de699 kconfig/menuconfi... |
708 |
(sym_has_value(sym) || !sym_is_changable(sym)) ? |
413f006ba kconfig: gettext ... |
709 |
"" : _(" (NEW)")); |
1da177e4c Linux-2.6.12-rc2 |
710 |
if (menu->prompt->type == P_MENU) { |
2982de699 kconfig/menuconfi... |
711 |
item_add_str(" --->"); |
1da177e4c Linux-2.6.12-rc2 |
712 713 |
return; } |
1da177e4c Linux-2.6.12-rc2 |
714 715 716 717 718 719 720 721 722 723 724 725 726 727 |
} conf_childs: indent += doint; for (child = menu->list; child; child = child->next) build_conf(child); indent -= doint; } static void conf(struct menu *menu) { struct menu *submenu; const char *prompt = menu_get_prompt(menu); struct symbol *sym; |
2982de699 kconfig/menuconfi... |
728 729 730 |
struct menu *active_menu = NULL; int res; int s_scroll = 0; |
1da177e4c Linux-2.6.12-rc2 |
731 |
|
1da177e4c Linux-2.6.12-rc2 |
732 |
while (1) { |
2982de699 kconfig/menuconfi... |
733 |
item_reset(); |
1da177e4c Linux-2.6.12-rc2 |
734 735 736 737 738 |
current_menu = menu; build_conf(menu); if (!child_count) break; if (menu == &rootmenu) { |
2982de699 kconfig/menuconfi... |
739 740 741 742 743 744 |
item_make("--- "); item_set_tag(':'); item_make(_(" Load an Alternate Configuration File")); item_set_tag('L'); item_make(_(" Save an Alternate Configuration File")); item_set_tag('S'); |
1da177e4c Linux-2.6.12-rc2 |
745 |
} |
e94c5bde7 kconfig/menuconfi... |
746 |
dialog_clear(); |
413f006ba kconfig: gettext ... |
747 |
res = dialog_menu(prompt ? _(prompt) : _("Main Menu"), |
2982de699 kconfig/menuconfi... |
748 |
_(menu_instructions), |
2982de699 kconfig/menuconfi... |
749 |
active_menu, &s_scroll); |
c8dc68ad0 kconfig/lxdialog:... |
750 |
if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL) |
1da177e4c Linux-2.6.12-rc2 |
751 |
break; |
2982de699 kconfig/menuconfi... |
752 753 754 |
if (!item_activate_selected()) continue; if (!item_tag()) |
1da177e4c Linux-2.6.12-rc2 |
755 |
continue; |
2982de699 kconfig/menuconfi... |
756 757 |
submenu = item_data(); active_menu = item_data(); |
c8dc68ad0 kconfig/lxdialog:... |
758 759 760 761 |
if (submenu) sym = submenu->sym; else sym = NULL; |
1da177e4c Linux-2.6.12-rc2 |
762 |
|
2982de699 kconfig/menuconfi... |
763 |
switch (res) { |
1da177e4c Linux-2.6.12-rc2 |
764 |
case 0: |
2982de699 kconfig/menuconfi... |
765 |
switch (item_tag()) { |
1da177e4c Linux-2.6.12-rc2 |
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 |
case 'm': if (single_menu_mode) submenu->data = (void *) (long) !submenu->data; else conf(submenu); break; case 't': if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) conf_choice(submenu); else if (submenu->prompt->type == P_MENU) conf(submenu); break; case 's': conf_string(submenu); break; case 'L': conf_load(); break; case 'S': conf_save(); break; } break; case 2: if (sym) show_help(submenu); else |
413f006ba kconfig: gettext ... |
793 |
show_helptext(_("README"), _(mconf_readme)); |
1da177e4c Linux-2.6.12-rc2 |
794 795 |
break; case 3: |
2982de699 kconfig/menuconfi... |
796 |
if (item_is_tag('t')) { |
1da177e4c Linux-2.6.12-rc2 |
797 798 799 800 801 802 803 |
if (sym_set_tristate_value(sym, yes)) break; if (sym_set_tristate_value(sym, mod)) show_textbox(NULL, setmod_text, 6, 74); } break; case 4: |
2982de699 kconfig/menuconfi... |
804 |
if (item_is_tag('t')) |
1da177e4c Linux-2.6.12-rc2 |
805 806 807 |
sym_set_tristate_value(sym, no); break; case 5: |
2982de699 kconfig/menuconfi... |
808 |
if (item_is_tag('t')) |
1da177e4c Linux-2.6.12-rc2 |
809 810 811 |
sym_set_tristate_value(sym, mod); break; case 6: |
2982de699 kconfig/menuconfi... |
812 |
if (item_is_tag('t')) |
1da177e4c Linux-2.6.12-rc2 |
813 |
sym_toggle_tristate_value(sym); |
2982de699 kconfig/menuconfi... |
814 |
else if (item_is_tag('m')) |
1da177e4c Linux-2.6.12-rc2 |
815 816 817 818 819 |
conf(submenu); break; case 7: search_conf(); break; |
22c7eca61 menuconfig: add s... |
820 821 822 |
case 8: show_all_options = !show_all_options; break; |
1da177e4c Linux-2.6.12-rc2 |
823 824 825 826 827 828 |
} } } static void show_textbox(const char *title, const char *text, int r, int c) { |
e94c5bde7 kconfig/menuconfi... |
829 |
dialog_clear(); |
c8dc68ad0 kconfig/lxdialog:... |
830 |
dialog_textbox(title, text, r, c); |
1da177e4c Linux-2.6.12-rc2 |
831 832 833 834 835 836 837 838 839 840 |
} static void show_helptext(const char *title, const char *text) { show_textbox(title, text, 0, 0); } static void show_help(struct menu *menu) { struct gstr help = str_new(); |
1d525e7c1 kconfig: make use... |
841 |
|
da60fbbcb menuconfig: wrap ... |
842 |
help.max_width = getmaxx(stdscr) - 10; |
1d525e7c1 kconfig: make use... |
843 |
menu_get_ext_help(menu, &help); |
413f006ba kconfig: gettext ... |
844 |
show_helptext(_(menu_get_prompt(menu)), str_get(&help)); |
1da177e4c Linux-2.6.12-rc2 |
845 846 |
str_free(&help); } |
1da177e4c Linux-2.6.12-rc2 |
847 848 |
static void conf_choice(struct menu *menu) { |
413f006ba kconfig: gettext ... |
849 |
const char *prompt = _(menu_get_prompt(menu)); |
1da177e4c Linux-2.6.12-rc2 |
850 851 |
struct menu *child; struct symbol *active; |
1da177e4c Linux-2.6.12-rc2 |
852 853 854 |
active = sym_get_choice_value(menu->sym); while (1) { |
2982de699 kconfig/menuconfi... |
855 856 857 |
int res; int selected; item_reset(); |
1da177e4c Linux-2.6.12-rc2 |
858 859 860 861 862 |
current_menu = menu; for (child = menu->list; child; child = child->next) { if (!menu_is_visible(child)) continue; |
af6c15988 kconfig: handle c... |
863 864 865 866 867 868 |
if (child->sym) item_make("%s", _(menu_get_prompt(child))); else { item_make("*** %s ***", _(menu_get_prompt(child))); item_set_tag(':'); } |
2982de699 kconfig/menuconfi... |
869 870 871 |
item_set_data(child); if (child->sym == active) item_set_selected(1); |
1da177e4c Linux-2.6.12-rc2 |
872 |
if (child->sym == sym_get_choice_value(menu->sym)) |
2982de699 kconfig/menuconfi... |
873 |
item_set_tag('X'); |
1da177e4c Linux-2.6.12-rc2 |
874 |
} |
e94c5bde7 kconfig/menuconfi... |
875 |
dialog_clear(); |
413f006ba kconfig: gettext ... |
876 |
res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"), |
2982de699 kconfig/menuconfi... |
877 878 879 880 |
_(radiolist_instructions), 15, 70, 6); selected = item_activate_selected(); switch (res) { |
1da177e4c Linux-2.6.12-rc2 |
881 |
case 0: |
2982de699 kconfig/menuconfi... |
882 883 |
if (selected) { child = item_data(); |
af6c15988 kconfig: handle c... |
884 885 |
if (!child->sym) break; |
2982de699 kconfig/menuconfi... |
886 887 |
sym_set_tristate_value(child->sym, yes); } |
1da177e4c Linux-2.6.12-rc2 |
888 889 |
return; case 1: |
2982de699 kconfig/menuconfi... |
890 891 |
if (selected) { child = item_data(); |
1da177e4c Linux-2.6.12-rc2 |
892 893 894 895 896 |
show_help(child); active = child->sym; } else show_help(menu); break; |
f3cbcdc95 kconfig/lxdialog:... |
897 |
case KEY_ESC: |
1da177e4c Linux-2.6.12-rc2 |
898 |
return; |
c8dc68ad0 kconfig/lxdialog:... |
899 900 |
case -ERRDISPLAYTOOSMALL: return; |
1da177e4c Linux-2.6.12-rc2 |
901 902 903 904 905 906 907 |
} } } static void conf_string(struct menu *menu) { const char *prompt = menu_get_prompt(menu); |
1da177e4c Linux-2.6.12-rc2 |
908 909 |
while (1) { |
2982de699 kconfig/menuconfi... |
910 |
int res; |
c4143a830 kconfig: fix MAC ... |
911 |
const char *heading; |
2982de699 kconfig/menuconfi... |
912 |
|
1da177e4c Linux-2.6.12-rc2 |
913 914 |
switch (sym_get_type(menu->sym)) { case S_INT: |
2982de699 kconfig/menuconfi... |
915 |
heading = _(inputbox_instructions_int); |
1da177e4c Linux-2.6.12-rc2 |
916 917 |
break; case S_HEX: |
2982de699 kconfig/menuconfi... |
918 |
heading = _(inputbox_instructions_hex); |
1da177e4c Linux-2.6.12-rc2 |
919 920 |
break; case S_STRING: |
2982de699 kconfig/menuconfi... |
921 |
heading = _(inputbox_instructions_string); |
1da177e4c Linux-2.6.12-rc2 |
922 923 |
break; default: |
413f006ba kconfig: gettext ... |
924 |
heading = _("Internal mconf error!"); |
1da177e4c Linux-2.6.12-rc2 |
925 |
} |
e94c5bde7 kconfig/menuconfi... |
926 |
dialog_clear(); |
413f006ba kconfig: gettext ... |
927 |
res = dialog_inputbox(prompt ? _(prompt) : _("Main Menu"), |
2982de699 kconfig/menuconfi... |
928 929 930 |
heading, 10, 75, sym_get_string_value(menu->sym)); switch (res) { |
1da177e4c Linux-2.6.12-rc2 |
931 |
case 0: |
2982de699 kconfig/menuconfi... |
932 |
if (sym_set_string_value(menu->sym, dialog_input_result)) |
1da177e4c Linux-2.6.12-rc2 |
933 |
return; |
3b9fa0931 [PATCH] Kconfig i... |
934 |
show_textbox(NULL, _("You have made an invalid entry."), 5, 43); |
1da177e4c Linux-2.6.12-rc2 |
935 936 937 938 |
break; case 1: show_help(menu); break; |
f3cbcdc95 kconfig/lxdialog:... |
939 |
case KEY_ESC: |
1da177e4c Linux-2.6.12-rc2 |
940 941 942 943 944 945 946 |
return; } } } static void conf_load(void) { |
1da177e4c Linux-2.6.12-rc2 |
947 948 |
while (1) { |
2982de699 kconfig/menuconfi... |
949 |
int res; |
e94c5bde7 kconfig/menuconfi... |
950 |
dialog_clear(); |
2982de699 kconfig/menuconfi... |
951 952 953 |
res = dialog_inputbox(NULL, load_config_text, 11, 55, filename); switch(res) { |
1da177e4c Linux-2.6.12-rc2 |
954 |
case 0: |
2982de699 kconfig/menuconfi... |
955 |
if (!dialog_input_result[0]) |
1da177e4c Linux-2.6.12-rc2 |
956 |
return; |
95e30f959 menuconfig: remem... |
957 958 |
if (!conf_read(dialog_input_result)) { set_config_filename(dialog_input_result); |
36ef805bd kconfig: mark con... |
959 |
sym_set_change_count(1); |
1da177e4c Linux-2.6.12-rc2 |
960 |
return; |
95e30f959 menuconfig: remem... |
961 |
} |
3b9fa0931 [PATCH] Kconfig i... |
962 |
show_textbox(NULL, _("File does not exist!"), 5, 38); |
1da177e4c Linux-2.6.12-rc2 |
963 964 |
break; case 1: |
3b9fa0931 [PATCH] Kconfig i... |
965 |
show_helptext(_("Load Alternate Configuration"), load_config_help); |
1da177e4c Linux-2.6.12-rc2 |
966 |
break; |
f3cbcdc95 kconfig/lxdialog:... |
967 |
case KEY_ESC: |
1da177e4c Linux-2.6.12-rc2 |
968 969 970 971 972 973 974 |
return; } } } static void conf_save(void) { |
1da177e4c Linux-2.6.12-rc2 |
975 |
while (1) { |
2982de699 kconfig/menuconfi... |
976 |
int res; |
e94c5bde7 kconfig/menuconfi... |
977 |
dialog_clear(); |
2982de699 kconfig/menuconfi... |
978 979 980 |
res = dialog_inputbox(NULL, save_config_text, 11, 55, filename); switch(res) { |
1da177e4c Linux-2.6.12-rc2 |
981 |
case 0: |
2982de699 kconfig/menuconfi... |
982 |
if (!dialog_input_result[0]) |
1da177e4c Linux-2.6.12-rc2 |
983 |
return; |
95e30f959 menuconfig: remem... |
984 985 |
if (!conf_write(dialog_input_result)) { set_config_filename(dialog_input_result); |
1da177e4c Linux-2.6.12-rc2 |
986 |
return; |
95e30f959 menuconfig: remem... |
987 |
} |
3b9fa0931 [PATCH] Kconfig i... |
988 |
show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60); |
1da177e4c Linux-2.6.12-rc2 |
989 990 |
break; case 1: |
3b9fa0931 [PATCH] Kconfig i... |
991 |
show_helptext(_("Save Alternate Configuration"), save_config_help); |
1da177e4c Linux-2.6.12-rc2 |
992 |
break; |
f3cbcdc95 kconfig/lxdialog:... |
993 |
case KEY_ESC: |
1da177e4c Linux-2.6.12-rc2 |
994 995 996 997 |
return; } } } |
564899f9f kconfig: handle S... |
998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 |
static int handle_exit(void) { int res; dialog_clear(); if (conf_get_changed()) res = dialog_yesno(NULL, _("Do you wish to save your new configuration ? " "<ESC><ESC> to continue."), 6, 60); else res = -1; end_dialog(saved_x, saved_y); switch (res) { case 0: if (conf_write(filename)) { fprintf(stderr, _(" " "Error while writing of the configuration. " "Your configuration changes were NOT saved." " ")); return 1; } /* fall through */ case -1: printf(_(" " "*** End of the configuration. " "*** Execute 'make' to start the build or try 'make help'." " ")); res = 0; break; default: fprintf(stderr, _(" " "Your configuration changes were NOT saved." " ")); } return res; } static void sig_handler(int signo) { exit(handle_exit()); } |
1da177e4c Linux-2.6.12-rc2 |
1058 1059 |
int main(int ac, char **av) { |
1da177e4c Linux-2.6.12-rc2 |
1060 |
char *mode; |
2982de699 kconfig/menuconfi... |
1061 |
int res; |
1da177e4c Linux-2.6.12-rc2 |
1062 |
|
3b9fa0931 [PATCH] Kconfig i... |
1063 1064 1065 |
setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); |
564899f9f kconfig: handle S... |
1066 |
signal(SIGINT, sig_handler); |
1da177e4c Linux-2.6.12-rc2 |
1067 1068 |
conf_parse(av[1]); conf_read(NULL); |
1da177e4c Linux-2.6.12-rc2 |
1069 1070 1071 1072 1073 |
mode = getenv("MENUCONFIG_MODE"); if (mode) { if (!strcasecmp(mode, "single_menu")) single_menu_mode = 1; } |
d0e1e0956 kconfig: initiali... |
1074 |
initscr(); |
09af091f5 kconfig: make kco... |
1075 1076 1077 1078 1079 1080 1081 1082 |
getyx(stdscr, saved_y, saved_x); if (init_dialog(NULL)) { fprintf(stderr, N_("Your display is too small to run Menuconfig! ")); fprintf(stderr, N_("It must be at least 19 lines by 80 columns. ")); return 1; } |
d802b50f0 kconfig/menuconfi... |
1083 |
set_config_filename(conf_get_configname()); |
f3cbcdc95 kconfig/lxdialog:... |
1084 1085 |
do { conf(&rootmenu); |
564899f9f kconfig: handle S... |
1086 |
res = handle_exit(); |
f3cbcdc95 kconfig/lxdialog:... |
1087 |
} while (res == KEY_ESC); |
1da177e4c Linux-2.6.12-rc2 |
1088 |
|
564899f9f kconfig: handle S... |
1089 |
return res; |
1da177e4c Linux-2.6.12-rc2 |
1090 |
} |
c4143a830 kconfig: fix MAC ... |
1091 |