Multi-line styled text with alignment and optional wrapping.
alignment places every line, and it is the last word rather than the first: a Line that carries an alignment of its own overrides it for that one row, and failing that the Text's own alignment overrides it for every row. A wrapped line keeps its alignment on every row it spills onto.
style is likewise the outermost style layer, not the only one. Every character is drawn with this style, then the text's own io.worxbend.tui.core.Text.style on top of it, then the line's, then the span's — each step a io.worxbend.tui.core.Style.patch, so the more specific layer wins wherever it speaks. A Paragraph given a style therefore no longer erases a style the Text was built with; it sits underneath it.
With Overflow.Wrap the text breaks at word boundaries: a word moves to the next row whole rather than being cut in half, and the blanks that sat at the break are dropped instead of becoming a stray indent on the next row. A word longer than the whole width has nowhere to go, so that one is broken between grapheme clusters — never inside one, so a wide character or emoji is never split. With Overflow.Clip, the default, long lines are cut at the area edge. Overflow.WrapTrimmed and Overflow.WrapPreserved wrap the same way and differ only in what becomes of the blanks at the head of a row — see Overflow for the three renderings side by side.
A line that is still wider than the area — one that is clipped, or a single unbreakable word — loses the side away from its alignment: a right-aligned line keeps its end, a centred one loses as much from each side, and a left-aligned one keeps its beginning. Keeping the beginning of a right-aligned line would hide exactly the part the alignment was chosen to show, which for a path or a timestamp is the part that identifies it.
scrollY and scrollX make the area a window into a larger document rather than the whole of it. scrollY skips that many composed rows before drawing: with Overflow.Wrap those are wrapped rows, not source lines, so scrolling a reflowed document by one moves the view by exactly one screen row whatever the width — which is the case ScrollView cannot express, because it scrolls a rendered widget and has to be told its content height. scrollX skips that many columns from the start of every row it draws, which only has anything to skip under Overflow.Clip: wrapped rows are never wider than the area. Both are clamped at zero, and scrolling past the end of the text leaves the area blank rather than failing.
style is the paragraph's own style, and it is painted over the whole area — not only the cells that carry a character. A paragraph given a background colour therefore reads as a block of colour with text in it, which is what a caller sets a background for; each span's style is then layered on top of it for the text itself.
heightAt reports the rows the paragraph needs from the same overflow field render draws with, so the two cannot disagree about whether the text wraps. Measurement memoization belongs to this immutable value: it keeps one height answer (the latest width) and one natural width, not rows or a global content index. Copies/rebuilt paragraphs start fresh, and the text must obey its immutable collection contract. Rendering never forces either measurement. Concurrent measurements are safe; rendering still inherits Buffer's caller-owned confinement.
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Measuredtrait Widgetclass Objecttrait Matchableclass Any