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

'Declaration
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
Public property Bottom Gets the position of the bottom edge of the caret in the text rendering coordinate system.
Public property ContainingTextViewLine Gets the ITextViewLine that contains the caret, provided that that text line is visible in the view.
Public property Height Gets the height of the caret in the text rendering coordinate system.
Public property InVirtualSpace Determines whether the caret lies in virtual space. A virtual space is one that is after the physical end of a line.
Public property IsHidden Gets or sets the visibility of the caret.
Public property Left Gets the position of the left edge of the caret in the text rendering coordinate system.
Public property OverwriteMode Determines whether the caret is in overwrite mode.
Public property Position Gets the current position of the caret.
Public property Right Gets the position of the right edge of the caret in the text rendering coordinate system.
Public property Top Gets the position of the top edge of the caret in the text rendering coordinate system.
Public property Width Gets the width of the caret in the text rendering coordinate system.

Top

Methods

  Name Description
Public method EnsureVisible Makes the caret visible by scrolling the view up or down and left or right until the caret is visible.
Public method MoveTo(ITextViewLine) Moves the caret to the specified text line while preserving its current x-coordinate.
Public method MoveTo(SnapshotPoint) Moves the caret to the given index in the underlying ITextBuffer.
Public method MoveTo(VirtualSnapshotPoint) Moves the caret to the specified buffer position.
Public method MoveTo(ITextViewLine, Double) Moves the caret to the best CaretPosition for the specified x-coordinate and text line.
Public method MoveTo(SnapshotPoint, PositionAffinity) Moves the caret to the given index in the underlying ITextBuffer.
Public method MoveTo(VirtualSnapshotPoint, PositionAffinity) Moves the caret to the specified buffer position.
Public method MoveTo(ITextViewLine, Double, Boolean) Moves the caret to the best CaretPosition for the specified x-coordinate and text line.
Public method MoveTo(SnapshotPoint, PositionAffinity, Boolean) Moves the caret to the given index in the underlying ITextBuffer.
Public method MoveTo(VirtualSnapshotPoint, PositionAffinity, Boolean) Moves the caret to the specified buffer position.
Public method MoveToNextCaretPosition Moves the caret to the next valid CaretPosition.
Public method MoveToPreferredCoordinates Moves the caret to the preferred x- and y-coordinates.
Public method MoveToPreviousCaretPosition Moves the caret to the previous valid CaretPosition.

Top

Events

  Name Description
Public event 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.

See Also

Reference

Microsoft.VisualStudio.Text.Editor Namespace