Property InsertionPoint
InsertionPoint
Gets or sets the insertion point within the text, measured as a 0-based index into text elements.
public virtual int InsertionPoint { get; set; }
Property Value
- int
The insertion point position, clamped to the range [0, Text.Length]. Position 0 is before the first character; position equal to the text length is after the last character.
Remarks
This property provides access to the logical insertion point within the text. The value is automatically clamped to valid bounds: values less than 0 become 0, and values greater than the text length become the text length.
Relationship to Cursor:
- InsertionPoint: Logical position in text elements (0-based index)
- Terminal.Gui.Views.TextField.UpdateCursor(): Converts logical position to screen coordinates, accounting for ScrollOffset and wide characters
Example: For text "Hello世界" (Hello + 2 CJK characters):
- InsertionPoint = 0: Before 'H'
- InsertionPoint = 5: Before '世'
- InsertionPoint = 7: After '界' (end of text)
Setting this property also updates the text selection via PrepareSelection(int, int).
- See Also