The previous implementation of Styled used chunks that consisted of a
String and a ContentStyle. The current implementation instead stores a
single String and chunks consisting of a ContentStyle and an ending
index.
This implementation may reduce allocations and makes width-related
operations easier, for example getting the width of a Styled with its
whitespace trimmed.
This lets the user restrict the drawable area to a sub-area of the
buffer. This lets the user draw without caring about the absolute
position, and guarantees that no glyphs or glyph parts appear outside of
the drawable area.
Previously, when overwriting wide graphemes, those were not first
cleared from the buffer. This could sometimes result in partial
graphemes, which is an invalid buffer state.
Now, when a wide grapheme is overwritten, it is removed from the buffer
entirely and replaced with spaces. Those spaces retain the style of the
removed grapheme.
A similar thing now happens with graphemes that only partially overlap
the buffer, either on the left or the right border. Those parts that are
inside the buffer are rendered as spaces with the grapheme's style.