Published release 0.2.1. Unreleased PR #2 reference.
LOOM 0.2.1 / TEXT, MARKDOWN, AND EDITING
TextSpan
Spans carry text and optional per-span styling, links, and fenced-code metadata into TextLayout. A nil style uses the painting fallback. Non-copyable spans remain visible but are excluded from copied selections. TextLayout sanitizes controls when combining spans.
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
let spans = [TextSpan("Hello "), TextSpan("Swift", style: Style(bold: true))]
_ = TextLayout(spans, width: 40, wrapping: .word)Members on this page
Feature guides and release status
TextSpan
struct TextSpanConforms to: Swift.Sendable, Swift.SendableMetatype.
A source-text segment with an optional style override.
A nil style inherits the paragraph's style; a supplied style replaces it. The optional patch then modifies that resolved appearance. Adjacent spans remain one continuous source string for layout, selection, and copying.
Source · TextSpan.swift:6sourceLine
let sourceLine: Int?One-based Markdown source line for the first character, when supplied.
Synthetic presentation prefixes have no source location.
Source · TextSpan.swift:10text
let text: StringThe stored text content.
Source · TextSpan.swift:11style
let style: Style?Visual attributes used when painting this value.
Source · TextSpan.swift:12patch
let patch: StylePatch?Changes applied after the span or inherited paragraph style.
Source · TextSpan.swift:14link
let link: String?An HTTP(S) destination associated with this visible text.
Source · TextSpan.swift:16codeBlock
let codeBlock: TextCodeBlock?The original code represented by this span's block, when supplied by the renderer.
Source · TextSpan.swift:18isCodeBlockHeader
let isCodeBlockHeader: BoolMarks a dedicated code-block header row for application-owned controls.
Source · TextSpan.swift:20copyable
let copyable: BoolDisplay-only text remains visible but is omitted from copied selections.
Source · TextSpan.swift:22init(_:style:link:codeBlock:isCodeBlockHeader:copyable:sourceLine:patch:)
init(_ text: String, style: Style? = nil, link: String? = nil, codeBlock: TextCodeBlock? = nil, isCodeBlockHeader: Bool = false, copyable: Bool = true, sourceLine: Int? = nil, patch: StylePatch? = nil)Creates a value with the supplied arguments. Default arguments are shown in the declaration.
Parameters (8)
text- Source text.
style- Text/cell appearance.
link- Argument type and any default are shown in the declaration; see the behavior notes above.
codeBlock- Argument type and any default are shown in the declaration; see the behavior notes above.
isCodeBlockHeader- Argument type and any default are shown in the declaration; see the behavior notes above.
copyable- Argument type and any default are shown in the declaration; see the behavior notes above.
sourceLine- Argument type and any default are shown in the declaration; see the behavior notes above.
patch- Argument type and any default are shown in the declaration; see the behavior notes above.