From 80378db26b2bc018325fa089e0b22e9be8cf54c1 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 2 Sep 2021 12:44:56 -0700 Subject: [PATCH] . Inline render-code-point in one of its call-sites before we add support for combining characters. --- 501draw-text.mu | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/501draw-text.mu b/501draw-text.mu index 9e2d5f43..9d73c27b 100644 --- a/501draw-text.mu +++ b/501draw-text.mu @@ -204,10 +204,10 @@ fn draw-text-wrapping-right-then-down screen: (addr screen), _text: (addr array # that way the caller can draw more if given the same min and max bounding-box. # if there isn't enough space, truncate fn draw-stream-wrapping-right-then-down screen: (addr screen), stream: (addr stream byte), xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int, background-color: int -> _/eax: int, _/ecx: int { - var xcurr/eax: int <- copy x - var ycurr/ecx: int <- copy y + var xcurr/ecx: int <- copy x + var ycurr/edx: int <- copy y var c/ebx: code-point <- copy 0 - { + $draw-stream-wrapping-right-then-down:loop: { { var g/eax: grapheme <- read-grapheme stream var _c/eax: code-point <- to-code-point g @@ -215,7 +215,23 @@ fn draw-stream-wrapping-right-then-down screen: (addr screen), stream: (addr str } compare c, 0xffffffff/end-of-file break-if-= - xcurr, ycurr <- render-code-point screen, c, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color + compare c, 0xa/newline + { + break-if-!= + # minimum effort to clear cursor + var dummy/eax: int <- draw-code-point screen, 0x20/space, xcurr, ycurr, color, background-color + xcurr <- copy xmin + ycurr <- increment + break $draw-stream-wrapping-right-then-down:loop + } + var offset/eax: int <- draw-code-point screen, c, xcurr, ycurr, color, background-color + xcurr <- add offset + compare xcurr, xmax + { + break-if-< + xcurr <- copy xmin + ycurr <- increment + } loop } set-cursor-position screen, xcurr, ycurr