about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-10-24 18:26:19 -0700
committerKartik Agaram <vc@akkartik.com>2020-10-24 18:26:19 -0700
commite648bc9c889978522acb068570d4c87790db9ca1 (patch)
tree1d1dc59d998f08164cadeb54848df215be6acdec
parent1137dd2a997a271761c8da0b7e2be05d977909e1 (diff)
downloadmu-e648bc9c889978522acb068570d4c87790db9ca1.tar.gz
tile: process space in middle of word
-rw-r--r--apps/tile/environment.mu16
-rw-r--r--apps/tile/gap-buffer.mu6
-rw-r--r--apps/tile/word.mu7
3 files changed, 28 insertions, 1 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index 1fc811aa..c60ce3b8 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -434,7 +434,21 @@ $process-sandbox:body: {
       break $process-sandbox:body
     }
     # otherwise split word into two
-    # TODO
+    append-word cursor-word-ah
+    var cursor-call-path/eax: (addr handle call-path-element) <- get sandbox, cursor-call-path
+    increment-final-element cursor-call-path
+    var next-word-ah/eax: (addr handle word) <- get cursor-word, next
+    var _next-word/eax: (addr word) <- lookup *next-word-ah
+    var next-word/ebx: (addr word) <- copy _next-word
+    {
+      var at-end?/eax: boolean <- cursor-at-end? cursor-word
+      compare at-end?, 0  # false
+      break-if-!=
+      var g/eax: grapheme <- pop-after-cursor cursor-word
+      add-grapheme-to-word next-word, g
+      loop
+    }
+    cursor-to-start next-word
     break $process-sandbox:body
   }
   compare key, 0xe  # ctrl-n
diff --git a/apps/tile/gap-buffer.mu b/apps/tile/gap-buffer.mu
index e694da08..627a6877 100644
--- a/apps/tile/gap-buffer.mu
+++ b/apps/tile/gap-buffer.mu
@@ -216,6 +216,12 @@ fn delete-before-gap _self: (addr gap-buffer) {
   var dummy/eax: grapheme <- pop-grapheme-stack left
 }
 
+fn pop-after-gap _self: (addr gap-buffer) -> result/eax: grapheme {
+  var self/eax: (addr gap-buffer) <- copy _self
+  var right/eax: (addr grapheme-stack) <- get self, right
+  result <- pop-grapheme-stack right
+}
+
 fn gap-buffer-equal? _self: (addr gap-buffer), s: (addr array byte) -> result/eax: boolean {
 $gap-buffer-equal?:body: {
   var self/esi: (addr gap-buffer) <- copy _self
diff --git a/apps/tile/word.mu b/apps/tile/word.mu
index 63695ae0..994f3819 100644
--- a/apps/tile/word.mu
+++ b/apps/tile/word.mu
@@ -213,6 +213,13 @@ fn delete-before-cursor _self: (addr word) {
   delete-before-gap data
 }
 
+fn pop-after-cursor _self: (addr word) -> result/eax: grapheme {
+  var self/esi: (addr word) <- copy _self
+  var data-ah/eax: (addr handle gap-buffer) <- get self, scalar-data
+  var data/eax: (addr gap-buffer) <- lookup *data-ah
+  result <- pop-after-gap data
+}
+
 fn delete-next _self: (addr word) {
 $delete-next:body: {
   var self/esi: (addr word) <- copy _self