From 73b7be20eb27b6690425bc370922687d4d18f963 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 7 Jun 2020 23:43:11 -0700 Subject: 6500 Minor formatting tweaks. --- prototypes/browse/28/main.mu | 158 +++++++++++++++++++++---------------------- 1 file changed, 79 insertions(+), 79 deletions(-) (limited to 'prototypes/browse/28') diff --git a/prototypes/browse/28/main.mu b/prototypes/browse/28/main.mu index b12ddc34..613e8aba 100644 --- a/prototypes/browse/28/main.mu +++ b/prototypes/browse/28/main.mu @@ -29,103 +29,103 @@ fn render fs: (addr file-state), state: (addr screen-position-state) { } fn render-normal fs: (addr file-state), state: (addr screen-position-state) { - var newline-seen?/esi: boolean <- copy 0 # false - var start-of-paragraph?/edi: boolean <- copy 1 # true - var previous-char/ebx: byte <- copy 0 + var newline-seen?/esi: boolean <- copy 0 # false + var start-of-paragraph?/edi: boolean <- copy 1 # true + var previous-char/ebx: byte <- copy 0 $render-normal:loop: { - # 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 done-drawing?(state) break + var done?/eax: boolean <- done-drawing? state + compare done?, 0 # false + break-if-!= + var c/eax: byte <- next-char fs $render-normal:loop-body: { - # if (c == EOF) break - compare c, 0xffffffff # EOF marker - break-if-= $render-normal:loop + # if (c == EOF) break + compare c, 0xffffffff # EOF marker + break-if-= $render-normal:loop - ## if (c == newline) perform some fairly sophisticated parsing for soft newlines - compare c, 0xa # newline + ## if (c == newline) perform some fairly sophisticated parsing for soft newlines + compare c, 0xa # newline + { + break-if-!= + # if it's the first newline, buffer it + compare newline-seen?, 0 { break-if-!= - # if it's the first newline, buffer it - compare newline-seen?, 0 - { - break-if-!= - newline-seen? <- copy 1 # true - break $render-normal:loop-body - } - # otherwise render two newlines - { - break-if-= - add-char state, 0xa # newline - add-char state, 0xa # newline - newline-seen? <- copy 0 # false - start-of-paragraph? <- copy 1 # true - break $render-normal:loop-body - } + newline-seen? <- copy 1 # true + break $render-normal:loop-body } - # if start of paragraph and c == '#', switch to header - compare start-of-paragraph?, 0 + # otherwise render two newlines { break-if-= - compare c, 0x23 # '#' - { - break-if-!= - render-header-line fs, state - newline-seen? <- copy 1 # true - break $render-normal:loop-body - } - } - # c is not a newline - start-of-paragraph? <- copy 0 # false - # if c is unprintable (particularly a '\r' CR), skip it - compare c, 0x20 - loop-if-< - # If there's a newline buffered and c is a space, print the buffered - # newline (hard newline). - # If there's a newline buffered and c is not a newline or space, print a - # space (soft newline). - compare newline-seen?, 0 # false -$render-normal:flush-buffered-newline: { - break-if-= + add-char state, 0xa # newline + add-char state, 0xa # newline newline-seen? <- copy 0 # false - { - compare c, 0x20 - break-if-!= - add-char state, 0xa # newline - break $render-normal:flush-buffered-newline - } - add-char state, 0x20 # space - # fall through to print c + start-of-paragraph? <- copy 1 # true + break $render-normal:loop-body } - ## end soft newline support - - # if (c == '*') switch to bold - compare c, 0x2a # '*' + } + # if start of paragraph and c == '#', switch to header + compare start-of-paragraph?, 0 + { + break-if-= + compare c, 0x23 # '#' { break-if-!= - start-bold - render-until-asterisk fs, state - normal-text + render-header-line fs, state + newline-seen? <- copy 1 # true break $render-normal:loop-body } - # if (c == '_') switch to bold - compare c, 0x5f # '_' + } + # c is not a newline + start-of-paragraph? <- copy 0 # false + # if c is unprintable (particularly a '\r' CR), skip it + compare c, 0x20 + loop-if-< + # If there's a newline buffered and c is a space, print the buffered + # newline (hard newline). + # If there's a newline buffered and c is not a newline or space, print a + # space (soft newline). + compare newline-seen?, 0 # false +$render-normal:flush-buffered-newline: { + break-if-= + newline-seen? <- copy 0 # false { + compare c, 0x20 break-if-!= - start-color 0xec, 7 # 236 = darkish gray - start-bold - render-until-underscore fs, state - reset-formatting - start-color 0xec, 7 # 236 = darkish gray - break $render-normal:loop-body + add-char state, 0xa # newline + break $render-normal:flush-buffered-newline } - # - add-char state, c + add-char state, 0x20 # space + # fall through to print c } - previous-char <- copy c - loop - } + ## end soft newline support + + # if (c == '*') switch to bold + compare c, 0x2a # '*' + { + break-if-!= + start-bold + render-until-asterisk fs, state + normal-text + break $render-normal:loop-body + } + # if (c == '_') switch to bold + compare c, 0x5f # '_' + { + break-if-!= + start-color 0xec, 7 # 236 = darkish gray + start-bold + render-until-underscore fs, state + reset-formatting + start-color 0xec, 7 # 236 = darkish gray + break $render-normal:loop-body + } + # + add-char state, c + } # $render-normal:loop-body + previous-char <- copy c + loop + } # $render-normal:loop } fn render-header-line fs: (addr file-state), state: (addr screen-position-state) { -- cgit 1.4.1-2-gfad0