KEY_UP,
KEY_DOWN,
KEY_SELECT,
+ KEY_QUIT,
};
static char *bootmenu_getoption(unsigned short int n)
case '\r':
*key = KEY_SELECT;
break;
+ case 0x3: /* ^C */
+ *key = KEY_QUIT;
+ break;
default:
*key = KEY_NONE;
break;
{
int c;
- while (!tstc()) {
- WATCHDOG_RESET();
- mdelay(10);
+ if (*esc == 1) {
+ if (tstc()) {
+ c = getchar();
+ } else {
+ WATCHDOG_RESET();
+ mdelay(10);
+ if (tstc())
+ c = getchar();
+ else
+ c = '\e';
+ }
+ } else {
+ while (!tstc()) {
+ WATCHDOG_RESET();
+ mdelay(10);
+ }
+ c = getchar();
}
- c = getchar();
-
switch (*esc) {
case 0:
/* First char of ANSI escape sequence '\e' */
*esc = 2;
*key = KEY_NONE;
} else {
- *esc = 0;
+ /* Alone ESC key was pressed */
+ *key = KEY_QUIT;
+ *esc = (c == '\e') ? 1 : 0;
}
break;
case 2:
/* enter key was pressed */
if (c == '\r')
*key = KEY_SELECT;
+
+ /* ^C was pressed */
+ if (c == 0x3)
+ *key = KEY_QUIT;
}
static char *bootmenu_choice_entry(void *data)
for (i = 0; i < menu->active; ++i)
iter = iter->next;
return iter->key;
+ case KEY_QUIT:
+ /* Quit by choosing the last entry - U-Boot console */
+ iter = menu->first;
+ while (iter->next)
+ iter = iter->next;
+ return iter->key;
default:
break;
}
printf(ANSI_CURSOR_POSITION, menu->count + 5, 1);
puts(ANSI_CLEAR_LINE);
printf(ANSI_CURSOR_POSITION, menu->count + 6, 1);
- puts(" Press UP/DOWN to move, ENTER to select");
+ puts(" Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit");
puts(ANSI_CLEAR_LINE_TO_END);
printf(ANSI_CURSOR_POSITION, menu->count + 7, 1);
puts(ANSI_CLEAR_LINE);