diff options
Diffstat (limited to 'apps/browse')
-rw-r--r-- | apps/browse/main.mu | 82 | ||||
-rw-r--r-- | apps/browse/paginated-screen.mu | 92 |
2 files changed, 87 insertions, 87 deletions
diff --git a/apps/browse/main.mu b/apps/browse/main.mu index 91eb46e0..5b4f2e06 100644 --- a/apps/browse/main.mu +++ b/apps/browse/main.mu @@ -50,7 +50,7 @@ fn interactive fs: (addr buffered-file) { { render paginated-screen, fs var key/eax: grapheme <- read-key-from-real-keyboard - compare key, 0x71 # 'q' + compare key, 0x71/'q' loop-if-!= } enable-keyboard-type-mode @@ -71,7 +71,7 @@ fn test-render-multicolumn-text { # output screen var pg: paginated-screen var pg-addr/ecx: (addr paginated-screen) <- address pg - initialize-fake-paginated-screen pg-addr, 3, 6, 2, 1, 1 # 3 rows, 6 columns, 2 pages * 2 columns each + initialize-fake-paginated-screen pg-addr, 3/rows, 6/cols, 2/page-width, 1/top-margin, 1/left-margin # render pg-addr, in var screen-ah/eax: (addr handle screen) <- get pg, screen @@ -90,7 +90,7 @@ fn test-render-heading-text { # output screen var pg: paginated-screen var pg-addr/ecx: (addr paginated-screen) <- address pg - initialize-fake-paginated-screen pg-addr, 8, 6, 5, 1, 1 # 6 columns, single page + initialize-fake-paginated-screen pg-addr, 8/rows, 6/cols, 5/page-width, 1/top-margin, 1/left-margin # render pg-addr, in var screen-ah/eax: (addr handle screen) <- get pg, screen @@ -110,7 +110,7 @@ fn test-render-bold-text { # output screen var pg: paginated-screen var pg-addr/ecx: (addr paginated-screen) <- address pg - initialize-fake-paginated-screen pg-addr, 8, 6, 5, 1, 1 # 6 columns, single page + initialize-fake-paginated-screen pg-addr, 8/rows, 6/cols, 5/page-width, 1/top-margin, 1/left-margin # render pg-addr, in var screen-ah/eax: (addr handle screen) <- get pg, screen @@ -130,7 +130,7 @@ fn test-render-pseudoitalic-text { # output screen var pg: paginated-screen var pg-addr/ecx: (addr paginated-screen) <- address pg - initialize-fake-paginated-screen pg-addr, 8, 6, 5, 1, 1 # 6 columns, single page + initialize-fake-paginated-screen pg-addr, 8/rows, 6/cols, 5/page-width, 1/top-margin, 1/left-margin # render pg-addr, in var screen-ah/eax: (addr handle screen) <- get pg, screen @@ -148,7 +148,7 @@ fn test-render-asterisk-in-text { # output screen var pg: paginated-screen var pg-addr/ecx: (addr paginated-screen) <- address pg - initialize-fake-paginated-screen pg-addr, 8, 6, 5, 1, 1 # 6 columns, single page + initialize-fake-paginated-screen pg-addr, 8/nrows, 6/cols, 5/page-width, 1/top-margin, 1/left-margin # render pg-addr, in var screen-ah/eax: (addr handle screen) <- get pg, screen @@ -158,38 +158,38 @@ fn test-render-asterisk-in-text { } fn render-normal screen: (addr paginated-screen), fs: (addr buffered-file) { - 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 var previous-grapheme/ebx: grapheme <- copy 0 $render-normal:loop: { # if done-drawing?(screen) break var done?/eax: boolean <- done-drawing? screen - compare done?, 0 # false + compare done?, 0/false break-if-!= var c/eax: grapheme <- read-grapheme-buffered fs $render-normal:loop-body: { # if (c == EOF) break - compare c, 0xffffffff # EOF marker + compare c, 0xffffffff/end-of-file break-if-= $render-normal:loop ## if (c == newline) perform some fairly sophisticated parsing for soft newlines - compare c, 0xa # newline + compare c, 0xa/newline { break-if-!= # if it's the first newline, buffer it compare newline-seen?, 0 { break-if-!= - newline-seen? <- copy 1 # true + newline-seen? <- copy 1/true break $render-normal:loop-body } # otherwise render two newlines { break-if-= - add-grapheme screen, 0xa # newline - add-grapheme screen, 0xa # newline - newline-seen? <- copy 0 # false - start-of-paragraph? <- copy 1 # true + add-grapheme screen, 0xa/newline + add-grapheme screen, 0xa/newline + newline-seen? <- copy 0/false + start-of-paragraph? <- copy 1/true break $render-normal:loop-body } } @@ -197,16 +197,16 @@ $render-normal:loop-body: { compare start-of-paragraph?, 0 { break-if-= - compare c, 0x23 # '#' + compare c, 0x23/'#' { break-if-!= render-header-line screen, fs - newline-seen? <- copy 1 # true + newline-seen? <- copy 1/true break $render-normal:loop-body } } # c is not a newline - start-of-paragraph? <- copy 0 # false + start-of-paragraph? <- copy 0/false # if c is unprintable (particularly a '\r' CR), skip it compare c, 0x20 loop-if-< $render-normal:loop @@ -214,17 +214,17 @@ $render-normal:loop-body: { # 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 + compare newline-seen?, 0/false $render-normal:flush-buffered-newline: { break-if-= - newline-seen? <- copy 0 # false + newline-seen? <- copy 0/false { compare c, 0x20 break-if-!= - add-grapheme screen, 0xa # newline + add-grapheme screen, 0xa/newline break $render-normal:flush-buffered-newline } - add-grapheme screen, 0x20 # space + add-grapheme screen, 0x20/space # fall through to print c } ## end soft newline support @@ -232,27 +232,27 @@ $render-normal:flush-buffered-newline: { $render-normal:whitespace-separated-regions: { # if previous-grapheme wasn't whitespace, skip this block { - compare previous-grapheme, 0x20 # space + compare previous-grapheme, 0x20/space break-if-= - compare previous-grapheme, 0xa # newline + compare previous-grapheme, 0xa/newline break-if-= break $render-normal:whitespace-separated-regions } # if (c == '*') switch to bold - compare c, 0x2a # '*' + compare c, 0x2a/* { break-if-!= - start-color-on-paginated-screen screen, 0xec, 7 # 236 = darkish gray + start-color-on-paginated-screen screen, 0xec/fg=darkish-grey, 7/bg=white start-bold-on-paginated-screen screen render-until-asterisk screen, fs normal-text screen break $render-normal:loop-body } # if (c == '_') switch to bold - compare c, 0x5f # '_' + compare c, 0x5f/_ { break-if-!= - start-color-on-paginated-screen screen, 0xec, 7 # 236 = darkish gray + start-color-on-paginated-screen screen, 0xec/fg=darkish-grey, 7/bg=white start-bold-on-paginated-screen screen render-until-underscore screen, fs normal-text screen @@ -276,13 +276,13 @@ $render-header-line:body: { # if done-drawing?(screen) return { var done?/eax: boolean <- done-drawing? screen - compare done?, 0 # false + compare done?, 0/false break-if-!= $render-header-line:body } # c <- read-grapheme-buffered fs # if (c != '#') break - compare c, 0x23 # '#' + compare c, 0x23/'#' break-if-!= # header-level <- increment @@ -294,16 +294,16 @@ $render-header-line:body: { # if done-drawing?(screen) break { var done?/eax: boolean <- done-drawing? screen - compare done?, 0 # false + compare done?, 0/false break-if-!= } # c <- read-grapheme-buffered fs # if (c == EOF) break - compare c, 0xffffffff # EOF marker + compare c, 0xffffffff/end-of-file break-if-= # if (c == newline) break - compare c, 0xa # newline + compare c, 0xa/newline break-if-= # add-grapheme screen, c @@ -350,15 +350,15 @@ fn render-until-asterisk screen: (addr paginated-screen), fs: (addr buffered-fil { # if done-drawing?(screen) break var done?/eax: boolean <- done-drawing? screen - compare done?, 0 # false + compare done?, 0/false break-if-!= # var c/eax: grapheme <- read-grapheme-buffered fs # if (c == EOF) break - compare c, 0xffffffff # EOF marker + compare c, 0xffffffff/end-of-file break-if-= # if (c == '*') break - compare c, 0x2a # '*' + compare c, 0x2a/'*' break-if-= # add-grapheme screen, c @@ -371,15 +371,15 @@ fn render-until-underscore screen: (addr paginated-screen), fs: (addr buffered-f { # if done-drawing?(screen) break var done?/eax: boolean <- done-drawing? screen - compare done?, 0 # false + compare done?, 0/false break-if-!= # var c/eax: grapheme <- read-grapheme-buffered fs # if (c == EOF) break - compare c, 0xffffffff # EOF marker + compare c, 0xffffffff/end-of-file break-if-= # if (c == '_') break - compare c, 0x5f # '_' + compare c, 0x5f/'_' break-if-= # add-grapheme screen, c @@ -390,5 +390,5 @@ fn render-until-underscore screen: (addr paginated-screen), fs: (addr buffered-f fn normal-text screen: (addr paginated-screen) { reset-formatting-on-paginated-screen screen - start-color-on-paginated-screen screen, 0xec, 7 # 236 = darkish gray + start-color-on-paginated-screen screen, 0xec/fg=darkish-grey, 7/bg=white } diff --git a/apps/browse/paginated-screen.mu b/apps/browse/paginated-screen.mu index 783a1cac..f4579d95 100644 --- a/apps/browse/paginated-screen.mu +++ b/apps/browse/paginated-screen.mu @@ -132,7 +132,7 @@ fn done-drawing? _self: (addr paginated-screen) -> _/eax: boolean { $done-drawing:first-page?: { compare first-col, *tmp break-if-!= - return 0 # false + return 0/false } # return self->rightcol > self->ncols + 1 tmp <- get self, ncols @@ -147,9 +147,9 @@ fn done-drawing? _self: (addr paginated-screen) -> _/eax: boolean { compare *tmp, max { break-if-> - return 0 # false + return 0/false } - return 1 # true + return 1/true } fn add-grapheme _self: (addr paginated-screen), c: grapheme { @@ -159,7 +159,7 @@ fn add-grapheme _self: (addr paginated-screen), c: grapheme { $add-grapheme:body: { var self/esi: (addr paginated-screen) <- copy _self { - compare c, 0xa # newline + compare c, 0xa/newline break-if-!= next-line self reposition-cursor self @@ -189,10 +189,10 @@ $add-grapheme:body: { fn test-print-grapheme-on-paginated-screen { var pg-on-stack: paginated-screen var pg/eax: (addr paginated-screen) <- address pg-on-stack - initialize-fake-paginated-screen pg, 3, 0xa, 0xa, 0, 0 + initialize-fake-paginated-screen pg, 3/rows, 0xa/cols, 0xa/page-width, 0, 0 start-drawing pg { - var c/ecx: grapheme <- copy 0x61 # 'a' + var c/ecx: grapheme <- copy 0x61/a add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? @@ -206,32 +206,32 @@ fn test-print-grapheme-on-paginated-screen { fn test-print-single-page { var pg-on-stack: paginated-screen var pg/eax: (addr paginated-screen) <- address pg-on-stack - initialize-fake-paginated-screen pg, 2, 4, 2, 0, 0 # 2 rows, 4 columns, 2 pages * 2 columns each + initialize-fake-paginated-screen pg, 2/rows, 4/cols, 2/page-width, 0, 0 start-drawing pg # pages at columns [1, 3), [3, 5) { - var c/ecx: grapheme <- copy 0x61 # 'a' + var c/ecx: grapheme <- copy 0x61/a add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page/done-1" } { - var c/ecx: grapheme <- copy 0x62 # 'b' + var c/ecx: grapheme <- copy 0x62/b add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page/done-2" } { - var c/ecx: grapheme <- copy 0x63 # 'c' + var c/ecx: grapheme <- copy 0x63/c add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page/done-3" } { - var c/ecx: grapheme <- copy 0x64 # 'd' + var c/ecx: grapheme <- copy 0x64/d add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? @@ -247,38 +247,38 @@ fn test-print-single-page { fn test-print-single-page-narrower-than-page-width { var pg-on-stack: paginated-screen var pg/eax: (addr paginated-screen) <- address pg-on-stack - initialize-fake-paginated-screen pg, 2, 4, 5, 0, 0 # 2 rows, 4 columns, 5-column pages + initialize-fake-paginated-screen pg, 2/rows, 4/cols, 5/page-width, 0, 0 start-drawing pg { - var c/ecx: grapheme <- copy 0x61 # 'a' + var c/ecx: grapheme <- copy 0x61/a add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page-narrower-than-page-width/done-1" } { - var c/ecx: grapheme <- copy 0x62 # 'b' + var c/ecx: grapheme <- copy 0x62/b add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page-narrower-than-page-width/done-2" } { - var c/ecx: grapheme <- copy 0x63 # 'c' + var c/ecx: grapheme <- copy 0x63/c add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page-narrower-than-page-width/done-3" } { - var c/ecx: grapheme <- copy 0x64 # 'd' + var c/ecx: grapheme <- copy 0x64/d add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page-narrower-than-page-width/done-4" } { - var c/ecx: grapheme <- copy 0x65 # 'e' + var c/ecx: grapheme <- copy 0x65/e add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? @@ -294,38 +294,38 @@ fn test-print-single-page-narrower-than-page-width { fn test-print-single-page-narrower-than-page-width-with-margin { var pg-on-stack: paginated-screen var pg/eax: (addr paginated-screen) <- address pg-on-stack - initialize-fake-paginated-screen pg, 2, 4, 5, 0, 1 # 2 rows, 4 columns, 5-column pages, left margin + initialize-fake-paginated-screen pg, 2/rows, 4/cols, 5/page-width, 0/top-margin, 1/left-margin start-drawing pg { - var c/ecx: grapheme <- copy 0x61 # 'a' + var c/ecx: grapheme <- copy 0x61/a add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page-narrower-than-page-width-with-margin/done-1" } { - var c/ecx: grapheme <- copy 0x62 # 'b' + var c/ecx: grapheme <- copy 0x62/b add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page-narrower-than-page-width-with-margin/done-2" } { - var c/ecx: grapheme <- copy 0x63 # 'c' + var c/ecx: grapheme <- copy 0x63/c add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page-narrower-than-page-width-with-margin/done-3" } { - var c/ecx: grapheme <- copy 0x64 # 'd' + var c/ecx: grapheme <- copy 0x64/d add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page-narrower-than-page-width-with-margin/done-4" } { - var c/ecx: grapheme <- copy 0x65 # 'e' + var c/ecx: grapheme <- copy 0x65/e add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? @@ -341,31 +341,31 @@ fn test-print-single-page-narrower-than-page-width-with-margin { fn test-print-multiple-pages { var pg-on-stack: paginated-screen var pg/eax: (addr paginated-screen) <- address pg-on-stack - initialize-fake-paginated-screen pg, 2, 2, 1, 0, 0 # 2 rows, 2 columns, 2 pages * 1 column each + initialize-fake-paginated-screen pg, 2/rows, 2/cols, 1/page-width, 0, 0 start-drawing pg { - var c/ecx: grapheme <- copy 0x61 # 'a' + var c/ecx: grapheme <- copy 0x61/a add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages/done-1" } { - var c/ecx: grapheme <- copy 0x62 # 'b' + var c/ecx: grapheme <- copy 0x62/b add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages/done-2" } { - var c/ecx: grapheme <- copy 0x63 # 'c' + var c/ecx: grapheme <- copy 0x63/c add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages/done-3" } { - var c/ecx: grapheme <- copy 0x64 # 'd' + var c/ecx: grapheme <- copy 0x64/d add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? @@ -381,59 +381,59 @@ fn test-print-multiple-pages { fn test-print-multiple-pages-2 { var pg-on-stack: paginated-screen var pg/eax: (addr paginated-screen) <- address pg-on-stack - initialize-fake-paginated-screen pg, 2, 4, 2, 0, 0 # 2 rows, 4 columns, 2 pages * 2 columns each + initialize-fake-paginated-screen pg, 2/rows, 4/cols, 2/page-width, 0, 0 start-drawing pg { - var c/ecx: grapheme <- copy 0x61 # 'a' + var c/ecx: grapheme <- copy 0x61/a add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-2/done-1" } { - var c/ecx: grapheme <- copy 0x62 # 'b' + var c/ecx: grapheme <- copy 0x62/b add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-2/done-2" } { - var c/ecx: grapheme <- copy 0x63 # 'c' + var c/ecx: grapheme <- copy 0x63/c add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-2/done-3" } { - var c/ecx: grapheme <- copy 0x64 # 'd' + var c/ecx: grapheme <- copy 0x64/d add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-2/done-4" } { - var c/ecx: grapheme <- copy 0x65 # 'e' + var c/ecx: grapheme <- copy 0x65/e add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-2/done-5" } { - var c/ecx: grapheme <- copy 0x66 # 'f' + var c/ecx: grapheme <- copy 0x66/f add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-2/done-6" } { - var c/ecx: grapheme <- copy 0x67 # 'g' + var c/ecx: grapheme <- copy 0x67/g add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-2/done-7" } { - var c/ecx: grapheme <- copy 0x68 # 'h' + var c/ecx: grapheme <- copy 0x68/h add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? @@ -449,59 +449,59 @@ fn test-print-multiple-pages-2 { fn test-print-multiple-pages-with-margins { var pg-on-stack: paginated-screen var pg/eax: (addr paginated-screen) <- address pg-on-stack - initialize-fake-paginated-screen pg, 3, 6, 2, 1, 1 # 3 rows, 5 columns, 2 pages * 2 columns each + initialize-fake-paginated-screen pg, 3/rows, 6/cols, 2/page-width, 1/top-margin, 1/left-margin start-drawing pg { - var c/ecx: grapheme <- copy 0x61 # 'a' + var c/ecx: grapheme <- copy 0x61/a add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-with-margins/grapheme-1" } { - var c/ecx: grapheme <- copy 0x62 # 'b' + var c/ecx: grapheme <- copy 0x62/b add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-with-margins/grapheme-2" } { - var c/ecx: grapheme <- copy 0x63 # 'c' + var c/ecx: grapheme <- copy 0x63/c add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-with-margins/grapheme-3" } { - var c/ecx: grapheme <- copy 0x64 # 'd' + var c/ecx: grapheme <- copy 0x64/d add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-with-margins/grapheme-4" } { - var c/ecx: grapheme <- copy 0x65 # 'e' + var c/ecx: grapheme <- copy 0x65/e add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-with-margins/grapheme-5" } { - var c/ecx: grapheme <- copy 0x66 # 'f' + var c/ecx: grapheme <- copy 0x66/f add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-with-margins/grapheme-6" } { - var c/ecx: grapheme <- copy 0x67 # 'g' + var c/ecx: grapheme <- copy 0x67/g add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-with-margins/grapheme-7" } { - var c/ecx: grapheme <- copy 0x68 # 'h' + var c/ecx: grapheme <- copy 0x68/h add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? |