loom & weft
Made for Swift.

Unreleased APIs from PR #2. Not in 0.2.1. Stable 0.2.1 reference.

LOOM Unreleased (PR #2) / TERMINAL ALIASES FROM WEFT

Backend

Implement a mutating throwing write(Data) method that writes every byte in order or throws. Terminal is generic over this protocol, so a custom backend can capture output for tests.

loom.Backend is an alias for weft.Backend. 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

struct Capture: Backend {
    var bytes = Data()
    mutating func write(_ data: Data) throws { bytes.append(data) }
}
var terminal = Terminal(backend: Capture(), width: 10, height: 2)
try terminal.draw { _ in }
_ = terminal.backend.bytes
Members on this page

Feature guides and release status

Backend

Type Alias
typealias Backend = weft.weft.Backend

Implement a mutating throwing write(Data) method that writes every byte in order or throws. Terminal is generic over this protocol, so a custom backend can capture output for tests.

Source · TerminalExports.swift:6

Underlying weft API

Backend

Protocol
protocol Backend

An output destination for terminal bytes.

Source · Backend.swift:4

write(_:)

Instance Method Throws
mutating func write(_ data: Data) throws

Writes every byte in order or throws an error.

Parameters (1)
data
Bytes to write in order.
Source · Backend.swift:6

execute(_:)

Instance Method Throws
mutating func execute(_ commands: [TerminalCommand]) throws

Batch commands in one write, preserving their order.

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