Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 38147
b: refs/heads/master
c: f3cbcdc
h: refs/heads/master
i:
  38145: b09e916
  38143: 9a2a82d
v: v3
  • Loading branch information
Sam Ravnborg authored and Sam Ravnborg committed Sep 30, 2006
1 parent 7d856ec commit c646e93
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 31 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2982de6993e6d9944f2215d7cb9b558b465a0c99
refs/heads/master: f3cbcdc955d0d2c8b4c52d6b73fc536b01b68c64
10 changes: 6 additions & 4 deletions trunk/scripts/kconfig/lxdialog/checklist.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ int dialog_checklist(const char *title, const char *prompt, int height,
wnoutrefresh(list);
doupdate();

while (key != ESC) {
while (key != KEY_ESC) {
key = wgetch(dialog);

for (i = 0; i < max_choice; i++) {
Expand Down Expand Up @@ -298,8 +298,10 @@ int dialog_checklist(const char *title, const char *prompt, int height,
break;
case 'X':
case 'x':
key = ESC;
case ESC:
key = KEY_ESC;
break;
case KEY_ESC:
key = on_key_esc(dialog);
break;
}

Expand All @@ -308,5 +310,5 @@ int dialog_checklist(const char *title, const char *prompt, int height,
}
delwin(list);
delwin(dialog);
return 255; /* ESC pressed */
return key; /* ESC pressed */
}
4 changes: 3 additions & 1 deletion trunk/scripts/kconfig/lxdialog/dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

#define TR(params) _tracef params

#define ESC 27
#define KEY_ESC 27
#define TAB 9
#define MAX_LEN 2048
#define BUF_SIZE (10*1024)
Expand Down Expand Up @@ -179,6 +179,8 @@ int item_is_tag(char tag);
for (item_cur = item_head ? item_head: item_cur; \
item_cur && (item_cur != &item_nil); item_cur = item_cur->next)

/* generic key handlers */
int on_key_esc(WINDOW *win);

void init_dialog(const char *backtitle);
void reset_dialog(void);
Expand Down
10 changes: 6 additions & 4 deletions trunk/scripts/kconfig/lxdialog/inputbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width

wrefresh(dialog);

while (key != ESC) {
while (key != KEY_ESC) {
key = wgetch(dialog);

if (button == -1) { /* Input box selected */
Expand Down Expand Up @@ -215,12 +215,14 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
return (button == -1 ? 0 : button);
case 'X':
case 'x':
key = ESC;
case ESC:
key = KEY_ESC;
break;
case KEY_ESC:
key = on_key_esc(dialog);
break;
}
}

delwin(dialog);
return 255; /* ESC pressed */
return KEY_ESC; /* ESC pressed */
}
10 changes: 6 additions & 4 deletions trunk/scripts/kconfig/lxdialog/menubox.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width,
wmove(menu, choice, item_x + 1);
wrefresh(menu);

while (key != ESC) {
while (key != KEY_ESC) {
key = wgetch(menu);

if (key < 256 && isalpha(key))
Expand Down Expand Up @@ -402,12 +402,14 @@ int dialog_menu(const char *title, const char *prompt, int height, int width,
return button;
case 'e':
case 'x':
key = ESC;
case ESC:
key = KEY_ESC;
break;
case KEY_ESC:
key = on_key_esc(menu);
break;
}
}
delwin(menu);
delwin(dialog);
return 255; /* ESC pressed */
return key; /* ESC pressed */
}
7 changes: 4 additions & 3 deletions trunk/scripts/kconfig/lxdialog/textbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int dialog_textbox(const char *title, const char *tbuf, int height, int width)
wmove(dialog, cur_y, cur_x); /* Restore cursor position */
wrefresh(dialog);

while ((key != ESC) && (key != '\n')) {
while ((key != KEY_ESC) && (key != '\n')) {
key = wgetch(dialog);
switch (key) {
case 'E': /* Exit */
Expand Down Expand Up @@ -228,13 +228,14 @@ int dialog_textbox(const char *title, const char *tbuf, int height, int width)
wmove(dialog, cur_y, cur_x);
wrefresh(dialog);
break;
case ESC:
case KEY_ESC:
key = on_key_esc(dialog);
break;
}
}
delwin(text);
delwin(dialog);
return 255; /* ESC pressed */
return key; /* ESC pressed */
}

/*
Expand Down
33 changes: 33 additions & 0 deletions trunk/scripts/kconfig/lxdialog/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,39 @@ int first_alpha(const char *string, const char *exempt)
return 0;
}

/*
* ncurses uses ESC to detect escaped char sequences. This resutl in
* a small timeout before ESC is actually delivered to the application.
* lxdialog suggest <ESC> <ESC> which is correctly translated to two
* times esc. But then we need to ignore the second esc to avoid stepping
* out one menu too much. Filter away all escaped key sequences since
* keypad(FALSE) turn off ncurses support for escape sequences - and thats
* needed to make notimeout() do as expected.
*/
int on_key_esc(WINDOW *win)
{
int key;
int key2;
int key3;

nodelay(win, TRUE);
keypad(win, FALSE);
key = wgetch(win);
key2 = wgetch(win);
do {
key3 = wgetch(win);
} while (key3 != ERR);
nodelay(win, FALSE);
keypad(win, TRUE);
if (key == KEY_ESC && key2 == ERR)
return KEY_ESC;
else if (key != ERR && key != KEY_ESC && key2 == ERR)
ungetch(key);

return -1;
}


struct dialog_list *item_cur;
struct dialog_list item_nil;
struct dialog_list *item_head;
Expand Down
7 changes: 4 additions & 3 deletions trunk/scripts/kconfig/lxdialog/yesno.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width)

print_buttons(dialog, height, width, 0);

while (key != ESC) {
while (key != KEY_ESC) {
key = wgetch(dialog);
switch (key) {
case 'Y':
Expand All @@ -93,11 +93,12 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width)
case '\n':
delwin(dialog);
return button;
case ESC:
case KEY_ESC:
key = on_key_esc(dialog);
break;
}
}

delwin(dialog);
return 255; /* ESC pressed */
return key; /* ESC pressed */
}
25 changes: 14 additions & 11 deletions trunk/scripts/kconfig/mconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ static void conf(struct menu *menu)
_(menu_instructions),
rows, cols, rows - 10,
active_menu, &s_scroll);
if (res == 1 || res == 255)
if (res == 1 || res == KEY_ESC)
break;
if (!item_activate_selected())
continue;
Expand Down Expand Up @@ -754,7 +754,7 @@ static void conf_choice(struct menu *menu)
} else
show_help(menu);
break;
case 255:
case KEY_ESC:
return;
}
}
Expand Down Expand Up @@ -794,7 +794,7 @@ static void conf_string(struct menu *menu)
case 1:
show_help(menu);
break;
case 255:
case KEY_ESC:
return;
}
}
Expand All @@ -819,7 +819,7 @@ static void conf_load(void)
case 1:
show_helptext(_("Load Alternate Configuration"), load_config_help);
break;
case 255:
case KEY_ESC:
return;
}
}
Expand All @@ -843,7 +843,7 @@ static void conf_save(void)
case 1:
show_helptext(_("Save Alternate Configuration"), save_config_help);
break;
case 255:
case KEY_ESC:
return;
}
}
Expand Down Expand Up @@ -883,12 +883,15 @@ int main(int ac, char **av)
init_wsize();
reset_dialog();
init_dialog(menu_backtitle);
conf(&rootmenu);
reset_dialog();
res = dialog_yesno(NULL,
_("Do you wish to save your "
"new kernel configuration?"),
5, 60);
do {
conf(&rootmenu);
reset_dialog();
res = dialog_yesno(NULL,
_("Do you wish to save your "
"new kernel configuration?\n"
"<ESC><ESC> to continue."),
6, 60);
} while (res == KEY_ESC);
end_dialog();
if (res == 0) {
if (conf_write(NULL)) {
Expand Down

0 comments on commit c646e93

Please sign in to comment.