Table of Contents

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

anchor int
active int

Properties

Active

Gets the moving endpoint.

public int Active { get; }

Property Value

int

Anchor

Gets the fixed endpoint.

public int Anchor { get; }

Property Value

int

IsEmpty

Gets whether this selection is collapsed.

public bool IsEmpty { get; }

Property Value

bool

IsReversed

Gets whether the active endpoint precedes the anchor.

public bool IsReversed { get; }

Property Value

bool

Range

Gets the normalized selected range.

public TextSpan Range { get; }

Property Value

TextSpan

Methods

Clamp(int)

Clamps both endpoints to the supplied source length.

public TextSelectionState Clamp(int length)

Parameters

length int

Returns

TextSelectionState

FromRange(TextSpan)

Creates a forward selection over a bounded range.

public static TextSelectionState FromRange(TextSpan range)

Parameters

range TextSpan

Returns

TextSelectionState

Map(PositionMap)

Maps both endpoints after inserted text through an exact position map.

public TextSelectionState Map(PositionMap map)

Parameters

map PositionMap

Returns

TextSelectionState