loom & weft
Made for Swift.

Published release 0.2.1. Unreleased PR #2 reference.

LOOM 0.2.1 / COLLECTIONS AND INTERACTION

Table

A selectable table with fixed headers/footers and clipped, independently scrollable body rows.

Sorting/filtering and cell actions belong to the caller. Set minimumWidth to allow horizontal scrolling instead of squeezing columns into a narrow viewport.

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

_ = Table(columns: [TableColumn("Name", width: .fill(1))], rows: [TableRow(id: 1, cells: [TableCell("Ready")])])
Members on this page

Feature guides and release status

Table

Structure
struct Table<ID> where ID : Hashable

Conforms to: StatefulWidget.

A selectable table with fixed headers/footers and clipped, independently scrollable body rows.

Sorting/filtering and cell actions belong to the caller. Set minimumWidth to allow horizontal scrolling instead of squeezing columns into a narrow viewport.

Source · Table.swift:133

columns

Instance Property
var columns: [TableColumn]

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Table.swift:134

rows

Instance Property
var rows: [TableRow<ID>]

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Table.swift:135

columnSpacing

Instance Property
var columnSpacing: Int

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Table.swift:136

automaticHeights

Instance Property
var automaticHeights: Bool

Measures body text using the final column widths.

Source · Table.swift:138

wrapping

Instance Property
var wrapping: TextWrapping

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Table.swift:139

wrapOptions

Instance Property
var wrapOptions: TextWrapOptions

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Table.swift:140

minimumWidth

Instance Property
var minimumWidth: Int

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Table.swift:141

showsHeader

Instance Property
var showsHeader: Bool

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Table.swift:142

headerHeight

Instance Property
var headerHeight: Int

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Table.swift:143

footerHeight

Instance Property
var footerHeight: Int

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Table.swift:145

style

Instance Property
var style: Style

Visual attributes used when painting this value.

Source · Table.swift:146

headerStyle

Instance Property
var headerStyle: Style

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Table.swift:147

footerStyle

Instance Property
var footerStyle: Style

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Table.swift:148

selectionStyle

Instance Property
var selectionStyle: Style

Style used for the selected choice/icon.

Source · Table.swift:149

markedStyle

Instance Property
var markedStyle: Style

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Table.swift:150

cellSelectionStyle

Instance Property
var cellSelectionStyle: Style

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Table.swift:151

columnSelectionStyle

Instance Property
var columnSelectionStyle: Style

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Table.swift:152

selectionSymbol

Instance Property
var selectionSymbol: String

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Table.swift:153

prefixReservation

Instance Property
var prefixReservation: SelectionPrefixReservation

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Table.swift:154

selectionPatch

Instance Property
var selectionPatch: StylePatch?

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Table.swift:155

columnSelectionPatch

Instance Property
var columnSelectionPatch: StylePatch?

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Table.swift:156

cellSelectionPatch

Instance Property
var cellSelectionPatch: StylePatch?

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Table.swift:157

emptyMessage

Instance Property
var emptyMessage: String

Text shown when the popup has no items.

Source · Table.swift:158

init(columns:rows:)

Initializer
init(columns: [TableColumn], rows: [TableRow<ID>])

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

Parameters (2)
columns
Cell-column count or signed column movement, according to the method.
rows
Row count or signed row movement, according to the method.
Source · Table.swift:160

bodyArea(in:)

Instance Method
func bodyArea(in area: Rect) -> Rect

Returns the body rectangle after reserving header and footer rows, clamped for small viewports.

Parameters (1)
in
Argument type and any default are shown in the declaration; see the behavior notes above.

Returns Rect.

Source · Table.swift:165

columnAreas(width:)

Instance Method
func columnAreas(width: Int) -> [Rect]

Column regions in logical content coordinates, before horizontal scrolling.

Parameters (1)
width
Available columns in terminal cells.

Returns [Rect].

Source · Table.swift:172

update(in:state:)

Instance Method
func update(in area: Rect, state: inout TableState<ID>)

Synchronizes data and geometry before dispatching events.

Drawing also calls this method.

Parameters (2)
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 · Table.swift:186

render(in:buffer:state:)

Instance Method
func render(in area: Rect, buffer: inout Buffer, state: inout TableState<ID>)

Reconciles the caller-owned selection metrics and paints visible rows using the same geometry as hit testing.

Parameters (3)
in
Argument type and any default are shown in the declaration; see the behavior notes above.
buffer
Mutable destination cell grid.
state
Argument type and any default are shown in the declaration; see the behavior notes above.
Source · Table.swift:199

cell(at:in:state:)

Instance Method
func cell(at point: Point, in area: Rect, state: TableState<ID>) -> (row: ID, column: Int)?

Returns body cells only; headers, footers, spacing, and unused columns return nil.

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

Returns (row: ID, column: Int)?.

Source · Table.swift:264

contentArea(in:state:)

Instance Method
func contentArea(in area: Rect, state: TableState<ID>) -> Rect

Content viewport after the fixed selection prefix gutter.

Parameters (2)
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.

Returns Rect.

Source · Table.swift:284