loom & weft
Made for Swift.

Published release 0.2.1. Unreleased PR #2 reference.

LOOM 0.2.1 / WIDGETS

Panel

Paints borders, rich top/bottom titles, and optional shadows. Render content separately inside inner(area). Negative padding contributes zero. BorderLayer merges shared edges explicitly. Titles require their border edge by default; title ordering and padding use whole-grapheme clipping.

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: 40, height: 8)
let panel = Panel(borderType: .rounded, title: "Status", padding: PanelPadding(all: 1))
frame.render(panel, in: frame.area)
let inner = panel.inner(frame.area)
frame.render(Paragraph(TextLayout("Ready", width: inner.width)), in: inner)
Members on this page

Feature guides and release status

Panel

Structure
struct Panel

Conforms to: Swift.Sendable, Swift.SendableMetatype, Widget.

Draws selectable borders and an optional title around an inner content area.

Source · Panel.swift:98

style

Instance Property
var style: Style

Visual attributes used when painting this value.

Source · Panel.swift:99

borders

Instance Property
var borders: BorderEdges

Enabled border sides.

Source · Panel.swift:100

borderType

Instance Property
var borderType: BorderType

Line/corner glyph style for the border.

Source · Panel.swift:101

title

Instance Property
var title: String?

Optional title displayed in the top border.

Source · Panel.swift:102

titleAlignment

Instance Property
var titleAlignment: PanelTitleAlignment

Horizontal placement of a panel’s title.

Source · Panel.swift:103

padding

Instance Property
var padding: PanelPadding

Padding between border and content.

Source · Panel.swift:104

titles

Instance Property
var titles: [PanelTitle]

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

Source · Panel.swift:105

borderStyle

Instance Property
var borderStyle: Style?

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

Source · Panel.swift:106

titleStyle

Instance Property
var titleStyle: Style?

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

Source · Panel.swift:107

shadow

Instance Property
var shadow: PanelShadow?

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

Source · Panel.swift:108

init(style:borders:borderType:title:titleAlignment:padding:titles:borderStyle:titleStyle:shadow:)

Initializer
init(style: Style = Style(), borders: BorderEdges = .all, borderType: BorderType = .single, title: String? = nil, titleAlignment: PanelTitleAlignment = .left, padding: PanelPadding = PanelPadding(), titles: [PanelTitle] = [], borderStyle: Style? = nil, titleStyle: Style? = nil, shadow: PanelShadow? = nil)

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

Parameters (10)
style
Text/cell appearance.
borders
Argument type and any default are shown in the declaration; see the behavior notes above.
borderType
Argument type and any default are shown in the declaration; see the behavior notes above.
title
Argument type and any default are shown in the declaration; see the behavior notes above.
titleAlignment
Argument type and any default are shown in the declaration; see the behavior notes above.
padding
Argument type and any default are shown in the declaration; see the behavior notes above.
titles
Argument type and any default are shown in the declaration; see the behavior notes above.
borderStyle
Argument type and any default are shown in the declaration; see the behavior notes above.
titleStyle
Argument type and any default are shown in the declaration; see the behavior notes above.
shadow
Argument type and any default are shown in the declaration; see the behavior notes above.
Source · Panel.swift:110

inner(_:)

Instance Method
func inner(_ area: Rect) -> Rect

Returns content geometry after border and padding cells have been removed.

Parameters (1)
area
Assigned absolute terminal-cell rectangle.

Returns Rect.

Source · Panel.swift:129

render(in:buffer:)

Instance Method
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.
Source · Panel.swift:144