IInputProcessor.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #nullable enable
  2. namespace Terminal.Gui;
  3. /// <summary>
  4. /// Interface for main loop class that will process the queued input buffer contents.
  5. /// Is responsible for <see cref="ProcessQueue"/> and translating into common Terminal.Gui
  6. /// events and data models.
  7. /// </summary>
  8. public interface IInputProcessor
  9. {
  10. /// <summary>Event fired when a key is pressed down. This is a precursor to <see cref="KeyUp"/>.</summary>
  11. event EventHandler<Key>? KeyDown;
  12. /// <summary>Event fired when a key is released.</summary>
  13. /// <remarks>
  14. /// Drivers that do not support key release events will fire this event after <see cref="KeyDown"/> processing is
  15. /// complete.
  16. /// </remarks>
  17. event EventHandler<Key>? KeyUp;
  18. /// <summary>Event fired when a terminal sequence read from input is not recognized and therefore ignored.</summary>
  19. public event EventHandler<string>? AnsiSequenceSwallowed;
  20. /// <summary>Event fired when a mouse event occurs.</summary>
  21. event EventHandler<MouseEventArgs>? MouseEvent;
  22. /// <summary>
  23. /// Called when a key is pressed down. Fires the <see cref="KeyDown"/> event. This is a precursor to
  24. /// <see cref="OnKeyUp"/>.
  25. /// </summary>
  26. /// <param name="key">The key event data.</param>
  27. void OnKeyDown (Key key);
  28. /// <summary>
  29. /// Called when a key is released. Fires the <see cref="KeyUp"/> event.
  30. /// </summary>
  31. /// <remarks>
  32. /// Drivers that do not support key release events will call this method after <see cref="OnKeyDown"/> processing
  33. /// is complete.
  34. /// </remarks>
  35. /// <param name="key">The key event data.</param>
  36. void OnKeyUp (Key key);
  37. /// <summary>
  38. /// Called when a mouse event occurs. Fires the <see cref="MouseEvent"/> event.
  39. /// </summary>
  40. /// <param name="mouseEventArgs">The mouse event data.</param>
  41. void OnMouseEvent (MouseEventArgs mouseEventArgs);
  42. /// <summary>
  43. /// Drains the input buffer, processing all available keystrokes
  44. /// </summary>
  45. void ProcessQueue ();
  46. /// <summary>
  47. /// Gets the response parser currently configured on this input processor.
  48. /// </summary>
  49. /// <returns></returns>
  50. public IAnsiResponseParser GetParser ();
  51. }