ITextCaret Interface
Represents the caret associated with an ITextView.
Namespace: Microsoft.VisualStudio.Text.Editor
Assembly: Microsoft.VisualStudio.Text.UI (in Microsoft.VisualStudio.Text.UI.dll)
Syntax
声明
Public Interface ITextCaret
public interface ITextCaret
public interface class ITextCaret
type ITextCaret = interface end
public interface ITextCaret
The ITextCaret type exposes the following members.
Properties
Name | Description | |
---|---|---|
Bottom | Gets the position of the bottom edge of the caret in the text rendering coordinate system. | |
ContainingTextViewLine | Gets the ITextViewLine that contains the caret, provided that that text line is visible in the view. | |
Height | Gets the height of the caret in the text rendering coordinate system. | |
InVirtualSpace | Determines whether the caret lies in virtual space. A virtual space is one that is after the physical end of a line. | |
IsHidden | Gets or sets the visibility of the caret. | |
Left | Gets the position of the left edge of the caret in the text rendering coordinate system. | |
OverwriteMode | Determines whether the caret is in overwrite mode. | |
Position | Gets the current position of the caret. | |
Right | Gets the position of the right edge of the caret in the text rendering coordinate system. | |
Top | Gets the position of the top edge of the caret in the text rendering coordinate system. | |
Width | Gets the width of the caret in the text rendering coordinate system. |
Top
Methods
Name | Description | |
---|---|---|
EnsureVisible | Makes the caret visible by scrolling the view up or down and left or right until the caret is visible. | |
MoveTo(ITextViewLine) | Moves the caret to the specified text line while preserving its current x-coordinate. | |
MoveTo(SnapshotPoint) | Moves the caret to the given index in the underlying ITextBuffer. | |
MoveTo(VirtualSnapshotPoint) | Moves the caret to the specified buffer position. | |
MoveTo(ITextViewLine, Double) | Moves the caret to the best CaretPosition for the specified x-coordinate and text line. | |
MoveTo(SnapshotPoint, PositionAffinity) | Moves the caret to the given index in the underlying ITextBuffer. | |
MoveTo(VirtualSnapshotPoint, PositionAffinity) | Moves the caret to the specified buffer position. | |
MoveTo(ITextViewLine, Double, Boolean) | Moves the caret to the best CaretPosition for the specified x-coordinate and text line. | |
MoveTo(SnapshotPoint, PositionAffinity, Boolean) | Moves the caret to the given index in the underlying ITextBuffer. | |
MoveTo(VirtualSnapshotPoint, PositionAffinity, Boolean) | Moves the caret to the specified buffer position. | |
MoveToNextCaretPosition | Moves the caret to the next valid CaretPosition. | |
MoveToPreferredCoordinates | Moves the caret to the preferred x- and y-coordinates. | |
MoveToPreviousCaretPosition | Moves the caret to the previous valid CaretPosition. |
Top
Events
Name | Description | |
---|---|---|
PositionChanged | Occurs when the position of the caret has been explicitly changed. |
Top
Remarks
This interface serves as a convenient way to get the current position of the caret and to move the caret to a different position. For more information about using the caret, see the editor walkthroughs, for example Walkthrough: Highlighting Text.
Most properties and parameters that are doubles correspond to coordinates or distances in the text rendering coordinate system. In this coordinate system, x = 0.0 corresponds to the left edge of the drawing surface onto which text is rendered (x = view.ViewportLeft corresponds to the left edge of the viewport), and y = view.ViewportTop corresponds to the top edge of the viewport. The x-coordinate increases from left to right, and the y-coordinate increases from top to bottom. The horizontal and vertical axes of the view behave differently. When the text in the view is formatted, only the visible lines are formatted. As a result, a viewport cannot be scrolled horizontally and vertically in the same way. A viewport is scrolled horizontally by changing the left coordinate of the viewport so that it moves with respect to the drawing surface. A view can be scrolled vertically only by performing a new layout. Doing a layout in the view may cause the ViewportTop property of the view to change.
For example, scrolling down one line will not translate any of the visible lines. Instead it will simply change the view's ViewportTop property (causing the lines to move on the screen even though their y-coordinates have not changed). Distances in the text rendering coordinate system correspond to logical pixels. If the text rendering surface is displayed without any scaling transform, then 1 unit in the text rendering coordinate system corresponds to one pixel on the display.