Published release 0.2.1. Unreleased PR #2 reference.
LOOM 0.2.1 / WIDGETS
Paragraph
Paints a cached TextLayout. scroll is a row offset into that layout; selection uses layout coordinates. Style supplies the fallback where a glyph has no explicit style. Rebuild layout when text or available width changes.
Standard inherited Swift protocol operations such as synthesized equality and OptionSet set operations are not repeated. The public declarations below are extracted from the exact source revision listed in the coverage manifest.
Example
let text = TextLayout("One\nTwo\nThree", width: 40)
let paragraph = Paragraph(text, scroll: 1)
var frame = Frame(width: 40, height: 2)
frame.render(paragraph, in: frame.area)Members on this page
Feature guides and release status
Paragraph
struct ParagraphConforms to: Widget.
A view of cached text layout, with optional scrolling and selection.
Source · Paragraph.swift:4layout
let layout: TextLayoutThe cached text layout to display.
Source · Paragraph.swift:5scroll
var scroll: IntNumber of layout/document rows skipped above the visible region.
Source · Paragraph.swift:6selection
var selection: TextSelection?The current selection; coordinate semantics are defined by the containing type.
Source · Paragraph.swift:7style
var style: StyleVisual attributes used when painting this value.
Source · Paragraph.swift:8horizontalScroll
var horizontalScroll: IntA public field of this type. Its value type and mutability are shown in the declaration.
Source · Paragraph.swift:9alignment
var alignment: CellAlignmentA public field of this type. Its value type and mutability are shown in the declaration.
Source · Paragraph.swift:10init(_:scroll:selection:style:horizontalScroll:alignment:)
init(_ layout: TextLayout, scroll: Int = 0, selection: TextSelection? = nil, style: Style = Style(), horizontalScroll: Int = 0, alignment: CellAlignment = .left)Creates a value with the supplied arguments. Default arguments are shown in the declaration.
Parameters (6)
layout- Argument type and any default are shown in the declaration; see the behavior notes above.
scroll- Number of document/layout rows skipped above the viewport.
selection- Selection using the containing type’s coordinate convention.
style- Text/cell appearance.
horizontalScroll- Argument type and any default are shown in the declaration; see the behavior notes above.
alignment- Argument type and any default are shown in the declaration; see the behavior notes above.
contentPoint(at:in:)
func contentPoint(at point: Point, in area: Rect) -> Point?Maps terminal cells to the content coordinates accepted by TextSelection.
Parameters (2)
at- Argument type and any default are shown in the declaration; see the behavior notes above.
in- Argument type and any default are shown in the declaration; see the behavior notes above.
Returns Point?.
viewportPoint(for:in:)
func viewportPoint(for point: Point, in area: Rect) -> Point?Maps a layout point into the assigned viewport using the same scroll/alignment geometry as painting.
Parameters (2)
for- Argument type and any default are shown in the declaration; see the behavior notes above.
in- Argument type and any default are shown in the declaration; see the behavior notes above.
Returns Point?.
render(in:buffer:)
func render(in area: Rect, buffer: inout Buffer)Paints this widget into the assigned terminal-cell rectangle. Application code owns state, input routing, and terminal lifetime.
Parameters (2)
in- Argument type and any default are shown in the declaration; see the behavior notes above.
buffer- Mutable destination cell grid.