From d3a9db3aff54ea485f409eaaef3d8f56ad77f0dc Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 5 Oct 2020 11:00:05 -0700 Subject: 6958 --- html/apps/browse/main.mu.html | 757 +++++++++++++++++++++--------------------- 1 file changed, 383 insertions(+), 374 deletions(-) (limited to 'html/apps/browse/main.mu.html') diff --git a/html/apps/browse/main.mu.html b/html/apps/browse/main.mu.html index 72eae1e4..6f66e8b8 100644 --- a/html/apps/browse/main.mu.html +++ b/html/apps/browse/main.mu.html @@ -14,15 +14,14 @@ pre { white-space: pre-wrap; font-family: monospace; color: #000000; background- body { font-size:12pt; font-family: monospace; color: #000000; background-color: #c6c6c6; } a { color:inherit; } * { font-size:12pt; font-size: 1em; } -.muTest { color: #5f8700; } +.muComment { color: #005faf; } .LineNr { } -.muFunction { color: #af5f00; text-decoration: underline; } -.Comment { color: #005faf; } .SpecialChar { color: #d70000; } .Constant { color: #008787; } +.muFunction { color: #af5f00; text-decoration: underline; } +.muTest { color: #5f8700; } .Delimiter { color: #c000c0; } .PreProc { color: #c000c0; } -.SalientComment { color: #0000af; } --> @@ -60,10 +59,10 @@ if ('onhashchange' in window) {
   1 fn main args-on-stack: (addr array addr array byte) -> exit-status/ebx: int {
   2   var args/eax: (addr array addr array byte) <- copy args-on-stack
-  3   var tmp/ecx: int <- length args
+  3   var len/ecx: int <- length args
   4   $main-body: {
-  5     # if (len(args) <= 1) print usage and exit
-  6     compare tmp, 1
+  5     # if (len(args) <= 1) print usage and exit
+  6     compare len, 1
   7     {
   8       break-if->
   9       print-string-to-real-screen "usage: browse [filename]\n"
@@ -71,390 +70,400 @@ if ('onhashchange' in window) {
  11       exit-status <- copy 1
  12       break $main-body
  13     }
- 14     # if (args[1] == "test") run-tests()
- 15     var tmp2/ecx: (addr addr array byte) <- index args, 1
- 16     var tmp3/eax: boolean <- string-equal? *tmp2, "test"
- 17     compare tmp3, 0
+ 14     # if (args[1] == "test") run-tests()
+ 15     var tmp/ecx: (addr addr array byte) <- index args, 1
+ 16     var tmp2/eax: boolean <- string-equal? *tmp, "test"
+ 17     compare tmp2, 0
  18     {
  19       break-if-=
  20       run-tests
- 21       exit-status <- copy 0  # TODO: get at Num-test-failures somehow
+ 21       exit-status <- copy 0  # TODO: get at Num-test-failures somehow
  22       break $main-body
  23     }
- 24     # otherwise interactive mode
+ 24     # otherwise interactive mode
  25     exit-status <- interactive args-on-stack
  26   }
  27 }
  28 
  29 fn interactive args: (addr array addr array byte) -> exit-status/ebx: int {
- 30   # initialize fs from args[1]
- 31   var filename/eax: (addr array byte) <- first-arg args
- 32   var file-storage: (handle buffered-file)
- 33   var file-storage-addr/esi: (addr handle buffered-file) <- address file-storage
- 34   open filename, 0, file-storage-addr
- 35   var _fs/eax: (addr buffered-file) <- lookup file-storage
- 36   var fs/esi: (addr buffered-file) <- copy _fs
- 37   #
- 38   enable-screen-grid-mode
- 39   enable-keyboard-immediate-mode
- 40   # initialize screen state
- 41   var paginated-screen-storage: paginated-screen
- 42   var paginated-screen/eax: (addr paginated-screen) <- address paginated-screen-storage
- 43   initialize-paginated-screen paginated-screen, 0x40, 2, 5
- 44   normal-text paginated-screen
- 45   #
- 46   {
- 47     render paginated-screen, fs
- 48     var key/eax: byte <- read-key
- 49     compare key, 0x71  # 'q'
- 50     loop-if-!=
- 51   }
- 52   enable-keyboard-type-mode
- 53   enable-screen-type-mode
- 54   exit-status <- copy 0
- 55 }
- 56 
- 57 fn render screen: (addr paginated-screen), fs: (addr buffered-file) {
- 58   start-drawing screen
- 59   render-normal screen, fs
- 60 }
- 61 
- 62 fn test-render-multicolumn-text {
- 63   # input text
- 64   var input-storage: (handle buffered-file)
- 65   var input-ah/eax: (addr handle buffered-file) <- address input-storage
- 66   populate-buffered-file-containing "abcdefgh", input-ah
- 67   var in/eax: (addr buffered-file) <- lookup input-storage
- 68   # output screen
- 69   var pg: paginated-screen
- 70   var pg-addr/ecx: (addr paginated-screen) <- address pg
- 71   initialize-fake-paginated-screen pg-addr, 3, 6, 2, 1, 1  # 3 rows, 6 columns, 2 pages * 2 columns each
- 72   #
- 73   render pg-addr, in
- 74   var screen-ah/eax: (addr handle screen) <- get pg, screen
- 75   var screen/eax: (addr screen) <- lookup *screen-ah
- 76   check-screen-row screen, 1, "      ", "F - test-render-multicolumn-text/row1"
- 77   check-screen-row screen, 2, " ab ef", "F - test-render-multicolumn-text/row2"
- 78   check-screen-row screen, 3, " cd gh", "F - test-render-multicolumn-text/row3"
- 79 }
- 80 
- 81 fn test-render-heading-text {
- 82   # input text
- 83   var input-storage: (handle buffered-file)
- 84   var input-ah/eax: (addr handle buffered-file) <- address input-storage
- 85   populate-buffered-file-containing "# abc\n\ndef", input-ah
- 86   var in/eax: (addr buffered-file) <- lookup input-storage
- 87   # output screen
- 88   var pg: paginated-screen
- 89   var pg-addr/ecx: (addr paginated-screen) <- address pg
- 90   initialize-fake-paginated-screen pg-addr, 8, 6, 5, 1, 1  # 6 columns, single page
- 91   #
- 92   render pg-addr, in
- 93   var screen-ah/eax: (addr handle screen) <- get pg, screen
- 94   var screen/eax: (addr screen) <- lookup *screen-ah
- 95   check-screen-row          screen,       1, "      ", "F - test-render-heading-text/row1"
- 96   check-screen-row-in-color screen, 0xa0, 2, " abc  ", "F - test-render-heading-text/heading"
- 97   check-screen-row          screen,       3, "      ", "F - test-render-heading-text/row3"
- 98   check-screen-row          screen,       4, " def  ", "F - test-render-heading-text/row4"
- 99 }
-100 
-101 fn test-render-bold-text {
-102   # input text
-103   var input-storage: (handle buffered-file)
-104   var input-ah/eax: (addr handle buffered-file) <- address input-storage
-105   populate-buffered-file-containing "a *b* c", input-ah
-106   var in/eax: (addr buffered-file) <- lookup input-storage
-107   # output screen
-108   var pg: paginated-screen
-109   var pg-addr/ecx: (addr paginated-screen) <- address pg
-110   initialize-fake-paginated-screen pg-addr, 8, 6, 5, 1, 1  # 6 columns, single page
-111   #
-112   render pg-addr, in
-113   var screen-ah/eax: (addr handle screen) <- get pg, screen
-114   var screen/eax: (addr screen) <- lookup *screen-ah
-115   check-screen-row         screen, 2, " a b c", "F - test-render-bold-text/text"
-116   check-screen-row-in-bold screen, 2, "   b  ", "F - test-render-bold-text/bold"
-117 }
-118 
-119 # terminals don't always support italics, so we'll just always render italics
-120 # as bold.
-121 fn test-render-pseudoitalic-text {
-122   # input text
-123   var input-storage: (handle buffered-file)
-124   var input-ah/eax: (addr handle buffered-file) <- address input-storage
-125   populate-buffered-file-containing "a _b_ c", input-ah
-126   var in/eax: (addr buffered-file) <- lookup input-storage
-127   # output screen
-128   var pg: paginated-screen
-129   var pg-addr/ecx: (addr paginated-screen) <- address pg
-130   initialize-fake-paginated-screen pg-addr, 8, 6, 5, 1, 1  # 6 columns, single page
-131   #
-132   render pg-addr, in
-133   var screen-ah/eax: (addr handle screen) <- get pg, screen
-134   var screen/eax: (addr screen) <- lookup *screen-ah
-135   check-screen-row         screen, 2, " a b c", "F - test-render-pseudoitalic-text/text"
-136   check-screen-row-in-bold screen, 2, "   b  ", "F - test-render-pseudoitalic-text/bold"
-137 }
-138 
-139 fn test-render-asterisk-in-text {
-140   # input text
-141   var input-storage: (handle buffered-file)
-142   var input-ah/eax: (addr handle buffered-file) <- address input-storage
-143   populate-buffered-file-containing "a*b*c", input-ah
-144   var in/eax: (addr buffered-file) <- lookup input-storage
-145   # output screen
-146   var pg: paginated-screen
-147   var pg-addr/ecx: (addr paginated-screen) <- address pg
-148   initialize-fake-paginated-screen pg-addr, 8, 6, 5, 1, 1  # 6 columns, single page
-149   #
-150   render pg-addr, in
-151   var screen-ah/eax: (addr handle screen) <- get pg, screen
-152   var screen/eax: (addr screen) <- lookup *screen-ah
-153   check-screen-row         screen, 2, " a*b*c", "F - test-render-bold-text/text"
-154   check-screen-row-in-bold screen, 2, "      ", "F - test-render-bold-text/bold"
-155 }
-156 
-157 fn render-normal screen: (addr paginated-screen), fs: (addr buffered-file) {
-158   var newline-seen?/esi: boolean <- copy 0  # false
-159   var start-of-paragraph?/edi: boolean <- copy 1  # true
-160   var previous-grapheme/ebx: grapheme <- copy 0
-161 $render-normal:loop: {
-162     # if done-drawing?(screen) break
-163     var done?/eax: boolean <- done-drawing? screen
-164     compare done?, 0  # false
-165     break-if-!=
-166     var c/eax: grapheme <- read-grapheme-buffered fs
-167 $render-normal:loop-body: {
-168       # if (c == EOF) break
-169       compare c, 0xffffffff  # EOF marker
-170       break-if-= $render-normal:loop
-171 
-172       ## if (c == newline) perform some fairly sophisticated parsing for soft newlines
-173       compare c, 0xa  # newline
-174       {
-175         break-if-!=
-176         # if it's the first newline, buffer it
-177         compare newline-seen?, 0
-178         {
-179           break-if-!=
-180           newline-seen? <- copy 1  # true
-181           break $render-normal:loop-body
-182         }
-183         # otherwise render two newlines
-184         {
-185           break-if-=
-186           add-grapheme screen, 0xa  # newline
-187           add-grapheme screen, 0xa  # newline
-188           newline-seen? <- copy 0  # false
-189           start-of-paragraph? <- copy 1  # true
-190           break $render-normal:loop-body
-191         }
-192       }
-193       # if start of paragraph and c == '#', switch to header
-194       compare start-of-paragraph?, 0
-195       {
-196         break-if-=
-197         compare c, 0x23  # '#'
-198         {
-199           break-if-!=
-200           render-header-line screen, fs
-201           newline-seen? <- copy 1  # true
-202           break $render-normal:loop-body
-203         }
-204       }
-205       # c is not a newline
-206       start-of-paragraph? <- copy 0  # false
-207       # if c is unprintable (particularly a '\r' CR), skip it
-208       compare c, 0x20
-209       loop-if-< $render-normal:loop
-210       # If there's a newline buffered and c is a space, print the buffered
-211       # newline (hard newline).
-212       # If there's a newline buffered and c is not a newline or space, print a
-213       # space (soft newline).
-214       compare newline-seen?, 0  # false
-215 $render-normal:flush-buffered-newline: {
-216         break-if-=
-217         newline-seen? <- copy 0  # false
-218         {
-219           compare c, 0x20
-220           break-if-!=
-221           add-grapheme screen, 0xa  # newline
-222           break $render-normal:flush-buffered-newline
-223         }
-224         add-grapheme screen, 0x20  # space
-225         # fall through to print c
-226       }
-227       ## end soft newline support
-228 
-229 $render-normal:whitespace-separated-regions: {
-230         # if previous-grapheme wasn't whitespace, skip this block
-231         {
-232           compare previous-grapheme, 0x20  # space
-233           break-if-=
-234           compare previous-grapheme, 0xa  # newline
-235           break-if-=
-236           break $render-normal:whitespace-separated-regions
-237         }
-238         # if (c == '*') switch to bold
-239         compare c, 0x2a  # '*'
-240         {
-241           break-if-!=
-242           start-color-on-paginated-screen screen, 0xec, 7  # 236 = darkish gray
-243           start-bold-on-paginated-screen screen
-244             render-until-asterisk screen, fs
-245           normal-text screen
-246           break $render-normal:loop-body
+ 30 $interactive:body: {
+ 31   # initialize fs from args[1]
+ 32   var filename/eax: (addr array byte) <- first-arg args
+ 33   var file-storage: (handle buffered-file)
+ 34   var file-storage-addr/esi: (addr handle buffered-file) <- address file-storage
+ 35   open filename, 0, file-storage-addr
+ 36   var _fs/eax: (addr buffered-file) <- lookup file-storage
+ 37   var fs/esi: (addr buffered-file) <- copy _fs
+ 38   # if no file, exit
+ 39   {
+ 40     compare fs, 0
+ 41     break-if-!=
+ 42     print-string-to-real-screen "file not found\n"
+ 43     exit-status <- copy 1
+ 44     break $interactive:body
+ 45   }
+ 46   #
+ 47   enable-screen-grid-mode
+ 48   enable-keyboard-immediate-mode
+ 49   # initialize screen state
+ 50   var paginated-screen-storage: paginated-screen
+ 51   var paginated-screen/eax: (addr paginated-screen) <- address paginated-screen-storage
+ 52   initialize-paginated-screen paginated-screen, 0x40, 2, 5
+ 53   normal-text paginated-screen
+ 54   #
+ 55   {
+ 56     render paginated-screen, fs
+ 57     var key/eax: byte <- read-key-from-real-keyboard
+ 58     compare key, 0x71  # 'q'
+ 59     loop-if-!=
+ 60   }
+ 61   enable-keyboard-type-mode
+ 62   enable-screen-type-mode
+ 63   exit-status <- copy 0
+ 64 }
+ 65 }
+ 66 
+ 67 fn render screen: (addr paginated-screen), fs: (addr buffered-file) {
+ 68   start-drawing screen
+ 69   render-normal screen, fs
+ 70 }
+ 71 
+ 72 fn test-render-multicolumn-text {
+ 73   # input text
+ 74   var input-storage: (handle buffered-file)
+ 75   var input-ah/eax: (addr handle buffered-file) <- address input-storage
+ 76   populate-buffered-file-containing "abcdefgh", input-ah
+ 77   var in/eax: (addr buffered-file) <- lookup input-storage
+ 78   # output screen
+ 79   var pg: paginated-screen
+ 80   var pg-addr/ecx: (addr paginated-screen) <- address pg
+ 81   initialize-fake-paginated-screen pg-addr, 3, 6, 2, 1, 1  # 3 rows, 6 columns, 2 pages * 2 columns each
+ 82   #
+ 83   render pg-addr, in
+ 84   var screen-ah/eax: (addr handle screen) <- get pg, screen
+ 85   var screen/eax: (addr screen) <- lookup *screen-ah
+ 86   check-screen-row screen, 1, "      ", "F - test-render-multicolumn-text/row1"
+ 87   check-screen-row screen, 2, " ab ef", "F - test-render-multicolumn-text/row2"
+ 88   check-screen-row screen, 3, " cd gh", "F - test-render-multicolumn-text/row3"
+ 89 }
+ 90 
+ 91 fn test-render-heading-text {
+ 92   # input text
+ 93   var input-storage: (handle buffered-file)
+ 94   var input-ah/eax: (addr handle buffered-file) <- address input-storage
+ 95   populate-buffered-file-containing "# abc\n\ndef", input-ah
+ 96   var in/eax: (addr buffered-file) <- lookup input-storage
+ 97   # output screen
+ 98   var pg: paginated-screen
+ 99   var pg-addr/ecx: (addr paginated-screen) <- address pg
+100   initialize-fake-paginated-screen pg-addr, 8, 6, 5, 1, 1  # 6 columns, single page
+101   #
+102   render pg-addr, in
+103   var screen-ah/eax: (addr handle screen) <- get pg, screen
+104   var screen/eax: (addr screen) <- lookup *screen-ah
+105   check-screen-row          screen,       1, "      ", "F - test-render-heading-text/row1"
+106   check-screen-row-in-color screen, 0xa0, 2, " abc  ", "F - test-render-heading-text/heading"
+107   check-screen-row          screen,       3, "      ", "F - test-render-heading-text/row3"
+108   check-screen-row          screen,       4, " def  ", "F - test-render-heading-text/row4"
+109 }
+110 
+111 fn test-render-bold-text {
+112   # input text
+113   var input-storage: (handle buffered-file)
+114   var input-ah/eax: (addr handle buffered-file) <- address input-storage
+115   populate-buffered-file-containing "a *b* c", input-ah
+116   var in/eax: (addr buffered-file) <- lookup input-storage
+117   # output screen
+118   var pg: paginated-screen
+119   var pg-addr/ecx: (addr paginated-screen) <- address pg
+120   initialize-fake-paginated-screen pg-addr, 8, 6, 5, 1, 1  # 6 columns, single page
+121   #
+122   render pg-addr, in
+123   var screen-ah/eax: (addr handle screen) <- get pg, screen
+124   var screen/eax: (addr screen) <- lookup *screen-ah
+125   check-screen-row         screen, 2, " a b c", "F - test-render-bold-text/text"
+126   check-screen-row-in-bold screen, 2, "   b  ", "F - test-render-bold-text/bold"
+127 }
+128 
+129 # terminals don't always support italics, so we'll just always render italics
+130 # as bold.
+131 fn test-render-pseudoitalic-text {
+132   # input text
+133   var input-storage: (handle buffered-file)
+134   var input-ah/eax: (addr handle buffered-file) <- address input-storage
+135   populate-buffered-file-containing "a _b_ c", input-ah
+136   var in/eax: (addr buffered-file) <- lookup input-storage
+137   # output screen
+138   var pg: paginated-screen
+139   var pg-addr/ecx: (addr paginated-screen) <- address pg
+140   initialize-fake-paginated-screen pg-addr, 8, 6, 5, 1, 1  # 6 columns, single page
+141   #
+142   render pg-addr, in
+143   var screen-ah/eax: (addr handle screen) <- get pg, screen
+144   var screen/eax: (addr screen) <- lookup *screen-ah
+145   check-screen-row         screen, 2, " a b c", "F - test-render-pseudoitalic-text/text"
+146   check-screen-row-in-bold screen, 2, "   b  ", "F - test-render-pseudoitalic-text/bold"
+147 }
+148 
+149 fn test-render-asterisk-in-text {
+150   # input text
+151   var input-storage: (handle buffered-file)
+152   var input-ah/eax: (addr handle buffered-file) <- address input-storage
+153   populate-buffered-file-containing "a*b*c", input-ah
+154   var in/eax: (addr buffered-file) <- lookup input-storage
+155   # output screen
+156   var pg: paginated-screen
+157   var pg-addr/ecx: (addr paginated-screen) <- address pg
+158   initialize-fake-paginated-screen pg-addr, 8, 6, 5, 1, 1  # 6 columns, single page
+159   #
+160   render pg-addr, in
+161   var screen-ah/eax: (addr handle screen) <- get pg, screen
+162   var screen/eax: (addr screen) <- lookup *screen-ah
+163   check-screen-row         screen, 2, " a*b*c", "F - test-render-bold-text/text"
+164   check-screen-row-in-bold screen, 2, "      ", "F - test-render-bold-text/bold"
+165 }
+166 
+167 fn render-normal screen: (addr paginated-screen), fs: (addr buffered-file) {
+168   var newline-seen?/esi: boolean <- copy 0  # false
+169   var start-of-paragraph?/edi: boolean <- copy 1  # true
+170   var previous-grapheme/ebx: grapheme <- copy 0
+171 $render-normal:loop: {
+172     # if done-drawing?(screen) break
+173     var done?/eax: boolean <- done-drawing? screen
+174     compare done?, 0  # false
+175     break-if-!=
+176     var c/eax: grapheme <- read-grapheme-buffered fs
+177 $render-normal:loop-body: {
+178       # if (c == EOF) break
+179       compare c, 0xffffffff  # EOF marker
+180       break-if-= $render-normal:loop
+181 
+182       ## if (c == newline) perform some fairly sophisticated parsing for soft newlines
+183       compare c, 0xa  # newline
+184       {
+185         break-if-!=
+186         # if it's the first newline, buffer it
+187         compare newline-seen?, 0
+188         {
+189           break-if-!=
+190           newline-seen? <- copy 1  # true
+191           break $render-normal:loop-body
+192         }
+193         # otherwise render two newlines
+194         {
+195           break-if-=
+196           add-grapheme screen, 0xa  # newline
+197           add-grapheme screen, 0xa  # newline
+198           newline-seen? <- copy 0  # false
+199           start-of-paragraph? <- copy 1  # true
+200           break $render-normal:loop-body
+201         }
+202       }
+203       # if start of paragraph and c == '#', switch to header
+204       compare start-of-paragraph?, 0
+205       {
+206         break-if-=
+207         compare c, 0x23  # '#'
+208         {
+209           break-if-!=
+210           render-header-line screen, fs
+211           newline-seen? <- copy 1  # true
+212           break $render-normal:loop-body
+213         }
+214       }
+215       # c is not a newline
+216       start-of-paragraph? <- copy 0  # false
+217       # if c is unprintable (particularly a '\r' CR), skip it
+218       compare c, 0x20
+219       loop-if-< $render-normal:loop
+220       # If there's a newline buffered and c is a space, print the buffered
+221       # newline (hard newline).
+222       # If there's a newline buffered and c is not a newline or space, print a
+223       # space (soft newline).
+224       compare newline-seen?, 0  # false
+225 $render-normal:flush-buffered-newline: {
+226         break-if-=
+227         newline-seen? <- copy 0  # false
+228         {
+229           compare c, 0x20
+230           break-if-!=
+231           add-grapheme screen, 0xa  # newline
+232           break $render-normal:flush-buffered-newline
+233         }
+234         add-grapheme screen, 0x20  # space
+235         # fall through to print c
+236       }
+237       ## end soft newline support
+238 
+239 $render-normal:whitespace-separated-regions: {
+240         # if previous-grapheme wasn't whitespace, skip this block
+241         {
+242           compare previous-grapheme, 0x20  # space
+243           break-if-=
+244           compare previous-grapheme, 0xa  # newline
+245           break-if-=
+246           break $render-normal:whitespace-separated-regions
 247         }
-248         # if (c == '_') switch to bold
-249         compare c, 0x5f  # '_'
+248         # if (c == '*') switch to bold
+249         compare c, 0x2a  # '*'
 250         {
 251           break-if-!=
-252           start-color-on-paginated-screen screen, 0xec, 7  # 236 = darkish gray
+252           start-color-on-paginated-screen screen, 0xec, 7  # 236 = darkish gray
 253           start-bold-on-paginated-screen screen
-254             render-until-underscore screen, fs
-255           normal-text screen
+254             render-until-asterisk screen, fs
+255           normal-text screen
 256           break $render-normal:loop-body
 257         }
-258       }
-259       #
-260       add-grapheme screen, c
-261     }  # $render-normal:loop-body
-262     previous-grapheme <- copy c
-263     loop
-264   }  # $render-normal:loop
-265 }
-266 
-267 fn render-header-line screen: (addr paginated-screen), fs: (addr buffered-file) {
-268 $render-header-line:body: {
-269   # compute color based on number of '#'s
-270   var header-level/esi: int <- copy 1  # caller already grabbed one
-271   var c/eax: grapheme <- copy 0
-272   {
-273     # if done-drawing?(screen) return
-274     {
-275       var done?/eax: boolean <- done-drawing? screen
-276       compare done?, 0  # false
-277       break-if-!= $render-header-line:body
-278     }
-279     #
-280     c <- read-grapheme-buffered fs
-281     # if (c != '#') break
-282     compare c, 0x23  # '#'
-283     break-if-!=
-284     #
-285     header-level <- increment
-286     #
-287     loop
-288   }
-289   start-heading screen, header-level
-290   {
-291     # if done-drawing?(screen) break
-292     {
-293       var done?/eax: boolean <- done-drawing? screen
-294       compare done?, 0  # false
-295       break-if-!=
-296     }
-297     #
-298     c <- read-grapheme-buffered fs
-299     # if (c == EOF) break
-300     compare c, 0xffffffff  # EOF marker
-301     break-if-=
-302     # if (c == newline) break
-303     compare c, 0xa  # newline
-304     break-if-=
-305     #
-306     add-grapheme screen, c
-307     #
-308     loop
-309   }
-310   normal-text screen
-311 }
-312 }
-313 
-314 # colors for a light background, going from bright to dark (meeting up with bold-text)
-315 fn start-heading screen: (addr paginated-screen), header-level: int {
-316 $start-heading:body: {
-317   start-bold-on-paginated-screen screen
-318   compare header-level, 1
-319   {
-320     break-if-!=
-321     start-color-on-paginated-screen screen, 0xa0, 7
-322     break $start-heading:body
-323   }
-324   compare header-level, 2
-325   {
-326     break-if-!=
-327     start-color-on-paginated-screen screen, 0x7c, 7
-328     break $start-heading:body
-329   }
-330   compare header-level, 3
-331   {
-332     break-if-!=
-333     start-color-on-paginated-screen screen, 0x58, 7
-334     break $start-heading:body
-335   }
-336   compare header-level, 4
-337   {
-338     break-if-!=
-339     start-color-on-paginated-screen screen, 0x34, 7
-340     break $start-heading:body
-341   }
-342   start-color-on-paginated-screen screen, 0xe8, 7
-343 }
-344 }
-345 
-346 fn render-until-asterisk screen: (addr paginated-screen), fs: (addr buffered-file) {
+258         # if (c == '_') switch to bold
+259         compare c, 0x5f  # '_'
+260         {
+261           break-if-!=
+262           start-color-on-paginated-screen screen, 0xec, 7  # 236 = darkish gray
+263           start-bold-on-paginated-screen screen
+264             render-until-underscore screen, fs
+265           normal-text screen
+266           break $render-normal:loop-body
+267         }
+268       }
+269       #
+270       add-grapheme screen, c
+271     }  # $render-normal:loop-body
+272     previous-grapheme <- copy c
+273     loop
+274   }  # $render-normal:loop
+275 }
+276 
+277 fn render-header-line screen: (addr paginated-screen), fs: (addr buffered-file) {
+278 $render-header-line:body: {
+279   # compute color based on number of '#'s
+280   var header-level/esi: int <- copy 1  # caller already grabbed one
+281   var c/eax: grapheme <- copy 0
+282   {
+283     # if done-drawing?(screen) return
+284     {
+285       var done?/eax: boolean <- done-drawing? screen
+286       compare done?, 0  # false
+287       break-if-!= $render-header-line:body
+288     }
+289     #
+290     c <- read-grapheme-buffered fs
+291     # if (c != '#') break
+292     compare c, 0x23  # '#'
+293     break-if-!=
+294     #
+295     header-level <- increment
+296     #
+297     loop
+298   }
+299   start-heading screen, header-level
+300   {
+301     # if done-drawing?(screen) break
+302     {
+303       var done?/eax: boolean <- done-drawing? screen
+304       compare done?, 0  # false
+305       break-if-!=
+306     }
+307     #
+308     c <- read-grapheme-buffered fs
+309     # if (c == EOF) break
+310     compare c, 0xffffffff  # EOF marker
+311     break-if-=
+312     # if (c == newline) break
+313     compare c, 0xa  # newline
+314     break-if-=
+315     #
+316     add-grapheme screen, c
+317     #
+318     loop
+319   }
+320   normal-text screen
+321 }
+322 }
+323 
+324 # colors for a light background, going from bright to dark (meeting up with bold-text)
+325 fn start-heading screen: (addr paginated-screen), header-level: int {
+326 $start-heading:body: {
+327   start-bold-on-paginated-screen screen
+328   compare header-level, 1
+329   {
+330     break-if-!=
+331     start-color-on-paginated-screen screen, 0xa0, 7
+332     break $start-heading:body
+333   }
+334   compare header-level, 2
+335   {
+336     break-if-!=
+337     start-color-on-paginated-screen screen, 0x7c, 7
+338     break $start-heading:body
+339   }
+340   compare header-level, 3
+341   {
+342     break-if-!=
+343     start-color-on-paginated-screen screen, 0x58, 7
+344     break $start-heading:body
+345   }
+346   compare header-level, 4
 347   {
-348     # if done-drawing?(screen) break
-349     var done?/eax: boolean <- done-drawing? screen
-350     compare done?, 0  # false
-351     break-if-!=
-352     #
-353     var c/eax: grapheme <- read-grapheme-buffered fs
-354     # if (c == EOF) break
-355     compare c, 0xffffffff  # EOF marker
-356     break-if-=
-357     # if (c == '*') break
-358     compare c, 0x2a  # '*'
-359     break-if-=
-360     #
-361     add-grapheme screen, c
-362     #
-363     loop
-364   }
-365 }
-366 
-367 fn render-until-underscore screen: (addr paginated-screen), fs: (addr buffered-file) {
-368   {
-369     # if done-drawing?(screen) break
-370     var done?/eax: boolean <- done-drawing? screen
-371     compare done?, 0  # false
-372     break-if-!=
-373     #
-374     var c/eax: grapheme <- read-grapheme-buffered fs
-375     # if (c == EOF) break
-376     compare c, 0xffffffff  # EOF marker
-377     break-if-=
-378     # if (c == '_') break
-379     compare c, 0x5f  # '_'
-380     break-if-=
-381     #
-382     add-grapheme screen, c
-383     #
-384     loop
-385   }
-386 }
-387 
-388 fn first-arg args-on-stack: (addr array addr array byte) -> out/eax: (addr array byte) {
-389   var args/eax: (addr array addr array byte) <- copy args-on-stack
-390   var result/eax: (addr addr array byte) <- index args, 1
-391   out <- copy *result
-392 }
-393 
-394 fn normal-text screen: (addr paginated-screen) {
-395   reset-formatting-on-paginated-screen screen
-396   start-color-on-paginated-screen screen, 0xec, 7  # 236 = darkish gray
-397 }
+348     break-if-!=
+349     start-color-on-paginated-screen screen, 0x34, 7
+350     break $start-heading:body
+351   }
+352   start-color-on-paginated-screen screen, 0xe8, 7
+353 }
+354 }
+355 
+356 fn render-until-asterisk screen: (addr paginated-screen), fs: (addr buffered-file) {
+357   {
+358     # if done-drawing?(screen) break
+359     var done?/eax: boolean <- done-drawing? screen
+360     compare done?, 0  # false
+361     break-if-!=
+362     #
+363     var c/eax: grapheme <- read-grapheme-buffered fs
+364     # if (c == EOF) break
+365     compare c, 0xffffffff  # EOF marker
+366     break-if-=
+367     # if (c == '*') break
+368     compare c, 0x2a  # '*'
+369     break-if-=
+370     #
+371     add-grapheme screen, c
+372     #
+373     loop
+374   }
+375 }
+376 
+377 fn render-until-underscore screen: (addr paginated-screen), fs: (addr buffered-file) {
+378   {
+379     # if done-drawing?(screen) break
+380     var done?/eax: boolean <- done-drawing? screen
+381     compare done?, 0  # false
+382     break-if-!=
+383     #
+384     var c/eax: grapheme <- read-grapheme-buffered fs
+385     # if (c == EOF) break
+386     compare c, 0xffffffff  # EOF marker
+387     break-if-=
+388     # if (c == '_') break
+389     compare c, 0x5f  # '_'
+390     break-if-=
+391     #
+392     add-grapheme screen, c
+393     #
+394     loop
+395   }
+396 }
+397 
+398 fn first-arg args-on-stack: (addr array addr array byte) -> out/eax: (addr array byte) {
+399   var args/eax: (addr array addr array byte) <- copy args-on-stack
+400   var result/eax: (addr addr array byte) <- index args, 1
+401   out <- copy *result
+402 }
+403 
+404 fn normal-text screen: (addr paginated-screen) {
+405   reset-formatting-on-paginated-screen screen
+406   start-color-on-paginated-screen screen, 0xec, 7  # 236 = darkish gray
+407 }
 
-- cgit 1.4.1-2-gfad0