IMainLoop.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #nullable enable
  2. using System.Collections.Concurrent;
  3. namespace Terminal.Gui;
  4. /// <summary>
  5. /// Interface for main loop that runs the core Terminal.Gui UI loop.
  6. /// </summary>
  7. /// <typeparam name="T"></typeparam>
  8. public interface IMainLoop<T> : IDisposable
  9. {
  10. /// <summary>
  11. /// Gets the class responsible for servicing user timeouts and idles
  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. void Initialize (ITimedEvents timedEvents, ConcurrentQueue<T> inputBuffer, IInputProcessor inputProcessor, IConsoleOutput consoleOutput);
  44. /// <summary>
  45. /// Perform a single iteration of the main loop then blocks for a fixed length
  46. /// of time, this method is designed to be run in a loop.
  47. /// </summary>
  48. public void Iteration ();
  49. }