about summary refs log tree commit diff stats
path: root/500fake-screen.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-09-02 15:38:45 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-09-02 15:38:45 -0700
commit60a50c92456fed87c4eaceee7a4649098238a2eb (patch)
tree4b388ddfdd0d901a07db0fce7f4880560ea96cde /500fake-screen.mu
parent3f953ea5c861706f4996e9d4a9133d3806ad7a93 (diff)
downloadmu-60a50c92456fed87c4eaceee7a4649098238a2eb.tar.gz
support combining characters in streams of text
Fake screens can't handle them yet.
Diffstat (limited to '500fake-screen.mu')
-rw-r--r--500fake-screen.mu23
1 files changed, 22 insertions, 1 deletions
diff --git a/500fake-screen.mu b/500fake-screen.mu
index be7d9e0f..bda3673f 100644
--- a/500fake-screen.mu
+++ b/500fake-screen.mu
@@ -23,7 +23,7 @@ type screen {
 }
 
 type screen-cell {
-  data: code-point
+  data: code-point  # TODO: support combining characters overlaid on another character
   color: int
   background-color: int
   unused?: boolean
@@ -109,6 +109,27 @@ fn draw-code-point _screen: (addr screen), c: code-point, x: int, y: int, color:
   return 1
 }
 
+fn overlay-code-point _screen: (addr screen), c: code-point, x: int, y: int, color: int, background-color: int -> _/eax: int {
+  var screen/esi: (addr screen) <- copy _screen
+  {
+    compare screen, 0
+    break-if-!=
+    var result/eax: int <- overlay-code-point-on-real-screen c, x, y, color, background-color
+    return result
+  }
+  # fake screen
+  # TODO: support overlays in fake screen
+  var wide?/eax: boolean <- wide-code-point? c
+  compare wide?, 0/false
+  {
+    break-if-=
+    draw-wide-code-point-on-fake-screen screen, c, x, y, color, background-color
+    return 2
+  }
+  draw-narrow-code-point-on-fake-screen screen, c, x, y, color, background-color
+  return 1
+}
+
 fn draw-narrow-code-point-on-fake-screen _screen: (addr screen), c: code-point, x: int, y: int, color: int, background-color: int {
   var screen/esi: (addr screen) <- copy _screen
   # ignore if out of bounds