about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-09-19 22:51:43 -0700
committerKartik Agaram <vc@akkartik.com>2020-09-19 22:51:43 -0700
commite43ff485e6fcff8cbf004d8db00c489a60437094 (patch)
treec5ca068306e2db95905c930c75be6a486756f64d
parent1436f0298f4c6b9a141a4f23fb89f5c00e98175d (diff)
downloadmu-e43ff485e6fcff8cbf004d8db00c489a60437094.tar.gz
6813 - tile: right-cursor is now easy
-rw-r--r--apps/tile/environment.mu29
1 files changed, 22 insertions, 7 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index d589464c..275b87df 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -49,7 +49,7 @@ $process:body: {
       var cursor-word-ah/edi: (addr handle word) <- get self, cursor-word
       var _cursor-word/eax: (addr word) <- lookup *cursor-word-ah
       var cursor-word/ecx: (addr word) <- copy _cursor-word
-      # if not at start, gap-left
+      # if not at start, move left within current word
       var at-start?/eax: boolean <- cursor-at-start? cursor-word
       compare at-start?, 0  # false
       {
@@ -57,7 +57,7 @@ $process:body: {
         cursor-left cursor-word
         break $process:body
       }
-      # otherwise, move gap to end of prev word
+      # otherwise, move to end of prev word
       var prev-word-ah/esi: (addr handle word) <- get cursor-word, prev
       var prev-word/eax: (addr word) <- lookup *prev-word-ah
       {
@@ -71,11 +71,26 @@ $process:body: {
     compare key, 0x435b1b  # right-arrow
     {
       break-if-!=
-      # TODO:
-      #   gap-right cursor-word
-      # or
-      #   cursor-word = cursor-word->next
-      #   gap-to-start cursor-word
+      var cursor-word-ah/edi: (addr handle word) <- get self, cursor-word
+      var _cursor-word/eax: (addr word) <- lookup *cursor-word-ah
+      var cursor-word/ecx: (addr word) <- copy _cursor-word
+      # if not at end, move right within current word
+      var at-end?/eax: boolean <- cursor-at-end? cursor-word
+      compare at-end?, 0  # false
+      {
+        break-if-=
+        cursor-right cursor-word
+        break $process:body
+      }
+      # otherwise, move to start of next word
+      var next-word-ah/esi: (addr handle word) <- get cursor-word, next
+      var next-word/eax: (addr word) <- lookup *next-word-ah
+      {
+        compare next-word, 0
+        break-if-=
+        copy-object next-word-ah, cursor-word-ah
+        cursor-to-start next-word
+      }
       break $process:body
     }
     compare key, 0x20  # space