Skip to content

Commit 44a44f0

Browse files
committed
Improve changelog.
1 parent 689dca0 commit 44a44f0

File tree

1 file changed

+8
-44
lines changed

1 file changed

+8
-44
lines changed

changelog.md

+8-44
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
## 0.5
44

55
* Extract existing HasChars definition into a module
6-
Text.DocLayout.HasChars (Evan Silberman) [API change].
6+
Text.DocLayout.HasChars (Evan Silberman).
77

8-
* Add a `build` method to the signature of HasChars
8+
* Add a `build` method to the signature of HasChars [API change]
99
(Evan Silberman). This has a default definition, and is only needed with
1010
the ANSI renderer, so existing users should not need to add anything to
1111
their HasChars instances.
@@ -14,48 +14,12 @@
1414
`renderPlain` and `renderANSI` are now exported; the old `render`
1515
is a synonym of `renderPlain`. In addition, various functions are
1616
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).
5923

6024
* Introduce FlatDocs and use them for rendering (Evan Silberman).
6125
This is an internal concept, not part of the public API.

0 commit comments

Comments
 (0)