about summary refs log tree commit diff stats
path: root/baremetal/shell/gap-buffer.mu
diff options
context:
space:
mode:
Diffstat (limited to 'baremetal/shell/gap-buffer.mu')
-rw-r--r--baremetal/shell/gap-buffer.mu22
1 files changed, 22 insertions, 0 deletions
diff --git a/baremetal/shell/gap-buffer.mu b/baremetal/shell/gap-buffer.mu
index 5b6591db..7fd961b2 100644
--- a/baremetal/shell/gap-buffer.mu
+++ b/baremetal/shell/gap-buffer.mu
@@ -752,6 +752,28 @@ fn skip-whitespace-from-gap-buffer self: (addr gap-buffer) {
 }
 
 fn edit-gap-buffer self: (addr gap-buffer), key: grapheme {
+  var g/edx: grapheme <- copy key
+  {
+    compare g, 8/backspace
+    break-if-!=
+    delete-before-gap self
+    return
+  }
+  # arrow keys
+  {
+    compare g, 0x4/ctrl-d
+    break-if-!=
+    # ctrl-d: cursor down
+    return
+  }
+  {
+    compare g, 0x15/ctrl-u
+    break-if-!=
+    # ctrl-u: cursor up
+    return
+  }
+  # default: insert character
+  add-grapheme-at-gap self, g
 }
 
 fn cursor-on-final-line? self: (addr gap-buffer) -> _/eax: boolean {