IMainLoop.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #nullable enable
  2. using System.Collections.Concurrent;
  3. namespace Terminal.Gui.Drivers;
  4. /// <summary>
  5. /// Interface for main loop that runs the core Terminal.Gui UI loop.
  6. /// </summary>
  7. /// <typeparam name="T">Type of raw input events processed by the loop e.g. <see cref="ConsoleKeyInfo"/></typeparam>
  8. public interface IMainLoop<T> : IDisposable
  9. {
  10. /// <summary>
  11. /// Gets the class responsible for servicing user timeouts
  12. /// </summary>
  13. public ITimedEvents TimedEvents { get; }
  14. /// <summary>
  15. /// Gets the class responsible for writing final rendered output to the console
  16. /// </summary>
  17. public IOutputBuffer OutputBuffer { get; }
  18. /// <summary>
  19. /// Class for writing output to the console.
  20. /// </summary>
  21. public IConsoleOutput Out { get; }
  22. /// <summary>
  23. /// Gets the class responsible for processing buffered console input and translating
  24. /// it into events on the UI thread.
  25. /// </summary>
  26. public IInputProcessor InputProcessor { get; }
  27. /// <summary>
  28. /// Gets the class responsible for sending ANSI escape requests which expect a response
  29. /// from the remote terminal e.g. Device Attribute Request
  30. /// </summary>
  31. public AnsiRequestScheduler AnsiRequestScheduler { get; }
  32. /// <summary>
  33. /// Gets the class responsible for determining the current console size
  34. /// </summary>
  35. public IWindowSizeMonitor WindowSizeMonitor { get; }
  36. /// <summary>
  37. /// Initializes the loop with a buffer from which data can be read
  38. /// </summary>
  39. /// <param name="timedEvents"></param>
  40. /// <param name="inputBuffer"></param>
  41. /// <param name="inputProcessor"></param>
  42. /// <param name="consoleOutput"></param>
  43. /// <param name="componentFactory"></param>
  44. void Initialize (
  45. ITimedEvents timedEvents,
  46. ConcurrentQueue<T> inputBuffer,
  47. IInputProcessor inputProcessor,
  48. IConsoleOutput consoleOutput,
  49. IComponentFactory<T> componentFactory
  50. );
  51. /// <summary>
  52. /// Perform a single iteration of the main loop then blocks for a fixed length
  53. /// of time, this method is designed to be run in a loop.
  54. /// </summary>
  55. public void Iteration ();
  56. }