CaretPosition Structure
Represents the position of a caret in an ITextView.
Namespace: Microsoft.VisualStudio.Text.Editor
Assembly: Microsoft.VisualStudio.Text.UI (in Microsoft.VisualStudio.Text.UI.dll)
Syntax
'Declaration
Public Structure CaretPosition
public struct CaretPosition
public value class CaretPosition
[<Sealed>]
type CaretPosition = struct end
JScript supports the use of structures, but not the declaration of new ones.
The CaretPosition type exposes the following members.
Constructors
Name | Description | |
---|---|---|
CaretPosition | Initializes a new instance of a CaretPosition. |
Top
Properties
Name | Description | |
---|---|---|
Affinity | Gets the affinity of the caret. | |
BufferPosition | Gets the position of the caret, corresponding to a gap between two characters in the ITextBuffer of the view. | |
Point | Gets the IMappingPoint that marks the position of the caret in the buffer. | |
VirtualBufferPosition | Gets the virtual buffer position as a VirtualSnapshotPoint. | |
VirtualSpaces | Gets the number of spaces past the physical end of the line of the caret position. |
Top
Methods
Name | Description | |
---|---|---|
Equals | Determines whether two CaretPosition objects are the same (Overrides ValueType.Equals(Object).) | |
GetHashCode | Gets the hash code for the CaretPosition. (Overrides ValueType.GetHashCode.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
ToString | Provides a string representation of the caret position. (Overrides ValueType.ToString.) |
Top
Operators
Name | Description | |
---|---|---|
Equality | Determines whether two CaretPosition objects are the same. | |
Inequality | Determines whether two CaretPosition objects are different. |
Top
Remarks
To get the caret's current position, you can listen to the PositionChanged event. (You can get the caret from the ITextView.)The ITextCaret class includes methods that allow you to move the caret to a different position.
Examples
For an example of finding the caret position, see Walkthrough: Displaying Matching Braces.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.