about summary refs log tree commit diff stats
path: root/apps/tile
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-11-15 20:29:43 -0800
committerKartik Agaram <vc@akkartik.com>2020-11-15 20:30:01 -0800
commit56ed1a1073596ccbfe66ed45a53f18fd97bb1193 (patch)
tree33b7cf49e6d89c5d0b451c066f903d079cdc707c /apps/tile
parenta8dfb603fdd72c826679546053b5b6bf1dc01179 (diff)
downloadmu-56ed1a1073596ccbfe66ed45a53f18fd97bb1193.tar.gz
7243 - tile: starting to make functions editable
Diffstat (limited to 'apps/tile')
-rw-r--r--apps/tile/environment.mu38
1 files changed, 24 insertions, 14 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index 64af0c3a..93fe2196 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -1515,33 +1515,43 @@ fn clear-canvas _env: (addr environment) {
   reset-formatting screen
   print-string screen, " define function  "
   # primitives
-  var start-col/ecx: int <- copy repl-col
-  start-col <- subtract 0x28
-  move-cursor screen, 1, start-col
+  render-primitives screen, repl-col
+  # currently defined functions
+  render-functions screen, repl-col, env
+}
+
+fn render-primitives screen: (addr screen), right-col: int {
+  var left-col/ecx: int <- copy right-col
+  left-col <- subtract 0x28
+  move-cursor screen, 1, left-col
   print-string screen, "primitives:"
-  start-col <- add 2
-  move-cursor screen, 2, start-col
+  left-col <- add 2
+  move-cursor screen, 2, left-col
   print-string screen, "+ - * len"
-  move-cursor screen, 3, start-col
+  move-cursor screen, 3, left-col
   print-string screen, "open read slurp lines"
-  move-cursor screen, 4, start-col
+  move-cursor screen, 4, left-col
   print-string screen, "fake-screen print move"
-  move-cursor screen, 5, start-col
+  move-cursor screen, 5, left-col
   print-string screen, "up down left right"
-  move-cursor screen, 6, start-col
+  move-cursor screen, 6, left-col
   print-string screen, "dup swap"
-  # currently defined functions
-  start-col <- subtract 2
-  move-cursor screen, 8, start-col
+}
+
+fn render-functions screen: (addr screen), right-col: int, _env: (addr environment) {
+  var left-col/ecx: int <- copy right-col
+  left-col <- subtract 0x28
+  move-cursor screen, 8, left-col
   print-string screen, "functions:"
-  start-col <- add 2
+  left-col <- add 2
   var row/ebx: int <- copy 9
+  var env/esi: (addr environment) <- copy _env
   var functions/esi: (addr handle function) <- get env, functions
   {
     var curr/eax: (addr function) <- lookup *functions
     compare curr, 0
     break-if-=
-    row <- render-function screen, row, start-col, curr
+    row <- render-function screen, row, left-col, curr
     functions <- get curr, next
     row <- increment
     loop