FakeMainLoop.cs 897 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. namespace Terminal.Gui;
  2. internal class FakeMainLoop : IMainLoopDriver
  3. {
  4. public Action<ConsoleKeyInfo> MockKeyPressed;
  5. public bool _forceRead { get; set; }
  6. public ManualResetEventSlim _waitForInput { get; set; } = new ();
  7. public FakeMainLoop (ConsoleDriver consoleDriver = null)
  8. {
  9. // No implementation needed for FakeMainLoop
  10. }
  11. public void Setup (MainLoop mainLoop)
  12. {
  13. // No implementation needed for FakeMainLoop
  14. }
  15. public void Wakeup ()
  16. {
  17. // No implementation needed for FakeMainLoop
  18. }
  19. public bool EventsPending ()
  20. {
  21. // Always return true for FakeMainLoop
  22. return true;
  23. }
  24. public void Iteration ()
  25. {
  26. if (FakeConsole.MockKeyPresses.Count > 0)
  27. {
  28. MockKeyPressed?.Invoke (FakeConsole.MockKeyPresses.Pop ());
  29. }
  30. }
  31. public void TearDown () { }
  32. }