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)

public interface ITextCaret

NameDescription
System_CAPS_pubpropertyBottom

Gets the position of the bottom edge of the caret in the text rendering coordinate system.

System_CAPS_pubpropertyContainingTextViewLine

Gets the ITextViewLine that contains the caret, provided that that text line is visible in the view.

System_CAPS_pubpropertyHeight

Gets the height of the caret in the text rendering coordinate system.

System_CAPS_pubpropertyInVirtualSpace

Determines whether the caret lies in virtual space. A virtual space is one that is after the physical end of a line.

System_CAPS_pubpropertyIsHidden

Gets or sets the visibility of the caret.

System_CAPS_pubpropertyLeft

Gets the position of the left edge of the caret in the text rendering coordinate system.

System_CAPS_pubpropertyOverwriteMode

Determines whether the caret is in overwrite mode.

System_CAPS_pubpropertyPosition

Gets the current position of the caret.

System_CAPS_pubpropertyRight

Gets the position of the right edge of the caret in the text rendering coordinate system.

System_CAPS_pubpropertyTop

Gets the position of the top edge of the caret in the text rendering coordinate system.

System_CAPS_pubpropertyWidth

Gets the width of the caret in the text rendering coordinate system.

NameDescription
System_CAPS_pubmethodEnsureVisible()

Makes the caret visible by scrolling the view up or down and left or right until the caret is visible.

System_CAPS_pubmethodMoveTo(ITextViewLine)

Moves the caret to the specified text line while preserving its current x-coordinate.

System_CAPS_pubmethodMoveTo(ITextViewLine, Double)

Moves the caret to the best CaretPosition for the specified x-coordinate and text line.

System_CAPS_pubmethodMoveTo(ITextViewLine, Double, Boolean)

Moves the caret to the best CaretPosition for the specified x-coordinate and text line.

System_CAPS_pubmethodMoveTo(SnapshotPoint)

Moves the caret to the given index in the underlying ITextBuffer.

System_CAPS_pubmethodMoveTo(SnapshotPoint, PositionAffinity)

Moves the caret to the given index in the underlying ITextBuffer.

System_CAPS_pubmethodMoveTo(SnapshotPoint, PositionAffinity, Boolean)

Moves the caret to the given index in the underlying ITextBuffer.

System_CAPS_pubmethodMoveTo(VirtualSnapshotPoint)

Moves the caret to the specified buffer position.

System_CAPS_pubmethodMoveTo(VirtualSnapshotPoint, PositionAffinity)

Moves the caret to the specified buffer position.

System_CAPS_pubmethodMoveTo(VirtualSnapshotPoint, PositionAffinity, Boolean)

Moves the caret to the specified buffer position.

System_CAPS_pubmethodMoveToNextCaretPosition()

Moves the caret to the next valid CaretPosition.

System_CAPS_pubmethodMoveToPreferredCoordinates()

Moves the caret to the preferred x- and y-coordinates.

System_CAPS_pubmethodMoveToPreviousCaretPosition()

Moves the caret to the previous valid CaretPosition.

NameDescription
System_CAPS_pubeventPositionChanged

Occurs when the position of the caret has been explicitly changed.

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.

Return to top
Show: