-
Notifications
You must be signed in to change notification settings - Fork 735
Fixes #4419, #4148, #4408 - Toplevel is GONE - Replaced by Runnable #4422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## v2_develop #4422 +/- ##
===============================================
+ Coverage 64.85% 77.21% +12.35%
===============================================
Files 388 386 -2
Lines 44984 44685 -299
Branches 6343 6276 -67
===============================================
+ Hits 29176 34504 +5328
+ Misses 13894 8327 -5567
+ Partials 1914 1854 -60
... and 153 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Refactored `StandardColors` to use lazy initialization for static fields, improving performance and avoiding static constructor convoy effects. Introduced `NamesValueFactory` and `MapValueFactory` methods for encapsulated initialization logic.
Simplified `GetColorNames` to directly return `_names.Value`. Improved `TryParseColor` by clarifying default value usage and adopting object initializer syntax. Updated `TryNameColor` to use `_argbNameMap.Value`.
Refactored `GetArgb` for better readability. Replaced `MultiStandardColorNameResolver` with `StandardColorsNameResolver` in `ColorPicker`. Commented out `app.Init("Fake")` in `ColorPickerTests` for testing purposes.
Made minor formatting improvements, including updated comments and XML documentation for consistency.
Replaced `Toplevel` with `Window` as the primary top-level UI element. Introduced the `IRunnable` interface to modernize the architecture, enabling greater flexibility and testability. Deprecated the static `Application` class in favor of the instance-based `IApplication` model, which supports multiple application contexts. Updated methods like `Application.Run()` and `Application.RequestStop()` to use `IRunnable`. Removed or replaced legacy `Modal` properties with `IsModal`. Enhanced the `IApplication` interface with a fluent API, including methods like `Run<TRunnable>()` and `GetResult<T>()`. Refactored tests and examples to align with the new architecture. Updated documentation to reflect the instance-based model. Deprecated obsolete members and methods, including `Application.Current` and `Application.TopRunnable`. Improved event handling by replacing the `Accept` event with `Accepting` and using `e.Handled` for event processing. Updated threading examples to use `App?.Invoke()` or `app.Invoke()` for UI updates. Cleaned up redundant code and redefined modal behavior for better consistency. These changes modernize the `Terminal.Gui` library, improving clarity, usability, and maintainability while ensuring backward compatibility where possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
This commit introduces a major architectural update to the `Terminal.Gui` library, replacing the legacy `Toplevel` class with the new `Runnable` class. The changes span the entire codebase, including core functionality, tests, documentation, and configuration files. - **Core Class Replacement**: - Replaced `Toplevel` with `Runnable` as the base class for modal views and session management. - Updated all references to `Toplevel` in the codebase, including constructors, methods, and properties. - **Configuration Updates**: - Updated `tui-config-schema.json` to reflect the new `Runnable` scheme. - **New Classes**: - Added `UICatalogRunnable` for managing the UI Catalog application. - Introduced `Runnable<TResult>` as a generic base class for blocking sessions with result handling. - **Documentation and Tests**: - Updated documentation to emphasize `Runnable` and mark `Toplevel` as obsolete. - Refactored test cases to use `Runnable` and ensure compatibility. - **Behavioral Improvements**: - Enhanced lifecycle management and alignment with the `IRunnable` interface. - Improved clarity and consistency in naming conventions. These changes modernize the library, improve flexibility, and provide a clearer architecture for developers.
BDisp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very glorious works done here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
|
I've got a bit more to do here:
Follow ons:
|
…tionImpl - Made Runnable<TResult> inherit from Runnable (eliminating ~180 LOC duplication) - Moved View init/layout/cursor logic from ApplicationImpl to Runnable lifecycle events - ApplicationImpl.Begin now operates purely on IRunnable interface Related to gui-cs#4419
the type-specific check for `View` with a more general check for `IDisposable`. This ensures proper disposal of any `IDisposable` object, improving robustness. Removed the `FrameworkOwnedRunnable` property from the `ApplicationImpl` class in `ApplicationImpl.cs` and the `IApplication` interface in `IApplication.cs`. This eliminates the need to manage this property, reducing complexity and improving maintainability. Updated `application.md` to reflect the removal of the `FrameworkOwnedRunnable` property, ensuring the documentation aligns with the updated codebase.
with the `IDisposable` pattern, ensuring proper resource cleanup and simplifying the API. The `Dispose()` method is now the recommended way to release resources, with `using` statements encouraged for automatic disposal. Key changes: - Marked `Shutdown()` as obsolete; it now internally calls `Dispose()`. - Updated the fluent API to remove `Shutdown()` from chaining. - Enhanced session lifecycle management for thread safety. - Updated tests to validate proper disposal and state reset. - Improved `IRunnable` integration with automatic disposal for framework-created runnables. - Maintained backward compatibility for the legacy static `Application` singleton. - Refactored documentation and examples to reflect modern practices and emphasize `Dispose()` usage. These changes modernize the `Terminal.Gui` lifecycle, improve testability, and encourage alignment with .NET conventions.
Refactor how the application context is set for `runnable` objects by introducing a new `SetApp` method in the `IRunnable` interface. This replaces the previous logic of directly setting the `App` property for `View` objects, making the process more generic and encapsulated within `IRunnable` implementations. Simplify `Mouse.UngrabMouse()` by removing the conditional check and calling it unconditionally. Make a minor formatting adjustment in the generic constraint of `Run<TRunnable>` in `ApplicationImpl`. Add `SetApp(IApplication app)` to the `IRunnable` interface and implement it in the `Runnable` class to set the `App` property to the provided application instance.
…2_4419-ByeBye-Toplevel
Reorganized and updated `CONTRIBUTING.md`: - Added **Key Architecture Concepts** section and reordered the table of contents. - Updated testing requirements to discourage legacy patterns. - Added instructions for replicating CI workflows locally. - Clarified PR guidelines and coding style expectations. Enhanced `README.md` with detailed CI/CD workflow documentation. Refactored `ColorPicker.Prompt` to use `IApplication` for improved modularity and testability. Introduced `IApplicationScreenChangedTests` for comprehensive testing of `ScreenChanged` events and `Screen` property. Refactored `ApplicationScreenTests` and `TextView.PromptForColors` to align with modern patterns. Updated `Terminal.sln` to include `.github/workflows/README.md`. Performed general cleanup: - Removed outdated documentation links. - Improved XML documentation and coding consistency.
Refactored `OutputBufferImpl.cs` to enhance thread safety by locking shared resources and adding bounds checks for columns and rows. Improved handling of wide characters and removed outdated TODO comments. Updated `Runnable.cs` to call `SetNeedsDraw()` on modal state changes, ensuring proper layout and drawing updates. Simplified layout handling in `ApplicationImpl.Run.cs` by replacing redundant comments with a `LayoutAndDraw()` call. Added a check in `AllViewsTester.cs` to skip creating instances of `RunnableWrapper` types with unsatisfiable generic constraints, logging a warning when encountered. Enhanced `ListViewTests.cs` by adding explicit `app.LayoutAndDraw()` calls to validate visual output and ensure tests reflect the updated application state. These changes improve robustness, prevent race conditions, and ensure consistent behavior across the application.
Updated the `Border` class to use `Command.Quit` instead of `Command.QuitToplevel` in the `CloseButton.Accept` handler. Renamed test methods in `GetViewsAtLocationTests.cs` to replace "Toplevel" with "Runnable" for consistency. Updated `Runnable<bool>` instances to use "topRunnable" as the `Id` property. These changes align the codebase with updated naming conventions and improve clarity.
`MouseDragTests` with improved structure and coverage. Updated tests to use `Application.Create`, `app.Begin`, and `app.End` for better resource management and lifecycle handling. Replaced direct event handling with `app.Mouse.RaiseMouseEvent` to align with the application's event-handling mechanism. Added `Runnable` objects to ensure views are properly initialized and disposed of within the application context. Enhanced tests to include assertions for minimum width and height constraints during resize operations. Removed redundant tests and streamlined logic to reduce duplication and improve maintainability.
Updated namespaces in `ArrangementTests.cs` and `MouseDragTests.cs` for better organization. Enhanced `ArrangementTests.cs` with additional checks for arrangement flags. Reformatted and re-added `MouseDragTests.cs` and `SchemeTests.cs` with modern C# features like nullable annotations and object initializers. Ensured no functional changes while improving code clarity and consistency.
Updated `app.End` calls to use the null-forgiving operator (`!`) on `app.SessionStack` to ensure it is treated as non-null. This change addresses potential nullability warnings and improves code safety and clarity. Applied consistently across all relevant test cases in the `MouseDragTests` class.
Fixes
Toplevelto implementIRunnableetc... #4408v2_developis broken - #4411 was merged prematurely #4419ToplevelwithIRunnable#4148Viewshould be able to be used withApplication.Run'd without it having to be a subclass ofToplevel#4149Toplevelanyway?). #4086BeginInit/EndInitshould follow CWP #2235UnitTeststhat require keyboard/mouse input toUnitTests.Parallelizable#4365