:: commit e3fb2c64ed2dc6434b0e1c8b0748f40bf50c35bb

czapek1337 <czapek1337@gmail.com> — 2022-01-28 22:51

parents: 290bcd1c79

readline: Handle END/HOME keys

diff --git a/stage23/lib/readline.c b/stage23/lib/readline.c
index 22415716..06667405 100644
--- a/stage23/lib/readline.c
+++ b/stage23/lib/readline.c
@@ -316,6 +316,18 @@ void readline(const char *orig_str, char *buf, size_t limit) {
             case '\n':
                 term_write((uintptr_t)"\n", 1);
                 goto out;
+            case GETCHAR_END:
+                for (size_t j = 0; j < strlen(buf) - i; j++) {
+                    cursor_fwd();
+                }
+                i = strlen(buf);
+                continue;
+            case GETCHAR_HOME:
+                for (size_t j = 0; j < i; j++) {
+                    cursor_back();
+                }
+                i = 0;
+                continue;
             default: {
                 if (strlen(buf) < limit - 1 && isprint(c)) {
                     for (size_t j = strlen(buf); ; j--) {
tab: 248 wrap: offon