about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-12-14 22:14:13 -0800
committerKartik Agaram <vc@akkartik.com>2020-12-14 22:14:13 -0800
commit001efc35f0702c5a0994b6bc11ebce4e3176be3e (patch)
tree78b1ec3c50794e16b2bab70ba5cfdd999ad14205
parent670cbb3d33807efb2d5e0db9e54ffed42f7ef0e3 (diff)
downloadmu-001efc35f0702c5a0994b6bc11ebce4e3176be3e.tar.gz
7352
-rw-r--r--apps/tile/environment.mu16
-rw-r--r--apps/tile/value-stack.mu26
-rw-r--r--apps/tile/value.mu10
3 files changed, 15 insertions, 37 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index a1dc11a3..5be85086 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -1877,8 +1877,6 @@ fn render-column screen: (addr screen), functions: (addr handle function), bindi
     # render stack
     var curr-row/edx: int <- copy top-row
     curr-row <- add 2  # stack-margin-top
-    var _max-width/eax: int <- value-stack-max-width stack-addr
-    max-width <- copy _max-width
     {
       var top-addr/ecx: (addr int) <- get stack-addr, top
       compare *top-addr, 0
@@ -1889,7 +1887,13 @@ fn render-column screen: (addr screen), functions: (addr handle function), bindi
       var top/ecx: int <- copy *top-addr
       var dest-offset/ecx: (offset value) <- compute-offset data, top
       var val/eax: (addr value) <- index data, dest-offset
-      render-value-at screen, curr-row, indented-col, val, max-width
+      render-value-at screen, curr-row, indented-col, val, 1  # top-level
+      {
+        var width/eax: int <- value-width val, 1
+        compare width, max-width
+        break-if-<=
+        max-width <- copy width
+      }
       var height/eax: int <- value-height val
       curr-row <- add height
       loop
@@ -1903,10 +1907,10 @@ fn render-column screen: (addr screen), functions: (addr handle function), bindi
   move-cursor screen, top-row, left-col
   print-word screen, final-word
   {
-    var size/eax: int <- word-length final-word
-    compare size, max-width
+    var width/eax: int <- word-length final-word
+    compare width, max-width
     break-if-<=
-    max-width <- copy size
+    max-width <- copy width
   }
 
   # post-process right-col
diff --git a/apps/tile/value-stack.mu b/apps/tile/value-stack.mu
index d2209b16..e437f616 100644
--- a/apps/tile/value-stack.mu
+++ b/apps/tile/value-stack.mu
@@ -122,32 +122,6 @@ fn value-stack-length _self: (addr value-stack) -> _/eax: int {
   return *top-addr
 }
 
-fn value-stack-max-width _self: (addr value-stack) -> _/eax: int {
-  var self/esi: (addr value-stack) <- copy _self
-  var data-ah/edi: (addr handle array value) <- get self, data
-  var _data/eax: (addr array value) <- lookup *data-ah
-  var data/edi: (addr array value) <- copy _data
-  var top-addr/ecx: (addr int) <- get self, top
-  var i/ebx: int <- copy 0
-  var result: int
-  {
-    compare i, *top-addr
-    break-if->=
-    var o/edx: (offset value) <- compute-offset data, i
-    var v/edx: (addr value) <- index data, o
-    var w/eax: int <- value-width v, 1  # top-level=true
-    # if (w > result) w = result
-    {
-      compare w, result
-      break-if-<=
-      copy-to result, w
-    }
-    i <- increment
-    loop
-  }
-  return result
-}
-
 fn save-lines in-h: (handle array (handle array byte)), _out-ah: (addr handle array value) {
   var _in/eax: (addr array (handle array byte)) <- lookup in-h
   var in/esi: (addr array (handle array byte)) <- copy _in
diff --git a/apps/tile/value.mu b/apps/tile/value.mu
index 3cb93a1d..912f9ffa 100644
--- a/apps/tile/value.mu
+++ b/apps/tile/value.mu
@@ -1,4 +1,4 @@
-fn render-value-at screen: (addr screen), row: int, col: int, _val: (addr value), max-width: int {
+fn render-value-at screen: (addr screen), row: int, col: int, _val: (addr value), top-level?: boolean {
   move-cursor screen, row, col
   var val/esi: (addr value) <- copy _val
   var val-type/ecx: (addr int) <- get val, type
@@ -58,14 +58,14 @@ fn render-value-at screen: (addr screen), row: int, col: int, _val: (addr value)
   }
   # render ints by default for now
   var val-num/eax: (addr float) <- get val, number-data
-  render-number screen, *val-num, max-width
+  render-number screen, *val-num, top-level?
 }
 
 # synaesthesia
 # TODO: right-justify
-fn render-number screen: (addr screen), val: float, max-width: int {
-  # if max-width is 0, we're inside an array. No coloring.
-  compare max-width, 0
+fn render-number screen: (addr screen), val: float, top-level?: boolean {
+  # if we're inside an array, don't color
+  compare top-level?, 0
   {
     break-if-!=
     print-float-decimal-approximate screen, val, 3