loom & weft
Made for Swift.

Published release 0.2.1. Unreleased PR #2 reference.

LOOM 0.2.1 / COLLECTIONS AND INTERACTION

ScrollState

Application-owned scrolling along one axis, measured in terminal cells.

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

ScrollState

Structure
struct ScrollState

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

Application-owned scrolling along one axis, measured in terminal cells.

Source · ScrollState.swift:2

contentLength

Instance Property
var contentLength: Int { get }

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

Source · ScrollState.swift:3

viewportLength

Instance Property
var viewportLength: Int { get }

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

Source · ScrollState.swift:4

offset

Instance Property
var offset: Int { get }

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

Source · ScrollState.swift:5

followsEnd

Instance Property
var followsEnd: Bool { get }

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

Source · ScrollState.swift:6

maximumOffset

Instance Property
var maximumOffset: Int { get }

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

Source · ScrollState.swift:8

isAtStart

Instance Property
var isAtStart: Bool { get }

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

Source · ScrollState.swift:9

isAtEnd

Instance Property
var isAtEnd: Bool { get }

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

Source · ScrollState.swift:10

visibleRange

Instance Property
var visibleRange: Range<Int> { get }

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

Source · ScrollState.swift:11

init(contentLength:viewportLength:offset:followsEnd:)

Initializer
init(contentLength: Int = 0, viewportLength: Int = 0, offset: Int = 0, followsEnd: Bool = false)

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

Parameters (4)
contentLength
Argument type and any default are shown in the declaration; see the behavior notes above.
viewportLength
Argument type and any default are shown in the declaration; see the behavior notes above.
offset
Offset in extended grapheme clusters.
followsEnd
Argument type and any default are shown in the declaration; see the behavior notes above.
Source · ScrollState.swift:13

update(contentLength:viewportLength:)

Instance Method
mutating func update(contentLength: Int, viewportLength: Int)

Updates metrics after content changes or resize, preserving the offset or following the end.

Parameters (2)
contentLength
Argument type and any default are shown in the declaration; see the behavior notes above.
viewportLength
Argument type and any default are shown in the declaration; see the behavior notes above.
Source · ScrollState.swift:22

scroll(to:)

Instance Method
mutating func scroll(to offset: Int)

Moves to a clamped cell offset.

Moving away from the end stops automatic following.

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

scroll(by:)

Instance Method
mutating func scroll(by cells: Int)

Moves by signed cell/row distance, clamping to the content range.

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

scrollPage(by:)

Instance Method
mutating func scrollPage(by pages: Int)

Moves by a signed number of viewport lengths, clamped to the content range.

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

scrollToEnd(follow:)

Instance Method
mutating func scrollToEnd(follow: Bool = false)

Moves to maximumOffset and optionally follows future growth at the end.

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

reveal(_:padding:)

Instance Method
mutating func reveal(_ range: Range<Int>, padding: Int = 0)

Reveals a cell range; a range larger than the viewport is aligned to its start.

Parameters (2)
range
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.
Source · ScrollState.swift:52

handle(_:axis:wheelStep:)

Instance Method
@discardableResult mutating func handle(_ event: InputEvent, axis: Direction = .vertical, wheelStep: Int = 3) -> Bool

Optional default navigation.

The caller routes only events belonging to this viewport.

Parameters (3)
event
Argument type and any default are shown in the declaration; see the behavior notes above.
axis
Argument type and any default are shown in the declaration; see the behavior notes above.
wheelStep
Argument type and any default are shown in the declaration; see the behavior notes above.

Returns Bool.

Source · ScrollState.swift:68