:: commit dd5c8b427591880533cbfe47b56a7bd557acb877

mintsuki <mintsuki@protonmail.com> — 2020-10-27 07:38

parents: 562bdf78a2

readline: Support delete key

diff --git a/limine.bin b/limine.bin
index b6df59b4..d4991e8a 100644
Binary files a/limine.bin and b/limine.bin differ
diff --git a/stage2/lib/blib.c b/stage2/lib/blib.c
index e16f2f1f..a9982be4 100644
--- a/stage2/lib/blib.c
+++ b/stage2/lib/blib.c
@@ -127,6 +127,8 @@ int getchar_internal(uint32_t eax) {
             return GETCHAR_CURSOR_UP;
         case 0x50:
             return GETCHAR_CURSOR_DOWN;
+        case 0x53:
+            return GETCHAR_DELETE;
     }
     return (char)(eax & 0xff);
 }
diff --git a/stage2/lib/blib.h b/stage2/lib/blib.h
index 141d888c..67053945 100644
--- a/stage2/lib/blib.h
+++ b/stage2/lib/blib.h
@@ -26,6 +26,7 @@ int pit_sleep_and_quit_on_keypress(uint32_t pit_ticks);
 #define GETCHAR_CURSOR_RIGHT (-11)
 #define GETCHAR_CURSOR_UP    (-12)
 #define GETCHAR_CURSOR_DOWN  (-13)
+#define GETCHAR_DELETE       (-14)
 
 int getchar(void);
 uint64_t strtoui(const char *s);
diff --git a/stage2/lib/readline.c b/stage2/lib/readline.c
index 59bfa662..bf752321 100644
--- a/stage2/lib/readline.c
+++ b/stage2/lib/readline.c
@@ -68,6 +68,7 @@ void readline(const char *orig_str, char *buf, size_t limit) {
                 if (i) {
                     i--;
                     cursor_back();
+            case GETCHAR_DELETE:;
                     size_t j;
                     for (j = i; ; j++) {
                         buf[j] = buf[j+1];
tab: 248 wrap: offon