readline: Fix handling of escape key for BIOS
diff --git a/stage23/lib/readline.c b/stage23/lib/readline.c
index 7f0d578b..201780ff 100644
--- a/stage23/lib/readline.c
+++ b/stage23/lib/readline.c
@@ -33,6 +33,8 @@ int getchar_internal(uint8_t scancode, uint8_t ascii) {
return GETCHAR_PGUP;
case 0x51:
return GETCHAR_PGDOWN;
+ case 0x01:
+ return GETCHAR_ESCAPE;
#elif defined (uefi)
case SCAN_F10:
return GETCHAR_F10;
@@ -55,7 +57,7 @@ int getchar_internal(uint8_t scancode, uint8_t ascii) {
case SCAN_PAGE_DOWN:
return GETCHAR_PGDOWN;
case SCAN_ESC:
- return '\e';
+ return GETCHAR_ESCAPE;
#endif
}
switch (ascii) {
@@ -65,8 +67,9 @@ int getchar_internal(uint8_t scancode, uint8_t ascii) {
return '\b';
}
// Guard against non-printable values
- if (ascii < 0x20 || ascii > 0x7e)
+ if (ascii < 0x20 || ascii > 0x7e) {
return -1;
+ }
return ascii;
}
diff --git a/stage23/lib/readline.h b/stage23/lib/readline.h
index 05e3425b..8ce83c07 100644
--- a/stage23/lib/readline.h
+++ b/stage23/lib/readline.h
@@ -13,6 +13,7 @@
#define GETCHAR_PGUP (-17)
#define GETCHAR_PGDOWN (-18)
#define GETCHAR_F10 (-19)
+#define GETCHAR_ESCAPE (-20)
int getchar(void);
void readline(const char *orig_str, char *buf, size_t limit);
diff --git a/stage23/menu.c b/stage23/menu.c
index f6506479..f30fc181 100644
--- a/stage23/menu.c
+++ b/stage23/menu.c
@@ -258,7 +258,7 @@ refresh:
case GETCHAR_F10:
disable_cursor();
return buffer;
- case '\e':
+ case GETCHAR_ESCAPE:
disable_cursor();
return NULL;
default:
