diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-06-05 22:35:23 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-06-05 22:35:23 -0700 |
commit | aa804a0a67a081ae55761c67053a07dc7fdf50c0 (patch) | |
tree | 3cb6190801839602d43da197cd8bf8ecff1f1613 /prototypes | |
parent | 4d8364749413a7cdc17ad6c49b3ce782d3b2a790 (diff) | |
download | mu-aa804a0a67a081ae55761c67053a07dc7fdf50c0.tar.gz |
6483 - finally, bold markup in the paginator
The state machines are still not composing perfectly. The initial asterisk gets added in one, and the trailing asterisk in another. I suppose "always render the terminator" is fairly regular.
Diffstat (limited to 'prototypes')
-rw-r--r-- | prototypes/browse/24-bold/main.mu | 76 |
1 files changed, 75 insertions, 1 deletions
diff --git a/prototypes/browse/24-bold/main.mu b/prototypes/browse/24-bold/main.mu index cf2fef0d..f0a74687 100644 --- a/prototypes/browse/24-bold/main.mu +++ b/prototypes/browse/24-bold/main.mu @@ -11,6 +11,7 @@ fn main args: (addr array (addr array byte)) -> exit-status/ebx: int { var screen-position-state-storage: screen-position-state var screen-position-state/eax: (addr screen-position-state) <- address screen-position-state-storage init-screen-position-state screen-position-state + start-color 0xec, 7 # 236 = darkish gray { render fs, screen-position-state var key/eax: byte <- read-key @@ -28,7 +29,73 @@ fn render fs: (addr file-state), state: (addr screen-position-state) { } fn render-normal fs: (addr file-state), state: (addr screen-position-state) { - { +$render-normal:body: { + # if done-drawing?(state) break + var done?/eax: boolean <- done-drawing? state + compare done?, 0 # false + break-if-!= + # + var c/eax: byte <- next-char fs + # if (c == EOF) break + compare c, 0xffffffff # EOF marker + break-if-= + # if (c == '*') print it and break + compare c, 0x2a # '*' + { + break-if-!= + start-color 0xec, 7 # 236 = darkish gray + start-bold + add-char state, c + render-until-asterisk fs, state + reset-formatting + start-color 0xec, 7 # 236 = darkish gray + loop $render-normal:body + } + compare c, 0x5f # '_' + { + break-if-!= + start-color 0xec, 7 # 236 = darkish gray + start-bold + add-char state, c + render-until-underscore fs, state + reset-formatting + start-color 0xec, 7 # 236 = darkish gray + loop $render-normal:body + } + # + add-char state, c + # + loop + } +} + +fn render-until-asterisk fs: (addr file-state), state: (addr screen-position-state) { +$render-until-asterisk:body: { + # if done-drawing?(state) break + var done?/eax: boolean <- done-drawing? state + compare done?, 0 # false + break-if-!= + # + var c/eax: byte <- next-char fs + # if (c == EOF) break + compare c, 0xffffffff # EOF marker + break-if-= + # if (c == '*') print it and break + compare c, 0x2a # '*' + { + break-if-!= + add-char state, c + break $render-until-asterisk:body + } + # + add-char state, c + # + loop + } +} + +fn render-until-underscore fs: (addr file-state), state: (addr screen-position-state) { +$render-until-underscore:body: { # if done-drawing?(state) break var done?/eax: boolean <- done-drawing? state compare done?, 0 # false @@ -38,6 +105,13 @@ fn render-normal fs: (addr file-state), state: (addr screen-position-state) { # if (c == EOF) break compare c, 0xffffffff # EOF marker break-if-= + # if (c == '_') print it and break + compare c, 0x5f # '_' + { + break-if-!= + add-char state, c + break $render-until-underscore:body + } # add-char state, c # |