diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-06-07 23:43:11 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-06-07 23:49:53 -0700 |
commit | 73b7be20eb27b6690425bc370922687d4d18f963 (patch) | |
tree | d9fa214f81d8f768fa0b7c0ae0e685b09ed3ac18 | |
parent | 64bf0e8b972e9d89b7dd8aeceac418f9e372dcc6 (diff) | |
download | mu-73b7be20eb27b6690425bc370922687d4d18f963.tar.gz |
6500
Minor formatting tweaks.
-rw-r--r-- | prototypes/browse/27/main.mu | 6 | ||||
-rw-r--r-- | prototypes/browse/28/main.mu | 158 | ||||
-rw-r--r-- | prototypes/browse/29/main.mu | 184 |
3 files changed, 174 insertions, 174 deletions
diff --git a/prototypes/browse/27/main.mu b/prototypes/browse/27/main.mu index 48664533..13764211 100644 --- a/prototypes/browse/27/main.mu +++ b/prototypes/browse/27/main.mu @@ -29,8 +29,8 @@ 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 newline-seen?/esi: boolean <- copy 0 # false + var start-of-paragraph?/edi: boolean <- copy 1 # true $render-normal:loop: { # if done-drawing?(state) break var done?/eax: boolean <- done-drawing? state @@ -123,7 +123,7 @@ $render-normal:flush-buffered-newline: { add-char state, c # loop - } + } # $render-normal:loop } fn render-header-line fs: (addr file-state), state: (addr screen-position-state) { 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) { diff --git a/prototypes/browse/29/main.mu b/prototypes/browse/29/main.mu index 747de544..e84c4176 100644 --- a/prototypes/browse/29/main.mu +++ b/prototypes/browse/29/main.mu @@ -29,113 +29,113 @@ 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 - } + 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 } - # 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 + } + # if start of paragraph and c == '#', switch to header + compare start-of-paragraph?, 0 + { + 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-= - 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 + break-if-= + newline-seen? <- copy 0 # false + { + compare c, 0x20 + break-if-!= + add-char state, 0xa # newline + break $render-normal:flush-buffered-newline } - ## end soft newline support + add-char state, 0x20 # space + # fall through to print c + } + ## end soft newline support $render-normal:whitespace-separated-regions: { - # if previous-char wasn't whitespace, skip this block - { - compare previous-char, 0x20 # space - break-if-= - compare previous-char, 0xa # newline - break-if-= - break $render-normal:whitespace-separated-regions - } - # 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 - } + # if previous-char wasn't whitespace, skip this block + { + compare previous-char, 0x20 # space + break-if-= + compare previous-char, 0xa # newline + break-if-= + break $render-normal:whitespace-separated-regions + } + # 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 } - previous-char <- copy c - loop - } + # + 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) { |