diff options
author | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2023-12-19 02:08:53 +0100 |
---|---|---|
committer | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2023-12-19 02:12:08 +0100 |
commit | 1e8c290a9937fb74ff7ec2b7ea288b2626ceba3c (patch) | |
tree | 79fe0e283f0bfc7671adbd57b419d522165ac8b0 /stage3 | |
parent | 6d263c7d4e0f4b1d34694b5d3d159ccb20b3db02 (diff) | |
download | cuddles-1e8c290a9937fb74ff7ec2b7ea288b2626ceba3c.tar.xz |
handle backspace
Diffstat (limited to 'stage3')
-rw-r--r-- | stage3/font.c | 4 | ||||
-rw-r--r-- | stage3/main.c | 11 |
2 files changed, 11 insertions, 4 deletions
diff --git a/stage3/font.c b/stage3/font.c index 69017ca..67127f6 100644 --- a/stage3/font.c +++ b/stage3/font.c @@ -113,8 +113,10 @@ void print_char(char c) break; case '\b': - if (cursor_x > 0) + if (cursor_x > 0) { cursor_x--; + render_char(' '); + } break; case '\r': diff --git a/stage3/main.c b/stage3/main.c index c8ff971..30f1bbd 100644 --- a/stage3/main.c +++ b/stage3/main.c @@ -33,13 +33,18 @@ void keyboard_handler() char c = keymap[e->data.scancode]; if (c != '\0') { - print_char(c); - - if (c == '\n') { + if (c == '\b') { + if (buffer.len > 0) { + print_char(c); + buffer.len--; + } + } else if (c == '\n') { + print_char(c); shell_run_cmd(buffer); buffer.len = 0; print(S("$ ")); } else { + print_char(c); if (buffer.len == cap) buffer.data = realloc(buffer.data, cap = cap ? cap*2 : 1); buffer.data[buffer.len++] = c; |