|
3 | 3 | ## 0.5
|
4 | 4 |
|
5 | 5 | * Extract existing HasChars definition into a module
|
6 |
| - Text.DocLayout.HasChars (Evan Silberman) [API change]. |
| 6 | + Text.DocLayout.HasChars (Evan Silberman). |
7 | 7 |
|
8 |
| - * Add a `build` method to the signature of HasChars |
| 8 | + * Add a `build` method to the signature of HasChars [API change] |
9 | 9 | (Evan Silberman). This has a default definition, and is only needed with
|
10 | 10 | the ANSI renderer, so existing users should not need to add anything to
|
11 | 11 | their HasChars instances.
|
|
14 | 14 | `renderPlain` and `renderANSI` are now exported; the old `render`
|
15 | 15 | is a synonym of `renderPlain`. In addition, various functions are
|
16 | 16 | exported to add ANSI formatting (including bold, italics,
|
17 |
| - underline, strikeout, links, and colors) to a Doc. |
18 |
| - |
19 |
| - The new Text.DocLayout.ANSIFont module introduces ADTs for various |
20 |
| - text properties that are supported by terminals, and for Fonts that |
21 |
| - indicate all the properties that should apply to a particular span of text. |
22 |
| - New fonts can be constructed by applying a StyleReq to an existing font, |
23 |
| - which replaces the requested property in the original font with the |
24 |
| - requested value. |
25 |
| - |
26 |
| - The new Text.DocLayout.Attributed model introduces Attributed strings, |
27 |
| - which carry a Font along with an inner string type. It instantiates the |
28 |
| - HasChars class so that various features of the existing DocLayout code can |
29 |
| - somewhat seamlessly support rendering styled text. |
30 |
| - |
31 |
| - Implementation outline: |
32 |
| - |
33 |
| - 1. Consumers add a smart constructor like `bold` to style a Doc. The |
34 |
| - inner doc gets wrapped in Doc's `Styled` constructor, indicating the |
35 |
| - text style requested for that block. |
36 |
| - 2. The renderer maintains a stack of `Font`s. When a `Styled` element is |
37 |
| - encountered, its `StyleReq` is applied to the `Font` on the top of |
38 |
| - the stack and pushed, the inner document is rendered, and then the |
39 |
| - font is popped and rendering continues. |
40 |
| - 3. The `Attributed a` returned by `prerender` can be rendered to `a` |
41 |
| - using `renderPlain`, which ignores all the font requests, or |
42 |
| - `renderANSI`, which adds the requisite control sequences to set the |
43 |
| - font every time the font changes. |
44 |
| - |
45 |
| - The most interesting wrinkle to this implementation is that the contents |
46 |
| - of `Block` elements need to be prerendered by the `block` helper so they |
47 |
| - can be broken up into lines and filled, but we want to defer the |
48 |
| - decision of rendering plain text or ANSI-styled text until the final |
49 |
| - document is rendered. To support this, the `Block` constructor for a |
50 |
| - `Doc a` now carries an `Attributed a` in its lines field. Once the next |
51 |
| - rendering pass merges blocks together, instead of using `literal` to |
52 |
| - construct `Text` elements carring an `a` to render, it uses `cook` to |
53 |
| - construct `Cooked` elements with an `Attributed a` to be copied directly |
54 |
| - to the output stream _without looking at the font stack_. This means |
55 |
| - that the contents of a block are only ever styled by style requests that |
56 |
| - were made in the inner document of the block: the contents of `bold $ |
57 |
| - cblock n $ literal "x"` will be printed in plain text, whereas the |
58 |
| - contents of `cblock n $ bold $ literal "x"` will be bold. |
| 17 | + underline, strikeout, links, and colors) to a Doc. The Attributed |
| 18 | + type constructor is also now exported. |
| 19 | + |
| 20 | + * Change type of Block constructor, replacing `[a]` with `[Attributed a]`, |
| 21 | + which carries a Font along with an inner string type [API change] |
| 22 | + (Evan Silberman). |
59 | 23 |
|
60 | 24 | * Introduce FlatDocs and use them for rendering (Evan Silberman).
|
61 | 25 | This is an internal concept, not part of the public API.
|
|
0 commit comments