diff options
author | Kartik Agaram <vc@akkartik.com> | 2021-01-22 20:57:29 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2021-01-22 20:57:29 -0800 |
commit | 1b09418c60cd48d021f95a8c3f248a33421d776f (patch) | |
tree | 22ce69760518152efcaf7f0950bc751facc95336 /baremetal/500text-screen.mu | |
parent | a51bc7a1e0c287d9a0be9c43cd3967dcfb6107f8 (diff) | |
download | mu-1b09418c60cd48d021f95a8c3f248a33421d776f.tar.gz |
7542 - baremetal: support cursor on a grapheme
So far we've drawn a space implicitly at the cursor. Now I allow drawing an arbitrary grapheme when drawing the cursor. But the caller has to specify what to draw. (The alternative would be for layer 103 to track every single grapheme on screen along with its color and any other future attributes, just to be able to paint and unpaint the background for a single character.) I've modified existing helpers for drawing multiple graphemes to always clear the final cursor position after they finish drawing. That seems reasonable for terminal-like applications. Applications that need to control the screen in a more random-access manner will need to track the grapheme at the cursor for themselves.
Diffstat (limited to 'baremetal/500text-screen.mu')
-rw-r--r-- | baremetal/500text-screen.mu | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/baremetal/500text-screen.mu b/baremetal/500text-screen.mu index b387496f..fbc2ef43 100644 --- a/baremetal/500text-screen.mu +++ b/baremetal/500text-screen.mu @@ -112,11 +112,11 @@ fn cursor-position screen: (addr screen) -> _/eax: int, _/ecx: int { return *cursor-x-addr, *cursor-y-addr } -fn set-cursor-position screen: (addr screen), x: int, y: int { +fn set-cursor-position screen: (addr screen), x: int, y: int, g: grapheme { { compare screen, 0 break-if-!= - set-cursor-position-on-real-screen x, y + set-cursor-position-on-real-screen x, y, g return } # fake screen @@ -157,6 +157,11 @@ fn set-cursor-position screen: (addr screen), x: int, y: int { dest <- get screen-addr, cursor-y src <- copy y copy-to *dest, src + # + var cursor-x/eax: int <- copy 0 + var cursor-y/ecx: int <- copy 0 + cursor-x, cursor-y <- cursor-position screen-addr + draw-grapheme screen-addr, g, cursor-x, cursor-y, 0 # cursor color not tracked for fake screen } fn clear-screen screen: (addr screen) { @@ -168,7 +173,7 @@ fn clear-screen screen: (addr screen) { } # fake screen var space/edi: grapheme <- copy 0x20 - set-cursor-position screen, 0, 0 + set-cursor-position screen, 0, 0, space var screen-addr/esi: (addr screen) <- copy screen var y/eax: int <- copy 1 var height/ecx: (addr int) <- get screen-addr, height @@ -187,7 +192,7 @@ fn clear-screen screen: (addr screen) { y <- increment loop } - set-cursor-position screen, 0, 0 + set-cursor-position screen, 0, 0, space } # there's no grapheme that guarantees to cover every pixel, so we'll bump down |