menu: Add support for home and end bindings in textbox

This commit is contained in:
mintsuki 2020-12-19 19:27:10 +01:00
parent 1f0636bcb7
commit 57360b15e7
6 changed files with 23 additions and 3 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -20,6 +20,14 @@ int getchar_internal(uint32_t eax) {
return GETCHAR_CURSOR_DOWN;
case 0x53:
return GETCHAR_DELETE;
case 0x4f:
return GETCHAR_END;
case 0x47:
return GETCHAR_HOME;
case 0x49:
return GETCHAR_PGUP;
case 0x51:
return GETCHAR_PGDOWN;
}
char c = eax & 0xff;
switch (c) {

View File

@ -8,7 +8,11 @@
#define GETCHAR_CURSOR_UP (-12)
#define GETCHAR_CURSOR_DOWN (-13)
#define GETCHAR_DELETE (-14)
#define GETCHAR_F10 (-15)
#define GETCHAR_END (-15)
#define GETCHAR_HOME (-16)
#define GETCHAR_PGUP (-17)
#define GETCHAR_PGDOWN (-18)
#define GETCHAR_F10 (-19)
int getchar(void);
void readline(const char *orig_str, char *buf, size_t limit);

View File

@ -13,8 +13,6 @@
#include <mm/pmm.h>
#include <drivers/vbe.h>
#include <sys/cpu.h>
static char *menu_branding = NULL;
#define EDITOR_MAX_BUFFER_SIZE 4096
@ -234,6 +232,16 @@ refresh:
cursor_offset++;
}
break;
case GETCHAR_HOME: {
size_t displacement;
get_line_offset(&displacement, cursor_offset, buffer);
cursor_offset -= displacement;
break;
}
case GETCHAR_END: {
cursor_offset += get_line_length(cursor_offset, buffer);
break;
}
case '\b':
if (cursor_offset) {
cursor_offset--;