loom & weft
Made for Swift.

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

LOOM Unreleased (PR #2) / 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

var table = Table(columns: [TableColumn("Name", width: .length(8))], rows: [TableRow(id: 1, cells: [TableCell("Ready")])])
table.columnFlex = .center
_ = table.columnAreas(width: 40)
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

columnFlex

Instance Property
var columnFlex: Flex

Places unused horizontal cells around columns after widths and column spacing are reserved.

Uses the same allocation and remainder rules as Layout.

Source · Table.swift:140

automaticHeights

Instance Property
var automaticHeights: Bool

Measures body text using the final column widths.

Source · Table.swift:142

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:143

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:144

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:145

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:146

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:147

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:149

style

Instance Property
var style: Style

Visual attributes used when painting this value.

Source · Table.swift:150

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:151

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:152

selectionStyle

Instance Property
var selectionStyle: Style

Style used for the selected choice/icon.

Source · Table.swift:153

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:154

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:155

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:156

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:157

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:158

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:159

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:160

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:161

emptyMessage

Instance Property
var emptyMessage: String

Text shown when the popup has no items.

Source · Table.swift:162

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:164

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:169

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:176

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:190

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:203

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:268

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:288