loom & weft
Made for Swift.

Unreleased APIs from PR #2. Not in 0.2.1. Stable 0.2.1 reference.

LOOM Unreleased (PR #2) / RENDERING AND LAYOUT

Frame

Coordinates are absolute, zero-based terminal cells. Render widgets in order: later writes replace earlier cells. Set cursor to a valid point to show it, or leave it nil to hide it. Terminal.draw resets the frame before each rendering pass.

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

var frame = Frame(width: 80, height: 24)
frame.render(Paragraph(TextLayout("Hello", width: 80)), in: frame.area)
frame.cursor = Point(x: 0, y: 1)
Members on this page

Feature guides and release status

Frame

Structure
struct Frame

The logical screen and cursor produced by one rendering pass.

Source · Frame.swift:4

buffer

Instance Property
var buffer: Buffer

The mutable grid of cells for the frame.

Source · Frame.swift:5

cursor

Instance Property
var cursor: Point?

The cursor position; see the type’s coordinate convention and lifecycle notes.

Source · Frame.swift:6

area

Instance Property
var area: Rect { get }

The available zero-based rectangle in terminal cells.

Source · Frame.swift:7

init(width:height:)

Initializer
init(width: Int, height: Int)

Creates a value with the supplied arguments. Default arguments are shown in the declaration.

Parameters (2)
width
Available columns in terminal cells.
height
Available rows in terminal cells.
Source · Frame.swift:11

render(_:in:)

Instance Method
mutating func render<W>(_ widget: W, in area: Rect) where W : Widget

Delegates to the widget with the assigned absolute rectangle and the frame’s mutable buffer. Does not automatically intersect the rectangle with the buffer.

Parameters (2)
widget
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.
Source · Frame.swift:20

render(_:in:state:)

Instance Method
mutating func render<W>(_ widget: W, in area: Rect, state: inout W.State) where W : StatefulWidget

Delegates rendering to a StatefulWidget using the supplied caller-owned state and assigned rectangle.

Parameters (3)
widget
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.
state
Argument type and any default are shown in the declaration; see the behavior notes above.
Source · StatefulWidget.swift:11