loom & weft
Made for Swift.

Published release 0.2.1. Unreleased PR #2 reference.

LOOM 0.2.1 / TERMINAL ALIASES FROM WEFT

InputDecoder

Incremental decoder for input bytes only. It retains partial UTF-8, escape sequences, and bracketed pastes across feed calls. flushEscape resolves a lone Escape byte after the caller’s timeout. Bracketed paste payloads are limited to one mebibyte. A TerminalSession already owns its decoder; use this directly for custom input transports.

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

var decoder = InputDecoder()
let events = decoder.feed(Array("Hello".utf8))
_ = events
_ = decoder.flushEscape()
Members on this page

Feature guides and release status

InputDecoder

Type Alias
typealias InputDecoder = weft.weft.InputDecoder

Incremental decoder for input bytes only. It retains partial UTF-8, escape sequences, and bracketed pastes across feed calls. flushEscape resolves a lone Escape byte after the caller’s timeout. Bracketed paste payloads are limited to one mebibyte. A TerminalSession already owns its decoder; use this directly for custom input transports.

Source · TerminalExports.swift:20

Underlying weft API

InputDecoder

Structure
struct InputDecoder

Decodes terminal input incrementally across arbitrary read boundaries.

Escape sequences, UTF-8 characters, and bracketed pastes can each span multiple calls to feed(_:).

Source · InputDecoder.swift:7

init(maximumPasteBytes:terminalReplies:)

Initializer
init(maximumPasteBytes: Int = 1_048_576, terminalReplies: Bool = false)

Bounds retained UTF-8 paste bytes; bytes beyond the limit are consumed until the terminator.

The default retains at most 1 MiB. Protocol-aware callers may choose a larger finite budget. Oversized pastes produce .pasteTruncated with a prefix ending at a complete UTF-8 scalar. Opt into recognized typed reports without turning unknown replies into text.

Parameters (2)
maximumPasteBytes
Argument type and any default are shown in the declaration; see the behavior notes above.
terminalReplies
Argument type and any default are shown in the declaration; see the behavior notes above.
Source · InputDecoder.swift:28

flushEscape()

Instance Method
mutating func flushEscape() -> [InputEvent]

Treats a lone escape byte as a key after the caller's input timeout.

Returns [InputEvent].

Source · InputDecoder.swift:38

feed(_:)

Instance Method
mutating func feed(_ bytes: [UInt8]) -> [InputEvent]

Decodes all complete input and retains any incomplete trailing sequence.

Parameters (1)
bytes
Input bytes to decode incrementally.

Returns [InputEvent].

Source · InputDecoder.swift:47