:: commit 638b74549e483c72c1db5a5e25ee1e31e43b48de

mintsuki <mintsuki@protonmail.com> — 2020-12-19 18:27

parents: 240dd3ca46

menu: Add support for home and end bindings in textbox

diff --git a/limine-pxe.bin b/limine-pxe.bin
index de04f533..e888346a 100644
Binary files a/limine-pxe.bin and b/limine-pxe.bin differ
diff --git a/limine.bin b/limine.bin
index 2eb31927..ef07be3c 100644
Binary files a/limine.bin and b/limine.bin differ
diff --git a/stage2.map b/stage2.map
index 0429fd95..2fca87cc 100644
Binary files a/stage2.map and b/stage2.map differ
diff --git a/stage2/lib/readline.c b/stage2/lib/readline.c
index 4d9a830a..42713d90 100644
--- a/stage2/lib/readline.c
+++ b/stage2/lib/readline.c
@@ -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) {
diff --git a/stage2/lib/readline.h b/stage2/lib/readline.h
index 94fab564..05e3425b 100644
--- a/stage2/lib/readline.h
+++ b/stage2/lib/readline.h
@@ -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);
diff --git a/stage2/menu.c b/stage2/menu.c
index f024088e..68994662 100644
--- a/stage2/menu.c
+++ b/stage2/menu.c
@@ -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--;
tab: 248 wrap: offon