about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-04-06 19:39:09 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-04-06 19:39:09 -0700
commit119aea6d06667c63a9b2225e7f5475cd442096b5 (patch)
treeb56450d6e3cbfd0db28d1ea1138a571e6b9d457e
parent7032a92cf22de2102e65c2bcaf8a5cdb0181f60e (diff)
downloadmu-119aea6d06667c63a9b2225e7f5475cd442096b5.tar.gz
shell: ctrl-u to clear sandbox
-rw-r--r--shell/gap-buffer.mu18
1 files changed, 14 insertions, 4 deletions
diff --git a/shell/gap-buffer.mu b/shell/gap-buffer.mu
index 394ec358..a5f55096 100644
--- a/shell/gap-buffer.mu
+++ b/shell/gap-buffer.mu
@@ -16,6 +16,14 @@ fn initialize-gap-buffer _self: (addr gap-buffer), max-word-size: int {
   initialize-grapheme-stack right, max-word-size
 }
 
+fn clear-gap-buffer _self: (addr gap-buffer) {
+  var self/esi: (addr gap-buffer) <- copy _self
+  var left/eax: (addr grapheme-stack) <- get self, left
+  clear-grapheme-stack left
+  var right/eax: (addr grapheme-stack) <- get self, right
+  clear-grapheme-stack right
+}
+
 # just for tests
 fn initialize-gap-buffer-with self: (addr gap-buffer), s: (addr array byte) {
   initialize-gap-buffer self, 0x10/max-word-size
@@ -783,10 +791,12 @@ fn edit-gap-buffer self: (addr gap-buffer), key: grapheme {
     gap-to-end self
     return
   }
+  {
+    compare g, 0x15/ctrl-u
+    break-if-!=
+    clear-gap-buffer self
+    return
+  }
   # default: insert character
   add-grapheme-at-gap self, g
 }
-
-fn cursor-on-final-line? self: (addr gap-buffer) -> _/eax: boolean {
-  return 1/true
-}