ITextInputMethodClient.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using Avalonia.VisualTree;
  3. namespace Avalonia.Input.TextInput
  4. {
  5. public interface ITextInputMethodClient
  6. {
  7. /// <summary>
  8. /// The cursor rectangle relative to the TextViewVisual
  9. /// </summary>
  10. Rect CursorRectangle { get; }
  11. /// <summary>
  12. /// Should be fired when cursor rectangle is changed inside the TextViewVisual
  13. /// </summary>
  14. event EventHandler? CursorRectangleChanged;
  15. /// <summary>
  16. /// The visual that's showing the text
  17. /// </summary>
  18. Visual TextViewVisual { get; }
  19. /// <summary>
  20. /// Should be fired when text-hosting visual is changed
  21. /// </summary>
  22. event EventHandler? TextViewVisualChanged;
  23. /// <summary>
  24. /// Indicates if TextViewVisual is capable of displaying non-committed input on the cursor position
  25. /// </summary>
  26. bool SupportsPreedit { get; }
  27. /// <summary>
  28. /// Sets the non-committed input string
  29. /// </summary>
  30. void SetPreeditText(string? text);
  31. /// <summary>
  32. /// Indicates if text input client is capable of providing the text around the cursor
  33. /// </summary>
  34. bool SupportsSurroundingText { get; }
  35. /// <summary>
  36. /// Returns the text around the cursor, usually the current paragraph, the cursor position inside that text and selection start position
  37. /// </summary>
  38. TextInputMethodSurroundingText SurroundingText { get; }
  39. /// <summary>
  40. /// Should be fired when surrounding text changed
  41. /// </summary>
  42. event EventHandler? SurroundingTextChanged;
  43. void SelectInSurroundingText(int start, int end);
  44. }
  45. public record struct TextInputMethodSurroundingText
  46. {
  47. public string Text { get; set; }
  48. public int CursorOffset { get; set; }
  49. public int AnchorOffset { get; set; }
  50. }
  51. }