Published release 0.2.1. Unreleased PR #2 reference.
LOOM 0.2.1 / RENDERING, VIEWPORTS, AND COMPOSITION
RenderTerminal
Immediate rendering with viewport-local frames and physical terminal output.
The caller owns raw mode, primary/alternate-screen choice, and input reading.
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 = RenderTerminal(backend: TestBackend(width: 20, height: 4), width: 20, height: 4)
try terminal.draw { frame in frame.render(Panel(title: "Test"), in: frame.area) }
_ = terminal.backend.screenMembers on this page
Feature guides and release status
RenderTerminal
struct RenderTerminal<R> where R : RenderBackendImmediate rendering with viewport-local frames and physical terminal output.
The caller owns raw mode, primary/alternate-screen choice, and input reading.
Source · RenderTerminal.swift:7backend
var backend: R { get }The output backend retained by the terminal; externally read-only.
Source · RenderTerminal.swift:8viewport
var viewport: Viewport { get }Available terminal-cell viewport.
Source · RenderTerminal.swift:9viewportArea
var viewportArea: Rect { get }A public field of this type. Its value type and mutability are shown in the declaration.
Source · RenderTerminal.swift:10requiresReanchor
var requiresReanchor: Bool { get }A public field of this type. Its value type and mutability are shown in the declaration.
Source · RenderTerminal.swift:11snapshot
var snapshot: FrameSnapshot? { get }An on-demand copy of the last successfully presented logical frame.
Nil before the first draw, after resize/invalidation, or after output failure.
Source · RenderTerminal.swift:24init(backend:width:height:viewport:)
init(backend: R, width: Int, height: Int, viewport: Viewport = .fullscreen)Creates a value with the supplied arguments. Default arguments are shown in the declaration.
Parameters (4)
backend- Destination that writes terminal bytes or throws.
width- Available columns in terminal cells.
height- Available rows in terminal cells.
viewport- Available terminal-cell viewport.
localPoint(from:)
func localPoint(from physicalPoint: Point) -> Point?Converts a physical terminal position to a local frame position, if inside the viewport.
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?Converts a valid local frame position to a physical terminal position.
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)Updates terminal dimensions and invalidates placement/snapshots when required. Frame geometry is recalculated from the viewport.
Parameters (2)
width- Available columns in terminal cells.
height- Available rows in terminal cells.
setViewport(_:)
mutating func setViewport(_ viewport: Viewport)Changes the owned footprint.
The previous footprint is erased on the next draw.
Inline anchors must be confirmed by the caller; this never queries or reads stdin.
Parameters (1)
viewport- Available terminal-cell viewport.
reanchor(at:)
mutating func reanchor(at anchor: Point) throwsConfirms where inline rendering may resume after resize or uncertain output.
This discards pending insertions and old footprint knowledge. The application must first establish a safe primary-screen cursor position by its own means.
Parameters (1)
at- Argument type and any default are shown in the declaration; see the behavior notes above.
invalidate()
mutating func invalidate()Repaints after external output.
Inline output requires a confirmed new anchor.
Source · RenderTerminal.swift:94draw(_:)
@discardableResult mutating func draw(_ render: (inout Frame) -> Void) throws -> RenderStatsBuilds a complete logical frame and presents it through the semantic backend. Only successful presentation advances snapshots.
Parameters (1)
render- Closure that builds the complete next logical frame.
Returns RenderStats.
insertBefore(_:)
mutating func insertBefore(_ content: Buffer) throwsCommits full-width styled rows above an inline frame and redraws its current contents.
Uses line feeds on the primary screen, preserving scrollback. Short rows are
padded; excess columns are clipped at whole graphemes. Failure may mean partial
insertion: subsequent draws and insertions require explicit reanchor(at:).
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 styled rows to commit above an inline viewport.
Parameters (2)
height- Available rows in terminal cells.
render- Closure that builds the complete next logical frame.