Condividi tramite


Selection Struct

Definition

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

public readonly struct Selection : IEquatable<Microsoft.VisualStudio.Extensibility.Editor.Selection>
type Selection = struct
Public Structure Selection
Implements IEquatable(Of Selection)
Inheritance
Selection
Implements

Constructors

Selection(TextPosition, TextPosition, TextPosition)
Selection(TextRange, 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

ActivePosition

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 InsertionPosition.

AnchorPosition

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 InsertionPosition.

End

Returns the larger of ActivePosition and AnchorPosition.

Extent

Returns the span from Start to End.

InsertionPosition

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

IsEmpty

True if AnchorPosition equals ActivePosition. False otherwise.

IsReversed

True if AnchorPosition is later in the document than ActivePosition. False otherwise.

RpcContract

Converts this thick object into a serializable representation for use in an RPC call.

Start

Returns the smaller of ActivePosition and AnchorPosition.

Methods

Equals(Object)

Determines whether this selection is the same as other selection.

Equals(Selection)
GetHashCode()

Serves as a hash function for this type.

ToString()

Operators

Equality(Selection, Selection)

Indicates whether left and right equiavlent.

Inequality(Selection, Selection)

Indicates whether left and right different.

Applies to