loom & weft
Made for Swift.

Published release 0.2.1. Unreleased PR #2 reference.

LOOM 0.2.1 / WIDGETS

DocumentView

A value snapshot of a TextDocument plus row scroll and document-space selection. Recreate it from current state when drawing. It delegates painting to the document’s cached entry layouts.

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 document = TextDocument(width: 40)
document.append("First")
document.append("Second")
var frame = Frame(width: 40, height: 5)
frame.render(DocumentView(document, scroll: 1), in: frame.area)
Members on this page

Feature guides and release status

DocumentView

Structure
struct DocumentView

Conforms to: Widget.

A visible region of a document that reuses its cached entry layouts.

Source · DocumentView.swift:4

document

Instance Property
let document: TextDocument

The document snapshot to display.

Source · DocumentView.swift:5

scroll

Instance Property
let scroll: Int

Number of layout/document rows skipped above the visible region.

Source · DocumentView.swift:6

selection

Instance Property
let selection: TextSelection?

The current selection; coordinate semantics are defined by the containing type.

Source · DocumentView.swift:7

init(_:scroll:selection:)

Initializer
init(_ document: TextDocument, scroll: Int = 0, selection: TextSelection? = nil)

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

Parameters (3)
document
Argument type and any default are shown in the declaration; see the behavior notes above.
scroll
Number of document/layout rows skipped above the viewport.
selection
Selection using the containing type’s coordinate convention.
Source · DocumentView.swift:9

render(in:buffer:)

Instance Method
func render(in area: Rect, buffer: inout Buffer)

Paints this widget into the assigned terminal-cell rectangle. Application code owns state, input routing, and terminal lifetime.

Parameters (2)
in
Argument type and any default are shown in the declaration; see the behavior notes above.
buffer
Mutable destination cell grid.
Source · DocumentView.swift:15