From aa804a0a67a081ae55761c67053a07dc7fdf50c0 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Fri, 5 Jun 2020 22:35:23 -0700 Subject: 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. --- prototypes/browse/24-bold/main.mu | 76 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) 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 # -- cgit 1.4.1-2-gfad0