aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/mconf.c
diff options
context:
space:
mode:
authorSam Ravnborg <sam@mars.ravnborg.org>2006-07-27 16:10:27 -0400
committerSam Ravnborg <sam@neptun.ravnborg.org>2006-09-30 05:19:19 -0400
commit2982de6993e6d9944f2215d7cb9b558b465a0c99 (patch)
tree3b4765905e7c53e2a03ed599692d2636623e22a5 /scripts/kconfig/mconf.c
parent350b5b76384e77bcc58217f00455fdbec5cac594 (diff)
kconfig/menuconfig: lxdialog is now built-in
lxdialog was previously called as an external program causing screen to flicker when used. With this patch lxdialog is now built-in. It is loosly based om previous work by: Petr Baudis <pasky@ucw.cz> Following is a list of changes: o Moved build of dialog routings to kconfig Makefile o menubox + checklist uses a new item list to hold all menu items o in util.c implmented helper function to deal with item list o menubox now uses parameters to save scroll state (avoids temp file) o textbox now get text to be displayed as parameter and not a file o make sure to properly delete subwin's before main windows o killed unused files: lxdialog.c msgbox.c o modified return value for ESC to match direct calling o in a few places the code has been adjusted to 80 char wide o in textbox a small refactoring was made to make code remotely readable o in mconf removed all unused stuff (functions/variables) Following is a list of know short comings: a) pressing ESC twice will be interpreted as two ESC presses b) resize does not work. menuconfig needs to be restarted to be adjusted Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/kconfig/mconf.c')
-rw-r--r--scripts/kconfig/mconf.c482
1 files changed, 141 insertions, 341 deletions
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 59926739d169..b1ad9a00ab19 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_(
@@ -270,16 +271,12 @@ search_help[] = N_(
270 " USB$ => find all CONFIG_ symbols ending with USB\n" 271 " USB$ => find all CONFIG_ symbols ending with USB\n"
271 "\n"); 272 "\n");
272 273
273static char buf[4096], *bufptr = buf;
274static char input_buf[4096];
275static char filename[PATH_MAX+1] = ".config"; 274static char filename[PATH_MAX+1] = ".config";
276static char *args[1024], **argptr = args;
277static int indent; 275static int indent;
278static struct termios ios_org; 276static struct termios ios_org;
279static int rows = 0, cols = 0; 277static int rows = 0, cols = 0;
280static struct menu *current_menu; 278static struct menu *current_menu;
281static int child_count; 279static int child_count;
282static int do_resize;
283static int single_menu_mode; 280static int single_menu_mode;
284 281
285static void conf(struct menu *menu); 282static void conf(struct menu *menu);
@@ -290,12 +287,6 @@ static void conf_save(void);
290static 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);
291static void show_helptext(const char *title, const char *text); 288static void show_helptext(const char *title, const char *text);
292static void show_help(struct menu *menu); 289static void show_help(struct menu *menu);
293static void show_file(const char *filename, const char *title, int r, int c);
294
295static void cprint_init(void);
296static int cprint1(const char *fmt, ...);
297static void cprint_done(void);
298static int cprint(const char *fmt, ...);
299 290
300static void init_wsize(void) 291static void init_wsize(void)
301{ 292{
@@ -332,54 +323,6 @@ static void init_wsize(void)
332 cols -= 5; 323 cols -= 5;
333} 324}
334 325
335static void cprint_init(void)
336{
337 bufptr = buf;
338 argptr = args;
339 memset(args, 0, sizeof(args));
340 indent = 0;
341 child_count = 0;
342 cprint("./scripts/kconfig/lxdialog/lxdialog");
343 cprint("--backtitle");
344 cprint(menu_backtitle);
345}
346
347static int cprint1(const char *fmt, ...)
348{
349 va_list ap;
350 int res;
351
352 if (!*argptr)
353 *argptr = bufptr;
354 va_start(ap, fmt);
355 res = vsprintf(bufptr, fmt, ap);
356 va_end(ap);
357 bufptr += res;
358
359 return res;
360}
361
362static void cprint_done(void)
363{
364 *bufptr++ = 0;
365 argptr++;
366}
367
368static int cprint(const char *fmt, ...)
369{
370 va_list ap;
371 int res;
372
373 *argptr++ = bufptr;
374 va_start(ap, fmt);
375 res = vsprintf(bufptr, fmt, ap);
376 va_end(ap);
377 bufptr += res;
378 *bufptr++ = 0;
379
380 return res;
381}
382
383static void get_prompt_str(struct gstr *r, struct property *prop) 326static void get_prompt_str(struct gstr *r, struct property *prop)
384{ 327{
385 int i, j; 328 int i, j;
@@ -452,108 +395,17 @@ static struct gstr get_relations_str(struct symbol **sym_arr)
452 return res; 395 return res;
453} 396}
454 397
455pid_t pid;
456
457static void winch_handler(int sig)
458{
459 if (!do_resize) {
460 kill(pid, SIGINT);
461 do_resize = 1;
462 }
463}
464
465static int exec_conf(void)
466{
467 int pipefd[2], stat, size;
468 struct sigaction sa;
469 sigset_t sset, osset;
470
471 sigemptyset(&sset);
472 sigaddset(&sset, SIGINT);
473 sigprocmask(SIG_BLOCK, &sset, &osset);
474
475 signal(SIGINT, SIG_DFL);
476
477 sa.sa_handler = winch_handler;
478 sigemptyset(&sa.sa_mask);
479 sa.sa_flags = SA_RESTART;
480 sigaction(SIGWINCH, &sa, NULL);
481
482 *argptr++ = NULL;
483
484 pipe(pipefd);
485 pid = fork();
486 if (pid == 0) {
487 sigprocmask(SIG_SETMASK, &osset, NULL);
488 dup2(pipefd[1], 2);
489 close(pipefd[0]);
490 close(pipefd[1]);
491 execv(args[0], args);
492 _exit(EXIT_FAILURE);
493 }
494
495 close(pipefd[1]);
496 bufptr = input_buf;
497 while (1) {
498 size = input_buf + sizeof(input_buf) - bufptr;
499 size = read(pipefd[0], bufptr, size);
500 if (size <= 0) {
501 if (size < 0) {
502 if (errno == EINTR || errno == EAGAIN)
503 continue;
504 perror("read");
505 }
506 break;
507 }
508 bufptr += size;
509 }
510 *bufptr++ = 0;
511 close(pipefd[0]);
512 waitpid(pid, &stat, 0);
513
514 if (do_resize) {
515 init_wsize();
516 do_resize = 0;
517 sigprocmask(SIG_SETMASK, &osset, NULL);
518 return -1;
519 }
520 if (WIFSIGNALED(stat)) {
521 printf("\finterrupted(%d)\n", WTERMSIG(stat));
522 exit(1);
523 }
524#if 0
525 printf("\fexit state: %d\nexit data: '%s'\n", WEXITSTATUS(stat), input_buf);
526 sleep(1);
527#endif
528 sigpending(&sset);
529 if (sigismember(&sset, SIGINT)) {
530 printf("\finterrupted\n");
531 exit(1);
532 }
533 sigprocmask(SIG_SETMASK, &osset, NULL);
534
535 return WEXITSTATUS(stat);
536}
537
538static void search_conf(void) 398static void search_conf(void)
539{ 399{
540 struct symbol **sym_arr; 400 struct symbol **sym_arr;
541 int stat;
542 struct gstr res; 401 struct gstr res;
543 402 int dres;
544again: 403again:
545 cprint_init(); 404 reset_dialog();
546 cprint("--title"); 405 dres = dialog_inputbox(_("Search Configuration Parameter"),
547 cprint(_("Search Configuration Parameter")); 406 _("Enter CONFIG_ (sub)string to search for (omit CONFIG_)"),
548 cprint("--inputbox"); 407 10, 75, "");
549 cprint(_("Enter CONFIG_ (sub)string to search for (omit CONFIG_)")); 408 switch (dres) {
550 cprint("10");
551 cprint("75");
552 cprint("");
553 stat = exec_conf();
554 if (stat < 0)
555 goto again;
556 switch (stat) {
557 case 0: 409 case 0:
558 break; 410 break;
559 case 1: 411 case 1:
@@ -563,7 +415,7 @@ again:
563 return; 415 return;
564 } 416 }
565 417
566 sym_arr = sym_re_search(input_buf); 418 sym_arr = sym_re_search(dialog_input_result);
567 res = get_relations_str(sym_arr); 419 res = get_relations_str(sym_arr);
568 free(sym_arr); 420 free(sym_arr);
569 show_textbox(_("Search Results"), str_get(&res), 0, 0); 421 show_textbox(_("Search Results"), str_get(&res), 0, 0);
@@ -590,24 +442,24 @@ static void build_conf(struct menu *menu)
590 switch (prop->type) { 442 switch (prop->type) {
591 case P_MENU: 443 case P_MENU:
592 child_count++; 444 child_count++;
593 cprint("m%p", menu);
594
595 if (single_menu_mode) { 445 if (single_menu_mode) {
596 cprint1("%s%*c%s", 446 item_make("%s%*c%s",
597 menu->data ? "-->" : "++>", 447 menu->data ? "-->" : "++>",
598 indent + 1, ' ', prompt); 448 indent + 1, ' ', prompt);
599 } else 449 } else
600 cprint1(" %*c%s --->", indent + 1, ' ', prompt); 450 item_make(" %*c%s --->", indent + 1, ' ', prompt);
601 451
602 cprint_done(); 452 item_set_tag('m');
453 item_set_data(menu);
603 if (single_menu_mode && menu->data) 454 if (single_menu_mode && menu->data)
604 goto conf_childs; 455 goto conf_childs;
605 return; 456 return;
606 default: 457 default:
607 if (prompt) { 458 if (prompt) {
608 child_count++; 459 child_count++;
609 cprint(":%p", menu); 460 item_make("---%*c%s", indent + 1, ' ', prompt);
610 cprint("---%*c%s", indent + 1, ' ', prompt); 461 item_set_tag(':');
462 item_set_data(menu);
611 } 463 }
612 } 464 }
613 } else 465 } else
@@ -628,10 +480,9 @@ static void build_conf(struct menu *menu)
628 480
629 val = sym_get_tristate_value(sym); 481 val = sym_get_tristate_value(sym);
630 if (sym_is_changable(sym)) { 482 if (sym_is_changable(sym)) {
631 cprint("t%p", menu);
632 switch (type) { 483 switch (type) {
633 case S_BOOLEAN: 484 case S_BOOLEAN:
634 cprint1("[%c]", val == no ? ' ' : '*'); 485 item_make("[%c]", val == no ? ' ' : '*');
635 break; 486 break;
636 case S_TRISTATE: 487 case S_TRISTATE:
637 switch (val) { 488 switch (val) {
@@ -639,84 +490,87 @@ static void build_conf(struct menu *menu)
639 case mod: ch = 'M'; break; 490 case mod: ch = 'M'; break;
640 default: ch = ' '; break; 491 default: ch = ' '; break;
641 } 492 }
642 cprint1("<%c>", ch); 493 item_make("<%c>", ch);
643 break; 494 break;
644 } 495 }
496 item_set_tag('t');
497 item_set_data(menu);
645 } else { 498 } else {
646 cprint("%c%p", def_menu ? 't' : ':', menu); 499 item_make(" ");
647 cprint1(" "); 500 item_set_tag(def_menu ? 't' : ':');
501 item_set_data(menu);
648 } 502 }
649 503
650 cprint1("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); 504 item_add_str("%*c%s", indent + 1, ' ', menu_get_prompt(menu));
651 if (val == yes) { 505 if (val == yes) {
652 if (def_menu) { 506 if (def_menu) {
653 cprint1(" (%s)", menu_get_prompt(def_menu)); 507 item_add_str(" (%s)", menu_get_prompt(def_menu));
654 cprint1(" --->"); 508 item_add_str(" --->");
655 cprint_done();
656 if (def_menu->list) { 509 if (def_menu->list) {
657 indent += 2; 510 indent += 2;
658 build_conf(def_menu); 511 build_conf(def_menu);
659 indent -= 2; 512 indent -= 2;
660 } 513 }
661 } else 514 }
662 cprint_done();
663 return; 515 return;
664 } 516 }
665 cprint_done();
666 } else { 517 } else {
667 if (menu == current_menu) { 518 if (menu == current_menu) {
668 cprint(":%p", menu); 519 item_make("---%*c%s", indent + 1, ' ', menu_get_prompt(menu));
669 cprint("---%*c%s", indent + 1, ' ', menu_get_prompt(menu)); 520 item_set_tag(':');
521 item_set_data(menu);
670 goto conf_childs; 522 goto conf_childs;
671 } 523 }
672 child_count++; 524 child_count++;
673 val = sym_get_tristate_value(sym); 525 val = sym_get_tristate_value(sym);
674 if (sym_is_choice_value(sym) && val == yes) { 526 if (sym_is_choice_value(sym) && val == yes) {
675 cprint(":%p", menu); 527 item_make(" ");
676 cprint1(" "); 528 item_set_tag(':');
529 item_set_data(menu);
677 } else { 530 } else {
678 switch (type) { 531 switch (type) {
679 case S_BOOLEAN: 532 case S_BOOLEAN:
680 cprint("t%p", menu);
681 if (sym_is_changable(sym)) 533 if (sym_is_changable(sym))
682 cprint1("[%c]", val == no ? ' ' : '*'); 534 item_make("[%c]", val == no ? ' ' : '*');
683 else 535 else
684 cprint1("---"); 536 item_make("---");
537 item_set_tag('t');
538 item_set_data(menu);
685 break; 539 break;
686 case S_TRISTATE: 540 case S_TRISTATE:
687 cprint("t%p", menu);
688 switch (val) { 541 switch (val) {
689 case yes: ch = '*'; break; 542 case yes: ch = '*'; break;
690 case mod: ch = 'M'; break; 543 case mod: ch = 'M'; break;
691 default: ch = ' '; break; 544 default: ch = ' '; break;
692 } 545 }
693 if (sym_is_changable(sym)) 546 if (sym_is_changable(sym))
694 cprint1("<%c>", ch); 547 item_make("<%c>", ch);
695 else 548 else
696 cprint1("---"); 549 item_make("---");
550 item_set_tag('t');
551 item_set_data(menu);
697 break; 552 break;
698 default: 553 default:
699 cprint("s%p", menu); 554 tmp = 2 + strlen(sym_get_string_value(sym)); /* () = 2 */
700 tmp = cprint1("(%s)", sym_get_string_value(sym)); 555 item_make("(%s)", sym_get_string_value(sym));
701 tmp = indent - tmp + 4; 556 tmp = indent - tmp + 4;
702 if (tmp < 0) 557 if (tmp < 0)
703 tmp = 0; 558 tmp = 0;
704 cprint1("%*c%s%s", tmp, ' ', menu_get_prompt(menu), 559 item_add_str("%*c%s%s", tmp, ' ', menu_get_prompt(menu),
705 (sym_has_value(sym) || !sym_is_changable(sym)) ? 560 (sym_has_value(sym) || !sym_is_changable(sym)) ?
706 "" : " (NEW)"); 561 "" : " (NEW)");
707 cprint_done(); 562 item_set_tag('s');
563 item_set_data(menu);
708 goto conf_childs; 564 goto conf_childs;
709 } 565 }
710 } 566 }
711 cprint1("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), 567 item_add_str("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu),
712 (sym_has_value(sym) || !sym_is_changable(sym)) ? 568 (sym_has_value(sym) || !sym_is_changable(sym)) ?
713 "" : " (NEW)"); 569 "" : " (NEW)");
714 if (menu->prompt->type == P_MENU) { 570 if (menu->prompt->type == P_MENU) {
715 cprint1(" --->"); 571 item_add_str(" --->");
716 cprint_done();
717 return; 572 return;
718 } 573 }
719 cprint_done();
720 } 574 }
721 575
722conf_childs: 576conf_childs:
@@ -731,59 +585,43 @@ static void conf(struct menu *menu)
731 struct menu *submenu; 585 struct menu *submenu;
732 const char *prompt = menu_get_prompt(menu); 586 const char *prompt = menu_get_prompt(menu);
733 struct symbol *sym; 587 struct symbol *sym;
734 char active_entry[40]; 588 struct menu *active_menu = NULL;
735 int stat, type, i; 589 int res;
590 int s_scroll = 0;
736 591
737 unlink("lxdialog.scrltmp");
738 active_entry[0] = 0;
739 while (1) { 592 while (1) {
740 cprint_init(); 593 item_reset();
741 cprint("--title");
742 cprint("%s", prompt ? prompt : _("Main Menu"));
743 cprint("--menu");
744 cprint(_(menu_instructions));
745 cprint("%d", rows);
746 cprint("%d", cols);
747 cprint("%d", rows - 10);
748 cprint("%s", active_entry);
749 current_menu = menu; 594 current_menu = menu;
750 build_conf(menu); 595 build_conf(menu);
751 if (!child_count) 596 if (!child_count)
752 break; 597 break;
753 if (menu == &rootmenu) { 598 if (menu == &rootmenu) {
754 cprint(":"); 599 item_make("--- ");
755 cprint("--- "); 600 item_set_tag(':');
756 cprint("L"); 601 item_make(_(" Load an Alternate Configuration File"));
757 cprint(_(" Load an Alternate Configuration File")); 602 item_set_tag('L');
758 cprint("S"); 603 item_make(_(" Save an Alternate Configuration File"));
759 cprint(_(" Save Configuration to an Alternate File")); 604 item_set_tag('S');
760 } 605 }
761 stat = exec_conf(); 606 reset_dialog();
762 if (stat < 0) 607 res = dialog_menu(prompt ? prompt : _("Main Menu"),
763 continue; 608 _(menu_instructions),
764 609 rows, cols, rows - 10,
765 if (stat == 1 || stat == 255) 610 active_menu, &s_scroll);
611 if (res == 1 || res == 255)
766 break; 612 break;
767 613 if (!item_activate_selected())
768 type = input_buf[0]; 614 continue;
769 if (!type) 615 if (!item_tag())
770 continue; 616 continue;
771 617
772 for (i = 0; input_buf[i] && !isspace(input_buf[i]); i++) 618 submenu = item_data();
773 ; 619 active_menu = item_data();
774 if (i >= sizeof(active_entry)) 620 sym = submenu->sym;
775 i = sizeof(active_entry) - 1;
776 input_buf[i] = 0;
777 strcpy(active_entry, input_buf);
778
779 sym = NULL;
780 submenu = NULL;
781 if (sscanf(input_buf + 1, "%p", &submenu) == 1)
782 sym = submenu->sym;
783 621
784 switch (stat) { 622 switch (res) {
785 case 0: 623 case 0:
786 switch (type) { 624 switch (item_tag()) {
787 case 'm': 625 case 'm':
788 if (single_menu_mode) 626 if (single_menu_mode)
789 submenu->data = (void *) (long) !submenu->data; 627 submenu->data = (void *) (long) !submenu->data;
@@ -814,7 +652,7 @@ static void conf(struct menu *menu)
814 show_helptext("README", _(mconf_readme)); 652 show_helptext("README", _(mconf_readme));
815 break; 653 break;
816 case 3: 654 case 3:
817 if (type == 't') { 655 if (item_is_tag('t')) {
818 if (sym_set_tristate_value(sym, yes)) 656 if (sym_set_tristate_value(sym, yes))
819 break; 657 break;
820 if (sym_set_tristate_value(sym, mod)) 658 if (sym_set_tristate_value(sym, mod))
@@ -822,17 +660,17 @@ static void conf(struct menu *menu)
822 } 660 }
823 break; 661 break;
824 case 4: 662 case 4:
825 if (type == 't') 663 if (item_is_tag('t'))
826 sym_set_tristate_value(sym, no); 664 sym_set_tristate_value(sym, no);
827 break; 665 break;
828 case 5: 666 case 5:
829 if (type == 't') 667 if (item_is_tag('t'))
830 sym_set_tristate_value(sym, mod); 668 sym_set_tristate_value(sym, mod);
831 break; 669 break;
832 case 6: 670 case 6:
833 if (type == 't') 671 if (item_is_tag('t'))
834 sym_toggle_tristate_value(sym); 672 sym_toggle_tristate_value(sym);
835 else if (type == 'm') 673 else if (item_is_tag('m'))
836 conf(submenu); 674 conf(submenu);
837 break; 675 break;
838 case 7: 676 case 7:
@@ -844,13 +682,8 @@ static void conf(struct menu *menu)
844 682
845static void show_textbox(const char *title, const char *text, int r, int c) 683static void show_textbox(const char *title, const char *text, int r, int c)
846{ 684{
847 int fd; 685 reset_dialog();
848 686 dialog_textbox(title, text, r ? r : rows, c ? c : cols);
849 fd = creat(".help.tmp", 0777);
850 write(fd, text, strlen(text));
851 close(fd);
852 show_file(".help.tmp", title, r, c);
853 unlink(".help.tmp");
854} 687}
855 688
856static void show_helptext(const char *title, const char *text) 689static void show_helptext(const char *title, const char *text)
@@ -878,62 +711,44 @@ static void show_help(struct menu *menu)
878 str_free(&help); 711 str_free(&help);
879} 712}
880 713
881static void show_file(const char *filename, const char *title, int r, int c)
882{
883 do {
884 cprint_init();
885 if (title) {
886 cprint("--title");
887 cprint("%s", title);
888 }
889 cprint("--textbox");
890 cprint("%s", filename);
891 cprint("%d", r ? r : rows);
892 cprint("%d", c ? c : cols);
893 } while (exec_conf() < 0);
894}
895
896static void conf_choice(struct menu *menu) 714static void conf_choice(struct menu *menu)
897{ 715{
898 const char *prompt = menu_get_prompt(menu); 716 const char *prompt = menu_get_prompt(menu);
899 struct menu *child; 717 struct menu *child;
900 struct symbol *active; 718 struct symbol *active;
901 int stat;
902 719
903 active = sym_get_choice_value(menu->sym); 720 active = sym_get_choice_value(menu->sym);
904 while (1) { 721 while (1) {
905 cprint_init(); 722 int res;
906 cprint("--title"); 723 int selected;
907 cprint("%s", prompt ? prompt : _("Main Menu")); 724 item_reset();
908 cprint("--radiolist");
909 cprint(_(radiolist_instructions));
910 cprint("15");
911 cprint("70");
912 cprint("6");
913 725
914 current_menu = menu; 726 current_menu = menu;
915 for (child = menu->list; child; child = child->next) { 727 for (child = menu->list; child; child = child->next) {
916 if (!menu_is_visible(child)) 728 if (!menu_is_visible(child))
917 continue; 729 continue;
918 cprint("%p", child); 730 item_make("%s", menu_get_prompt(child));
919 cprint("%s", menu_get_prompt(child)); 731 item_set_data(child);
732 if (child->sym == active)
733 item_set_selected(1);
920 if (child->sym == sym_get_choice_value(menu->sym)) 734 if (child->sym == sym_get_choice_value(menu->sym))
921 cprint("ON"); 735 item_set_tag('X');
922 else if (child->sym == active)
923 cprint("SELECTED");
924 else
925 cprint("OFF");
926 } 736 }
927 737 reset_dialog();
928 stat = exec_conf(); 738 res = dialog_checklist(prompt ? prompt : _("Main Menu"),
929 switch (stat) { 739 _(radiolist_instructions),
740 15, 70, 6);
741 selected = item_activate_selected();
742 switch (res) {
930 case 0: 743 case 0:
931 if (sscanf(input_buf, "%p", &child) != 1) 744 if (selected) {
932 break; 745 child = item_data();
933 sym_set_tristate_value(child->sym, yes); 746 sym_set_tristate_value(child->sym, yes);
747 }
934 return; 748 return;
935 case 1: 749 case 1:
936 if (sscanf(input_buf, "%p", &child) == 1) { 750 if (selected) {
751 child = item_data();
937 show_help(child); 752 show_help(child);
938 active = child->sym; 753 active = child->sym;
939 } else 754 } else
@@ -948,33 +763,31 @@ static void conf_choice(struct menu *menu)
948static void conf_string(struct menu *menu) 763static void conf_string(struct menu *menu)
949{ 764{
950 const char *prompt = menu_get_prompt(menu); 765 const char *prompt = menu_get_prompt(menu);
951 int stat;
952 766
953 while (1) { 767 while (1) {
954 cprint_init(); 768 int res;
955 cprint("--title"); 769 char *heading;
956 cprint("%s", prompt ? prompt : _("Main Menu")); 770
957 cprint("--inputbox");
958 switch (sym_get_type(menu->sym)) { 771 switch (sym_get_type(menu->sym)) {
959 case S_INT: 772 case S_INT:
960 cprint(_(inputbox_instructions_int)); 773 heading = _(inputbox_instructions_int);
961 break; 774 break;
962 case S_HEX: 775 case S_HEX:
963 cprint(_(inputbox_instructions_hex)); 776 heading = _(inputbox_instructions_hex);
964 break; 777 break;
965 case S_STRING: 778 case S_STRING:
966 cprint(_(inputbox_instructions_string)); 779 heading = _(inputbox_instructions_string);
967 break; 780 break;
968 default: 781 default:
969 /* panic? */; 782 heading = "Internal mconf error!";
970 } 783 }
971 cprint("10"); 784 reset_dialog();
972 cprint("75"); 785 res = dialog_inputbox(prompt ? prompt : _("Main Menu"),
973 cprint("%s", sym_get_string_value(menu->sym)); 786 heading, 10, 75,
974 stat = exec_conf(); 787 sym_get_string_value(menu->sym));
975 switch (stat) { 788 switch (res) {
976 case 0: 789 case 0:
977 if (sym_set_string_value(menu->sym, input_buf)) 790 if (sym_set_string_value(menu->sym, dialog_input_result))
978 return; 791 return;
979 show_textbox(NULL, _("You have made an invalid entry."), 5, 43); 792 show_textbox(NULL, _("You have made an invalid entry."), 5, 43);
980 break; 793 break;
@@ -989,21 +802,17 @@ static void conf_string(struct menu *menu)
989 802
990static void conf_load(void) 803static void conf_load(void)
991{ 804{
992 int stat;
993 805
994 while (1) { 806 while (1) {
995 cprint_init(); 807 int res;
996 cprint("--inputbox"); 808 reset_dialog();
997 cprint(load_config_text); 809 res = dialog_inputbox(NULL, load_config_text,
998 cprint("11"); 810 11, 55, filename);
999 cprint("55"); 811 switch(res) {
1000 cprint("%s", filename);
1001 stat = exec_conf();
1002 switch(stat) {
1003 case 0: 812 case 0:
1004 if (!input_buf[0]) 813 if (!dialog_input_result[0])
1005 return; 814 return;
1006 if (!conf_read(input_buf)) 815 if (!conf_read(dialog_input_result))
1007 return; 816 return;
1008 show_textbox(NULL, _("File does not exist!"), 5, 38); 817 show_textbox(NULL, _("File does not exist!"), 5, 38);
1009 break; 818 break;
@@ -1018,21 +827,16 @@ static void conf_load(void)
1018 827
1019static void conf_save(void) 828static void conf_save(void)
1020{ 829{
1021 int stat;
1022
1023 while (1) { 830 while (1) {
1024 cprint_init(); 831 int res;
1025 cprint("--inputbox"); 832 reset_dialog();
1026 cprint(save_config_text); 833 res = dialog_inputbox(NULL, save_config_text,
1027 cprint("11"); 834 11, 55, filename);
1028 cprint("55"); 835 switch(res) {
1029 cprint("%s", filename);
1030 stat = exec_conf();
1031 switch(stat) {
1032 case 0: 836 case 0:
1033 if (!input_buf[0]) 837 if (!dialog_input_result[0])
1034 return; 838 return;
1035 if (!conf_write(input_buf)) 839 if (!conf_write(dialog_input_result))
1036 return; 840 return;
1037 show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60); 841 show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60);
1038 break; 842 break;
@@ -1048,15 +852,13 @@ static void conf_save(void)
1048static void conf_cleanup(void) 852static void conf_cleanup(void)
1049{ 853{
1050 tcsetattr(1, TCSAFLUSH, &ios_org); 854 tcsetattr(1, TCSAFLUSH, &ios_org);
1051 unlink(".help.tmp");
1052 unlink("lxdialog.scrltmp");
1053} 855}
1054 856
1055int main(int ac, char **av) 857int main(int ac, char **av)
1056{ 858{
1057 struct symbol *sym; 859 struct symbol *sym;
1058 char *mode; 860 char *mode;
1059 int stat; 861 int res;
1060 862
1061 setlocale(LC_ALL, ""); 863 setlocale(LC_ALL, "");
1062 bindtextdomain(PACKAGE, LOCALEDIR); 864 bindtextdomain(PACKAGE, LOCALEDIR);
@@ -1079,18 +881,16 @@ int main(int ac, char **av)
1079 tcgetattr(1, &ios_org); 881 tcgetattr(1, &ios_org);
1080 atexit(conf_cleanup); 882 atexit(conf_cleanup);
1081 init_wsize(); 883 init_wsize();
884 reset_dialog();
885 init_dialog(menu_backtitle);
1082 conf(&rootmenu); 886 conf(&rootmenu);
1083 887 reset_dialog();
1084 do { 888 res = dialog_yesno(NULL,
1085 cprint_init(); 889 _("Do you wish to save your "
1086 cprint("--yesno"); 890 "new kernel configuration?"),
1087 cprint(_("Do you wish to save your new kernel configuration?")); 891 5, 60);
1088 cprint("5"); 892 end_dialog();
1089 cprint("60"); 893 if (res == 0) {
1090 stat = exec_conf();
1091 } while (stat < 0);
1092
1093 if (stat == 0) {
1094 if (conf_write(NULL)) { 894 if (conf_write(NULL)) {
1095 fprintf(stderr, _("\n\n" 895 fprintf(stderr, _("\n\n"
1096 "Error during writing of the kernel configuration.\n" 896 "Error during writing of the kernel configuration.\n"