From 56ed1a1073596ccbfe66ed45a53f18fd97bb1193 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 15 Nov 2020 20:29:43 -0800 Subject: 7243 - tile: starting to make functions editable --- apps/tile/environment.mu | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'apps/tile/environment.mu') 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 -- cgit 1.4.1-2-gfad0