diff --git a/_02_.Writing-programs.sz b/_02_.Writing-programs.sz index b3b292e..cb3f203 100644 --- a/_02_.Writing-programs.sz +++ b/_02_.Writing-programs.sz @@ -870,15 +870,15 @@ In @code{tabular} a column's cells are separated by @code{nl}. In @code{tabular/ @codeblock[#:lang "bjolang"]|{ (show [(tabular/rows [["tea" (each [3 " cups"])] ["kettle" (each ["boils in" nl "4 minutes"])]] - #:style StyleLight)]) + #:style StyleAscii)]) }| @codeblock[#:lang "text"]|{ -┌────────┬───────────┐ -│ tea │ 3 cups │ -│ kettle │ boils in │ -│ │ 4 minutes │ -└────────┴───────────┘ ++--------+-----------+ +| tea | 3 cups | +| kettle | boils in | +| | 4 minutes | ++--------+-----------+ }| Rows from data come from a function with a signature, for the reason given above. Here is the high-score ledger from "Files and I/O" as a table: @@ -892,19 +892,19 @@ Rows from data come from a function with a signature, for the reason given above (show [(tabular/rows (vec-map score-row (read-scores)) #:titles ["Player" "Score"] #:align [AlignLeft AlignRight] - #:style StyleRounded)]) + #:style StyleAscii)]) }| @codeblock[#:lang "text"]|{ -╭────────┬───────╮ -│ Player │ Score │ -├────────┼───────┤ -│ ada │ 31 │ -│ bo │ 27 │ -╰────────┴───────╯ ++--------+-------+ +| Player | Score | ++--------+-------+ +| ada | 31 | +| bo | 27 | ++--------+-------+ }| -@code{#:style} takes a @code{TableStyle}: @code{StyleNone}, the default, @code{StyleSimple}, @code{StyleAscii}, @code{StyleLight}, @code{StyleHeavy}, @code{StyleDouble}, @code{StyleRounded}, @code{StyleMarkdown}, or @code{StyleCustom} with pieces of your own. @code{#:align} takes an @code{Align} for each column, from the first: @code{AlignLeft}, @code{AlignRight}, @code{AlignCentre}, or @code{(AlignOn #\.)}, which puts every decimal point of the column in one place. @code{#:widths} and @code{#:overflow} make a table fit @code{current-width}, by cutting or wrapping its cells. +The tables here are drawn with @code{StyleAscii}, whose characters every font has. @code{#:style} takes a @code{TableStyle}: @code{StyleNone}, the default, @code{StyleSimple}, @code{StyleAscii}, @code{StyleLight}, @code{StyleHeavy}, @code{StyleDouble}, @code{StyleRounded}, @code{StyleMarkdown}, or @code{StyleCustom} with pieces of your own. @code{#:align} takes an @code{Align} for each column, from the first: @code{AlignLeft}, @code{AlignRight}, @code{AlignCentre}, or @code{(AlignOn #\.)}, which puts every decimal point of the column in one place. @code{#:widths} and @code{#:overflow} make a table fit @code{current-width}, by cutting or wrapping its cells. A table whose rows are not all known yet, such as results that come one at a time, is laid out a row at a time with @code{table-layout} and @code{table-row}. The widths are fixed beforehand, so each row is written when it is known: @@ -924,7 +924,7 @@ bo 27 A table can also be a quoted literal, which the compiler checks where it is written. A column can say what kind of number it holds: @codeblock[#:lang "bjolang"]|{ -(show-table '(table (style light) header +(show-table '(table (style ascii) header (column "Player") (column "Score" (align right)) (column "Share" (percent (precision 0))) @@ -932,13 +932,13 @@ A table can also be a quoted literal, which the compiler checks where it is writ }| @codeblock[#:lang "text"]|{ -┌────────┬───────┬───────┐ -│ Player │ Score │ Share │ -├────────┼───────┼───────┤ -│ ada │ 31 │ 46% │ -│ bo │ 27 │ 40% │ -│ cy │ 9 │ 13% │ -└────────┴───────┴───────┘ ++--------+-------+-------+ +| Player | Score | Share | ++--------+-------+-------+ +| ada | 31 | 46% | +| bo | 27 | 40% | +| cy | 9 | 13% | ++--------+-------+-------+ }| The rows can be spliced, @code{(rows ,scores)}, from a @code{(Vec (Vec TableCell))}. See @code{Table} on the module's page.