using System; using Avalonia.Media.TextFormatting; using Avalonia.VisualTree; namespace Avalonia.Input.TextInput { public interface ITextInputMethodClient { /// /// The cursor rectangle relative to the TextViewVisual /// Rect CursorRectangle { get; } /// /// Should be fired when cursor rectangle is changed inside the TextViewVisual /// event EventHandler? CursorRectangleChanged; /// /// The visual that's showing the text /// Visual TextViewVisual { get; } /// /// Should be fired when text-hosting visual is changed /// event EventHandler? TextViewVisualChanged; /// /// Indicates if TextViewVisual is capable of displaying non-committed input on the cursor position /// bool SupportsPreedit { get; } /// /// Sets the non-committed input string /// void SetPreeditText(string? text); /// /// Sets the current composing region. This doesn't remove the composing text from the commited text. /// void SetComposingRegion(TextRange? region); /// /// Indicates if text input client is capable of providing the text around the cursor /// bool SupportsSurroundingText { get; } /// /// Returns the text around the cursor, usually the current paragraph, the cursor position inside that text and selection start position /// TextInputMethodSurroundingText SurroundingText { get; } /// /// Should be fired when surrounding text changed /// event EventHandler? SurroundingTextChanged; /// /// Gets or sets a platform editable. Text and selection changes made in the editable are forwarded to the IM client. /// ITextEditable? TextEditable { get; set; } void SelectInSurroundingText(int start, int end); } public record struct TextInputMethodSurroundingText { public string Text { get; set; } public int CursorOffset { get; set; } public int AnchorOffset { get; set; } } }