diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-08-29 22:16:34 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-08-29 22:20:09 -0700 |
commit | 6e05a8fa27139ddf75a029ad94d44b48a92785b2 (patch) | |
tree | 8d04ae5d057030246305c9dc4b46fb2fe176f643 /501draw-text.mu | |
parent | 4b90a26d71513f3b908b7f7ec651996ddf6460d6 (diff) | |
download | mu-6e05a8fa27139ddf75a029ad94d44b48a92785b2.tar.gz |
fix bad terminology: grapheme -> code point
Unix text-mode terminals transparently support utf-8 these days, and so I treat utf-8 sequences (which I call graphemes in Mu) as fundamental. I then blindly carried over this state of affairs to bare-metal Mu, where it makes no sense. If you don't have a terminal handling font-rendering for you, fonts are most often indexed by code points and not utf-8 sequences.
Diffstat (limited to '501draw-text.mu')
-rw-r--r-- | 501draw-text.mu | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/501draw-text.mu b/501draw-text.mu index 4a415ddd..0b74c160 100644 --- a/501draw-text.mu +++ b/501draw-text.mu @@ -81,11 +81,11 @@ fn move-cursor-to-left-margin-of-next-line screen: (addr screen) { set-cursor-position screen, cursor-x, cursor-y } -fn draw-grapheme-at-cursor-over-full-screen screen: (addr screen), g: grapheme, color: int, background-color: int { +fn draw-code-point-at-cursor-over-full-screen screen: (addr screen), c: code-point, color: int, background-color: int { var cursor-x/eax: int <- copy 0 var cursor-y/ecx: int <- copy 0 cursor-x, cursor-y <- cursor-position screen - var _offset/eax: int <- draw-grapheme screen, g, cursor-x, cursor-y, color, background-color + var _offset/eax: int <- draw-code-point screen, c, cursor-x, cursor-y, color, background-color var offset/edx: int <- copy _offset var width/eax: int <- copy 0 var dummy/ecx: int <- copy 0 @@ -100,11 +100,6 @@ fn draw-grapheme-at-cursor-over-full-screen screen: (addr screen), g: grapheme, } } -fn draw-code-point-at-cursor-over-full-screen screen: (addr screen), c: code-point, color: int, background-color: int { - var g/eax: grapheme <- copy c - draw-grapheme-at-cursor-over-full-screen screen, g, color, background-color -} - # draw a single line of text from x, y to xmax # return the next 'x' coordinate # if there isn't enough space, truncate @@ -125,7 +120,8 @@ fn draw-stream-rightward screen: (addr screen), stream: (addr stream byte), x: i var g/eax: grapheme <- read-grapheme stream compare g, 0xffffffff/end-of-file break-if-= - var offset/eax: int <- draw-grapheme screen, g, xcurr, y, color, background-color + var c/eax: code-point <- to-code-point g + var offset/eax: int <- draw-code-point screen, c, xcurr, y, color, background-color xcurr <- add offset loop } @@ -156,8 +152,8 @@ fn draw-text-rightward-from-cursor-over-full-screen screen: (addr screen), text: draw-text-rightward-from-cursor screen, text, width, color, background-color } -fn render-grapheme screen: (addr screen), g: grapheme, xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int, background-color: int -> _/eax: int, _/ecx: int { - compare g, 0xa/newline +fn render-code-point screen: (addr screen), c: code-point, xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int, background-color: int -> _/eax: int, _/ecx: int { + compare c, 0xa/newline var x/ecx: int <- copy x { break-if-!= @@ -167,7 +163,7 @@ fn render-grapheme screen: (addr screen), g: grapheme, xmin: int, ymin: int, xma increment y return x, y } - var offset/eax: int <- draw-grapheme screen, g, x, y, color, background-color + var offset/eax: int <- draw-code-point screen, c, x, y, color, background-color x <- add offset compare x, xmax { @@ -210,15 +206,16 @@ fn draw-text-wrapping-right-then-down screen: (addr screen), _text: (addr array 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 g/ebx: grapheme <- copy 0 + var c/ebx: code-point <- copy 0 { { - var _g/eax: grapheme <- read-grapheme stream - g <- copy _g + var g/eax: grapheme <- read-grapheme stream + var _c/eax: code-point <- to-code-point g + c <- copy _c } - compare g, 0xffffffff/end-of-file + compare c, 0xffffffff/end-of-file break-if-= - xcurr, ycurr <- render-grapheme screen, g, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color + xcurr, ycurr <- render-code-point screen, c, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color loop } set-cursor-position screen, xcurr, ycurr @@ -301,7 +298,8 @@ fn draw-int32-hex-wrapping-right-then-down screen: (addr screen), n: int, xmin: var g/eax: grapheme <- read-grapheme stream compare g, 0xffffffff/end-of-file break-if-= - var offset/eax: int <- draw-grapheme screen, g, xcurr, ycurr, color, background-color + var c/eax: code-point <- to-code-point g + var offset/eax: int <- draw-code-point screen, c, xcurr, ycurr, color, background-color xcurr <- add offset compare xcurr, xmax { @@ -355,7 +353,8 @@ fn draw-int32-decimal-wrapping-right-then-down screen: (addr screen), n: int, xm var g/eax: grapheme <- read-grapheme stream compare g, 0xffffffff/end-of-file break-if-= - var offset/eax: int <- draw-grapheme screen, g, xcurr, ycurr, color, background-color + var c/eax: code-point <- to-code-point g + var offset/eax: int <- draw-code-point screen, c, xcurr, ycurr, color, background-color xcurr <- add offset compare xcurr, xmax { @@ -422,7 +421,8 @@ fn draw-stream-downward screen: (addr screen), stream: (addr stream byte), x: in var g/eax: grapheme <- read-grapheme stream compare g, 0xffffffff/end-of-file break-if-= - var dummy/eax: int <- draw-grapheme screen, g, x, ycurr, color, background-color + var c/eax: code-point <- to-code-point g + var dummy/eax: int <- draw-code-point screen, c, x, ycurr, color, background-color ycurr <- increment loop } @@ -463,7 +463,8 @@ fn draw-stream-wrapping-down-then-right screen: (addr screen), stream: (addr str var g/eax: grapheme <- read-grapheme stream compare g, 0xffffffff/end-of-file break-if-= - var offset/eax: int <- draw-grapheme screen, g, xcurr, ycurr, color, background-color + var c/eax: code-point <- to-code-point g + var offset/eax: int <- draw-code-point screen, c, xcurr, ycurr, color, background-color ycurr <- increment compare ycurr, ymax { |