IComponentFactory.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #nullable enable
  2. using System.Collections.Concurrent;
  3. namespace Terminal.Gui.Drivers;
  4. /// <summary>
  5. /// Base untyped interface for <see cref="IComponentFactory{T}"/> for methods that are not templated on low level
  6. /// console input type.
  7. /// </summary>
  8. public interface IComponentFactory
  9. {
  10. /// <summary>
  11. /// Create the <see cref="IOutput"/> class for the current driver implementation i.e. the class responsible for
  12. /// rendering <see cref="IOutputBuffer"/> into the console.
  13. /// </summary>
  14. /// <returns></returns>
  15. IOutput CreateOutput ();
  16. }
  17. /// <summary>
  18. /// Creates driver specific subcomponent classes (<see cref="IInput{TInputRecord}"/>, <see cref="IInputProcessor"/>
  19. /// etc) for a
  20. /// <see cref="IMainLoopCoordinator"/>.
  21. /// </summary>
  22. /// <typeparam name="TInputRecord">
  23. /// The platform specific console input type. Must be a value type (struct).
  24. /// Valid types are <see cref="ConsoleKeyInfo"/>, <see cref="WindowsConsole.InputRecord"/>, and <see cref="char"/>.
  25. /// </typeparam>
  26. public interface IComponentFactory<TInputRecord> : IComponentFactory
  27. where TInputRecord : struct
  28. {
  29. /// <summary>
  30. /// Create <see cref="IInput{T}"/> class for the current driver implementation i.e. the class responsible for reading
  31. /// user input from the console.
  32. /// </summary>
  33. /// <returns></returns>
  34. IInput<TInputRecord> CreateInput ();
  35. /// <summary>
  36. /// Creates the <see cref="InputProcessorImpl{T}"/> class for the current driver implementation i.e. the class
  37. /// responsible for
  38. /// translating raw console input into Terminal.Gui common event <see cref="Key"/> and <see cref="MouseEventArgs"/>.
  39. /// </summary>
  40. /// <param name="inputQueue">
  41. /// The input queue containing raw console input events, populated by <see cref="IInput{TInputRecord}"/>
  42. /// implementations on the input thread and
  43. /// read by <see cref="IInputProcessor"/> on the main loop thread.
  44. /// </param>
  45. /// <returns></returns>
  46. IInputProcessor CreateInputProcessor (ConcurrentQueue<TInputRecord> inputQueue);
  47. /// <summary>
  48. /// Creates <see cref="ISizeMonitor"/> class for the current driver implementation i.e. the class responsible for
  49. /// reporting the current size of the terminal.
  50. /// </summary>
  51. /// <param name="consoleOutput"></param>
  52. /// <param name="outputBuffer"></param>
  53. /// <returns></returns>
  54. ISizeMonitor CreateSizeMonitor (IOutput consoleOutput, IOutputBuffer outputBuffer);
  55. }