about summary refs log tree commit diff stats
path: root/501draw-text.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-09-02 12:44:56 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-09-02 12:44:56 -0700
commit80378db26b2bc018325fa089e0b22e9be8cf54c1 (patch)
treeb05f02cfccb41a4a48f6adef814d908bf67cf055 /501draw-text.mu
parent1e1dd6b4d5c82c780e096931a55778a2932c5a85 (diff)
downloadmu-80378db26b2bc018325fa089e0b22e9be8cf54c1.tar.gz
.
Inline render-code-point in one of its call-sites before we add support
for combining characters.
Diffstat (limited to '501draw-text.mu')
-rw-r--r--501draw-text.mu24
1 files 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