diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-10-26 22:46:17 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-10-26 23:45:40 -0700 |
commit | 22ade886d56c3336c7104ca54d86fa3625275a44 (patch) | |
tree | 352daf896b340088141fc00bca5f04ba1b217083 /apps | |
parent | 0f9a65dc0d10d93319eacf8ccff75a068e5f97a8 (diff) | |
download | mu-22ade886d56c3336c7104ca54d86fa3625275a44.tar.gz |
7121
Starting to polish 'line-count' demo: filename line-count = filename open lines len
Diffstat (limited to 'apps')
-rw-r--r-- | apps/tile/environment.mu | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu index 971e8d9f..f483367f 100644 --- a/apps/tile/environment.mu +++ b/apps/tile/environment.mu @@ -1555,7 +1555,7 @@ fn clear-canvas _env: (addr environment) { print-string screen, " define function " # primitives var start-col/ecx: int <- copy repl-col - start-col <- subtract 0x18 + start-col <- subtract 0x20 move-cursor screen, 1, start-col print-string screen, "primitives:" start-col <- add 2 @@ -1576,8 +1576,7 @@ fn clear-canvas _env: (addr environment) { var curr/eax: (addr function) <- lookup *functions compare curr, 0 break-if-= - move-cursor screen, row, start-col - render-function screen, curr + row <- render-function screen, row, start-col, curr functions <- get curr, next row <- increment loop @@ -1585,18 +1584,25 @@ fn clear-canvas _env: (addr environment) { } # only single-line functions supported for now -fn render-function screen: (addr screen), _f: (addr function) { +fn render-function screen: (addr screen), row: int, col: int, _f: (addr function) -> out-row/ebx: int { var f/esi: (addr function) <- copy _f var args/ecx: (addr handle word) <- get f, args + move-cursor screen, row, col print-words-in-reverse screen, args var name-ah/eax: (addr handle array byte) <- get f, name var name/eax: (addr array byte) <- lookup *name-ah + start-bold screen print-string screen, name - print-string screen, " = " + reset-formatting screen + increment row + add-to col, 2 + move-cursor screen, row, col + print-string screen, "= " var body-ah/eax: (addr handle line) <- get f, body var body/eax: (addr line) <- lookup *body-ah var body-words-ah/eax: (addr handle word) <- get body, data print-words screen, body-words-ah + out-row <- copy row } fn real-grapheme? g: grapheme -> result/eax: boolean { |