:: commit 1de574944a5ff75b440ce1b614a05d7b2e8d984c

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

parents: 530b4a8f3b

readline: Support delete key

diff --git a/limine.bin b/limine.bin
index 559ba57d..aaee5376 100644
Binary files a/limine.bin and b/limine.bin differ
diff --git a/stage2/lib/blib.c b/stage2/lib/blib.c
index 1d89e5a5..6c8db7c6 100644
--- a/stage2/lib/blib.c
+++ b/stage2/lib/blib.c
@@ -197,6 +197,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 f36c2dc8..d1bccbeb 100644
--- a/stage2/lib/blib.h
+++ b/stage2/lib/blib.h
@@ -31,6 +31,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