Unreleased APIs from PR #2. Not in 0.2.1. Stable 0.2.1 reference.
LOOM Unreleased (PR #2) / RENDERING AND LAYOUT
Terminal
Describe the whole logical screen in every draw closure. Each draw starts with a cleared frame and no cursor. The first draw, a resize, or invalidation forces a repaint. Unchanged cells and cursor emit no bytes. A failed backend write propagates its error and forces the next draw to repaint. Output settings are explicit; environment capabilities are not inferred automatically.
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 terminal = Terminal(backend: ANSIBackend(), width: 80, height: 24)
let stats = try terminal.draw { frame in
frame.render(Paragraph(TextLayout("Hello", width: frame.area.width)), in: frame.area)
}
_ = stats.bytesMembers on this page
Feature guides and release status
Terminal
struct Terminal<B> where B : BackendANSI terminal rendering over a weft byte sink.
This compatible facade shares viewport and failure behavior with RenderTerminal.
The caller owns terminal modes and input reading.
backend
var backend: B { get }The output backend retained by the terminal; externally read-only.
Source · Terminal.swift:10viewport
var viewport: Viewport { get }Available terminal-cell viewport.
Source · Terminal.swift:11viewportArea
var viewportArea: Rect { get }A public field of this type. Its value type and mutability are shown in the declaration.
Source · Terminal.swift:12requiresReanchor
var requiresReanchor: Bool { get }A public field of this type. Its value type and mutability are shown in the declaration.
Source · Terminal.swift:13snapshot
var snapshot: FrameSnapshot? { get }A public field of this type. Its value type and mutability are shown in the declaration.
Source · Terminal.swift:14init(backend:width:height:synchronizedOutput:colorDepth:hyperlinks:viewport:)
init(backend: B, width: Int, height: Int, synchronizedOutput: Bool = true, colorDepth: TerminalColorDepth = .trueColor, hyperlinks: Bool = false, viewport: Viewport = .fullscreen)Creates a value with the supplied arguments. Default arguments are shown in the declaration.
Parameters (7)
backend- Destination that writes terminal bytes or throws.
width- Available columns in terminal cells.
height- Available rows in terminal cells.
synchronizedOutput- Argument type and any default are shown in the declaration; see the behavior notes above.
colorDepth- Argument type and any default are shown in the declaration; see the behavior notes above.
hyperlinks- Argument type and any default are shown in the declaration; see the behavior notes above.
viewport- Available terminal-cell viewport.
localPoint(from:)
func localPoint(from physicalPoint: Point) -> Point?Maps a physical terminal cell inside the active viewport into frame-local coordinates; returns nil outside it.
Parameters (1)
from- Argument type and any default are shown in the declaration; see the behavior notes above.
Returns Point?.
physicalPoint(from:)
func physicalPoint(from localPoint: Point) -> Point?Maps a valid local frame cell to physical terminal coordinates; returns nil outside it.
Parameters (1)
from- Argument type and any default are shown in the declaration; see the behavior notes above.
Returns Point?.
resize(width:height:)
mutating func resize(width: Int, height: Int)Replaces both buffers and forces a full repaint when dimensions change. A call with unchanged dimensions does nothing.
Parameters (2)
width- Available columns in terminal cells.
height- Available rows in terminal cells.
setViewport(_:)
mutating func setViewport(_ viewport: Viewport)Changes viewport policy and invalidates placement. Inline viewports require a confirmed physical anchor.
Parameters (1)
viewport- Available terminal-cell viewport.
reanchor(at:)
mutating func reanchor(at anchor: Point) throwsConfirms a new physical inline anchor after uncertain scrolling; throws if the viewport is not inline.
Parameters (1)
at- Argument type and any default are shown in the declaration; see the behavior notes above.
invalidate()
mutating func invalidate()Invalidates rendering assumptions after external output. Inline scrolling uncertainty may require explicit reanchoring.
Source · Terminal.swift:33draw(_:)
@discardableResult mutating func draw(_ render: (inout Frame) -> Void) throws -> RenderStatsClears and rebuilds the complete logical frame, encodes changes, writes nonempty output, and returns RenderStats. Throws the backend write error; the next draw then performs a full repaint.
Parameters (1)
render- Closure that builds the complete next logical frame.
Returns RenderStats.
insertBefore(_:)
mutating func insertBefore(_ content: Buffer) throwsInserts transcript cells before the retained inline frame, then repaints it. Requires inline placement; failed uncertain scrolling requires reanchoring and must not be blindly replayed.
Parameters (1)
content- Argument type and any default are shown in the declaration; see the behavior notes above.
insertBefore(height:render:)
mutating func insertBefore(height: Int, render: (inout Frame) -> Void) throwsBuilds full-width transcript rows with the supplied closure and inserts them before the retained inline frame.
Parameters (2)
height- Available rows in terminal cells.
render- Closure that builds the complete next logical frame.