Class TextSelectionSet
- Namespace
- TextEdit.Core
- Assembly
- TextEdit.Core.dll
An immutable, normalized set of selections with one primary native selection.
public sealed class TextSelectionSet : IReadOnlyList<TextSelection>, IReadOnlyCollection<TextSelection>, IEnumerable<TextSelection>, IEnumerable
- Inheritance
-
TextSelectionSet
- Implements
- Inherited Members
Remarks
Overlapping or touching ranges and duplicate carets merge. The primary selection's identity and direction win when it participates in a merge.
Constructors
TextSelectionSet(IEnumerable<TextSelection>, int)
Copies and normalizes selections. The primary index addresses the supplied enumeration before sorting.
public TextSelectionSet(IEnumerable<TextSelection> selections, int primaryIndex = 0)
Parameters
selectionsIEnumerable<TextSelection>primaryIndexint
Properties
Count
Gets the number of elements in the collection.
public int Count { get; }
Property Value
- int
The number of elements in the collection.
this[int]
Gets the element at the specified index in the read-only list.
public TextSelection this[int index] { get; }
Parameters
indexintThe zero-based index of the element to get.
Property Value
- TextSelection
The element at the specified index in the read-only list.
Primary
Gets the primary selection controlled by native input.
public TextSelection Primary { get; }
Property Value
PrimaryIndex
Gets the normalized primary index.
public int PrimaryIndex { get; }
Property Value
Methods
Caret(int)
Creates one collapsed selection.
public static TextSelectionSet Caret(int position)
Parameters
positionint
Returns
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<TextSelection> GetEnumerator()
Returns
- IEnumerator<TextSelection>
An enumerator that can be used to iterate through the collection.
Validate(int)
Validates every selection against the document length.
public void Validate(int textLength)
Parameters
textLengthint
Validate(TextSnapshot)
Validates real endpoints and requires virtual endpoints to be at a logical line end.
public void Validate(TextSnapshot snapshot)
Parameters
snapshotTextSnapshot