Merge pull request #91 from ArsenArsen/trunk

readline: rewrite Ctrl-[pnbf] to arrows
This commit is contained in:
mint 2021-07-08 17:02:16 +02:00 committed by GitHub
commit 2a64832923
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,6 +35,22 @@ int getchar_internal(uint8_t scancode, uint8_t ascii) {
return GETCHAR_PGDOWN;
case 0x01:
return GETCHAR_ESCAPE;
// special case checks for C-[pnfb]
#define CTRL_CHECK(ch, key) \
if ((ascii | 0x60) == ch) { \
return key; \
} else { \
break; \
}
case 0x19:
CTRL_CHECK('p', GETCHAR_CURSOR_UP);
case 0x31:
CTRL_CHECK('n', GETCHAR_CURSOR_DOWN);
case 0x21:
CTRL_CHECK('f', GETCHAR_CURSOR_RIGHT);
case 0x30:
CTRL_CHECK('b', GETCHAR_CURSOR_LEFT);
#elif defined (uefi)
case SCAN_F10:
return GETCHAR_F10;
@ -58,8 +74,22 @@ int getchar_internal(uint8_t scancode, uint8_t ascii) {
return GETCHAR_PGDOWN;
case SCAN_ESC:
return GETCHAR_ESCAPE;
// special case checks for C-[pnfb]
// EFI for some reason reports scancode zero if Ctrl is held
#define CTRL_CHECK(ch, key) \
if ((ascii | 0x60) == ch) { \
return key; \
}
case 0:
CTRL_CHECK('p', GETCHAR_CURSOR_UP);
CTRL_CHECK('n', GETCHAR_CURSOR_DOWN);
CTRL_CHECK('f', GETCHAR_CURSOR_RIGHT);
CTRL_CHECK('b', GETCHAR_CURSOR_LEFT);
break;
#endif
}
#undef CTRL_CHECK
switch (ascii) {
case '\r':
return '\n';