Unreleased APIs from PR #2. Not in 0.2.1. Stable 0.2.1 reference.
LOOM Unreleased (PR #2) / 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
struct DocumentViewConforms to: Widget.
A visible region of a document that reuses its cached entry layouts.
Source · DocumentView.swift:4document
let document: TextDocumentThe document snapshot to display.
Source · DocumentView.swift:5scroll
let scroll: IntNumber of layout/document rows skipped above the visible region.
Source · DocumentView.swift:6selection
let selection: TextSelection?The current selection; coordinate semantics are defined by the containing type.
Source · DocumentView.swift:7init(_:scroll:selection:)
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.
render(in:buffer:)
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.