loom & weft
Made for Swift.

Published release 0.2.1. Unreleased PR #2 reference.

LOOM 0.2.1 / WIDGETS

WindowFrame

Owns geometry and pointer interaction for one window; the app renders content and manages window lifetime. An expanded window fills its viewport. Normal windows are clamped to the viewport and configured minimum sizes. Only chrome events are consumed by handleMouse. edgeResizing is an alias for insetTitle; resizing still starts at the lower-right border.

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 window = WindowFrame(viewport: Rect(width: 80, height: 24), preferredWidth: 40, preferredHeight: 12)
window.move(byColumns: 2, rows: 1)
window.toggleExpanded()
_ = window.contentArea
Members on this page

Feature guides and release status

WindowFrame

Structure
struct WindowFrame

Conforms to: Widget.

A single floating window's terminal-cell geometry and pointer interaction.

The caller owns its content and paints it inside bounds. This type draws only the border and controls. Pointer events starting in the content remain available to the caller, so text selection and other body interactions stay independent.

Source · WindowFrame.swift:8

viewport

Instance Property
var viewport: Rect { get }

Available terminal-cell viewport.

Source · WindowFrame.swift:9

bounds

Instance Property
var bounds: Rect { get }

Current window rectangle within the viewport.

Source · WindowFrame.swift:10

isExpanded

Instance Property
var isExpanded: Bool { get }

Whether the window fills its viewport.

Source · WindowFrame.swift:11

style

Instance Property
var style: Style

Visual attributes used when painting this value.

Source · WindowFrame.swift:12

insetTitle

Instance Property
var insetTitle: Bool

Places the draggable title row below the top border.

Source · WindowFrame.swift:14

edgeResizing

Instance Property
var edgeResizing: Bool { get set }

A source-compatible alias for insetTitle; resizing always starts at the lower-right border.

Source · WindowFrame.swift:16

init(viewport:preferredWidth:preferredHeight:minimumWidth:minimumHeight:)

Initializer
init(viewport: Rect, preferredWidth: Int, preferredHeight: Int, minimumWidth: Int = 24, minimumHeight: Int = 8)

Creates a centered window, bounded by the available terminal-cell viewport.

Parameters (5)
viewport
Available terminal-cell viewport.
preferredWidth
Argument type and any default are shown in the declaration; see the behavior notes above.
preferredHeight
Argument type and any default are shown in the declaration; see the behavior notes above.
minimumWidth
Argument type and any default are shown in the declaration; see the behavior notes above.
minimumHeight
Argument type and any default are shown in the declaration; see the behavior notes above.
Source · WindowFrame.swift:32

contentArea

Instance Property
var contentArea: Rect { get }

The space inside the border, measured in terminal cells.

Source · WindowFrame.swift:50

titleArea

Instance Property
var titleArea: Rect { get }

The draggable row between the corners, below the top border when insetTitle is enabled.

Source · WindowFrame.swift:53

expandButton

Instance Property
var expandButton: Rect { get }

The three-cell control just inside the upper-right border.

Source · WindowFrame.swift:59

minimizeButton

Instance Property
var minimizeButton: Rect { get }

The inset minimize control immediately left of expand.

Source · WindowFrame.swift:65

resizeHandle

Instance Property
var resizeHandle: Rect { get }

The lower-right border's resize region, measured in terminal cells.

Only its outer border cells resize the window; use isResizeHandle(at:) for hit testing.

Source · WindowFrame.swift:73

isResizeHandle(at:)

Instance Method
func isResizeHandle(at point: Point) -> Bool

Tests the connected bottom and right border cells beside the lower-right corner.

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

Returns Bool.

Source · WindowFrame.swift:83

resizeViewport(to:)

Instance Method
mutating func resizeViewport(to viewport: Rect)

Clamps the window to a new terminal-cell viewport while retaining its normal size.

An expanded window continues to fill the viewport. Repeating the current viewport preserves active drags.

Parameters (1)
to
Argument type and any default are shown in the declaration; see the behavior notes above.
Source · WindowFrame.swift:90

toggleExpanded()

Instance Method
mutating func toggleExpanded()

Expands to the viewport or restores the previous window bounds.

Source · WindowFrame.swift:98

move(byColumns:rows:)

Instance Method
mutating func move(byColumns columns: Int, rows: Int)

Moves an unexpanded window by terminal cells, keeping it inside the viewport.

Parameters (2)
byColumns
Argument type and any default are shown in the declaration; see the behavior notes above.
rows
Row count or signed row movement, according to the method.
Source · WindowFrame.swift:111

resize(byColumns:rows:)

Instance Method
mutating func resize(byColumns columns: Int, rows: Int)

Resizes an unexpanded window by terminal cells, subject to its minimum size.

Parameters (2)
byColumns
Argument type and any default are shown in the declaration; see the behavior notes above.
rows
Row count or signed row movement, according to the method.
Source · WindowFrame.swift:121

handleMouse(_:)

Instance Method
@discardableResult mutating func handleMouse(_ mouse: MouseEvent) -> Bool

Handles title dragging, lower-right border resizing, and expand/restore clicks.

Returns true only for window-chrome interactions; the caller handles body input.

Parameters (1)
mouse
Mouse action and terminal-cell position.

Returns Bool.

Source · WindowFrame.swift:131

render(in:buffer:)

Instance Method
func render(in area: Rect, buffer: inout Buffer)

Draws a thin square border and inset window controls.

Pass bounds as area so rendering and hit testing use the same cells.

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