From bec147690f631800265d4771b911c1d54a05e489 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 6 Dec 2020 21:48:14 -0800 Subject: 7341 - tile: function editing done A tiny modicum of reuse amidst all this copypasta: I'm able to reuse the same function that renders lines without stacks in the sandbox. --- apps/tile/environment.mu | 15 ++++++--------- apps/tile/word.mu | 13 ------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu index e15c6e83..3103dd6e 100644 --- a/apps/tile/environment.mu +++ b/apps/tile/environment.mu @@ -1608,7 +1608,6 @@ fn render-line-without-stack screen: (addr screen), _line: (addr line), curr-row #? } #? print-string 0, "\n" var old-col/edx: int <- copy curr-col - reset-formatting screen move-cursor screen, curr-row, curr-col print-word screen, curr-word { @@ -2047,16 +2046,14 @@ fn render-function screen: (addr screen), row: int, col: int, _f: (addr function move-cursor screen, row, col print-string screen, "≡ " add-to col, 2 - var cursor-row/eax: (addr int) <- get f, cursor-row - var src/ecx: int <- copy row - copy-to *cursor-row, src - var cursor-col/eax: (addr int) <- get f, cursor-col - src <- copy col - copy-to *cursor-col, src + var cursor-row/ecx: (addr int) <- get f, cursor-row + var cursor-col/edx: (addr int) <- get f, cursor-col + var cursor-word-ah/eax: (addr handle word) <- get f, cursor-word + var _cursor-word/eax: (addr word) <- lookup *cursor-word-ah + var cursor-word/ebx: (addr word) <- copy _cursor-word 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 + render-line-without-stack screen, body, row, col, cursor-word, cursor-row, cursor-col } fn real-grapheme? g: grapheme -> _/eax: boolean { diff --git a/apps/tile/word.mu b/apps/tile/word.mu index 69d20fc2..2d776caf 100644 --- a/apps/tile/word.mu +++ b/apps/tile/word.mu @@ -257,19 +257,6 @@ fn print-word screen: (addr screen), _self: (addr word) { render-gap-buffer screen, data } -fn print-words screen: (addr screen), _words-ah: (addr handle word) { - var words-ah/eax: (addr handle word) <- copy _words-ah - var words-a/eax: (addr word) <- lookup *words-ah - compare words-a, 0 - break-if-= - # print - print-word screen, words-a - print-string screen, " " - # recurse - var next-ah/eax: (addr handle word) <- get words-a, next - print-words screen, next-ah -} - fn print-words-in-reverse screen: (addr screen), _words-ah: (addr handle word) { var words-ah/eax: (addr handle word) <- copy _words-ah var words-a/eax: (addr word) <- lookup *words-ah -- cgit 1.4.1-2-gfad0