Fixes #4125. Remove legacy MainLoop infrastructure (#4343)

* Initial plan

* Phase 1: Update IConsoleDriver.Init() to return void instead of MainLoop

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Phase 2: Remove legacy MainLoop infrastructure

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Complete Phase 1 and Phase 2 - All tests pass

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Update deep dive docs to reflect MainLoop removal

Co-authored-by: tig <585482+tig@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tig <585482+tig@users.noreply.github.com>
Co-authored-by: Tig <tig@users.noreply.github.com>
This commit is contained in:
Copilot
2025-10-26 13:39:44 -06:00
committed by GitHub
parent 4ea7d32d65
commit a0979368cb
31 changed files with 25 additions and 1533 deletions

View File

@@ -291,6 +291,8 @@ Application.Init();
Terminal.Gui v1 drivers that implement `IConsoleDriver` but not `IConsoleDriverFacade` are still supported through a legacy compatibility layer. However, they do not benefit from the v2 architecture improvements (multi-threading, component separation, etc.).
**Note**: The legacy `MainLoop` infrastructure (including the `MainLoop` class, `IMainLoopDriver` interface, and `FakeMainLoop`) has been removed in favor of the modern architecture. All drivers now use the `MainLoopCoordinator` and `ApplicationMainLoop` system exclusively.
## See Also
- @Terminal.Gui.Drivers - API Reference

View File

@@ -456,17 +456,26 @@ Additionally, the `Toggle` event was renamed `CheckStateChanging` and made cance
+cb.AdvanceCheckState ();
```
## `MainLoop` is no longer accessible from `Application`
## `MainLoop` has been removed from `Application`
In v1, you could add timeouts via `Application.MainLoop.AddTimeout` among other things. In v2, the `MainLoop` object is internal to `Application` and methods previously accessed via `MainLoop` can now be accessed directly via `Application`
In v1, you could add timeouts via `Application.MainLoop.AddTimeout` and access the `MainLoop` object directly. In v2, the legacy `MainLoop` class has been completely removed as part of the architectural modernization. Timeout functionality and other features previously accessed via `MainLoop` are now available directly through `Application` or `ApplicationImpl`.
### How to Fix
Replace any `Application.MainLoop` references:
```diff
- Application.MainLoop.AddTimeout (TimeSpan time, Func<MainLoop, bool> callback)
+ Application.AddTimeout (TimeSpan time, Func<bool> callback)
```
```diff
- Application.MainLoop.Wakeup ()
+ // No replacement needed - wakeup is handled automatically by the modern architecture
```
**Note**: The legacy `MainLoop` infrastructure (including `IMainLoopDriver` and `FakeMainLoop`) has been removed. The modern v2 architecture uses `ApplicationImpl`, `MainLoopCoordinator`, and `ApplicationMainLoop` instead.
## `SendSubViewXXX` renamed and corrected
In v1, the `View` methods to move SubViews within the SubViews list were poorly named and actually operated in reverse of what their names suggested.