about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-10-09 22:27:22 -0700
committerKartik Agaram <vc@akkartik.com>2020-10-09 22:27:22 -0700
commit8c43582fb2cafd6471f01fb3e4cb75e5b200a4b3 (patch)
treea15a7ac58db1d89a1843797b5dfe51a7213aadb9 /apps
parentec6221b4852a65b4a6f41523cfc937380c678c09 (diff)
downloadmu-8c43582fb2cafd6471f01fb3e4cb75e5b200a4b3.tar.gz
6981
Tile: simplify the contract for render-column.
Diffstat (limited to 'apps')
-rw-r--r--apps/tile/environment.mu30
1 files changed, 14 insertions, 16 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index c5a85f33..6763f5a9 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -387,8 +387,19 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding
 #?         }
 #?       reset-formatting screen
 #?     increment top-row
-    # now render main column
-    curr-col <- render-column screen, functions, bindings, line, curr-word, top-row, curr-col, cursor-word, cursor-col-a
+    # render main column
+    var old-col/edx: int <- copy curr-col
+    curr-col <- render-column screen, functions, bindings, line, curr-word, top-row, curr-col
+    # cache cursor column if necessary
+    compare curr-word, cursor-word
+    {
+      break-if-!=
+      var dest/edi: (addr int) <- copy cursor-col-a
+      copy-to *dest, old-col
+      var cursor-index-in-word/eax: int <- cursor-index curr-word
+      add-to *dest, cursor-index-in-word
+    }
+    # loop update
     var next-word-ah/edx: (addr handle word) <- get curr-word, next
     curr-word <- lookup *next-word-ah
     increment-final-element curr-path
@@ -403,9 +414,7 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding
 #
 # Outputs:
 # - Return the farthest column written.
-# - If final-word is same as cursor-word, do some additional computation to set
-#   cursor-col-a.
-fn render-column screen: (addr screen), functions: (addr handle function), bindings: (addr table), scratch: (addr line), final-word: (addr word), top-row: int, left-col: int, cursor-word: (addr word), cursor-col-a: (addr int) -> right-col/ecx: int {
+fn render-column screen: (addr screen), functions: (addr handle function), bindings: (addr table), scratch: (addr line), final-word: (addr word), top-row: int, left-col: int -> right-col/ecx: int {
   var max-width/ecx: int <- copy 0
   {
     # indent stack
@@ -451,17 +460,6 @@ fn render-column screen: (addr screen), functions: (addr handle function), bindi
     max-width <- copy size
   }
 
-  # update cursor
-  {
-    var f/eax: (addr word) <- copy final-word
-    compare f, cursor-word
-    break-if-!=
-    var cursor-index/eax: int <- cursor-index cursor-word
-    cursor-index <- add left-col
-    var dest/edi: (addr int) <- copy cursor-col-a
-    copy-to *dest, cursor-index
-  }
-
   # post-process right-col
   right-col <- copy max-width
   right-col <- add left-col