DXCore Services – Caret
August 31st, 2011
The Caret DXCore service provides methods and properties for the code editor text caret (cursor). It allows you to move, hide, show the caret and execute many text operations, such as text insertion, deletion, and retrieving for the current caret position.
Methods of this service:
Method name |
Description |
DeleteLeft(Int32) | Deletes the specified number of characters to the left of the editor caret. |
DeleteLeftWhiteSpace | Deletes whitespace characters to the left of the editor caret and returns the number of characters deleted. |
DeleteRight(Int32) | Deletes the specified number of characters to the right of the editor caret. |
DeleteRightWhiteSpace | Deletes whitespace characters to the right of the editor caret and returns the number of characters deleted. |
GetSurroundingCharacters( Char, Char) | Gets the character to the left and right of the editor caret (on the current line). |
GetSurroundingText(String, String) | Gets the text to the left and right of the editor caret (on the current line) in the active text document. |
GetSurroundingText( SourcePoint, SourcePoint, String, String) | Gets the text to the left and right of the specific source points in the active text document. |
Hide | Hides the editor caret. You can restore the editor caret after calling Hide() through a call to CodeRush.Caret.Show(). Every call to Hide() must have a matching call to Show(). |
InCodeSnippetField | Determines whether or not the editor caret is currently in a code snippet field. This will only return true in Visual Studio 2005 or newer. |
InCurrentStatementMarker | Determines whether or not the editor caret is currently in a current statement marker. This will only return true in Visual Studio 2005 or newer. |
Insert(Char) | Inserts a character at the editor caret position and moves the caret. |
Insert(Char, Boolean) | Inserts a character at the editor caret position and optionally moves the caret. |
Insert(String) | Inserts the given text at the editor caret position and optionally moves the caret. |
Insert(String, Boolean) | Inserts the given text at the caret position and optionally moves the caret. |
MoveLeft(Int32) | Moves the editor caret to the left a specified number of characters. If the caret is currently inside virtual space, it will moved to the end of the current line first. |
MoveOutOfVirtualSpace | If the editor caret is in virtual space, it will be moved to the position of the end-of-line terminator on the line. |
MoveRight(Int32) | Moves the editor caret to the right a specified number of characters. If the caret is currently inside virtual space, it will moved to the end of the current line first. |
MoveTo(Int32) | Moves the editor caret to the location represented by the specified stream position. |
MoveTo(Int32, Boolean) | Moves the editor caret to the location represented by the specified stream position, and optionally, extends the selection. |
MoveTo(Int32, Int32) | Moves the active point to the specified line and column. |
MoveTo(Int32, Int32, Boolean) | Moves the active point to the specified line and column. |
MoveTo(SourcePoint) | Moves the editor caret to the given position. |
MoveTo(SourcePoint, Boolean) | Moves the editor caret to the given position. |
MoveToEndOfLine | Positions the editor caret at the end of the current line. |
MoveToStartOfLine | Positions the editor caret at the start of the current line. |
Show | Shows the editor caret. Call this after calling Hide(). |
Properties:
Property name |
Description |
AtCompilerDirective | Returns true when the editor caret is at the line with a compiler directive (e.g. #warning, #error). |
AtEndOfWord | Returns true if the editor caret is at the end of a word. |
AtStartOfWord | Returns true if the editor caret is at the start of a word. |
InsideCode | Returns true if the editor caret is inside a code block. |
InsideComment | Returns true if the editor caret is inside of a comment. |
InsideParens | Returns true if the editor caret is inside parentheses. |
InsideString | Returns true if the editor caret is inside of a string. |
InsideVirtualSpace | Returns true if the editor caret is inside virtual space. |
InsideXmlDocComment | Returns true if the editor caret is inside an XML documentation comment. |
LeftChar | Gets the character to the left of the editor caret. |
LeftText | Gets the text to the left of the editor caret. |
Line | Returns the line number of the active editor caret, or -1 if a text view is not active. |
Location | Returns a CaretLocation instance that is the current location of the editor caret. |
Offset | Returns the line character offset of the active editor caret, or -1 if a text view is not active. If the caret is in virtual space, this will be the position of the end-of-line terminator on the line. |
OnDeclaration | Returns true if the editor caret is on a declaration. |
OnDeclarationName | Returns true if the editor caret is on a declaration name. |
OnDeclarationStartToken | Returns true if the editor caret is on a start token of the declaration. |
OnDeclarationType | Returns true if the editor caret is on a declaration type. |
OnDeclarationVisibility | Returns true if the editor caret is on a declaration visibility keyword. |
OnEmptyLine | Returns true if the editor caret is on an empty line. |
OnMethod | Returns true if the editor caret is on a method. |
OnMethodName | Returns true if the editor caret is on a method name. |
OnMethodType | Returns true if the editor caret is on a method type. |
OnMethodVisibility | Returns true if the editor caret is on a visibility keyword. |
OnProperty | Returns true if the editor caret is on a property. |
OnPropertyName | Returns true if the editor caret is on a property name. |
OnPropertyType | Returns true if the editor caret is on a property type. |
OnPropertyVisibility | Returns true if the editor caret is on a property visibility keyword. |
RightChar | Gets the character to the right of the editor caret. |
RightText | Gets the text to the right of the editor caret. |
ScreenPosition | Returns the screen position of the editor caret. |
SourcePoint | Gets a source point of the current editor caret position, or an empty source point if a text view is not active. A source point can be located inside a virtual space. |
ViewColumn | Returns the current view column of the active editor caret, or -1 if a text view is not active. A value can be inside a virtual space. |