# Prose.TextWithCaret class

Namespace: [Grasshopper2](https://developer.rhino3d.com/api/gh2/namespace/grasshopper2.md) · Assembly: [Grasshopper2](https://developer.rhino3d.com/api/gh2/assembly/grasshopper2.md)

```cs
public sealed class Prose.TextWithCaret : IEquatable<Prose.TextWithCaret>
```

Represents a string with caret location and block selection. This is useful for mimicking text area inputs that are not tied to specific controls.

All positions ([Prose.TextWithCaret.Caret](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/caret.md), [Prose.TextWithCaret.Block](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/block.md) and the block bounds) are measured in grapheme clusters, not [char](https://learn.microsoft.com/dotnet/api/system.char) code units. The text is segmented into complete grapheme runs (base character plus any combining marks, and whole surrogate pairs) via [Prose.Graphemes](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.graphemes.md), so the caret can never land inside a cluster and no edit can split one into invalid UTF-16.

## Constructors

- [Prose.TextWithCaret](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/ctor.md): (2 overloads)

## Properties

- [Block](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/block.md): Gets the length of the selection block (in grapheme clusters), starting at the caret.
- [BlockEnd](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/blockend.md): Gets the index of the right edge of the block.
- [BlockStart](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/blockstart.md): Gets the index of the left edge of the block.
- [Caret](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/caret.md): Gets the position of the caret, measured in grapheme clusters.
- [Empty](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/empty.md): (static)
- [IsEmpty](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/isempty.md): Gets whether the [Prose.TextWithCaret.Text](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/text.md) field is null or empty.
- [Length](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/length.md): Gets the number of grapheme clusters in the text.
- [SelectedText](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/selectedtext.md): Gets the currently selected text.
- [Text](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/text.md): Gets the string inside this instance.

## Methods

- [ControlCaretLeft](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/controlcaretleft.md): Perform the default caret+block modification based on a COMMAND+LEFT arrow key press.
- [ControlCaretRight](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/controlcaretright.md): Perform the default caret+block modification based on a COMMAND+Right arrow key press.
- [DeleteAfter](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/deleteafter.md): Delete either the block or, if there is no block, the grapheme after the caret.
- [DeleteBefore](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/deletebefore.md): Delete either the block or, if there is no block, the grapheme before the caret.
- [DeleteBlock](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/deleteblock.md): Delete the block, if any.
- [Equals](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/equals.md): (2 overloads)
- [GetHashCode](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/gethashcode.md)
- [HandleKeyDown](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/handlekeydown.md): (2 overloads) Handle a key press, additionally reporting when the key asks to leave this text altogether (see [Prose.CaretDeparture](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.caretdeparture.md)). A departing key never edits the text; whether it counts as handled depends on the key: the four editing keys always do - a text context owns them even when it cannot act, and letting them bubble would trigger shortcuts elsewhere - while up and down stay unhandled, so hosts which don't accept the departure keep their existing behaviour.
- [Insert](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/insert.md): Replace the block with a text fragment, or insert the fragment at the caret.
- [IsCharacterInBlock](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/ischaracterinblock.md): Gets whether the grapheme at the given index is inside the selection.
- [IsPositionInBlock](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/ispositioninblock.md): Gets whether the given caret position is inside the selection. This is true even if the block length is zero.
- [MoveCaret](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/movecaret.md): Move the caret left or right.
- [MoveCaretLeft](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/movecaretleft.md): (2 overloads) Perform the default caret+block modification based on a LEFT arrow key press.
- [MoveCaretRight](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/movecaretright.md): (2 overloads) Perform the default caret+block modification based on a Right arrow key press.
- [ReplaceBlock](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/replaceblock.md): Replace the contents of the selected block with a different text fragment. If there is no selected block, this method does nothing.
- [SelectAll](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/selectall.md): Select the entire text.
- [SelectWordAt](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/selectwordat.md): Select the word surrounding a caret position. A 'word' here is a run of graphemes which all classify the same way (letters and digits, whitespace, symbols), i.e. exactly the runs the by-word caret jumps step over. The caret ends up at the end of the run, where typing is expected to continue, with the block reaching back to its start.
- [ShiftCaretLeft](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/shiftcaretleft.md): Perform the default caret+block modification based on a LEFT+SHIFT arrow key press.
- [ShiftCaretRight](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/shiftcaretright.md): Perform the default caret+block modification based on a RIGHT+SHIFT arrow key press.
- [ShiftControlCaretLeft](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/shiftcontrolcaretleft.md): Perform the default caret+block modification based on a LEFT+SHIFT arrow key press.
- [ShiftControlCaretRight](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/shiftcontrolcaretright.md): Perform the default caret+block modification based on a LEFT+SHIFT arrow key press.
- [ToString](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/tostring.md)
- [WithBlock](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/withblock.md): Modify the block of this text.
- [WithCaret](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/withcaret.md): Set the caret of this text.
- [WithCaretAtEnd](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/withcaretatend.md): Move the caret to the end of this text.
- [WithCaretAtStart](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/withcaretatstart.md): Move the caret to the start of this text.

## Operators

- [operator ==](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/op-equality.md): (static)
- [operator !=](https://developer.rhino3d.com/api/gh2/type/grasshopper2.prose.textwithcaret/op-inequality.md): (static)
