aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/mconf.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-10-03 11:51:38 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-03 11:51:38 -0400
commitb4a9071af62f95dc6d22040a0b37ac7225ce4d54 (patch)
treeb40a3ec798f42674f0ff62a071ff4c29348c8605 /scripts/kconfig/mconf.c
parent8b2a1fd1b394c60eaa2587716102dd5e9b4e5990 (diff)
parent99c8b9477f2b8c4f625545c41f0318570fa38894 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild
* git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild: kbuild: trivial documentation fixes kconfig: fix saving alternate kconfig file in parent dir kbuild: make modpost processing configurable kconfig/menuconfig: do not let ncurses clutter screen on exit kconfig/lxdialog: clear long menu lines kbuild: do not build mconf & lxdialog unless needed kconfig/lxdialog: fix make mrproper kconfig/lxdialog: support resize kconfig/lxdialog: let <ESC><ESC> behave as expected kconfig/menuconfig: lxdialog is now built-in kconfig/lxdialog: add a new theme bluetitle which is now default kconfig/lxdialog: add support for color themes and add blackbg theme kconfig/lxdialog: refactor color support
Diffstat (limited to 'scripts/kconfig/mconf.c')
-rw-r--r--scripts/kconfig/mconf.c511
1 files changed, 166 insertions, 345 deletions
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 7f973195e79a..08a4c7af93ea 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -24,6 +24,7 @@
24 24
25#define LKC_DIRECT_LINK 25#define LKC_DIRECT_LINK
26#include "lkc.h" 26#include "lkc.h"
27#include "lxdialog/dialog.h"
27 28
28static char menu_backtitle[128]; 29static char menu_backtitle[128];
29static const char mconf_readme[] = N_( 30static const char mconf_readme[] = N_(
@@ -159,7 +160,21 @@ static const char mconf_readme[] = N_(
159"\n" 160"\n"
160"Note that this mode can eventually be a little more CPU expensive\n" 161"Note that this mode can eventually be a little more CPU expensive\n"
161"(especially with a larger number of unrolled categories) than the\n" 162"(especially with a larger number of unrolled categories) than the\n"
162"default mode.\n"), 163"default mode.\n"
164"\n"
165"Different color themes available\n"
166"--------------------------------\n"
167"It is possible to select different color themes using the variable\n"
168"MENUCONFIG_COLOR. To select a theme use:\n"
169"\n"
170"make MENUCONFIG_COLOR=<theme> menuconfig\n"
171"\n"
172"Available themes are\n"
173" mono => selects colors suitable for monochrome displays\n"
174" blackbg => selects a color scheme with black background\n"
175" classic => theme with blue background. The classic look\n"
176" bluetitle => a LCD friendly version of classic. (default)\n"
177"\n"),
163menu_instructions[] = N_( 178menu_instructions[] = N_(
164 "Arrow keys navigate the menu. " 179 "Arrow keys navigate the menu. "
165 "<Enter> selects submenus --->. " 180 "<Enter> selects submenus --->. "
@@ -256,16 +271,12 @@ search_help[] = N_(
256 " USB$ => find all CONFIG_ symbols ending with USB\n" 271 " USB$ => find all CONFIG_ symbols ending with USB\n"
257 "\n"); 272 "\n");
258 273
259static char buf[4096], *bufptr = buf;
260static char input_buf[4096];
261static char filename[PATH_MAX+1] = ".config"; 274static char filename[PATH_MAX+1] = ".config";
262static char *args[1024], **argptr = args;
263static int indent; 275static int indent;
264static struct termios ios_org; 276static struct termios ios_org;
265static int rows = 0, cols = 0; 277static int rows = 0, cols = 0;
266static struct menu *current_menu; 278static struct menu *current_menu;
267static int child_count; 279static int child_count;
268static int do_resize;
269static int single_menu_mode; 280static int single_menu_mode;
270 281
271static void conf(struct menu *menu); 282static void conf(struct menu *menu);
@@ -276,12 +287,6 @@ static void conf_save(void);
276static void show_textbox(const char *title, const char *text, int r, int c); 287static void show_textbox(const char *title, const char *text, int r, int c);
277static void show_helptext(const char *title, const char *text); 288static void show_helptext(const char *title, const char *text);
278static void show_help(struct menu *menu); 289static void show_help(struct menu *menu);
279static void show_file(const char *filename, const char *title, int r, int c);
280
281static void cprint_init(void);
282static int cprint1(const char *fmt, ...);
283static void cprint_done(void);
284static int cprint(const char *fmt, ...);
285 290
286static void init_wsize(void) 291static void init_wsize(void)
287{ 292{
@@ -318,54 +323,6 @@ static void init_wsize(void)
318 cols -= 5; 323 cols -= 5;
319} 324}
320 325
321static void cprint_init(void)
322{
323 bufptr = buf;
324 argptr = args;
325 memset(args, 0, sizeof(args));
326 indent = 0;
327 child_count = 0;
328 cprint("./scripts/kconfig/lxdialog/lxdialog");
329 cprint("--backtitle");
330 cprint(menu_backtitle);
331}
332
333static int cprint1(const char *fmt, ...)
334{
335 va_list ap;
336 int res;
337
338 if (!*argptr)
339 *argptr = bufptr;
340 va_start(ap, fmt);
341 res = vsprintf(bufptr, fmt, ap);
342 va_end(ap);
343 bufptr += res;
344
345 return res;
346}
347
348static void cprint_done(void)
349{
350 *bufptr++ = 0;
351 argptr++;
352}
353
354static int cprint(const char *fmt, ...)
355{
356 va_list ap;
357 int res;
358
359 *argptr++ = bufptr;
360 va_start(ap, fmt);
361 res = vsprintf(bufptr, fmt, ap);
362 va_end(ap);
363 bufptr += res;
364 *bufptr++ = 0;
365
366 return res;
367}
368
369static void get_prompt_str(struct gstr *r, struct property *prop) 326static void get_prompt_str(struct gstr *r, struct property *prop)
370{ 327{
371 int i, j; 328 int i, j;
@@ -438,108 +395,17 @@ static struct gstr get_relations_str(struct symbol **sym_arr)
438 return res; 395 return res;
439} 396}
440 397
441pid_t pid;
442
443static void winch_handler(int sig)
444{
445 if (!do_resize) {
446 kill(pid, SIGINT);
447 do_resize = 1;
448 }
449}
450
451static int exec_conf(void)
452{
453 int pipefd[2], stat, size;
454 struct sigaction sa;
455 sigset_t sset, osset;
456
457 sigemptyset(&sset);
458 sigaddset(&sset, SIGINT);
459 sigprocmask(SIG_BLOCK, &sset, &osset);
460
461 signal(SIGINT, SIG_DFL);
462
463 sa.sa_handler = winch_handler;
464 sigemptyset(&sa.sa_mask);
465 sa.sa_flags = SA_RESTART;
466 sigaction(SIGWINCH, &sa, NULL);
467
468 *argptr++ = NULL;
469
470 pipe(pipefd);
471 pid = fork();
472 if (pid == 0) {
473 sigprocmask(SIG_SETMASK, &osset, NULL);
474 dup2(pipefd[1], 2);
475 close(pipefd[0]);
476 close(pipefd[1]);
477 execv(args[0], args);
478 _exit(EXIT_FAILURE);
479 }
480
481 close(pipefd[1]);
482 bufptr = input_buf;
483 while (1) {
484 size = input_buf + sizeof(input_buf) - bufptr;
485 size = read(pipefd[0], bufptr, size);
486 if (size <= 0) {
487 if (size < 0) {
488 if (errno == EINTR || errno == EAGAIN)
489 continue;
490 perror("read");
491 }
492 break;
493 }
494 bufptr += size;
495 }
496 *bufptr++ = 0;
497 close(pipefd[0]);
498 waitpid(pid, &stat, 0);
499
500 if (do_resize) {
501 init_wsize();
502 do_resize = 0;
503 sigprocmask(SIG_SETMASK, &osset, NULL);
504 return -1;
505 }
506 if (WIFSIGNALED(stat)) {
507 printf("\finterrupted(%d)\n", WTERMSIG(stat));
508 exit(1);
509 }
510#if 0
511 printf("\fexit state: %d\nexit data: '%s'\n", WEXITSTATUS(stat), input_buf);
512 sleep(1);
513#endif
514 sigpending(&sset);
515 if (sigismember(&sset, SIGINT)) {
516 printf("\finterrupted\n");
517 exit(1);
518 }
519 sigprocmask(SIG_SETMASK, &osset, NULL);
520
521 return WEXITSTATUS(stat);
522}
523
524static void search_conf(void) 398static void search_conf(void)
525{ 399{
526 struct symbol **sym_arr; 400 struct symbol **sym_arr;
527 int stat;
528 struct gstr res; 401 struct gstr res;
529 402 int dres;
530again: 403again:
531 cprint_init(); 404 dialog_clear();
532 cprint("--title"); 405 dres = dialog_inputbox(_("Search Configuration Parameter"),
533 cprint(_("Search Configuration Parameter")); 406 _("Enter CONFIG_ (sub)string to search for (omit CONFIG_)"),
534 cprint("--inputbox"); 407 10, 75, "");
535 cprint(_("Enter CONFIG_ (sub)string to search for (omit CONFIG_)")); 408 switch (dres) {
536 cprint("10");
537 cprint("75");
538 cprint("");
539 stat = exec_conf();
540 if (stat < 0)
541 goto again;
542 switch (stat) {
543 case 0: 409 case 0:
544 break; 410 break;
545 case 1: 411 case 1:
@@ -549,7 +415,7 @@ again:
549 return; 415 return;
550 } 416 }
551 417
552 sym_arr = sym_re_search(input_buf); 418 sym_arr = sym_re_search(dialog_input_result);
553 res = get_relations_str(sym_arr); 419 res = get_relations_str(sym_arr);
554 free(sym_arr); 420 free(sym_arr);
555 show_textbox(_("Search Results"), str_get(&res), 0, 0); 421 show_textbox(_("Search Results"), str_get(&res), 0, 0);
@@ -576,24 +442,24 @@ static void build_conf(struct menu *menu)
576 switch (prop->type) { 442 switch (prop->type) {
577 case P_MENU: 443 case P_MENU:
578 child_count++; 444 child_count++;
579 cprint("m%p", menu);
580
581 if (single_menu_mode) { 445 if (single_menu_mode) {
582 cprint1("%s%*c%s", 446 item_make("%s%*c%s",
583 menu->data ? "-->" : "++>", 447 menu->data ? "-->" : "++>",
584 indent + 1, ' ', prompt); 448 indent + 1, ' ', prompt);
585 } else 449 } else
586 cprint1(" %*c%s --->", indent + 1, ' ', prompt); 450 item_make(" %*c%s --->", indent + 1, ' ', prompt);
587 451
588 cprint_done(); 452 item_set_tag('m');
453 item_set_data(menu);
589 if (single_menu_mode && menu->data) 454 if (single_menu_mode && menu->data)
590 goto conf_childs; 455 goto conf_childs;
591 return; 456 return;
592 default: 457 default:
593 if (prompt) { 458 if (prompt) {
594 child_count++; 459 child_count++;
595 cprint(":%p", menu); 460 item_make("---%*c%s", indent + 1, ' ', prompt);
596 cprint("---%*c%s", indent + 1, ' ', prompt); 461 item_set_tag(':');
462 item_set_data(menu);
597 } 463 }
598 } 464 }
599 } else 465 } else
@@ -614,10 +480,9 @@ static void build_conf(struct menu *menu)
614 480
615 val = sym_get_tristate_value(sym); 481 val = sym_get_tristate_value(sym);
616 if (sym_is_changable(sym)) { 482 if (sym_is_changable(sym)) {
617 cprint("t%p", menu);
618 switch (type) { 483 switch (type) {
619 case S_BOOLEAN: 484 case S_BOOLEAN:
620 cprint1("[%c]", val == no ? ' ' : '*'); 485 item_make("[%c]", val == no ? ' ' : '*');
621 break; 486 break;
622 case S_TRISTATE: 487 case S_TRISTATE:
623 switch (val) { 488 switch (val) {
@@ -625,84 +490,87 @@ static void build_conf(struct menu *menu)
625 case mod: ch = 'M'; break; 490 case mod: ch = 'M'; break;
626 default: ch = ' '; break; 491 default: ch = ' '; break;
627 } 492 }
628 cprint1("<%c>", ch); 493 item_make("<%c>", ch);
629 break; 494 break;
630 } 495 }
496 item_set_tag('t');
497 item_set_data(menu);
631 } else { 498 } else {
632 cprint("%c%p", def_menu ? 't' : ':', menu); 499 item_make(" ");
633 cprint1(" "); 500 item_set_tag(def_menu ? 't' : ':');
501 item_set_data(menu);
634 } 502 }
635 503
636 cprint1("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); 504 item_add_str("%*c%s", indent + 1, ' ', menu_get_prompt(menu));
637 if (val == yes) { 505 if (val == yes) {
638 if (def_menu) { 506 if (def_menu) {
639 cprint1(" (%s)", menu_get_prompt(def_menu)); 507 item_add_str(" (%s)", menu_get_prompt(def_menu));
640 cprint1(" --->"); 508 item_add_str(" --->");
641 cprint_done();
642 if (def_menu->list) { 509 if (def_menu->list) {
643 indent += 2; 510 indent += 2;
644 build_conf(def_menu); 511 build_conf(def_menu);
645 indent -= 2; 512 indent -= 2;
646 } 513 }
647 } else 514 }
648 cprint_done();
649 return; 515 return;
650 } 516 }
651 cprint_done();
652 } else { 517 } else {
653 if (menu == current_menu) { 518 if (menu == current_menu) {
654 cprint(":%p", menu); 519 item_make("---%*c%s", indent + 1, ' ', menu_get_prompt(menu));
655 cprint("---%*c%s", indent + 1, ' ', menu_get_prompt(menu)); 520 item_set_tag(':');
521 item_set_data(menu);
656 goto conf_childs; 522 goto conf_childs;
657 } 523 }
658 child_count++; 524 child_count++;
659 val = sym_get_tristate_value(sym); 525 val = sym_get_tristate_value(sym);
660 if (sym_is_choice_value(sym) && val == yes) { 526 if (sym_is_choice_value(sym) && val == yes) {
661 cprint(":%p", menu); 527 item_make(" ");
662 cprint1(" "); 528 item_set_tag(':');
529 item_set_data(menu);
663 } else { 530 } else {
664 switch (type) { 531 switch (type) {
665 case S_BOOLEAN: 532 case S_BOOLEAN:
666 cprint("t%p", menu);
667 if (sym_is_changable(sym)) 533 if (sym_is_changable(sym))
668 cprint1("[%c]", val == no ? ' ' : '*'); 534 item_make("[%c]", val == no ? ' ' : '*');
669 else 535 else
670 cprint1("---"); 536 item_make("---");
537 item_set_tag('t');
538 item_set_data(menu);
671 break; 539 break;
672 case S_TRISTATE: 540 case S_TRISTATE:
673 cprint("t%p", menu);
674 switch (val) { 541 switch (val) {
675 case yes: ch = '*'; break; 542 case yes: ch = '*'; break;
676 case mod: ch = 'M'; break; 543 case mod: ch = 'M'; break;
677 default: ch = ' '; break; 544 default: ch = ' '; break;
678 } 545 }
679 if (sym_is_changable(sym)) 546 if (sym_is_changable(sym))
680 cprint1("<%c>", ch); 547 item_make("<%c>", ch);
681 else 548 else
682 cprint1("---"); 549 item_make("---");
550 item_set_tag('t');
551 item_set_data(menu);
683 break; 552 break;
684 default: 553 default:
685 cprint("s%p", menu); 554 tmp = 2 + strlen(sym_get_string_value(sym)); /* () = 2 */
686 tmp = cprint1("(%s)", sym_get_string_value(sym)); 555 item_make("(%s)", sym_get_string_value(sym));
687 tmp = indent - tmp + 4; 556 tmp = indent - tmp + 4;
688 if (tmp < 0) 557 if (tmp < 0)
689 tmp = 0; 558 tmp = 0;
690 cprint1("%*c%s%s", tmp, ' ', menu_get_prompt(menu), 559 item_add_str("%*c%s%s", tmp, ' ', menu_get_prompt(menu),
691 (sym_has_value(sym) || !sym_is_changable(sym)) ? 560 (sym_has_value(sym) || !sym_is_changable(sym)) ?
692 "" : " (NEW)"); 561 "" : " (NEW)");
693 cprint_done(); 562 item_set_tag('s');
563 item_set_data(menu);
694 goto conf_childs; 564 goto conf_childs;
695 } 565 }
696 } 566 }
697 cprint1("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), 567 item_add_str("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu),
698 (sym_has_value(sym) || !sym_is_changable(sym)) ? 568 (sym_has_value(sym) || !sym_is_changable(sym)) ?
699 "" : " (NEW)"); 569 "" : " (NEW)");
700 if (menu->prompt->type == P_MENU) { 570 if (menu->prompt->type == P_MENU) {
701 cprint1(" --->"); 571 item_add_str(" --->");
702 cprint_done();
703 return; 572 return;
704 } 573 }
705 cprint_done();
706 } 574 }
707 575
708conf_childs: 576conf_childs:
@@ -717,59 +585,45 @@ static void conf(struct menu *menu)
717 struct menu *submenu; 585 struct menu *submenu;
718 const char *prompt = menu_get_prompt(menu); 586 const char *prompt = menu_get_prompt(menu);
719 struct symbol *sym; 587 struct symbol *sym;
720 char active_entry[40]; 588 struct menu *active_menu = NULL;
721 int stat, type, i; 589 int res;
590 int s_scroll = 0;
722 591
723 unlink("lxdialog.scrltmp");
724 active_entry[0] = 0;
725 while (1) { 592 while (1) {
726 cprint_init(); 593 item_reset();
727 cprint("--title");
728 cprint("%s", prompt ? prompt : _("Main Menu"));
729 cprint("--menu");
730 cprint(_(menu_instructions));
731 cprint("%d", rows);
732 cprint("%d", cols);
733 cprint("%d", rows - 10);
734 cprint("%s", active_entry);
735 current_menu = menu; 594 current_menu = menu;
736 build_conf(menu); 595 build_conf(menu);
737 if (!child_count) 596 if (!child_count)
738 break; 597 break;
739 if (menu == &rootmenu) { 598 if (menu == &rootmenu) {
740 cprint(":"); 599 item_make("--- ");
741 cprint("--- "); 600 item_set_tag(':');
742 cprint("L"); 601 item_make(_(" Load an Alternate Configuration File"));
743 cprint(_(" Load an Alternate Configuration File")); 602 item_set_tag('L');
744 cprint("S"); 603 item_make(_(" Save an Alternate Configuration File"));
745 cprint(_(" Save Configuration to an Alternate File")); 604 item_set_tag('S');
746 } 605 }
747 stat = exec_conf(); 606 dialog_clear();
748 if (stat < 0) 607 res = dialog_menu(prompt ? prompt : _("Main Menu"),
749 continue; 608 _(menu_instructions),
750 609 active_menu, &s_scroll);
751 if (stat == 1 || stat == 255) 610 if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL)
752 break; 611 break;
753 612 if (!item_activate_selected())
754 type = input_buf[0]; 613 continue;
755 if (!type) 614 if (!item_tag())
756 continue; 615 continue;
757 616
758 for (i = 0; input_buf[i] && !isspace(input_buf[i]); i++) 617 submenu = item_data();
759 ; 618 active_menu = item_data();
760 if (i >= sizeof(active_entry)) 619 if (submenu)
761 i = sizeof(active_entry) - 1;
762 input_buf[i] = 0;
763 strcpy(active_entry, input_buf);
764
765 sym = NULL;
766 submenu = NULL;
767 if (sscanf(input_buf + 1, "%p", &submenu) == 1)
768 sym = submenu->sym; 620 sym = submenu->sym;
621 else
622 sym = NULL;
769 623
770 switch (stat) { 624 switch (res) {
771 case 0: 625 case 0:
772 switch (type) { 626 switch (item_tag()) {
773 case 'm': 627 case 'm':
774 if (single_menu_mode) 628 if (single_menu_mode)
775 submenu->data = (void *) (long) !submenu->data; 629 submenu->data = (void *) (long) !submenu->data;
@@ -800,7 +654,7 @@ static void conf(struct menu *menu)
800 show_helptext("README", _(mconf_readme)); 654 show_helptext("README", _(mconf_readme));
801 break; 655 break;
802 case 3: 656 case 3:
803 if (type == 't') { 657 if (item_is_tag('t')) {
804 if (sym_set_tristate_value(sym, yes)) 658 if (sym_set_tristate_value(sym, yes))
805 break; 659 break;
806 if (sym_set_tristate_value(sym, mod)) 660 if (sym_set_tristate_value(sym, mod))
@@ -808,17 +662,17 @@ static void conf(struct menu *menu)
808 } 662 }
809 break; 663 break;
810 case 4: 664 case 4:
811 if (type == 't') 665 if (item_is_tag('t'))
812 sym_set_tristate_value(sym, no); 666 sym_set_tristate_value(sym, no);
813 break; 667 break;
814 case 5: 668 case 5:
815 if (type == 't') 669 if (item_is_tag('t'))
816 sym_set_tristate_value(sym, mod); 670 sym_set_tristate_value(sym, mod);
817 break; 671 break;
818 case 6: 672 case 6:
819 if (type == 't') 673 if (item_is_tag('t'))
820 sym_toggle_tristate_value(sym); 674 sym_toggle_tristate_value(sym);
821 else if (type == 'm') 675 else if (item_is_tag('m'))
822 conf(submenu); 676 conf(submenu);
823 break; 677 break;
824 case 7: 678 case 7:
@@ -830,13 +684,8 @@ static void conf(struct menu *menu)
830 684
831static void show_textbox(const char *title, const char *text, int r, int c) 685static void show_textbox(const char *title, const char *text, int r, int c)
832{ 686{
833 int fd; 687 dialog_clear();
834 688 dialog_textbox(title, text, r, c);
835 fd = creat(".help.tmp", 0777);
836 write(fd, text, strlen(text));
837 close(fd);
838 show_file(".help.tmp", title, r, c);
839 unlink(".help.tmp");
840} 689}
841 690
842static void show_helptext(const char *title, const char *text) 691static void show_helptext(const char *title, const char *text)
@@ -864,68 +713,52 @@ static void show_help(struct menu *menu)
864 str_free(&help); 713 str_free(&help);
865} 714}
866 715
867static void show_file(const char *filename, const char *title, int r, int c)
868{
869 do {
870 cprint_init();
871 if (title) {
872 cprint("--title");
873 cprint("%s", title);
874 }
875 cprint("--textbox");
876 cprint("%s", filename);
877 cprint("%d", r ? r : rows);
878 cprint("%d", c ? c : cols);
879 } while (exec_conf() < 0);
880}
881
882static void conf_choice(struct menu *menu) 716static void conf_choice(struct menu *menu)
883{ 717{
884 const char *prompt = menu_get_prompt(menu); 718 const char *prompt = menu_get_prompt(menu);
885 struct menu *child; 719 struct menu *child;
886 struct symbol *active; 720 struct symbol *active;
887 int stat;
888 721
889 active = sym_get_choice_value(menu->sym); 722 active = sym_get_choice_value(menu->sym);
890 while (1) { 723 while (1) {
891 cprint_init(); 724 int res;
892 cprint("--title"); 725 int selected;
893 cprint("%s", prompt ? prompt : _("Main Menu")); 726 item_reset();
894 cprint("--radiolist");
895 cprint(_(radiolist_instructions));
896 cprint("15");
897 cprint("70");
898 cprint("6");
899 727
900 current_menu = menu; 728 current_menu = menu;
901 for (child = menu->list; child; child = child->next) { 729 for (child = menu->list; child; child = child->next) {
902 if (!menu_is_visible(child)) 730 if (!menu_is_visible(child))
903 continue; 731 continue;
904 cprint("%p", child); 732 item_make("%s", menu_get_prompt(child));
905 cprint("%s", menu_get_prompt(child)); 733 item_set_data(child);
734 if (child->sym == active)
735 item_set_selected(1);
906 if (child->sym == sym_get_choice_value(menu->sym)) 736 if (child->sym == sym_get_choice_value(menu->sym))
907 cprint("ON"); 737 item_set_tag('X');
908 else if (child->sym == active)
909 cprint("SELECTED");
910 else
911 cprint("OFF");
912 } 738 }
913 739 dialog_clear();
914 stat = exec_conf(); 740 res = dialog_checklist(prompt ? prompt : _("Main Menu"),
915 switch (stat) { 741 _(radiolist_instructions),
742 15, 70, 6);
743 selected = item_activate_selected();
744 switch (res) {
916 case 0: 745 case 0:
917 if (sscanf(input_buf, "%p", &child) != 1) 746 if (selected) {
918 break; 747 child = item_data();
919 sym_set_tristate_value(child->sym, yes); 748 sym_set_tristate_value(child->sym, yes);
749 }
920 return; 750 return;
921 case 1: 751 case 1:
922 if (sscanf(input_buf, "%p", &child) == 1) { 752 if (selected) {
753 child = item_data();
923 show_help(child); 754 show_help(child);
924 active = child->sym; 755 active = child->sym;
925 } else 756 } else
926 show_help(menu); 757 show_help(menu);
927 break; 758 break;
928 case 255: 759 case KEY_ESC:
760 return;
761 case -ERRDISPLAYTOOSMALL:
929 return; 762 return;
930 } 763 }
931 } 764 }
@@ -934,40 +767,38 @@ static void conf_choice(struct menu *menu)
934static void conf_string(struct menu *menu) 767static void conf_string(struct menu *menu)
935{ 768{
936 const char *prompt = menu_get_prompt(menu); 769 const char *prompt = menu_get_prompt(menu);
937 int stat;
938 770
939 while (1) { 771 while (1) {
940 cprint_init(); 772 int res;
941 cprint("--title"); 773 char *heading;
942 cprint("%s", prompt ? prompt : _("Main Menu")); 774
943 cprint("--inputbox");
944 switch (sym_get_type(menu->sym)) { 775 switch (sym_get_type(menu->sym)) {
945 case S_INT: 776 case S_INT:
946 cprint(_(inputbox_instructions_int)); 777 heading = _(inputbox_instructions_int);
947 break; 778 break;
948 case S_HEX: 779 case S_HEX:
949 cprint(_(inputbox_instructions_hex)); 780 heading = _(inputbox_instructions_hex);
950 break; 781 break;
951 case S_STRING: 782 case S_STRING:
952 cprint(_(inputbox_instructions_string)); 783 heading = _(inputbox_instructions_string);
953 break; 784 break;
954 default: 785 default:
955 /* panic? */; 786 heading = "Internal mconf error!";
956 } 787 }
957 cprint("10"); 788 dialog_clear();
958 cprint("75"); 789 res = dialog_inputbox(prompt ? prompt : _("Main Menu"),
959 cprint("%s", sym_get_string_value(menu->sym)); 790 heading, 10, 75,
960 stat = exec_conf(); 791 sym_get_string_value(menu->sym));
961 switch (stat) { 792 switch (res) {
962 case 0: 793 case 0:
963 if (sym_set_string_value(menu->sym, input_buf)) 794 if (sym_set_string_value(menu->sym, dialog_input_result))
964 return; 795 return;
965 show_textbox(NULL, _("You have made an invalid entry."), 5, 43); 796 show_textbox(NULL, _("You have made an invalid entry."), 5, 43);
966 break; 797 break;
967 case 1: 798 case 1:
968 show_help(menu); 799 show_help(menu);
969 break; 800 break;
970 case 255: 801 case KEY_ESC:
971 return; 802 return;
972 } 803 }
973 } 804 }
@@ -975,28 +806,24 @@ static void conf_string(struct menu *menu)
975 806
976static void conf_load(void) 807static void conf_load(void)
977{ 808{
978 int stat;
979 809
980 while (1) { 810 while (1) {
981 cprint_init(); 811 int res;
982 cprint("--inputbox"); 812 dialog_clear();
983 cprint(load_config_text); 813 res = dialog_inputbox(NULL, load_config_text,
984 cprint("11"); 814 11, 55, filename);
985 cprint("55"); 815 switch(res) {
986 cprint("%s", filename);
987 stat = exec_conf();
988 switch(stat) {
989 case 0: 816 case 0:
990 if (!input_buf[0]) 817 if (!dialog_input_result[0])
991 return; 818 return;
992 if (!conf_read(input_buf)) 819 if (!conf_read(dialog_input_result))
993 return; 820 return;
994 show_textbox(NULL, _("File does not exist!"), 5, 38); 821 show_textbox(NULL, _("File does not exist!"), 5, 38);
995 break; 822 break;
996 case 1: 823 case 1:
997 show_helptext(_("Load Alternate Configuration"), load_config_help); 824 show_helptext(_("Load Alternate Configuration"), load_config_help);
998 break; 825 break;
999 case 255: 826 case KEY_ESC:
1000 return; 827 return;
1001 } 828 }
1002 } 829 }
@@ -1004,28 +831,23 @@ static void conf_load(void)
1004 831
1005static void conf_save(void) 832static void conf_save(void)
1006{ 833{
1007 int stat;
1008
1009 while (1) { 834 while (1) {
1010 cprint_init(); 835 int res;
1011 cprint("--inputbox"); 836 dialog_clear();
1012 cprint(save_config_text); 837 res = dialog_inputbox(NULL, save_config_text,
1013 cprint("11"); 838 11, 55, filename);
1014 cprint("55"); 839 switch(res) {
1015 cprint("%s", filename);
1016 stat = exec_conf();
1017 switch(stat) {
1018 case 0: 840 case 0:
1019 if (!input_buf[0]) 841 if (!dialog_input_result[0])
1020 return; 842 return;
1021 if (!conf_write(input_buf)) 843 if (!conf_write(dialog_input_result))
1022 return; 844 return;
1023 show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60); 845 show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60);
1024 break; 846 break;
1025 case 1: 847 case 1:
1026 show_helptext(_("Save Alternate Configuration"), save_config_help); 848 show_helptext(_("Save Alternate Configuration"), save_config_help);
1027 break; 849 break;
1028 case 255: 850 case KEY_ESC:
1029 return; 851 return;
1030 } 852 }
1031 } 853 }
@@ -1034,15 +856,13 @@ static void conf_save(void)
1034static void conf_cleanup(void) 856static void conf_cleanup(void)
1035{ 857{
1036 tcsetattr(1, TCSAFLUSH, &ios_org); 858 tcsetattr(1, TCSAFLUSH, &ios_org);
1037 unlink(".help.tmp");
1038 unlink("lxdialog.scrltmp");
1039} 859}
1040 860
1041int main(int ac, char **av) 861int main(int ac, char **av)
1042{ 862{
1043 struct symbol *sym; 863 struct symbol *sym;
1044 char *mode; 864 char *mode;
1045 int stat; 865 int res;
1046 866
1047 setlocale(LC_ALL, ""); 867 setlocale(LC_ALL, "");
1048 bindtextdomain(PACKAGE, LOCALEDIR); 868 bindtextdomain(PACKAGE, LOCALEDIR);
@@ -1065,18 +885,19 @@ int main(int ac, char **av)
1065 tcgetattr(1, &ios_org); 885 tcgetattr(1, &ios_org);
1066 atexit(conf_cleanup); 886 atexit(conf_cleanup);
1067 init_wsize(); 887 init_wsize();
1068 conf(&rootmenu); 888 reset_dialog();
1069 889 init_dialog(menu_backtitle);
1070 do { 890 do {
1071 cprint_init(); 891 conf(&rootmenu);
1072 cprint("--yesno"); 892 dialog_clear();
1073 cprint(_("Do you wish to save your new kernel configuration?")); 893 res = dialog_yesno(NULL,
1074 cprint("5"); 894 _("Do you wish to save your "
1075 cprint("60"); 895 "new kernel configuration?\n"
1076 stat = exec_conf(); 896 "<ESC><ESC> to continue."),
1077 } while (stat < 0); 897 6, 60);
1078 898 } while (res == KEY_ESC);
1079 if (stat == 0) { 899 end_dialog();
900 if (res == 0) {
1080 if (conf_write(NULL)) { 901 if (conf_write(NULL)) {
1081 fprintf(stderr, _("\n\n" 902 fprintf(stderr, _("\n\n"
1082 "Error during writing of the kernel configuration.\n" 903 "Error during writing of the kernel configuration.\n"