about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/tile/environment.mu38
-rw-r--r--apps/tile/main.mu14
2 files changed, 39 insertions, 13 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index e2a9f454..44a93eff 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -287,6 +287,44 @@ $process:body: {
       copy-object caller-cursor-element-ah, cursor-call-path-ah
       break $process:body
     }
+    # line-based motions
+    compare key, 1  # ctrl-a
+    $process:start-of-line: {
+      break-if-!=
+      # move cursor to initial word of sandbox
+      var cursor-call-path-ah/eax: (addr handle call-path-element) <- get sandbox, cursor-call-path
+      allocate cursor-call-path-ah
+      # move cursor to start of initial word
+      var functions/ecx: (addr handle function) <- get self, functions
+      get-cursor-word sandbox, functions, cursor-word-ah
+      var cursor-word/eax: (addr word) <- lookup *cursor-word-ah
+      cursor-to-start cursor-word
+      # this works as long as the first word isn't expanded
+      # but we don't expect to see zero-arg functions first-up
+      break $process:body
+    }
+    compare key, 5  # ctrl-e
+    $process:end-of-line: {
+      break-if-!=
+      # move cursor to final word of sandbox
+      var cursor-call-path-ah/eax: (addr handle call-path-element) <- get sandbox, cursor-call-path
+      allocate cursor-call-path-ah
+      var cursor-call-path/eax: (addr call-path-element) <- lookup *cursor-call-path-ah
+      var dest/edx: (addr int) <- get cursor-call-path, index-in-body
+      var line-ah/eax: (addr handle line) <- get sandbox, data
+      var line/eax: (addr line) <- lookup *line-ah
+      var n/eax: int <- line-length line
+      n <- decrement
+      copy-to *dest, n
+      # move cursor to end of final word
+      var functions/ecx: (addr handle function) <- get self, functions
+      get-cursor-word sandbox, functions, cursor-word-ah
+      var cursor-word/eax: (addr word) <- lookup *cursor-word-ah
+      cursor-to-end cursor-word
+      # this works because expanded words lie to the right of their bodies
+      # so the final word is always guaranteed to be at the top-level
+      break $process:body
+    }
     # if cursor is within a call, disable editing hotkeys below
     var cursor-call-path-ah/eax: (addr handle call-path-element) <- get sandbox, cursor-call-path
     var cursor-call-path/eax: (addr call-path-element) <- lookup *cursor-call-path-ah
diff --git a/apps/tile/main.mu b/apps/tile/main.mu
index 157adc48..457fef83 100644
--- a/apps/tile/main.mu
+++ b/apps/tile/main.mu
@@ -81,25 +81,13 @@ fn test {
   process env, g
   g <- copy 0x32  # '2'
   process env, g
-  g <- copy 0x2b  # '+'
-  process env, g
-  g <- copy 0xa  # <enter>
-  process env, g
   g <- copy 0x445b1b  # left-arrow
   process env, g
   g <- copy 0x445b1b  # left-arrow
   process env, g
   g <- copy 0x445b1b  # left-arrow
   process env, g
-  g <- copy 0x10  # <ctrl-p>
-  process env, g
-  g <- copy 0x10  # <ctrl-p>
-  process env, g
-  g <- copy 0xe  # <ctrl-n>
-  process env, g
-  g <- copy 0xe  # <ctrl-n>
-  process env, g
-  g <- copy 0xe  # <ctrl-n>
+  g <- copy 5  # <ctrl-e>
   process env, g
 }