| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using System;
- namespace Avalonia.Input.TextInput
- {
- public abstract class TextInputMethodClient
- {
- /// <summary>
- /// Fires when the text view visual has changed
- /// </summary>
- public event EventHandler? TextViewVisualChanged;
- /// <summary>
- /// Fires when the cursor rectangle has changed
- /// </summary>
- public event EventHandler? CursorRectangleChanged;
- /// <summary>
- /// Fires when the surrounding text has changed
- /// </summary>
- public event EventHandler? SurroundingTextChanged;
- /// <summary>
- /// Fires when the selection has changed
- /// </summary>
- public event EventHandler? SelectionChanged;
- /// <summary>
- /// The visual that's showing the text
- /// </summary>
- public abstract Visual TextViewVisual { get; }
- /// <summary>
- /// Indicates if TextViewVisual is capable of displaying non-committed input on the cursor position
- /// </summary>
- public abstract bool SupportsPreedit { get; }
- /// <summary>
- /// Indicates if text input client is capable of providing the text around the cursor
- /// </summary>
- public abstract bool SupportsSurroundingText { get; }
- /// <summary>
- /// Returns the text around the cursor, usually the current paragraph
- /// </summary>
- public abstract string SurroundingText { get; }
- /// <summary>
- /// Gets the cursor rectangle relative to the TextViewVisual
- /// </summary>
- public abstract Rect CursorRectangle { get; }
- /// <summary>
- /// Gets or sets the curent selection range within current surrounding text.
- /// </summary>
- public abstract TextSelection Selection { get; set; }
- /// <summary>
- /// Sets the non-committed input string
- /// </summary>
- public virtual void SetPreeditText(string? preeditText) { }
- protected virtual void OnTextViewVisualChanged(Visual? oldValue, Visual? newValue)
- {
- TextViewVisualChanged?.Invoke(this, EventArgs.Empty);
- }
- protected virtual void OnCursorRectangleChanged()
- {
- CursorRectangleChanged?.Invoke(this, EventArgs.Empty);
- }
- protected virtual void OnSurroundingTextChanged()
- {
- SurroundingTextChanged?.Invoke(this, EventArgs.Empty);
- }
- protected virtual void OnSelectionChanged()
- {
- SelectionChanged?.Invoke(this, EventArgs.Empty);
- }
- }
- public record struct TextSelection(int Start, int End);
- }
|