Back to API Reference
Struct
TextSelection
sealed
Implements:IEquatable<TextSelection>
Anchor / focus / affinity selection over codepoint indices. Anchor is where the selection began; Focus is the current caret position (always where the caret is rendered). Affinity disambiguates caret rendering at soft-wrap and BiDi boundaries.
Remarks
Indices are codepoint offsets — the same space used by
codepoints and cluster. Cursor movement at the consumer level is grapheme-cluster-aware (via GraphemeNavigator), but the storage representation is codepoints (D-006). Direction is implicit in the Anchor/Focus ordering — matches the W3C Selection API and Flutter TextSelection conventions. Multi-cursor (P3 code-editor) is reserved as a non-breaking IReadOnlyList<TextSelection> overload alongside the single-region property (D-001 revised). Immutable — mutations go through UniTextSelectable named methods (SetCaret / SetSelection / ExtendSelection). Direct construction is allowed for read-only producers (parsers, deserializers, snapshot diffs).public CaretAffinity Affinity{ get }Visual side of the caret at a soft-wrap or BiDi run boundary. See CaretAffinity.
public static TextSelection Caret()Caret-only selection at codepointIndex with the given affinity.
public TextSelection Clamp()Returns a new TextSelection with both endpoints clamped to [0, codepointCount]. Returns the original instance when no clamping is needed.
