about summary refs log tree commit diff stats
path: root/apps/tile
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-10-15 21:19:52 -0700
committerKartik Agaram <vc@akkartik.com>2020-10-15 21:19:52 -0700
commit02cefc70650690248fb4b4e758e0643d103843a5 (patch)
treea59b9e8b797839181ce536213ed7268c7e29eb05 /apps/tile
parent2885e1d4414fc3614f9ef4e5b3561cff00c82ef7 (diff)
downloadmu-02cefc70650690248fb4b4e758e0643d103843a5.tar.gz
7038
Arrow keys now seem to be working right within expanded functions. Still
seeing one minor issue with left-arrow skipping words.
Diffstat (limited to 'apps/tile')
-rw-r--r--apps/tile/environment.mu36
1 files changed, 25 insertions, 11 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index b8de4cf1..0aad72f2 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -185,13 +185,23 @@ $process:body: {
         increment-final-element cursor-call-path
         # Is the new cursor word expanded? If so, it's a function call. Add a
         # new level to the cursor-call-path for the call's body.
-        {
+        $process:key-right-arrow-next-word-is-call-expanded: {
 #?           print-string 0, "c\n"
-          var expanded-words/eax: (addr handle call-path) <- get sandbox, expanded-words
-          var curr-word-is-expanded?/eax: boolean <- find-in-call-path expanded-words, cursor-call-path
-          compare curr-word-is-expanded?, 0  # false
-          break-if-=
-          push-to-call-path-element cursor-call-path, 0
+          {
+            var expanded-words/eax: (addr handle call-path) <- get sandbox, expanded-words
+            var curr-word-is-expanded?/eax: boolean <- find-in-call-path expanded-words, cursor-call-path
+            compare curr-word-is-expanded?, 0  # false
+            break-if-= $process:key-right-arrow-next-word-is-call-expanded
+          }
+          var callee-h: (handle function)
+          var callee-ah/edx: (addr handle function) <- address callee-h
+          var functions/ebx: (addr handle function) <- get self, functions
+          callee functions, next-word, callee-ah
+          var callee/eax: (addr function) <- lookup *callee-ah
+          var callee-body-ah/eax: (addr handle line) <- get callee, body
+          var callee-body/eax: (addr line) <- lookup *callee-body-ah
+          var callee-body-first-word/edx: (addr handle word) <- get callee-body, data
+          push-to-call-path-element cursor-call-path, callee-body-first-word
           # position cursor at left
           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
@@ -552,12 +562,9 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding
       # does function exist?
       var callee/edi: (addr function) <- copy 0
       {
-        var curr-stream-storage: (stream byte 0x10)
-        var curr-stream/esi: (addr stream byte) <- address curr-stream-storage
-        emit-word curr-word, curr-stream
         var callee-h: (handle function)
-        var callee-ah/eax: (addr handle function) <- address callee-h
-        find-function functions, curr-stream, callee-ah
+        var callee-ah/ecx: (addr handle function) <- address callee-h
+        callee functions, curr-word, callee-ah
         var _callee/eax: (addr function) <- lookup *callee-ah
         callee <- copy _callee
         compare callee, 0
@@ -632,6 +639,13 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding
   right-col <- copy curr-col
 }
 
+fn callee functions: (addr handle function), word: (addr word), out: (addr handle function) {
+  var stream-storage: (stream byte 0x10)
+  var stream/esi: (addr stream byte) <- address stream-storage
+  emit-word word, stream
+  find-function functions, stream, out
+}
+
 # Render:
 #   - starting at top-row, left-col: final-word
 #   - starting somewhere below at left-col: the stack result from interpreting first-world to final-word (inclusive)