Published release 0.2.1. Unreleased PR #2 reference.
LOOM 0.2.1 / RENDERING AND LAYOUT
Layout
Allocates the supplied constraints along one axis, with insets, explicit gaps/overlap, and a Flex policy for unused space. split returns one rectangle per constraint, including zero-sized rectangles. Optional caller-owned LayoutCache retains complete input/output pairs; uncached split has no global state.
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 rows = Layout(.vertical, [.length(1), .fill(1), .length(1)])
.split(Rect(width: 80, height: 24))
_ = rows[1]Members on this page
Feature guides and release status
Layout
struct LayoutConforms to: Swift.Equatable, Swift.Hashable, Swift.Sendable, Swift.SendableMetatype.
Splits an area into regions in its original constraint order; explicit overlap is opt-in.
Minimum bounds are reserved first, followed by length, percentage, and ratio requests. Equal-priority requests are clipped in source order when the area is too small. Maximum-bounded regions then share excess cells equally until their caps are reached. Weighted fills consume what remains, or minimum-bounded regions grow equally if no positive fill exists. Otherwise unused cells trail the last region.
Source · Layout.swift:61direction
var direction: DirectionThe horizontal or vertical allocation axis.
Source · Layout.swift:62constraints
var constraints: [Constraint]Constraints in the order returned by split.
Source · Layout.swift:63insets
var insets: LayoutInsetsA public field of this type. Its value type and mutability are shown in the declaration.
Source · Layout.swift:64spacing
var spacing: IntA public field of this type. Its value type and mutability are shown in the declaration.
Source · Layout.swift:65flex
var flex: FlexA public field of this type. Its value type and mutability are shown in the declaration.
Source · Layout.swift:66overlap
var overlap: IntA public field of this type. Its value type and mutability are shown in the declaration.
Source · Layout.swift:67init(_:_:insets:spacing:flex:)
init(_ direction: Direction, _ constraints: [Constraint], insets: LayoutInsets = LayoutInsets(), spacing: Int = 0, flex: Flex = .start)Creates a value with the supplied arguments. Default arguments are shown in the declaration.
Parameters (5)
direction- Argument type and any default are shown in the declaration; see the behavior notes above.
constraints- Argument type and any default are shown in the declaration; see the behavior notes above.
insets- Argument type and any default are shown in the declaration; see the behavior notes above.
spacing- Argument type and any default are shown in the declaration; see the behavior notes above.
flex- Argument type and any default are shown in the declaration; see the behavior notes above.
init(_:_:insets:spacing:flex:)
init(_ direction: Direction, _ constraints: [Constraint], insets: LayoutInsets = LayoutInsets(), spacing: LayoutSpacing, flex: Flex = .start)Explicitly chooses a gap or overlap in terminal cells.
Negative amounts clamp to zero.
Parameters (5)
direction- Argument type and any default are shown in the declaration; see the behavior notes above.
constraints- Argument type and any default are shown in the declaration; see the behavior notes above.
insets- Argument type and any default are shown in the declaration; see the behavior notes above.
spacing- Argument type and any default are shown in the declaration; see the behavior notes above.
flex- Argument type and any default are shown in the declaration; see the behavior notes above.
split(_:cache:)
func split(_ area: Rect, cache: inout LayoutCache) -> [Rect]Uses only the caller-owned cache; ordinary split calls remain uncached.
Parameters (2)
area- Assigned absolute terminal-cell rectangle.
cache- Argument type and any default are shown in the declaration; see the behavior notes above.
Returns [Rect].
split(_:)
func split(_ area: Rect) -> [Rect]Returns a region for every constraint, including zero-sized regions.
Parameters (1)
area- Assigned absolute terminal-cell rectangle.
Returns [Rect].