Caret service
Read and position the caret in the current editing view. Use it to place inserted content or restore a visible authoring position.
The facade is available as editor.Caret; its interface can be replaced by an application implementation.

Use it in your application
Text indices are UTF-16 units in the API-defined current view. They are not positions in an encoded HTML file or interchangeable with legacy MSHTML ranges.
All examples assume an editor named editor, already attached to a visible window, and an awaited editor.Ready. Keep operations asynchronous instead of blocking the UI thread.
await editor.Caret.SetCaretAtEndAsync();
int index = await editor.Caret.GetCaretIndexAsync();Members
These signatures come from the delivered 1.0.2 assemblies and XML documentation. Cancellation tokens can be supplied to awaited operations. Follow the source-specific notes above when adapting a WPF integration.
| Member | Signature |
|---|---|
GetCaretBoundsAsync | Task<Nullable<Rect>> GetCaretBoundsAsync(CancellationToken cancellationToken) |
GetCaretIndexAsync | Task<int> GetCaretIndexAsync(CancellationToken cancellationToken) |
GetCaretIndexInHtmlAsync | Task<int> GetCaretIndexInHtmlAsync(CancellationToken cancellationToken) |
GetCaretPositionAsync | Task<Nullable<Point>> GetCaretPositionAsync(CancellationToken cancellationToken) |
HideAsync | Task HideAsync(CancellationToken cancellationToken) |
ScrollToCaretViewAsync | Task ScrollToCaretViewAsync(CancellationToken cancellationToken) |
SetCaretAtAsync | Task SetCaretAtAsync(double x, double y, bool scrollToView, CancellationToken cancellationToken) |
SetCaretAtEndAsync | Task SetCaretAtEndAsync(CancellationToken cancellationToken) |
SetCaretAtHomeAsync | Task SetCaretAtHomeAsync(CancellationToken cancellationToken) |
SetCaretAtLineBeginningAsync | Task SetCaretAtLineBeginningAsync(CancellationToken cancellationToken) |
SetCaretAtLineEndAsync | Task SetCaretAtLineEndAsync(CancellationToken cancellationToken) |
SetCaretByIndexAsync | Task SetCaretByIndexAsync(int index, CancellationToken cancellationToken) |
SetCaretByIndexAsync | Task SetCaretByIndexAsync(int index, int length, CancellationToken cancellationToken) |
SetCaretPositionAsync | Task SetCaretPositionAsync(double x, double y, bool scrollToView, CancellationToken cancellationToken) |
ShowAsync | Task ShowAsync(bool scrollToView, CancellationToken cancellationToken) |