loom & weft
Made for Swift.

Published release 0.2.1. Unreleased PR #2 reference.

LOOM 0.2.1 / COLLECTIONS AND INTERACTION

Scrollbar

A reusable scrollbar for any content measured by ScrollState.

Vertical bars occupy the area's first column; horizontal bars occupy its first row. Route drag/up events to the captured bar even when the pointer leaves its track.

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.

Members on this page

Feature guides and release status

Scrollbar

Structure
struct Scrollbar

Conforms to: Widget.

A reusable scrollbar for any content measured by ScrollState.

Vertical bars occupy the area's first column; horizontal bars occupy its first row. Route drag/up events to the captured bar even when the pointer leaves its track.

Source · Scrollbar.swift:12

state

Instance Property
var state: ScrollState

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

Source · Scrollbar.swift:13

direction

Instance Property
var direction: Direction

The horizontal or vertical allocation axis.

Source · Scrollbar.swift:14

trackStyle

Instance Property
var trackStyle: Style

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

Source · Scrollbar.swift:15

thumbStyle

Instance Property
var thumbStyle: Style

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

Source · Scrollbar.swift:16

hidesWhenUnneeded

Instance Property
var hidesWhenUnneeded: Bool

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

Source · Scrollbar.swift:17

thumbSymbol

Instance Property
var thumbSymbol: String

Invalid or non-single-cell symbols fall back to the default symbol.

Source · Scrollbar.swift:19

trackSymbol

Instance Property
var trackSymbol: String?

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

Source · Scrollbar.swift:20

startSymbol

Instance Property
var startSymbol: String?

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

Source · Scrollbar.swift:21

endSymbol

Instance Property
var endSymbol: String?

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

Source · Scrollbar.swift:22

init(_:direction:)

Initializer
init(_ state: ScrollState, direction: Direction = .vertical)

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

Parameters (2)
state
Argument type and any default are shown in the declaration; see the behavior notes above.
direction
Argument type and any default are shown in the declaration; see the behavior notes above.
Source · Scrollbar.swift:24

trackArea(in:)

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

Draggable track, excluding configured endpoint cells.

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

Returns Rect.

Source · Scrollbar.swift:37

thumbRange(length:)

Instance Method
func thumbRange(length: Int) -> Range<Int>

Thumb cells relative to the start of the track.

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

Returns Range<Int>.

Source · Scrollbar.swift:58

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 · Scrollbar.swift:67

handle(_:in:state:drag:)

Instance Method
@discardableResult func handle(_ mouse: MouseEvent, in area: Rect, state: inout ScrollState, drag: inout ScrollbarDrag?) -> Bool

Track clicks page; thumb drags preserve the pointer's grab position; wheel events scroll.

Parameters (4)
mouse
Mouse action and terminal-cell position.
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.
drag
Argument type and any default are shown in the declaration; see the behavior notes above.

Returns Bool.

Source · Scrollbar.swift:106