ITextInputMethodClient.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. IVisual 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. /// <summary>
  44. /// Deletes specified length before and after current selection.
  45. /// </summary>
  46. /// <param name="beforeLength">The length before current selection.</param>
  47. /// <param name="afterLength">The length after current selection.</param>
  48. void DeleteSurroundingText(int beforeLength, int afterLength);
  49. /// <summary>
  50. /// Returns the text before the cursor. Must return a non-empty string if cursor is not at the beginning of the text entry
  51. /// </summary>
  52. string? TextBeforeCursor { get; }
  53. /// <summary>
  54. /// Returns the text before the cursor. Must return a non-empty string if cursor is not at the end of the text entry
  55. /// </summary>
  56. string? TextAfterCursor { get; }
  57. public void SelectInSurroundingText(int start, int end);
  58. }
  59. public struct TextInputMethodSurroundingText
  60. {
  61. public string Text { get; set; }
  62. public int CursorOffset { get; set; }
  63. public int AnchorOffset { get; set; }
  64. }
  65. }