다음을 통해 공유


Selection Struct

Definition

Manages the insertion, anchor, and active points for a single caret and its associated selection.

public value class Selection : IEquatable<Microsoft::VisualStudio::Text::Selection>
public struct Selection : IEquatable<Microsoft.VisualStudio.Text.Selection>
type Selection = struct
Public Structure Selection
Implements IEquatable(Of Selection)
Inheritance
Selection
Implements

Constructors

Selection(SnapshotPoint, PositionAffinity)

Instantiates a new Selection with a zero-width extent at the provided insertion point.

Selection(SnapshotPoint, SnapshotPoint, SnapshotPoint, PositionAffinity)

Instantiates a new Selection.

Selection(SnapshotPoint, SnapshotPoint)

Instantiates a new Selection with the given anchor and active points, and the insertion point is located at the active point.

Selection(SnapshotSpan, Boolean)

Instantiates a new Selection with the given extent. Anchor and active points are defined by isReversed, and the insertion point is located at the active point.

Selection(VirtualSnapshotPoint, PositionAffinity)

Instantiates a new Selection with a zero-width extent at the provided insertion point.

Selection(VirtualSnapshotPoint, VirtualSnapshotPoint, VirtualSnapshotPoint, PositionAffinity)

Instantiates a new Selection.

Selection(VirtualSnapshotPoint, VirtualSnapshotPoint)

Instantiates a new Selection with the given anchor and active points, and the insertion point is located at the active point.

Selection(VirtualSnapshotSpan, Boolean)

Instantiates a new Selection with the given extent. Anchor and active points are defined by isReversed, and the insertion point is located at the active point.

Fields

Invalid

A static instance of a selection that is invalid and can be used to check for instantiation.

Properties

ActivePoint

Gets the location of the movable selection endpoint, meaning if a user were to hold shift and click, this point would be changed to the location of the click. If this is an empty selection, this will be at the InsertionPoint.

AnchorPoint

Gets the location of the fixed selection endpoint, meaning if a user were to hold shift and click, this point would remain where it is. If this is an empty selection, this will be at the InsertionPoint.

End

Returns the larger of ActivePoint and AnchorPoint.

Extent

Returns the span from Start to End.

InsertionPoint

Gets the location where a caret should be rendered and edits performed.

InsertionPointAffinity

Gets the affinity of the insertion point. This is used in places like word-wrap where one buffer position can represent both the end of one line and the beginning of the next.

IsEmpty

True if AnchorPoint equals ActivePoint. False otherwise.

IsReversed

True if AnchorPoint is later in the document than ActivePoint. False otherwise.

IsValid

Gets whether this selection contains meaningful data.

Start

Returns the smaller of ActivePoint and AnchorPoint.

Methods

Equals(Object)
Equals(Selection)
GetHashCode()
ToString()

Operators

Equality(Selection, Selection)
Inequality(Selection, Selection)

Applies to