loom & weft
Made for Swift.

Published release 0.2.1. Unreleased PR #2 reference.

LOOM 0.2.1 / TERMINAL ALIASES FROM WEFT

TerminalEvents

This class and its members are @MainActor. Consume batches with for try await. Do not poll the session concurrently. A batch may contain multiple .text characters, so keyboardEvent alone is not sufficient. The app handles resize and signals, and must stop the source before closing its session.

loom.TerminalEvents is an alias for weft.TerminalEvents. It is available through import loom. The underlying type’s members are documented here.

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

let session = try TerminalSession()
defer { session.close() }
let input = TerminalEvents(session: session)
defer { input.stop() }
for try await batch in input.events {
    for event in batch { _ = event.keyboardEvent }
    break
}
Members on this page

Feature guides and release status

TerminalEvents

Type Alias @MainActor
typealias TerminalEvents = weft.weft.TerminalEvents

This class and its members are @MainActor. Consume batches with for try await. Do not poll the session concurrently. A batch may contain multiple .text characters, so keyboardEvent alone is not sufficient. The app handles resize and signals, and must stop the source before closing its session.

Source · TerminalExports.swift:11

Underlying weft API

TerminalEvents

Class @MainActor
@MainActor final class TerminalEvents

Conforms to: Swift.Sendable.

Delivers terminal input and resize events without an idle polling timer.

Create and consume this source on the main actor. Do not also call the session's poll method while it is active. Handoff pauses this source automatically; closing the session or calling stop() finishes it.

Source · TerminalEvents.swift:18

events

Instance Property @MainActor
@MainActor let events: AsyncThrowingStream<[InputEvent], Error>

Asynchronous throwing stream of InputEvent batches, consumed on the main actor.

Source · TerminalEvents.swift:19

init(session:)

Initializer @MainActor
@MainActor init(session: TerminalSession)

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

Parameters (1)
session
The active terminal session; the caller owns its lifetime.
Source · TerminalEvents.swift:31

stop()

Instance Method @MainActor
@MainActor func stop()

Cancels readiness observers and finishes event delivery.

Safe to repeat.

Source · TerminalEvents.swift:60