Struct TextSelectionState
- Namespace
- TextEdit.Core
- Assembly
- TextEdit.Core.dll
A directional selection expressed as zero-based UTF-16 anchor and active offsets.
public readonly record struct TextSelectionState : IEquatable<TextSelectionState>
- Implements
- Inherited Members
Constructors
TextSelectionState(int, int)
Creates a selection whose active endpoint is the caret.
public TextSelectionState(int anchor, int active)
Parameters
Properties
Active
Gets the moving endpoint.
public int Active { get; }
Property Value
Anchor
Gets the fixed endpoint.
public int Anchor { get; }
Property Value
IsEmpty
Gets whether this selection is collapsed.
public bool IsEmpty { get; }
Property Value
IsReversed
Gets whether the active endpoint precedes the anchor.
public bool IsReversed { get; }
Property Value
Range
Gets the normalized selected range.
public TextSpan Range { get; }
Property Value
Methods
Clamp(int)
Clamps both endpoints to the supplied source length.
public TextSelectionState Clamp(int length)
Parameters
lengthint
Returns
FromRange(TextSpan)
Creates a forward selection over a bounded range.
public static TextSelectionState FromRange(TextSpan range)
Parameters
rangeTextSpan
Returns
Map(PositionMap)
Maps both endpoints after inserted text through an exact position map.
public TextSelectionState Map(PositionMap map)
Parameters
mapPositionMap