Unreleased APIs from PR #2. Not in 0.2.1. Stable 0.2.1 reference.
LOOM Unreleased (PR #2) / TEXT, MARKDOWN, AND EDITING
TextSelection
Endpoints are inclusive display-cell coordinates ordered by row, then column. A selection is independent of drag direction: first and last normalize anchor/head. Wide graphemes are highlighted and copied whole. These points are not LineEditor’s half-open grapheme offsets.
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 selection = TextSelection(anchor: Point(x: 4, y: 0), head: Point(x: 0, y: 0))
_ = selection.intersects(x: 1, y: 0, width: 2)Members on this page
Feature guides and release status
TextSelection
struct TextSelectionConforms to: Swift.Equatable, Swift.Sendable, Swift.SendableMetatype.
An inclusive selection between two positions in laid-out text.
Source · TextSelection.swift:4anchor
var anchor: PointThe fixed selection endpoint.
Source · TextSelection.swift:5head
var head: PointThe current selection endpoint.
Source · TextSelection.swift:6init(anchor:head:)
init(anchor: Point, head: Point)Creates a value with the supplied arguments. Default arguments are shown in the declaration.
Parameters (2)
anchor- Argument type and any default are shown in the declaration; see the behavior notes above.
head- Argument type and any default are shown in the declaration; see the behavior notes above.
first
var first: Point { get }The earlier normalized display-cell endpoint.
Source · TextSelection.swift:12last
var last: Point { get }The later normalized display-cell endpoint.
Source · TextSelection.swift:15intersects(x:y:width:)
func intersects(x: Int, y: Int, width: Int) -> BoolTests whether a glyph occupying width cells at (x, y) intersects the inclusive selection.
Parameters (3)
x- Argument type and any default are shown in the declaration; see the behavior notes above.
y- Argument type and any default are shown in the declaration; see the behavior notes above.
width- Available columns in terminal cells.
Returns Bool.