diff --git a/scripts/lxdialog/inputbox.c b/scripts/lxdialog/inputbox.c index 1d0200fa..0449d690 100644 --- a/scripts/lxdialog/inputbox.c +++ b/scripts/lxdialog/inputbox.c @@ -29,11 +29,12 @@ unsigned char dialog_input_result[MAX_LEN + 1]; static void print_buttons(WINDOW *dialog, int height, int width, int selected) { - int x = width / 2 - 11; + int x = width / 2 - 17; int y = height - 2; print_button (dialog, " Ok ", y, x, selected==0); - print_button (dialog, " Help ", y, x + 14, selected==1); + print_button (dialog, "Cancel", y, x + 14, selected==1); + print_button (dialog, " Help ", y, x + 28, selected==2); wmove(dialog, y, x+1+14*selected); wrefresh(dialog); @@ -180,8 +181,8 @@ dialog_inputbox (const char *title, const char *prompt, int height, int width, case KEY_LEFT: switch (button) { case -1: - button = 1; /* Indicates "Cancel" button is selected */ - print_buttons(dialog, height, width, 1); + button = 2; /* Indicates "Help" button is selected */ + print_buttons(dialog, height, width, 2); break; case 0: button = -1; /* Indicates input box is selected */ @@ -193,6 +194,10 @@ dialog_inputbox (const char *title, const char *prompt, int height, int width, button = 0; /* Indicates "OK" button is selected */ print_buttons(dialog, height, width, 0); break; + case 2: + button = 1; /* Indicates "Cancel" button is selected */ + print_buttons(dialog, height, width, 1); + break; } break; case TAB: @@ -208,6 +213,10 @@ dialog_inputbox (const char *title, const char *prompt, int height, int width, print_buttons(dialog, height, width, 1); break; case 1: + button = 2; /* Indicates "Help" button is selected */ + print_buttons(dialog, height, width, 2); + break; + case 2: button = -1; /* Indicates input box is selected */ print_buttons(dialog, height, width, 0); wmove (dialog, box_y, box_x + input_x); @@ -218,6 +227,13 @@ dialog_inputbox (const char *title, const char *prompt, int height, int width, case ' ': case '\n': delwin (dialog); + if (button == 1) { + if (!init) + instr[0] = '\0'; + else + strcpy (instr, init); + button = 0; + } return (button == -1 ? 0 : button); case 'X': case 'x': diff --git a/scripts/lxdialog/menubox.c b/scripts/lxdialog/menubox.c index e208d57e..f218ec75 100644 --- a/scripts/lxdialog/menubox.c +++ b/scripts/lxdialog/menubox.c @@ -68,9 +68,9 @@ print_item (WINDOW * win, const char *item, int choice, int selected, int hotkey if ((ls = strlen(item)) != (li = itemlen(item))) { memset(&menu_item[MCUT-2],'.',3); memmove(&menu_item[MCUT+1],&menu_item[ls-(li-MCUT)], li-MCUT+1); - } + } else menu_item[menu_width] = 0; - j = first_alpha(menu_item, "YyNnMm"); + j = first_alpha(menu_item, "YyNn"); /* Clear 'residue' of last item */ wattrset (win, menubox_attr); @@ -237,20 +237,22 @@ dialog_menu (const char *title, const char *prompt, int height, int width, if (key < 256 && isalpha(key)) key = tolower(key); - if (strchr("ynm", key)) + if (strchr("yn", key)) i = max_choice; else { for (i = choice+1; i < max_choice; i++) { - j = first_alpha(items[(scroll+i)*2+1], "YyNnMm"); - if (key == tolower(items[(scroll+i)*2+1][j])) - break; - } - if (i == max_choice) - for (i = 0; i < max_choice; i++) { - j = first_alpha(items[(scroll+i)*2+1], "YyNnMm"); - if (key == tolower(items[(scroll+i)*2+1][j])) - break; + j = first_alpha(items[(scroll+i)*2+1], "YyNn"); + if ((key == tolower(items[(scroll+i)*2+1][j])) && + (strncmp(items[(scroll+i)*2+1], "---", 3))) + break; } + if (i == max_choice) + for (i = 0; i < max_choice; i++) { + j = first_alpha(items[(scroll+i)*2+1], "YyNn"); + if ((key == tolower(items[(scroll+i)*2+1][j])) && + (strncmp(items[(scroll+i)*2+1], "---", 3))) + break; + } } if (i < max_choice || @@ -348,14 +350,12 @@ dialog_menu (const char *title, const char *prompt, int height, int width, case 's': case 'y': case 'n': - case 'm': delwin (dialog); fprintf(stderr, "%s\n", items[(scroll + choice) * 2]); switch (key) { case 's': return 3; case 'y': return 3; case 'n': return 4; - case 'm': return 5; case ' ': return 6; } return 0; diff --git a/scripts/lxdialog/util.c b/scripts/lxdialog/util.c index b3a7af9d..5a0478f4 100644 --- a/scripts/lxdialog/util.c +++ b/scripts/lxdialog/util.c @@ -342,15 +342,39 @@ draw_shadow (WINDOW * win, int y, int x, int height, int width) int first_alpha(const char *string, const char *exempt) { - int i, in_paren=0, c; + int i, in_paren=0, in_str=0, dot_cnt = 0, c; for (i = 0; i < strlen(string); i++) { c = tolower(string[i]); - if (strchr("<[(", c)) ++in_paren; - if (strchr(">])", c)) --in_paren; + switch (c) { + case '<': + case '[': + case '(': + dot_cnt = 0; + ++in_paren; + break; + case '>': + case ']': + case ')': + dot_cnt = 0; + --in_paren; + break; + case '"': + in_str = !in_str; + dot_cnt = 0; + break; + case '.': + ++dot_cnt; + break; + case ' ': + if ((dot_cnt > 2) && in_str) + in_str = 0; + default: + dot_cnt = 0; + } - if ((! in_paren) && isalpha(c) && + if ((! in_paren) && (! in_str) && isalpha(c) && strchr(exempt, c) == 0) return i; }