SIGN IN SIGN UP
gui-cs / Terminal.Gui UNCLAIMED

Cross Platform Terminal UI toolkit for .NET

0 0 0 C#
using System.Reactive.Concurrency;
using ReactiveUI.Builder;
Fixes #4107 - Revamps Terminal.Gui's `namespace` (#4109) * upgraded to gitversion 6 2 * Remove invalid prevent-increment property * upgraded to gitversion 6 3 * Fixed gitversion * touching publish.yml * cleanup * Fixes #4000. Named colors as enums. (#4005) * Add W3C color enum with the RGB as numeric value * Add transform helper class for W3cColor enum For the sake of backwards compatibility prioritize parsing 16 color mode color names over the W3C colors because the previous resource-based color names/values had a mix of W3C and 16 color mode RGB values. Mechanism for choosing/prioritizing one color scheme over the other is currently only available at higher application/driver/output level. * IColorNameResolver enable null analysis * Remove obsolete color name related ResourceManagerTests * Replace remains of W3CColors with direct W3C color name resolver Temporarily breaks backwards compatibility and tests even further. * Add ANSI 4-bit (ColorName16) color name resolver * Add multi-standard color name resolver Combined resolver for both ANSI 4-bit (ColorName16) and W3C colors while trying to maintain backwards compatibility for ColorPicker. * Split conditional name resolver test cases * Change W3C colors tests to be similar to name resolvers * Change W3cColorsTests to W3cColorNameResolverTests More consistent when all the tests refer to the color name resolver layer. * Make W3cColors internal Color name resolver is the public interface. * W3cColors: Use Color.Argb instead of individual RGB components * MultiStandardColorNameResolver: Substitute instead of blocking alternative W3C names Changes color picker behavior a bit, e.g. Aqua will match to Cyan instead of jumping to Aquamarine. * Remove leftover color string resources * Consistent position for IColorNameResolver #nullable enable directive * Add missing XML comments to ColorScheme.Colors.cs * Fixes #3691 - Adds `ViewArrangement.Popover` (#3852) * Added Applicaton.Popover. Refactored FindDeepestView * Popover prototype * Testing highlight * Fixed click outside issue * Fixed DialogTests * Fixed click outside issue (agbain) * Enabled mouse wheel in Bar * Enabled mouse wheel in Bar * Progress. Broke arrangement * Added popover tests. Fixed a bunch more CM issues related ot unreliable unit tests. Updated config.json to include Glyphs. * Can't set ForceDriver to empty in Resources/config.json. * added BUGBUG * Made Position/ScreenPosition clear * Added View.IsInHierarchy tests * Added Contextmenuv2 scenario. * Implemented CM2 in TextView * Removed unneeded CM stuff from testhelpers * Shortcut API docs * Fixed keybinding unit tests * Fixed mouse handling * Fighting with CM related unit test failures * Unit tests pass. I think. * Shortcut code cleanup * TextView uses new CM2 * Starting on OnSelect etc... * Starting on OnSelect etc... * Fixed ContextMenuv2 * ContextMenu is working again. * Ugh. ANd fixed button api docs * Fixed DrawHorizontalShadowTransparent (vertical was already fixed). * Made Scenarios compatible with #nullable enable * Undid some keybinding stuff * Fixed stuff * Sped up unit tests * Sped up unit tests 2 * Sped up unit tests 3 * Messing with menus * merged latest v2_develop * Added more Popover unit tests * Added more Popover unit tests2 * Fixed positioning bug * Fixed mouse bug * Fixed Bar draw issue * WIP * merge v2_develop * CM2 sorta works * Enabled Bar subclasses to have IDesignable * Added ViewportSettings.Transparent * Region -> nullable enable * Added ViewportSettigs Editor * merged v2_develop part 2 * merged v2_develop part 3 * WIP: GetViewsUnderMouse * WIP: More GetViewsUnderMouse work * Bars works again * Added unit tests * CM now works * MenuItemv2 POC * SubMenu POC * CommandNotBound * More POC * Optimize Margin to not defer draw if there's no shadow * Logger cleanup * Reverted Generic * Cascading mostly working * fixed layout bug * API docs * API docs * Fixed cascade * Events basically work * code cleanup * Fixed IsDefault bug; * Enabled hotkey support * Made context-menu-like * Improved usability * Refactored ApplicationPopover again * Cleanup * Menuv2 POC basically complete * Code Cleanup * Made menu API simpler * Fixed Strings bugs * Got old ContextMenu scenario mostly working * ContextMenu scenario now works * ContextMenu fixes * ContextMenu fixes * Tons of menu cleanup * ContextMenu works in TextView * Fixed unit tes * Added unit tests * Fixed tests * code cleanup * More code cleanup * Deep dive * scenario * typos * Demo colorpicker in a Menu * Added Region tests proving Region is broken in some Union cases * fixed v2win/net * Partially Fixes #2975 - Replaces old `ContextMenu` with new `Bar/Shortcut` based implementation (#4008) * touching publish.yml * Nuked ContextMenuv2 - use PopverMenu instead * WIP context menu stuff * More robust dispose * Removed ConextMenu; use PopoverMenu instead * Code cleanup * Code cleanup2 * Partially Fixes #2975 - Upgrades UICatalog to `Menuv2` (#4011) * Fixes #4009 - fix tree ordering (#4015) * Fixes #4022 file dialog tests and bugfix for cancellation (#4024) * Add class for detecting information about console in extensible way * WIP - Create test for reordering * Change Dictionary to List and preserve TreeBuilder order * Add test to ensure branch expansion/status remains consistent despite reorder * Cleanup code * Fix regression when removed child was the selected one * Revert "Add class for detecting information about console in extensible way" This reverts commit 7e4253cf28428ea80a4773b137d4bd89cf321746. * Code cleanup and enable nullable on Branch * Remove color scheme and driver from Branch draw * Add xunit context extensions * Investigate codegen for xunit * Getting closer to something that works * Fix code generation * Further explore code gen * Generate all methods in single class for easier extensibility * Simplify code gen by moving parameter creation to its own method * Implement asserts A-I * Add remaining assert calls that are not obsolete * Fix unit test * Roll back versions to be compatible with CI version of csharp * Handle params and ref etc * Fix null warning * WIP - start to add integration tests for FileDialog * Add ability to tab focus to specific control with simple one line delegate * Clarify test criteria * Add unit tests for Ok and other ways of canceling dialog * Fix other buttons also triggering save * Fix for linux environment tests * Fix for linux again * Fix application null race condition - add better way of knowing if stuff is finished * Better fix for shutdown detection * Add test that shows #4026 is not an issue * Switch to `_fileSystem.Directory.GetLogicalDrives ()` * Don't show duplicate MyDocuments etc * Partial on #2975 - Replaces Menu v1 in many places with v2 (#4040) * touching publish.yml * Fixed UICatalog bugs. Added fluent tests. * marked v1 menu stuff as obsolte * Tweaks. Added View.GetSubMenus<type>(). * fixed unit tests * general messing around * general messing around * Playing with Fluent * ColorScheme tweaks * WIP: ColorScheme tweaks * Playing with Fluent * Merged from laptop2 * Hacky-ish fixes to: - #4016 - #4014 * Fixed Region bug preventing menus without borders from working * Tweaks * Fixed a bunch of CM issues * Fixed OoptionSelector * ip * FixedCM issues * Fixed CM issues2 * Revert "FixedCM issues" This reverts commit dd6c6a70a3d16a6a13b572b80f9a41c8a721ed1c. * Reverted stuff * Found and fixed bug in AllViews_Center_Properly * Fixed CM issues2 * removed menuv2 onapplied. Changed how UICatalog Applys CM * changed test time out to see if it helkps with ubuntu fails * reset app on fail? * back to 1500ms * Made StatusBar nullable. * Code Cleanup. * HexEditor Code Cleanup. * HexEditor Code Cleanup. * Back to 3000ms. Sigh. * Trying different logic * Trying different logic2 * Fixed potential crash in runlop * Fixed potential crash in runlop2 * Tweaked Spinner stuff * Removed TabView from TextEffects scenario. Not needed and possible culprit. * back to 2000ms * WIP: Revamping menu scenarios * Menu Scenario refinements. Fixed a few bugs. Code cleanup. * fixed unit test * Fixed warnings * Fixed warnings2 * Fixed File.Exit * WIP: Dealing with QuitKey struggles * WIP: Dealing with QuitKey struggles 2 * WIP: Dealing with QuitKey struggles 3 * Fixed ListView collection nav bug * Fixed a bunch of menu stuff. Fixed Appv2 stuff. * Lots of refactoring and fixing * Lots of unit test issues * Fixed DebugIDisposable issues * Fixed release build issue * Fixed release build issue 2 * DebugIDisposable -> EnableDebugIDisposableAsserts and more * DebugIDisposable -> EnableDebugIDisposableAsserts and more 2 * Fixed Menus scenario - context menu * Added @bdisp suggested assert. Commented it out as it breaks tests. * Code cleanup * Fixed disposed but * Fixed UICatalog exit * Fixed Unit test I broke. Added 'Minimal' Theme that turns off all borders etc... * Fixes #3966. TextField crashes app when pasting unicode surrogate pair (#3982) * Add constructor Key(int) and operator for handled with non-Bmp. * Fix TextField non-BMP issues * Fix TextField PositionCursor. * Reformat * Add IsValidInput method to handle clipboard paste when pressing CTRL+V in WT * Add handle IsValidInput in FakeDriver and unit tests * Fixes #3984 - `Margin` w/out shadow should not force draw (#3985) * shortcut tests * Generic demos * Optimize Margin to not defer draw if there's no shadow * Fixes #4041. WSLClipboard doesn't handles well with surrogate pairs * Avoid running Clipboard.Contents twice * Fixes #4042. Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost * Moving tests to the parallelizable unit tests * Remove unused folder * Prevent warnings about not installed nuget packages * Using Toplevel instead of Application.Top * Cleanup code --------- Co-authored-by: Tig <tig@users.noreply.github.com> * Goblin fighter (#4037) * touching publish.yml * WIP Investigate how to build random maze * Fix maze rendering * Use line canvas for rendering * Move around the maze * Code cleanup * Infinite maze * Fight goblins * Generate new npcs on new maps * Code cleanup * Make it possible to die * Fix variable naming * Refactored Mazing to use Commmands and KeyBindings. Code cleanup of Mazing. Refactored Snake to use KeyBindings/Commmands + some code cleanup * Fix bug where your health would regenerate when reaching end making it impossible to loose. --------- Co-authored-by: Tig <tig@users.noreply.github.com> * Fixes #4046 - Moves examples into `./Examples` and fixes `./Tests` (#4047) * touching publish.yml * Moved Examples into ./Examples * Moved Benchmarks into ./Tests * Moved Benchmarks into ./Tests * Moved UICatalog into ./Examples * Moved UICatalog into ./Examples 2 * Moved tests into ./Tests * Updated nuget * Fixes #4027. Add collection search matcher (#4029) * Add collection search matcher * Fix naming * fix naming * Move FileDialogCollectionNavigator to its own file (no longer private class) Add class diagram for collectionNavigation * Add ICollectionNavigator interface * Move to separate file IListCollectionNavigator * Update class diagram * update class diagram * Add tests for overriding ICollectionNavigatorMatcher * xmldoc and nullability warning fixes * Code Cleanup * Make requested changes to naming and terminology * Move to seperate namespace * Update class diagram and change TreeView to reference the interface not concrete class * Switch to implicit new * highlight that this class also works with tree view * Apply tig patch to ensure keybindings get priority over navigator See: https://github.com/gui-cs/Terminal.Gui/issues/4027#issuecomment-2810020893 * Apply 'keybinding has priority' fix to TreeView too * Apply 'keybindngs priority over navigation' fix to TableView * Remove entire branch for selectively returning false now that it is default when there is a keybinding collision * Make classes internal and remove 'custom' navigator that was configured in UICatlaogToplevel * Change logging in collection navigator from Trace to Debug * Switch to NewKeyDownEvent and directly setting HasFocus * Remove application top dependency * Remove references to application * Remove Application * Move new tests to parallel --------- Co-authored-by: Tig <tig@users.noreply.github.com> * Fixes #4051 - Adds `cancellable_work_pattern.md` (#4052) * touching publish.yml * Updated md files * Updated md files 2 * Updated md files 3 * Updated API docs to point * commmand->command * Update Terminal.Gui/View/View.Command.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update getting-started.md (#4063) * Fixes #4035 - FileDialog keeps path when selecting folder (optionally) (#4065) * WIP keep path * Make new 'sticky filename' behaviour optional * Tests for new behaviour when selecting in TreeView * Add more tests, this time for table view navigation * Add the new style option into UICatalog scenario * Allow hotkey specifier to be at any position in label (#4067) Allow hotkey specifier to be at any position in label "D_irectory" doesn't work because hotPos is hardcoded 0 * Fixes #4053. v2 WindowsDriver and v2win doesn't show any scenario in the UICatalog with cmd or conhost (#4055) * Fix WindowsDriver to work with non-WindowsTerminal * Fix unit test failure * Fix v2win to work with non-WindowsTerminal * Force16Colors isn't being setting in v2win driver on changing. --------- Co-authored-by: Tig <tig@users.noreply.github.com> * Fixes #4023 - Changes `CommandEventArgs` to be based on `HandledEventArgs` instead of `CancelEventArgs` (#4054) * touching publish.yml * CancelEventArgs->HandledEventArgs * Fixed Handled issues * Fixes #4076 cursor text field (#4077) * Add test for TextField cursor position * Add comment and one more assert * Fix cursor position at the end * Remove unused local field --------- Co-authored-by: BDisp <bd.bdisp@gmail.com> * Fixes #4074 - Popover eats `Key.Space` (#4075) * touching publish.yml * Added unit tests. Fixed * Actually fixed bug. * Addres Bdisp feedback * Addres Bdisp feedback2 * Addresses #4058. Basic support for non-color text styles. (#4071) * TextStyle enum * CSI_AppendTextStyleChange * Add TextStyle to Attribute * Apply text style in NetOutput.Write() * Don't append escape code if nothing to change * Make TextStyle an init property * Apply TextStyle to OutputBuffer attributes * Fix flag checking Misunderstood how Enum.HasFlag worked, fixed now * Allow bold-faint text Also adds remarks to TextStyle noting that they may be incompatible depending on terminal settings. * Remove unnecessary check Realized it's actually impossible for no escape codes to be added, as this is only the case when prev and next are the same, which is already accounted for. * Remove redundant check Attributes are records, and thus already use equality-by-value, meaning attr != redrawAttr will already be false when the TextStyle changes. * WindowsOutput support for text style --------- Co-authored-by: Tig <tig@users.noreply.github.com> * More on #4058 - Adds `TextStyle` Scenario (#4079) * Fixed Generic.cs. Added TextStyles Scenario. * Code cleanup * Fixes #4070 - `GetContentSize()` api docs (#4081) * touching publish.yml * Fixed api docs * Fixes #4070 - `GetContentSize()` API docs -2nd try (#4082) * Fixed api docs again * Fixes 4088 mouse released flag cannot be combined safely with report position (#4091) * added more mouse under tests * Fixes #4057 - MASSIVE! Fully implements `ColorScheme`->`Scheme` + `VisualRole` + `Colors.`->`SchemeManager.` (#4062) * touching publish.yml * ColorScheme->Scheme * ColorScheme->Scheme 2 * Prototype of GetAttributeForRole * Badly broke CM * Further Badly broke CM * Refactored CM big-time. View still broken * All unit test pass again. Tons added. CM is still WIP, but Schemes is not mostly refactored and working. * Actually: All unit test pass again. Tons added. CM is still WIP, but Schemes is not mostly refactored and working. * Bug fixes. DeepMemberWiseClone cleanup * Further cleanup of Scope<T>, ConfigProperty, etc. * Made ConfigManager thread safe. * WIP: Broken * WIP: new deep clone impl * WIP: new deep clone impl is done. Now fixing CM * WIP: - config.md - Working on AOT clean up - Core CM is broken; but known. * WIP * Merged. Removed CM from Application.Init * WIP * More WIP; Less broke * All CM unit tests pass... Not sure if it actually works though * All unit tests pass... Themes are broken though in UI Cat * CM Ready for review? * Fixed failures due to TextStyles PR * Working on Scheme/Attribute * Working on Scheme/Attribute 2 * Working on Scheme/Attribute 3 * Working on Scheme/Attribute 4 * Working on Scheme/Attribute 5 * Working on Scheme/Attribute 6 * Added test to show how awful memory usage is * Improved schema. Updated config.json * Nade Scope<T> concurrentdictionary and added test to prove * Made Themes ConcrurrentDictionary. Added bunches of tests * Code cleanup * Code cleanup 2 * Code cleanup 3 * Tweaking Scheme * ClearJsonErrors * ClearJsonErrors2 * Updated Attribute API * It all (mostly) works! * Skip odd unit test * Messed with Themes * Theme tweaks * Code reorg. New .md stuff * Fixed Enabled. Added mock driver * Fixed a bunch of View.Enabled related issues * Scheme -> Get/SetScheme() * Cleanup * Cleanup2 * Broke something * Fixed everything * Made CM.Enable better * Text Style Scenario * Added comments * Fixed UI Catalog Theme Changing * Fixed more dynamic CM update stuff * Warning cleanup * New Default Theme * fixed unit test * Refactoring Scheme and Attribute to fix inheritance * more unit tests * ConfigProperty is not updating schemes correctly * All unit tests pass. Code cleanup * All unit tests pass. Code cleanup2 * Fixed unit tests * Upgraded TextField and TextView * Fixed TextView !Enabled bug * More updates to TextView. More unit tests for SchemeManager * Upgraded CharMap * API docs * Fixe HexView API * upgrade HexView * Fixed shortcut KeyView * Fixed more bugs. Added new themes * updated themes * upgraded Border * Fixed themes memory usage...mostly * Fixed themes memory usage...mostly2 * Fixed themes memory usage...2 * Fixed themes memory usage...3 * Added new colors * Fixed GetHardCodedConfig bug * Added Themes Scenario - WIP * Added Themes Scenario * Tweaked Themes Scenario * Code cleanup * Fixed json schmea * updated deepdives * updated deepdives * Tweaked Themes Scenario * Made Schemes a concurrent dict * Test cleanup * Thread safe ConfigProperty tests * trying to make things more thread safe * more trying to make things more thread safe * Fixing bugs in shadowview * Fixing bugs in shadowview 2 * Refactored GetViewsUnderMouse to GetViewsUnderLocation etc... * Fixed dupe unit tests? * Added better description of layout and coordiantes to deep dive * Added better description of layout and coordiantes to deep dive * Modified tests that call v2.AddTimeout; they were returning true which means restart the timer! This was causing mac/linux unit test failures. I think * Fixed auto scheme. Broke TextView/TextField selection * Realized Attribute.IsExplicitlySet is stupid; just use nullable * Fixed Attribute. Simplified. MOre theme testing * Updated themes again * GetViewsUnderMouse to GetViewsUnderLocation broke TransparentMouse. * Fixing mouseunder bugs * rewriting... * All working again. Shadows are now slick as snot. GetViewsUnderLocation is rewritten to actually work and be readable. Tons more low-level unit tests. Margin is now actually ViewportSettings.Transparent. * Code cleanup * Code cleanup * Code cleanup of color apis * Fixed Hover/Highlight * Update Examples/UICatalog/Scenarios/AllViewsTester.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Examples/UICatalog/Scenarios/Clipping.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fixed race condition? * reverted * Simplified Attribute API by removing events from SetAttributeForRole * Removed recursion from GetViewsAtLocation * Removed unneeded code * Code clean up. Fixed Scheme bug. * reverted temporary disable * Adjusted scheme algo * Upgraded TextValidateField * Fixed TextValidate bugs * Tweaks * Frameview rounded border by default * API doc cleanup * Readme fix * Addressed tznind feeback * Fixed more unit test issues by protecting Application statics from being set if Application.Initialized is not true * Fixed more unit test issues by protecting Application statics from being set if Application.Initialized is not true 2 * cleanup --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Removed API key2? * Simplified usings * Cleand up curses. Fixed css * One proposal * Proposal 2 * Clean up * Fixed API docs * Auto gen list of views * Auto gen list of views * More API doc cleanup * TextValidateField IDesignable * regen view.md * Fixed unit test failure * Clean up * Fixed CM editor bug * Removed dupe file * Deep dive clean up * Fixed warnings --------- Co-authored-by: Tonttu <15074459+TheTonttu@users.noreply.github.com> Co-authored-by: Thomas Nind <31306100+tznind@users.noreply.github.com> Co-authored-by: BDisp <bd.bdisp@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Brandon G <bgiromini@users.noreply.github.com> Co-authored-by: M3Logic <joe.bailey@m3logic.com> Co-authored-by: Error-String-Expected-Got-Nil <103805191+Error-String-Expected-Got-Nil@users.noreply.github.com>
2025-05-31 15:58:16 -06:00
using Terminal.Gui.App;
Fixes #4419, #4148, #4408 - Toplevel is GONE - Replaced by Runnable (#4422) * WIP: Broken * Got working. Mostly. * Parllel tests pass * More progres * Fixed app tests. * Mouse * more progress. * working on shortcut * Shortcut accept on ENTER is broken. * One left... * More test progress. * All unit tests pass. Still some issues though. * tweak * Fixed Integration Tests * Fixed UI Catalog * Tweaking CP to try to find race condition * Refactor StandardColors and improve ColorPicker logic 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. * revert * Throttle input loop to prevent CPU spinning Introduce a 20ms delay in the input loop of `InputImpl<TInputRecord>` to prevent excessive CPU usage when no input is available. Removed the `DateTime dt = Now();` line and the `while (Peek())` block, which previously enqueued input records. This change improves resource management, especially in scenarios where multiple `ApplicationImpl` instances are created in parallel tests without calling `Shutdown()`. It prevents thread pool exhaustion and ensures better performance in such cases. * Refactor ApplicationImpl to use IDisposable pattern Implemented the IDisposable pattern in ApplicationImpl to improve resource management. Added `Dispose` and `DisposeCore` methods, and marked the `Shutdown` method as obsolete, encouraging the use of `Dispose` or `using` statements instead. Updated the `IApplication` interface to inherit from IDisposable and added `GetResult` methods for retrieving run session results. Refactored unit tests to adopt the new lifecycle management approach, replacing legacy `Shutdown` calls with `Dispose` or `using`. Removed fragile and obsolete tests, and re-enabled previously skipped tests after addressing underlying issues. Updated `FakeApplicationLifecycle` and `SetupFakeApplicationAttribute` to align with the new disposal pattern. Improved documentation and examples to guide users toward modern usage patterns. Maintained backward compatibility for legacy singleton usage. * Add IDisposable pattern with input loop throttling - Add IDisposable to IApplication for proper resource cleanup - Add 20ms throttle to input loop (prevents CPU spinning) - Add Lazy<T> to StandardColors (eliminates convoy effect) - Add MainLoopCoordinatorTests suite (5 new tests) - Add Dispose() calls to all 16 ColorPickerTests - Mark Application.Shutdown() as [Obsolete] IApplication now requires Dispose() for cleanup Performance: 100x CPU reduction, 15x faster disposal, tests complete in <5s Fixes: Thread leaks, CPU saturation, test hangs in parallel execution Docs: Updated application.md and newinv2.md with disposal patterns * Refactor test for input loop throttling clarity Updated `InputLoop_Throttle_Limits_Poll_Rate` test to improve clarity, reliability, and efficiency: - Rewrote summary comment to clarify purpose and emphasize the 20ms throttle's role in preventing CPU spinning. - Replaced `var` with explicit types for better readability. - Reduced test duration from 1s to 500ms to improve test speed. - Revised assertions: - Replaced range-based assertion with upper-bound check to ensure poll count is below 500, avoiding timing sensitivity issues. - Added assertion to verify the thread ran and was not immediately canceled. - Added a 2-second timeout to `inputTask.Wait` and verified task completion. - Improved comments to explain test behavior and reasoning behind changes. * tweaks * Fix nullabiltiy stuff. * runnable fixes * more nullabe * More nullability * warnings gone * Fixed fluent test failure. * Refactor ApplicationImpl and update Runnable layout logic Refactored `ApplicationImpl.Run.cs` for improved readability and atomicity: - Combined `if (wasModal)` with `SessionStack?.TryPop` to streamline logic. - Simplified restoration of `previousRunnable` by reducing nesting. - Updated comments for clarity and retained `SetIsModal` call. Simplified focus-setting logic in `ApplicationImpl.Run.cs` using pattern matching for `TopRunnableView`. In `Runnable<TResult>`, added `SetNeedsLayout` after `IsModalChanged` to ensure layout updates. Removed an unused empty line for cleanup. Corrected namespace in `GetViewsUnderLocationForRootTests.cs` to align with test structure. * Update layout on modal state change A call to `SetNeedsLayout()` was added to the `OnIsModalChanged` method in the `Runnable` class. This ensures that the layout is updated whenever the modal state changes. * Increase test timeout for inputTask.Wait to 10 seconds Extended the timeout duration for the `inputTask.Wait` method from 4 seconds to 10 seconds in `MainLoopCoordinatorTests`. This change ensures the test has a longer window to complete under conditions of increased load or slower execution environments, reducing the likelihood of false test failures. * Refactor project files and simplify test logic Removed `<LangVersion>` and `<ImplicitUsings>` properties from `UnitTests.csproj` and `UnitTests.Parallelizable.csproj` to rely on default SDK settings and disable implicit global usings. Simplified the `SizeChanged_Event_Still_Fires_For_Compatibility` test in `FakeDriverTests` by removing the `screenChangedFired` variable, its associated event handler, and related assertions. Also removed obsolete warning suppression directives as they are no longer needed. * Reduce UnitTestsParallelizable iterations from 10 to 3 Reduced the number of iterations for the UnitTestsParallelizable test suite from 10 to 3 to save time and resources while still exposing concurrency issues. Updated the loop and log messages to reflect the new iteration count. * disabled InputLoop_Throttle_Limits_Poll_Rate * Refactor app lifecycle and improve Runnable API Refactored `Program.cs` to simplify application lifecycle: - Modularized app creation, initialization, and disposal. - Improved result handling and ensured proper resource cleanup. Re-implemented `Runnable<TResult>` with a cleaner design: - Retained functionality while improving readability and structure. - Added XML documentation and followed the Cancellable Work Pattern. Re-implemented `RunnableWrapper<TView, TResult>`: - Enabled wrapping any `View` to make it runnable with typed results. - Added examples and remarks for better developer guidance. Re-implemented `ViewRunnableExtensions`: - Provided fluent API for making views runnable with or without results. - Enhanced documentation with examples for common use cases. General improvements: - Enhanced code readability, maintainability, and error handling. - Replaced redundant code with cleaner, more maintainable versions. * Modernize codebase for Terminal.Gui and MVVM updates Refactored `LoginView` to remove redundant `Application.LayoutAndDraw()` call. Enhanced `LoginViewModel` with new observable properties for automatic property change notifications. Updated `Message` class to use nullable generics for improved type safety. Replaced legacy `Application.Init()` and `Application.Run()` calls with the modern `IApplication` API across `Program.cs`, `Example.cs`, and `ReactiveExample`. Ensured proper disposal of `IApplication` instances to prevent resource leaks. Updated `TerminalScheduler` to integrate with `IApplication` for invoking actions and managing timeouts. Added null checks and improved timeout disposal logic for robustness. Refactored `ExampleWindow` for better readability and alignment with modern `Terminal.Gui` conventions. Cleaned up unused imports and improved code clarity across the codebase. Updated README.md to reflect the latest `Terminal.Gui` practices, including examples of the `IApplication` API and automatic UI refresh handling. Renamed `LoginAction` to `LoginActions` for consistency. * Refactor: Transition to IRunnable-based architecture 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. * Refactor: Replace Toplevel with Runnable class 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. * Refactor: Consolidate Runnable classes and decouple View from ApplicationImpl - 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 #4419 * Simplified the disposal logic in `ApplicationImpl.Run.cs` by replacing 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. * Replaces the legacy `Shutdown()` method with `Dispose()` to align 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 runnable app context handling in ApplicationImpl 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. * Improve docs, tests, and modularity across the codebase 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. * readme tweaks * Improve thread safety, layout, and test coverage 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. * Refactor: Rename Toplevel to Runnable and update logic 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. * Removed `ToplevelTests` and migrated relevant test cases to `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. * Reorged Unit Test namespaces. * more * Refactor tests and update namespaces for consistency 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. * Fix nullability warnings in MouseDragTests.cs 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.
2025-12-01 12:54:21 -07:00
using Terminal.Gui.Configuration;
2020-09-30 23:30:01 +03:00
Fixes #3192. Improve correctness / clarity of existing `View.AutoSize` functionality/unit tests (#3202) * Removed resharper settings from editorconfig * Remove constructors with frame parameters from Button class. * Remove constructors with frame parameters from CheckBox class. * Cleanup code. * Remove constructors with frame parameters from ComboBox class. * @BDisp Remove constructors with frame parameters from FrameView class. * Remove constructors with frame parameters from Label class. * Remove constructors with frame parameters from ListView class. * Remove constructors with frame parameters from ScrollBarView class. * Remove constructors with frame parameters from ScrollView class. * Remove namespace braces. * Cleanup code. * Cleanup code. * Cleanup code. * Remove constructors with frame parameters from TextField class. * Remove constructors with frame parameters from TimeField class. * Fixes #3182. OnResizeNeeded returns int.MaxValue and int.MaxValue when Application.Top is null, should return Size.Empty. * Remove constructors with frame parameters from Toplevel class. * Remove constructors with frame parameters from Window class. * Fix merge errors. * Revert "Fixes #3182. OnResizeNeeded returns int.MaxValue and int.MaxValue when Application.Top is null, should return Size.Empty." This reverts commit cf9c24b846c1831eb340833e5a792c1d6cce31ea. * Revert unit test. * Fixes #2882. TabView: 'Frame.DrawFrame(Rect, bool)' is obsolete: 'This method is obsolete in v2. Use use LineCanvas or Frame (#2980) * Fixes #2882. TabView: 'Frame.DrawFrame(Rect, bool)' is obsolete: 'This method is obsolete in v2. Use use LineCanvas or Frame * Trying fix this unit test that sometimes fail. * Fixes #2983. View need a alternative DrawFrame for the v2. * Use new DrawFrame method. * Change _lines field to Lines property. * Add TabWindow unit test. * Add DrawIncompleteFrame method and unit tests. * Add more unit tests to LineCanvas. * Fix newline conflict errors. * Revert "Change _lines field to Lines property." This reverts commit ab6c5f3094c78e884a52d26840671f1140a24ab4. * Add DrawIncompleteFrame method and unit tests. * Add more unit tests to LineCanvas. * Fix newline conflict errors. * Force render immediately instead of join. * I will never rely on zero-location-based unit test again. * Fix TestTreeViewColor unit test fail. * Using location of 3 to avoid be divisible by 2 and so avoiding bugs. * Revert "Using location of 3 to avoid be divisible by 2 and so avoiding bugs." This reverts commit dd3df135d8e6f18ff1cc11440823b3f3eafddcac. * Revert "I will never rely on zero-location-based unit test again." This reverts commit 62adf6f2850b0fb9e83782cee8c47a1202a3031e. * Revert "Fix newline conflict errors." This reverts commit 4acf72612dff0ba907f20c7f8826253d73c102c8. * Revert "Add more unit tests to LineCanvas." This reverts commit 66bc6f514e88ae9844c5608f89d7368938ed2486. * Revert "Add DrawIncompleteFrame method and unit tests." This reverts commit 680ba264e16b42e2261e697dca9aa54761feae1e. * Resolving merge conflicts. * Revert "Use new DrawFrame method." This reverts commit 69a7f17f19fbb7985a49b039b37403d9735d8f70. * Revert "Fixes #2983. View need a alternative DrawFrame for the v2." This reverts commit dade9fd767ce3aacc91fa13d0b4537d233de0a49. * Reverting this changes to start a new one. * Add horizontal and vertical support for combining glyphs. * Fix text and auto size behavior. * Add TabWidth property. * Add unit test for WordWrap. * Fixes #3017. View TextDirection returns incorrect size on a vertical direction instance with AutoSize as false. * Using Frame to force read from the get method. * Fix some issues with AutoSize and ForceValidatePosDim. * Fixing broken unit tests. * Restoring code I've broken. * Removing forgotten code. * Only LayoutStyle.Computed can change the Frame. * DateField and TimeField depends on LayoutStyle.Computed. * Fix unit tests related with LayoutStyle. * Implements tabs, left and right arrows as View. * Draws a minimum full border. * Adds missing XML parameter. * Adds assert tests for Frame. * Removes duplicates InlineData. * Adds more unit tests for minimum full border without Left and Right thickness. * Trying to fix the TestTreeViewColor unit test fail. * Prevents a user to set TextDirection to -1. * Prevents any invalid TextDirection value. * Removes (TextDirection)(-1). * Removes unnecessary TextDirection initialization. * Removes LayoutStyle. * Fixing unit tests with border. * Trying to fix TestTreeViewColor again. * Revert "Trying to fix TestTreeViewColor again." This reverts commit c2efa8e42e7776f23a8f664746d946506351244b. * Trying to fix TestTreeViewColor again. * Fix merge errors. * Fix merge errors. * Restoring unit test. * Restores the right XML comment. * Fix Disposing unit tests that sometimes throws because some instances aren't cleared on others unit tests classes. * Fix Disposing unit tests that sometimes throws because some instances aren't cleared on others unit tests classes. * Only call OnResizeNeeded if it's LayoutStyle.Computed. * Fix merge errors. * Fix merge errors. * Fix unit tests fail. * Reformat. * Again. * Rename to OnDrawAdornments. * Fix failing unit tests. * Reduces indentation and cleanup code. * Cleanup code. * Fix bug done when cleanup. * Replace FrameHandledMouseEvent to AdornmentHandledMouseEvent. * Removes Tab constructor parameters. --------- Co-authored-by: Tig <tig@users.noreply.github.com> * Fix merge errors. * Remove constructors with parameters from Button. * Remove parenthesis on objects initializers from Button. * Remove constructors with parameters from CheckBox. * Remove parenthesis on objects initializers from CheckBox. * Remove constructors with parameters from ComboBox. * Remove constructors with parameters from FrameView. * Remove parenthesis on objects initializers from FrameView. * Initial commit * Renamed Direction enum for clarity in refactoring unit tests * Moved nav tests to NavigationTests * Moved view tests around * Cleaning up TextFormatter and View.AutoSize code * Fixed latent TextFormatter bug with \n * removed Application dependency on some autosize unit tests * Fixed Label tests to deal with auotsize overriding height/width * Fixed more label tests. WIP * Fixed all places where AutoSize = happend after setting Dims * Started adding new primitive View.Text tests * Code comments * WIP: Enforce that it makes no sense to set Width/Height if AutoSize = true. Update Unit tests to match. * WIP: Enforce that it makes no sense to set Width/Height if AutoSize = true. Update Unit tests to match. * Remove frame set from the View constructor and prevent SetRelativeLayout running if not yet initialized. * Changes needed for unit tests pass on remove parameters constructors from the Label class. * Remove constructors with parameters from Label. * Remove parenthesis on objects initializers from Label. * Prefix private fields with underscore. * Renamed to MaxLength. * Remove constructors with parameters from ListView. * MakeWrapper not needed anymore. * Remove parenthesis on objects initializers from ListView. * WIP: Enforce that it makes no sense to set Width/Height if AutoSize = true. Update Unit tests to match. * Massive code cleanup - use parameterless constructors and ensure AutoSize is set properly. Code reformat. * Massive code cleanup - use parameterless constructors and ensure AutoSize is set properly. Code reformat. * Fixed messagebox * Remove constructors with parameters from ScrollBarView and ScrollView. * Remove parenthesis on objects initializers from ScrollBarView and ScrollView. * Cleanup code. * Fix merge errors. * Add empty dotsettings for solution and projects. * Set ReSharper language analysis level for projects to C#12 * Make ReSharper consider itself the boss for style * Add rule to enforce property backing fields above the property * Disable auto-detection of naming rules so ReSharper doesn't change them by itself * Don't let someone's VS settings override the indent settings * Explicitly set tab width to 4 spaces and force spaces. * Rules to keep various multi-line constructs aligned within themselves * Curly brace rules (Using K&R style, per current project spec) * Blank line rules Mostly to add breaks in various situations, and also to enforce max of 1 blank line. * Increase auto-wrap to 160 from default of 120 * Line break at end of all files, to make Unixy systems happy * Keep attributes on their own lines except for methods and records that are themselves single-line * Increase attribute auto-wrap to 60 from default of 38 * Wrap/chop rules for long method signatures and record declarations Chop if either already multi-line or if over 8 parameters. Chop AFTER the left paren and BEFORE the first parameter. * Chop rules for generics For generics with multi-line type parameters or multiple type parameter constraints, chop in a way that has consistent alignment. * Always enforce enum members on their own lines * One-line functions completely on one line They're usually expression-bodied anyway, here, so this is almost irrelevant * Keep control flow statements on their own lines * Follow same chop rules for method invocation as method declaration * Chop long or multi-line method chains or patterns * Wrap rules for binary operators Operator at beginning of new lines Auto-chop if long or already multi-line * Spaces between keywords and their opening parentheses * Add file layout rules for organization of reorderable items like fields, properties, etc. Ugly XML, so load it up in the UI to look at it It's MOSTLY the ReSharper defaults, but with more aggressive sorting, generally by access modifier and name, within each grouping. * Deconstructors use per-member types * Use keywords for built-in types and increase severity of inspection for violations Also apply to IntPtr and similar, which should now be nint and similar * Apply syntax style on completion. * Use var when evident for built-in and simple types, but not elsewhere * Increase severity for some minor redundancy and clarity inspections * Enforce braces always required for blocks, and treat as error * Warn if a local function is not statement-bodied * Increase various inspection severities IF Condition => Severity: Attributes not wrapped property => Suggestion Constructors expression-bodied => Error default doesn't have type when it isn't clear => suggestion Namespaces not file-scoped => error Methods not statement-bodied => hint Null check pattern not the object property pattern => Error * Adjust preference order of null check patterns to make object pattern highest * XmlDoc rules to keep tags and contents aligned and wrapped * Add a few custom profiles for code cleanup and make the full profile default * Remove parts for languages not used in this solution * copied in v2_develop changes * Merged v2_develop * Added Begin/Init unit tests. Removed Application dependencey from AutoSizeFalse tests * TextFormatter.Lines -> GetLines () * Let ReSharper know we intend to localize things * TextFormatter code cleanup * copied in v2_develop changes * Merged v2_develop * Spaces aren't wanted here either. * Fix merge errors. * Fixes ContentBottomRightCorner related with https://github.com/gui-cs/Terminal.Gui/issues/3211#issue-2098878820 * Remove constructors with parameters from ContextMenu. * Remove commented code. * Remove constructors with parameters from OpenDialog. * Remove constructors with parameters from SaveDialog. * Remove constructors with parameters from TextField. * Remove constructors with parameters from TimeField. * Fix unit test. * Remove unnecessary SetInitialProperties method. * Remove unnecessary SetInitialProperties method. * Remove parenthesis on objects initializers from Toplevel and Window. * Remove constructors with parameters from RadioGroup. * Remove constructors with parameters from TextView. * Remove constructors with parameters from MenuBar. * TEMPORARY: Turn everything that was set to error down to warning or lower * Fixes #3219. MenuBar is opened by call OpenMenu even it's disabled. * Remove constructors with parameters from Menu. * Remove constructors with parameters from View. * Change constructor to internal because is mainly useful for testing. * ReSharper Cleanup Code. * Added format only r# config * Fixes #3224. TextFormatter.Lines should return a single string.Empty list even with Width or Height equal to zero. * Remove constructors with parameters from Dialog. * Remove constructors with parameters from TextValidateField. * Fixes https://github.com/gui-cs/Terminal.Gui/issues/3224#issuecomment-1924096038 * Fixes #3225. Press CursorDown on TabView doesn't move to the next view. * Fixes #3229. TextFormatter should have a FillRemaining property. * Testing formatting merge in bdisp * Testing formatting merge * Testing formatting merge bdisp * Testing formatting merge 2 * xmldoc format * R# Full Code Cleanup * R# Full Code Cleanup2 * R# Full Code Cleanup2 * Merged! But broke tests * Refixing... * Refixed DrawTests * Refixed ViewTests * Refixed Text Tests * Refixed more unit tests * Refixed scenarios * Refixed rest of scenarios * Refixed ViewsTests * Refixed rest of tests. All unit tests pass again! * Fixed warnings * Updated R# version. Added new code cleanup settings * Applied latest code cleanup to solution * Another code cleanup pass * Tweaked r# settings. .editorconfig now matches. * r# else on separate line * r# - update * r# - full solution * test commit * test commit * test commit * Removed extra profiles * Full cleanup following cleaning up profiles * Null checking pattern rules/inspections * Tabs and extra whitespace are evil * Attributes on their own lines * Code layout rules to put fields first and to put backing fields with their properties * Merged v2_develop * Full cleanup following dodexahedron's PR --------- Co-authored-by: BDisp <bd.bdisp@gmail.com> Co-authored-by: Brandon Thetford <github@snapsinazfs.com>
2024-02-11 15:54:03 -07:00
namespace ReactiveExample;
public static class Program
{
internal static ReactiveUIBuilder _rxApp;
private static void Main (string [] _)
Fixes #3192. Improve correctness / clarity of existing `View.AutoSize` functionality/unit tests (#3202) * Removed resharper settings from editorconfig * Remove constructors with frame parameters from Button class. * Remove constructors with frame parameters from CheckBox class. * Cleanup code. * Remove constructors with frame parameters from ComboBox class. * @BDisp Remove constructors with frame parameters from FrameView class. * Remove constructors with frame parameters from Label class. * Remove constructors with frame parameters from ListView class. * Remove constructors with frame parameters from ScrollBarView class. * Remove constructors with frame parameters from ScrollView class. * Remove namespace braces. * Cleanup code. * Cleanup code. * Cleanup code. * Remove constructors with frame parameters from TextField class. * Remove constructors with frame parameters from TimeField class. * Fixes #3182. OnResizeNeeded returns int.MaxValue and int.MaxValue when Application.Top is null, should return Size.Empty. * Remove constructors with frame parameters from Toplevel class. * Remove constructors with frame parameters from Window class. * Fix merge errors. * Revert "Fixes #3182. OnResizeNeeded returns int.MaxValue and int.MaxValue when Application.Top is null, should return Size.Empty." This reverts commit cf9c24b846c1831eb340833e5a792c1d6cce31ea. * Revert unit test. * Fixes #2882. TabView: 'Frame.DrawFrame(Rect, bool)' is obsolete: 'This method is obsolete in v2. Use use LineCanvas or Frame (#2980) * Fixes #2882. TabView: 'Frame.DrawFrame(Rect, bool)' is obsolete: 'This method is obsolete in v2. Use use LineCanvas or Frame * Trying fix this unit test that sometimes fail. * Fixes #2983. View need a alternative DrawFrame for the v2. * Use new DrawFrame method. * Change _lines field to Lines property. * Add TabWindow unit test. * Add DrawIncompleteFrame method and unit tests. * Add more unit tests to LineCanvas. * Fix newline conflict errors. * Revert "Change _lines field to Lines property." This reverts commit ab6c5f3094c78e884a52d26840671f1140a24ab4. * Add DrawIncompleteFrame method and unit tests. * Add more unit tests to LineCanvas. * Fix newline conflict errors. * Force render immediately instead of join. * I will never rely on zero-location-based unit test again. * Fix TestTreeViewColor unit test fail. * Using location of 3 to avoid be divisible by 2 and so avoiding bugs. * Revert "Using location of 3 to avoid be divisible by 2 and so avoiding bugs." This reverts commit dd3df135d8e6f18ff1cc11440823b3f3eafddcac. * Revert "I will never rely on zero-location-based unit test again." This reverts commit 62adf6f2850b0fb9e83782cee8c47a1202a3031e. * Revert "Fix newline conflict errors." This reverts commit 4acf72612dff0ba907f20c7f8826253d73c102c8. * Revert "Add more unit tests to LineCanvas." This reverts commit 66bc6f514e88ae9844c5608f89d7368938ed2486. * Revert "Add DrawIncompleteFrame method and unit tests." This reverts commit 680ba264e16b42e2261e697dca9aa54761feae1e. * Resolving merge conflicts. * Revert "Use new DrawFrame method." This reverts commit 69a7f17f19fbb7985a49b039b37403d9735d8f70. * Revert "Fixes #2983. View need a alternative DrawFrame for the v2." This reverts commit dade9fd767ce3aacc91fa13d0b4537d233de0a49. * Reverting this changes to start a new one. * Add horizontal and vertical support for combining glyphs. * Fix text and auto size behavior. * Add TabWidth property. * Add unit test for WordWrap. * Fixes #3017. View TextDirection returns incorrect size on a vertical direction instance with AutoSize as false. * Using Frame to force read from the get method. * Fix some issues with AutoSize and ForceValidatePosDim. * Fixing broken unit tests. * Restoring code I've broken. * Removing forgotten code. * Only LayoutStyle.Computed can change the Frame. * DateField and TimeField depends on LayoutStyle.Computed. * Fix unit tests related with LayoutStyle. * Implements tabs, left and right arrows as View. * Draws a minimum full border. * Adds missing XML parameter. * Adds assert tests for Frame. * Removes duplicates InlineData. * Adds more unit tests for minimum full border without Left and Right thickness. * Trying to fix the TestTreeViewColor unit test fail. * Prevents a user to set TextDirection to -1. * Prevents any invalid TextDirection value. * Removes (TextDirection)(-1). * Removes unnecessary TextDirection initialization. * Removes LayoutStyle. * Fixing unit tests with border. * Trying to fix TestTreeViewColor again. * Revert "Trying to fix TestTreeViewColor again." This reverts commit c2efa8e42e7776f23a8f664746d946506351244b. * Trying to fix TestTreeViewColor again. * Fix merge errors. * Fix merge errors. * Restoring unit test. * Restores the right XML comment. * Fix Disposing unit tests that sometimes throws because some instances aren't cleared on others unit tests classes. * Fix Disposing unit tests that sometimes throws because some instances aren't cleared on others unit tests classes. * Only call OnResizeNeeded if it's LayoutStyle.Computed. * Fix merge errors. * Fix merge errors. * Fix unit tests fail. * Reformat. * Again. * Rename to OnDrawAdornments. * Fix failing unit tests. * Reduces indentation and cleanup code. * Cleanup code. * Fix bug done when cleanup. * Replace FrameHandledMouseEvent to AdornmentHandledMouseEvent. * Removes Tab constructor parameters. --------- Co-authored-by: Tig <tig@users.noreply.github.com> * Fix merge errors. * Remove constructors with parameters from Button. * Remove parenthesis on objects initializers from Button. * Remove constructors with parameters from CheckBox. * Remove parenthesis on objects initializers from CheckBox. * Remove constructors with parameters from ComboBox. * Remove constructors with parameters from FrameView. * Remove parenthesis on objects initializers from FrameView. * Initial commit * Renamed Direction enum for clarity in refactoring unit tests * Moved nav tests to NavigationTests * Moved view tests around * Cleaning up TextFormatter and View.AutoSize code * Fixed latent TextFormatter bug with \n * removed Application dependency on some autosize unit tests * Fixed Label tests to deal with auotsize overriding height/width * Fixed more label tests. WIP * Fixed all places where AutoSize = happend after setting Dims * Started adding new primitive View.Text tests * Code comments * WIP: Enforce that it makes no sense to set Width/Height if AutoSize = true. Update Unit tests to match. * WIP: Enforce that it makes no sense to set Width/Height if AutoSize = true. Update Unit tests to match. * Remove frame set from the View constructor and prevent SetRelativeLayout running if not yet initialized. * Changes needed for unit tests pass on remove parameters constructors from the Label class. * Remove constructors with parameters from Label. * Remove parenthesis on objects initializers from Label. * Prefix private fields with underscore. * Renamed to MaxLength. * Remove constructors with parameters from ListView. * MakeWrapper not needed anymore. * Remove parenthesis on objects initializers from ListView. * WIP: Enforce that it makes no sense to set Width/Height if AutoSize = true. Update Unit tests to match. * Massive code cleanup - use parameterless constructors and ensure AutoSize is set properly. Code reformat. * Massive code cleanup - use parameterless constructors and ensure AutoSize is set properly. Code reformat. * Fixed messagebox * Remove constructors with parameters from ScrollBarView and ScrollView. * Remove parenthesis on objects initializers from ScrollBarView and ScrollView. * Cleanup code. * Fix merge errors. * Add empty dotsettings for solution and projects. * Set ReSharper language analysis level for projects to C#12 * Make ReSharper consider itself the boss for style * Add rule to enforce property backing fields above the property * Disable auto-detection of naming rules so ReSharper doesn't change them by itself * Don't let someone's VS settings override the indent settings * Explicitly set tab width to 4 spaces and force spaces. * Rules to keep various multi-line constructs aligned within themselves * Curly brace rules (Using K&R style, per current project spec) * Blank line rules Mostly to add breaks in various situations, and also to enforce max of 1 blank line. * Increase auto-wrap to 160 from default of 120 * Line break at end of all files, to make Unixy systems happy * Keep attributes on their own lines except for methods and records that are themselves single-line * Increase attribute auto-wrap to 60 from default of 38 * Wrap/chop rules for long method signatures and record declarations Chop if either already multi-line or if over 8 parameters. Chop AFTER the left paren and BEFORE the first parameter. * Chop rules for generics For generics with multi-line type parameters or multiple type parameter constraints, chop in a way that has consistent alignment. * Always enforce enum members on their own lines * One-line functions completely on one line They're usually expression-bodied anyway, here, so this is almost irrelevant * Keep control flow statements on their own lines * Follow same chop rules for method invocation as method declaration * Chop long or multi-line method chains or patterns * Wrap rules for binary operators Operator at beginning of new lines Auto-chop if long or already multi-line * Spaces between keywords and their opening parentheses * Add file layout rules for organization of reorderable items like fields, properties, etc. Ugly XML, so load it up in the UI to look at it It's MOSTLY the ReSharper defaults, but with more aggressive sorting, generally by access modifier and name, within each grouping. * Deconstructors use per-member types * Use keywords for built-in types and increase severity of inspection for violations Also apply to IntPtr and similar, which should now be nint and similar * Apply syntax style on completion. * Use var when evident for built-in and simple types, but not elsewhere * Increase severity for some minor redundancy and clarity inspections * Enforce braces always required for blocks, and treat as error * Warn if a local function is not statement-bodied * Increase various inspection severities IF Condition => Severity: Attributes not wrapped property => Suggestion Constructors expression-bodied => Error default doesn't have type when it isn't clear => suggestion Namespaces not file-scoped => error Methods not statement-bodied => hint Null check pattern not the object property pattern => Error * Adjust preference order of null check patterns to make object pattern highest * XmlDoc rules to keep tags and contents aligned and wrapped * Add a few custom profiles for code cleanup and make the full profile default * Remove parts for languages not used in this solution * copied in v2_develop changes * Merged v2_develop * Added Begin/Init unit tests. Removed Application dependencey from AutoSizeFalse tests * TextFormatter.Lines -> GetLines () * Let ReSharper know we intend to localize things * TextFormatter code cleanup * copied in v2_develop changes * Merged v2_develop * Spaces aren't wanted here either. * Fix merge errors. * Fixes ContentBottomRightCorner related with https://github.com/gui-cs/Terminal.Gui/issues/3211#issue-2098878820 * Remove constructors with parameters from ContextMenu. * Remove commented code. * Remove constructors with parameters from OpenDialog. * Remove constructors with parameters from SaveDialog. * Remove constructors with parameters from TextField. * Remove constructors with parameters from TimeField. * Fix unit test. * Remove unnecessary SetInitialProperties method. * Remove unnecessary SetInitialProperties method. * Remove parenthesis on objects initializers from Toplevel and Window. * Remove constructors with parameters from RadioGroup. * Remove constructors with parameters from TextView. * Remove constructors with parameters from MenuBar. * TEMPORARY: Turn everything that was set to error down to warning or lower * Fixes #3219. MenuBar is opened by call OpenMenu even it's disabled. * Remove constructors with parameters from Menu. * Remove constructors with parameters from View. * Change constructor to internal because is mainly useful for testing. * ReSharper Cleanup Code. * Added format only r# config * Fixes #3224. TextFormatter.Lines should return a single string.Empty list even with Width or Height equal to zero. * Remove constructors with parameters from Dialog. * Remove constructors with parameters from TextValidateField. * Fixes https://github.com/gui-cs/Terminal.Gui/issues/3224#issuecomment-1924096038 * Fixes #3225. Press CursorDown on TabView doesn't move to the next view. * Fixes #3229. TextFormatter should have a FillRemaining property. * Testing formatting merge in bdisp * Testing formatting merge * Testing formatting merge bdisp * Testing formatting merge 2 * xmldoc format * R# Full Code Cleanup * R# Full Code Cleanup2 * R# Full Code Cleanup2 * Merged! But broke tests * Refixing... * Refixed DrawTests * Refixed ViewTests * Refixed Text Tests * Refixed more unit tests * Refixed scenarios * Refixed rest of scenarios * Refixed ViewsTests * Refixed rest of tests. All unit tests pass again! * Fixed warnings * Updated R# version. Added new code cleanup settings * Applied latest code cleanup to solution * Another code cleanup pass * Tweaked r# settings. .editorconfig now matches. * r# else on separate line * r# - update * r# - full solution * test commit * test commit * test commit * Removed extra profiles * Full cleanup following cleaning up profiles * Null checking pattern rules/inspections * Tabs and extra whitespace are evil * Attributes on their own lines * Code layout rules to put fields first and to put backing fields with their properties * Merged v2_develop * Full cleanup following dodexahedron's PR --------- Co-authored-by: BDisp <bd.bdisp@gmail.com> Co-authored-by: Brandon Thetford <github@snapsinazfs.com>
2024-02-11 15:54:03 -07:00
{
Fixes #4057 - MASSIVE! Fully implements `ColorScheme`->`Scheme` + `VisualRole` + `Colors.`->`SchemeManager.` (#4062) * touching publish.yml * ColorScheme->Scheme * ColorScheme->Scheme 2 * Prototype of GetAttributeForRole * Badly broke CM * Further Badly broke CM * Refactored CM big-time. View still broken * All unit test pass again. Tons added. CM is still WIP, but Schemes is not mostly refactored and working. * Actually: All unit test pass again. Tons added. CM is still WIP, but Schemes is not mostly refactored and working. * Bug fixes. DeepMemberWiseClone cleanup * Further cleanup of Scope<T>, ConfigProperty, etc. * Made ConfigManager thread safe. * WIP: Broken * WIP: new deep clone impl * WIP: new deep clone impl is done. Now fixing CM * WIP: - config.md - Working on AOT clean up - Core CM is broken; but known. * WIP * Merged. Removed CM from Application.Init * WIP * More WIP; Less broke * All CM unit tests pass... Not sure if it actually works though * All unit tests pass... Themes are broken though in UI Cat * CM Ready for review? * Fixed failures due to TextStyles PR * Working on Scheme/Attribute * Working on Scheme/Attribute 2 * Working on Scheme/Attribute 3 * Working on Scheme/Attribute 4 * Working on Scheme/Attribute 5 * Working on Scheme/Attribute 6 * Added test to show how awful memory usage is * Improved schema. Updated config.json * Nade Scope<T> concurrentdictionary and added test to prove * Made Themes ConcrurrentDictionary. Added bunches of tests * Code cleanup * Code cleanup 2 * Code cleanup 3 * Tweaking Scheme * ClearJsonErrors * ClearJsonErrors2 * Updated Attribute API * It all (mostly) works! * Skip odd unit test * Messed with Themes * Theme tweaks * Code reorg. New .md stuff * Fixed Enabled. Added mock driver * Fixed a bunch of View.Enabled related issues * Scheme -> Get/SetScheme() * Cleanup * Cleanup2 * Broke something * Fixed everything * Made CM.Enable better * Text Style Scenario * Added comments * Fixed UI Catalog Theme Changing * Fixed more dynamic CM update stuff * Warning cleanup * New Default Theme * fixed unit test * Refactoring Scheme and Attribute to fix inheritance * more unit tests * ConfigProperty is not updating schemes correctly * All unit tests pass. Code cleanup * All unit tests pass. Code cleanup2 * Fixed unit tests * Upgraded TextField and TextView * Fixed TextView !Enabled bug * More updates to TextView. More unit tests for SchemeManager * Upgraded CharMap * API docs * Fixe HexView API * upgrade HexView * Fixed shortcut KeyView * Fixed more bugs. Added new themes * updated themes * upgraded Border * Fixed themes memory usage...mostly * Fixed themes memory usage...mostly2 * Fixed themes memory usage...2 * Fixed themes memory usage...3 * Added new colors * Fixed GetHardCodedConfig bug * Added Themes Scenario - WIP * Added Themes Scenario * Tweaked Themes Scenario * Code cleanup * Fixed json schmea * updated deepdives * updated deepdives * Tweaked Themes Scenario * Made Schemes a concurrent dict * Test cleanup * Thread safe ConfigProperty tests * trying to make things more thread safe * more trying to make things more thread safe * Fixing bugs in shadowview * Fixing bugs in shadowview 2 * Refactored GetViewsUnderMouse to GetViewsUnderLocation etc... * Fixed dupe unit tests? * Added better description of layout and coordiantes to deep dive * Added better description of layout and coordiantes to deep dive * Modified tests that call v2.AddTimeout; they were returning true which means restart the timer! This was causing mac/linux unit test failures. I think * Fixed auto scheme. Broke TextView/TextField selection * Realized Attribute.IsExplicitlySet is stupid; just use nullable * Fixed Attribute. Simplified. MOre theme testing * Updated themes again * GetViewsUnderMouse to GetViewsUnderLocation broke TransparentMouse. * Fixing mouseunder bugs * rewriting... * All working again. Shadows are now slick as snot. GetViewsUnderLocation is rewritten to actually work and be readable. Tons more low-level unit tests. Margin is now actually ViewportSettings.Transparent. * Code cleanup * Code cleanup * Code cleanup of color apis * Fixed Hover/Highlight * Update Examples/UICatalog/Scenarios/AllViewsTester.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Examples/UICatalog/Scenarios/Clipping.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fixed race condition? * reverted * Simplified Attribute API by removing events from SetAttributeForRole * Removed recursion from GetViewsAtLocation * Removed unneeded code * Code clean up. Fixed Scheme bug. * reverted temporary disable * Adjusted scheme algo * Upgraded TextValidateField * Fixed TextValidate bugs * Tweaks * Frameview rounded border by default * API doc cleanup * Readme fix * Addressed tznind feeback * Fixed more unit test issues by protecting Application statics from being set if Application.Initialized is not true * Fixed more unit test issues by protecting Application statics from being set if Application.Initialized is not true 2 * cleanup --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-05-29 13:55:54 -06:00
ConfigurationManager.Enable (ConfigLocations.All);
Fixes #4419, #4148, #4408 - Toplevel is GONE - Replaced by Runnable (#4422) * WIP: Broken * Got working. Mostly. * Parllel tests pass * More progres * Fixed app tests. * Mouse * more progress. * working on shortcut * Shortcut accept on ENTER is broken. * One left... * More test progress. * All unit tests pass. Still some issues though. * tweak * Fixed Integration Tests * Fixed UI Catalog * Tweaking CP to try to find race condition * Refactor StandardColors and improve ColorPicker logic 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. * revert * Throttle input loop to prevent CPU spinning Introduce a 20ms delay in the input loop of `InputImpl<TInputRecord>` to prevent excessive CPU usage when no input is available. Removed the `DateTime dt = Now();` line and the `while (Peek())` block, which previously enqueued input records. This change improves resource management, especially in scenarios where multiple `ApplicationImpl` instances are created in parallel tests without calling `Shutdown()`. It prevents thread pool exhaustion and ensures better performance in such cases. * Refactor ApplicationImpl to use IDisposable pattern Implemented the IDisposable pattern in ApplicationImpl to improve resource management. Added `Dispose` and `DisposeCore` methods, and marked the `Shutdown` method as obsolete, encouraging the use of `Dispose` or `using` statements instead. Updated the `IApplication` interface to inherit from IDisposable and added `GetResult` methods for retrieving run session results. Refactored unit tests to adopt the new lifecycle management approach, replacing legacy `Shutdown` calls with `Dispose` or `using`. Removed fragile and obsolete tests, and re-enabled previously skipped tests after addressing underlying issues. Updated `FakeApplicationLifecycle` and `SetupFakeApplicationAttribute` to align with the new disposal pattern. Improved documentation and examples to guide users toward modern usage patterns. Maintained backward compatibility for legacy singleton usage. * Add IDisposable pattern with input loop throttling - Add IDisposable to IApplication for proper resource cleanup - Add 20ms throttle to input loop (prevents CPU spinning) - Add Lazy<T> to StandardColors (eliminates convoy effect) - Add MainLoopCoordinatorTests suite (5 new tests) - Add Dispose() calls to all 16 ColorPickerTests - Mark Application.Shutdown() as [Obsolete] IApplication now requires Dispose() for cleanup Performance: 100x CPU reduction, 15x faster disposal, tests complete in <5s Fixes: Thread leaks, CPU saturation, test hangs in parallel execution Docs: Updated application.md and newinv2.md with disposal patterns * Refactor test for input loop throttling clarity Updated `InputLoop_Throttle_Limits_Poll_Rate` test to improve clarity, reliability, and efficiency: - Rewrote summary comment to clarify purpose and emphasize the 20ms throttle's role in preventing CPU spinning. - Replaced `var` with explicit types for better readability. - Reduced test duration from 1s to 500ms to improve test speed. - Revised assertions: - Replaced range-based assertion with upper-bound check to ensure poll count is below 500, avoiding timing sensitivity issues. - Added assertion to verify the thread ran and was not immediately canceled. - Added a 2-second timeout to `inputTask.Wait` and verified task completion. - Improved comments to explain test behavior and reasoning behind changes. * tweaks * Fix nullabiltiy stuff. * runnable fixes * more nullabe * More nullability * warnings gone * Fixed fluent test failure. * Refactor ApplicationImpl and update Runnable layout logic Refactored `ApplicationImpl.Run.cs` for improved readability and atomicity: - Combined `if (wasModal)` with `SessionStack?.TryPop` to streamline logic. - Simplified restoration of `previousRunnable` by reducing nesting. - Updated comments for clarity and retained `SetIsModal` call. Simplified focus-setting logic in `ApplicationImpl.Run.cs` using pattern matching for `TopRunnableView`. In `Runnable<TResult>`, added `SetNeedsLayout` after `IsModalChanged` to ensure layout updates. Removed an unused empty line for cleanup. Corrected namespace in `GetViewsUnderLocationForRootTests.cs` to align with test structure. * Update layout on modal state change A call to `SetNeedsLayout()` was added to the `OnIsModalChanged` method in the `Runnable` class. This ensures that the layout is updated whenever the modal state changes. * Increase test timeout for inputTask.Wait to 10 seconds Extended the timeout duration for the `inputTask.Wait` method from 4 seconds to 10 seconds in `MainLoopCoordinatorTests`. This change ensures the test has a longer window to complete under conditions of increased load or slower execution environments, reducing the likelihood of false test failures. * Refactor project files and simplify test logic Removed `<LangVersion>` and `<ImplicitUsings>` properties from `UnitTests.csproj` and `UnitTests.Parallelizable.csproj` to rely on default SDK settings and disable implicit global usings. Simplified the `SizeChanged_Event_Still_Fires_For_Compatibility` test in `FakeDriverTests` by removing the `screenChangedFired` variable, its associated event handler, and related assertions. Also removed obsolete warning suppression directives as they are no longer needed. * Reduce UnitTestsParallelizable iterations from 10 to 3 Reduced the number of iterations for the UnitTestsParallelizable test suite from 10 to 3 to save time and resources while still exposing concurrency issues. Updated the loop and log messages to reflect the new iteration count. * disabled InputLoop_Throttle_Limits_Poll_Rate * Refactor app lifecycle and improve Runnable API Refactored `Program.cs` to simplify application lifecycle: - Modularized app creation, initialization, and disposal. - Improved result handling and ensured proper resource cleanup. Re-implemented `Runnable<TResult>` with a cleaner design: - Retained functionality while improving readability and structure. - Added XML documentation and followed the Cancellable Work Pattern. Re-implemented `RunnableWrapper<TView, TResult>`: - Enabled wrapping any `View` to make it runnable with typed results. - Added examples and remarks for better developer guidance. Re-implemented `ViewRunnableExtensions`: - Provided fluent API for making views runnable with or without results. - Enhanced documentation with examples for common use cases. General improvements: - Enhanced code readability, maintainability, and error handling. - Replaced redundant code with cleaner, more maintainable versions. * Modernize codebase for Terminal.Gui and MVVM updates Refactored `LoginView` to remove redundant `Application.LayoutAndDraw()` call. Enhanced `LoginViewModel` with new observable properties for automatic property change notifications. Updated `Message` class to use nullable generics for improved type safety. Replaced legacy `Application.Init()` and `Application.Run()` calls with the modern `IApplication` API across `Program.cs`, `Example.cs`, and `ReactiveExample`. Ensured proper disposal of `IApplication` instances to prevent resource leaks. Updated `TerminalScheduler` to integrate with `IApplication` for invoking actions and managing timeouts. Added null checks and improved timeout disposal logic for robustness. Refactored `ExampleWindow` for better readability and alignment with modern `Terminal.Gui` conventions. Cleaned up unused imports and improved code clarity across the codebase. Updated README.md to reflect the latest `Terminal.Gui` practices, including examples of the `IApplication` API and automatic UI refresh handling. Renamed `LoginAction` to `LoginActions` for consistency. * Refactor: Transition to IRunnable-based architecture 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. * Refactor: Replace Toplevel with Runnable class 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. * Refactor: Consolidate Runnable classes and decouple View from ApplicationImpl - 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 #4419 * Simplified the disposal logic in `ApplicationImpl.Run.cs` by replacing 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. * Replaces the legacy `Shutdown()` method with `Dispose()` to align 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 runnable app context handling in ApplicationImpl 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. * Improve docs, tests, and modularity across the codebase 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. * readme tweaks * Improve thread safety, layout, and test coverage 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. * Refactor: Rename Toplevel to Runnable and update logic 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. * Removed `ToplevelTests` and migrated relevant test cases to `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. * Reorged Unit Test namespaces. * more * Refactor tests and update namespaces for consistency 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. * Fix nullability warnings in MouseDragTests.cs 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.
2025-12-01 12:54:21 -07:00
using IApplication app = Application.Create ();
app.Init ();
_rxApp = RxAppBuilder.CreateReactiveUIBuilder ();
_rxApp.WithMainThreadScheduler (new TerminalScheduler (app));
_rxApp.WithTaskPoolScheduler (TaskPoolScheduler.Default);
var loginView = new LoginView (new LoginViewModel ());
Fixes #4419, #4148, #4408 - Toplevel is GONE - Replaced by Runnable (#4422) * WIP: Broken * Got working. Mostly. * Parllel tests pass * More progres * Fixed app tests. * Mouse * more progress. * working on shortcut * Shortcut accept on ENTER is broken. * One left... * More test progress. * All unit tests pass. Still some issues though. * tweak * Fixed Integration Tests * Fixed UI Catalog * Tweaking CP to try to find race condition * Refactor StandardColors and improve ColorPicker logic 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. * revert * Throttle input loop to prevent CPU spinning Introduce a 20ms delay in the input loop of `InputImpl<TInputRecord>` to prevent excessive CPU usage when no input is available. Removed the `DateTime dt = Now();` line and the `while (Peek())` block, which previously enqueued input records. This change improves resource management, especially in scenarios where multiple `ApplicationImpl` instances are created in parallel tests without calling `Shutdown()`. It prevents thread pool exhaustion and ensures better performance in such cases. * Refactor ApplicationImpl to use IDisposable pattern Implemented the IDisposable pattern in ApplicationImpl to improve resource management. Added `Dispose` and `DisposeCore` methods, and marked the `Shutdown` method as obsolete, encouraging the use of `Dispose` or `using` statements instead. Updated the `IApplication` interface to inherit from IDisposable and added `GetResult` methods for retrieving run session results. Refactored unit tests to adopt the new lifecycle management approach, replacing legacy `Shutdown` calls with `Dispose` or `using`. Removed fragile and obsolete tests, and re-enabled previously skipped tests after addressing underlying issues. Updated `FakeApplicationLifecycle` and `SetupFakeApplicationAttribute` to align with the new disposal pattern. Improved documentation and examples to guide users toward modern usage patterns. Maintained backward compatibility for legacy singleton usage. * Add IDisposable pattern with input loop throttling - Add IDisposable to IApplication for proper resource cleanup - Add 20ms throttle to input loop (prevents CPU spinning) - Add Lazy<T> to StandardColors (eliminates convoy effect) - Add MainLoopCoordinatorTests suite (5 new tests) - Add Dispose() calls to all 16 ColorPickerTests - Mark Application.Shutdown() as [Obsolete] IApplication now requires Dispose() for cleanup Performance: 100x CPU reduction, 15x faster disposal, tests complete in <5s Fixes: Thread leaks, CPU saturation, test hangs in parallel execution Docs: Updated application.md and newinv2.md with disposal patterns * Refactor test for input loop throttling clarity Updated `InputLoop_Throttle_Limits_Poll_Rate` test to improve clarity, reliability, and efficiency: - Rewrote summary comment to clarify purpose and emphasize the 20ms throttle's role in preventing CPU spinning. - Replaced `var` with explicit types for better readability. - Reduced test duration from 1s to 500ms to improve test speed. - Revised assertions: - Replaced range-based assertion with upper-bound check to ensure poll count is below 500, avoiding timing sensitivity issues. - Added assertion to verify the thread ran and was not immediately canceled. - Added a 2-second timeout to `inputTask.Wait` and verified task completion. - Improved comments to explain test behavior and reasoning behind changes. * tweaks * Fix nullabiltiy stuff. * runnable fixes * more nullabe * More nullability * warnings gone * Fixed fluent test failure. * Refactor ApplicationImpl and update Runnable layout logic Refactored `ApplicationImpl.Run.cs` for improved readability and atomicity: - Combined `if (wasModal)` with `SessionStack?.TryPop` to streamline logic. - Simplified restoration of `previousRunnable` by reducing nesting. - Updated comments for clarity and retained `SetIsModal` call. Simplified focus-setting logic in `ApplicationImpl.Run.cs` using pattern matching for `TopRunnableView`. In `Runnable<TResult>`, added `SetNeedsLayout` after `IsModalChanged` to ensure layout updates. Removed an unused empty line for cleanup. Corrected namespace in `GetViewsUnderLocationForRootTests.cs` to align with test structure. * Update layout on modal state change A call to `SetNeedsLayout()` was added to the `OnIsModalChanged` method in the `Runnable` class. This ensures that the layout is updated whenever the modal state changes. * Increase test timeout for inputTask.Wait to 10 seconds Extended the timeout duration for the `inputTask.Wait` method from 4 seconds to 10 seconds in `MainLoopCoordinatorTests`. This change ensures the test has a longer window to complete under conditions of increased load or slower execution environments, reducing the likelihood of false test failures. * Refactor project files and simplify test logic Removed `<LangVersion>` and `<ImplicitUsings>` properties from `UnitTests.csproj` and `UnitTests.Parallelizable.csproj` to rely on default SDK settings and disable implicit global usings. Simplified the `SizeChanged_Event_Still_Fires_For_Compatibility` test in `FakeDriverTests` by removing the `screenChangedFired` variable, its associated event handler, and related assertions. Also removed obsolete warning suppression directives as they are no longer needed. * Reduce UnitTestsParallelizable iterations from 10 to 3 Reduced the number of iterations for the UnitTestsParallelizable test suite from 10 to 3 to save time and resources while still exposing concurrency issues. Updated the loop and log messages to reflect the new iteration count. * disabled InputLoop_Throttle_Limits_Poll_Rate * Refactor app lifecycle and improve Runnable API Refactored `Program.cs` to simplify application lifecycle: - Modularized app creation, initialization, and disposal. - Improved result handling and ensured proper resource cleanup. Re-implemented `Runnable<TResult>` with a cleaner design: - Retained functionality while improving readability and structure. - Added XML documentation and followed the Cancellable Work Pattern. Re-implemented `RunnableWrapper<TView, TResult>`: - Enabled wrapping any `View` to make it runnable with typed results. - Added examples and remarks for better developer guidance. Re-implemented `ViewRunnableExtensions`: - Provided fluent API for making views runnable with or without results. - Enhanced documentation with examples for common use cases. General improvements: - Enhanced code readability, maintainability, and error handling. - Replaced redundant code with cleaner, more maintainable versions. * Modernize codebase for Terminal.Gui and MVVM updates Refactored `LoginView` to remove redundant `Application.LayoutAndDraw()` call. Enhanced `LoginViewModel` with new observable properties for automatic property change notifications. Updated `Message` class to use nullable generics for improved type safety. Replaced legacy `Application.Init()` and `Application.Run()` calls with the modern `IApplication` API across `Program.cs`, `Example.cs`, and `ReactiveExample`. Ensured proper disposal of `IApplication` instances to prevent resource leaks. Updated `TerminalScheduler` to integrate with `IApplication` for invoking actions and managing timeouts. Added null checks and improved timeout disposal logic for robustness. Refactored `ExampleWindow` for better readability and alignment with modern `Terminal.Gui` conventions. Cleaned up unused imports and improved code clarity across the codebase. Updated README.md to reflect the latest `Terminal.Gui` practices, including examples of the `IApplication` API and automatic UI refresh handling. Renamed `LoginAction` to `LoginActions` for consistency. * Refactor: Transition to IRunnable-based architecture 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. * Refactor: Replace Toplevel with Runnable class 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. * Refactor: Consolidate Runnable classes and decouple View from ApplicationImpl - 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 #4419 * Simplified the disposal logic in `ApplicationImpl.Run.cs` by replacing 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. * Replaces the legacy `Shutdown()` method with `Dispose()` to align 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 runnable app context handling in ApplicationImpl 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. * Improve docs, tests, and modularity across the codebase 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. * readme tweaks * Improve thread safety, layout, and test coverage 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. * Refactor: Rename Toplevel to Runnable and update logic 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. * Removed `ToplevelTests` and migrated relevant test cases to `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. * Reorged Unit Test namespaces. * more * Refactor tests and update namespaces for consistency 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. * Fix nullability warnings in MouseDragTests.cs 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.
2025-12-01 12:54:21 -07:00
app.Run (loginView);
loginView.Dispose ();
Fixes #3192. Improve correctness / clarity of existing `View.AutoSize` functionality/unit tests (#3202) * Removed resharper settings from editorconfig * Remove constructors with frame parameters from Button class. * Remove constructors with frame parameters from CheckBox class. * Cleanup code. * Remove constructors with frame parameters from ComboBox class. * @BDisp Remove constructors with frame parameters from FrameView class. * Remove constructors with frame parameters from Label class. * Remove constructors with frame parameters from ListView class. * Remove constructors with frame parameters from ScrollBarView class. * Remove constructors with frame parameters from ScrollView class. * Remove namespace braces. * Cleanup code. * Cleanup code. * Cleanup code. * Remove constructors with frame parameters from TextField class. * Remove constructors with frame parameters from TimeField class. * Fixes #3182. OnResizeNeeded returns int.MaxValue and int.MaxValue when Application.Top is null, should return Size.Empty. * Remove constructors with frame parameters from Toplevel class. * Remove constructors with frame parameters from Window class. * Fix merge errors. * Revert "Fixes #3182. OnResizeNeeded returns int.MaxValue and int.MaxValue when Application.Top is null, should return Size.Empty." This reverts commit cf9c24b846c1831eb340833e5a792c1d6cce31ea. * Revert unit test. * Fixes #2882. TabView: 'Frame.DrawFrame(Rect, bool)' is obsolete: 'This method is obsolete in v2. Use use LineCanvas or Frame (#2980) * Fixes #2882. TabView: 'Frame.DrawFrame(Rect, bool)' is obsolete: 'This method is obsolete in v2. Use use LineCanvas or Frame * Trying fix this unit test that sometimes fail. * Fixes #2983. View need a alternative DrawFrame for the v2. * Use new DrawFrame method. * Change _lines field to Lines property. * Add TabWindow unit test. * Add DrawIncompleteFrame method and unit tests. * Add more unit tests to LineCanvas. * Fix newline conflict errors. * Revert "Change _lines field to Lines property." This reverts commit ab6c5f3094c78e884a52d26840671f1140a24ab4. * Add DrawIncompleteFrame method and unit tests. * Add more unit tests to LineCanvas. * Fix newline conflict errors. * Force render immediately instead of join. * I will never rely on zero-location-based unit test again. * Fix TestTreeViewColor unit test fail. * Using location of 3 to avoid be divisible by 2 and so avoiding bugs. * Revert "Using location of 3 to avoid be divisible by 2 and so avoiding bugs." This reverts commit dd3df135d8e6f18ff1cc11440823b3f3eafddcac. * Revert "I will never rely on zero-location-based unit test again." This reverts commit 62adf6f2850b0fb9e83782cee8c47a1202a3031e. * Revert "Fix newline conflict errors." This reverts commit 4acf72612dff0ba907f20c7f8826253d73c102c8. * Revert "Add more unit tests to LineCanvas." This reverts commit 66bc6f514e88ae9844c5608f89d7368938ed2486. * Revert "Add DrawIncompleteFrame method and unit tests." This reverts commit 680ba264e16b42e2261e697dca9aa54761feae1e. * Resolving merge conflicts. * Revert "Use new DrawFrame method." This reverts commit 69a7f17f19fbb7985a49b039b37403d9735d8f70. * Revert "Fixes #2983. View need a alternative DrawFrame for the v2." This reverts commit dade9fd767ce3aacc91fa13d0b4537d233de0a49. * Reverting this changes to start a new one. * Add horizontal and vertical support for combining glyphs. * Fix text and auto size behavior. * Add TabWidth property. * Add unit test for WordWrap. * Fixes #3017. View TextDirection returns incorrect size on a vertical direction instance with AutoSize as false. * Using Frame to force read from the get method. * Fix some issues with AutoSize and ForceValidatePosDim. * Fixing broken unit tests. * Restoring code I've broken. * Removing forgotten code. * Only LayoutStyle.Computed can change the Frame. * DateField and TimeField depends on LayoutStyle.Computed. * Fix unit tests related with LayoutStyle. * Implements tabs, left and right arrows as View. * Draws a minimum full border. * Adds missing XML parameter. * Adds assert tests for Frame. * Removes duplicates InlineData. * Adds more unit tests for minimum full border without Left and Right thickness. * Trying to fix the TestTreeViewColor unit test fail. * Prevents a user to set TextDirection to -1. * Prevents any invalid TextDirection value. * Removes (TextDirection)(-1). * Removes unnecessary TextDirection initialization. * Removes LayoutStyle. * Fixing unit tests with border. * Trying to fix TestTreeViewColor again. * Revert "Trying to fix TestTreeViewColor again." This reverts commit c2efa8e42e7776f23a8f664746d946506351244b. * Trying to fix TestTreeViewColor again. * Fix merge errors. * Fix merge errors. * Restoring unit test. * Restores the right XML comment. * Fix Disposing unit tests that sometimes throws because some instances aren't cleared on others unit tests classes. * Fix Disposing unit tests that sometimes throws because some instances aren't cleared on others unit tests classes. * Only call OnResizeNeeded if it's LayoutStyle.Computed. * Fix merge errors. * Fix merge errors. * Fix unit tests fail. * Reformat. * Again. * Rename to OnDrawAdornments. * Fix failing unit tests. * Reduces indentation and cleanup code. * Cleanup code. * Fix bug done when cleanup. * Replace FrameHandledMouseEvent to AdornmentHandledMouseEvent. * Removes Tab constructor parameters. --------- Co-authored-by: Tig <tig@users.noreply.github.com> * Fix merge errors. * Remove constructors with parameters from Button. * Remove parenthesis on objects initializers from Button. * Remove constructors with parameters from CheckBox. * Remove parenthesis on objects initializers from CheckBox. * Remove constructors with parameters from ComboBox. * Remove constructors with parameters from FrameView. * Remove parenthesis on objects initializers from FrameView. * Initial commit * Renamed Direction enum for clarity in refactoring unit tests * Moved nav tests to NavigationTests * Moved view tests around * Cleaning up TextFormatter and View.AutoSize code * Fixed latent TextFormatter bug with \n * removed Application dependency on some autosize unit tests * Fixed Label tests to deal with auotsize overriding height/width * Fixed more label tests. WIP * Fixed all places where AutoSize = happend after setting Dims * Started adding new primitive View.Text tests * Code comments * WIP: Enforce that it makes no sense to set Width/Height if AutoSize = true. Update Unit tests to match. * WIP: Enforce that it makes no sense to set Width/Height if AutoSize = true. Update Unit tests to match. * Remove frame set from the View constructor and prevent SetRelativeLayout running if not yet initialized. * Changes needed for unit tests pass on remove parameters constructors from the Label class. * Remove constructors with parameters from Label. * Remove parenthesis on objects initializers from Label. * Prefix private fields with underscore. * Renamed to MaxLength. * Remove constructors with parameters from ListView. * MakeWrapper not needed anymore. * Remove parenthesis on objects initializers from ListView. * WIP: Enforce that it makes no sense to set Width/Height if AutoSize = true. Update Unit tests to match. * Massive code cleanup - use parameterless constructors and ensure AutoSize is set properly. Code reformat. * Massive code cleanup - use parameterless constructors and ensure AutoSize is set properly. Code reformat. * Fixed messagebox * Remove constructors with parameters from ScrollBarView and ScrollView. * Remove parenthesis on objects initializers from ScrollBarView and ScrollView. * Cleanup code. * Fix merge errors. * Add empty dotsettings for solution and projects. * Set ReSharper language analysis level for projects to C#12 * Make ReSharper consider itself the boss for style * Add rule to enforce property backing fields above the property * Disable auto-detection of naming rules so ReSharper doesn't change them by itself * Don't let someone's VS settings override the indent settings * Explicitly set tab width to 4 spaces and force spaces. * Rules to keep various multi-line constructs aligned within themselves * Curly brace rules (Using K&R style, per current project spec) * Blank line rules Mostly to add breaks in various situations, and also to enforce max of 1 blank line. * Increase auto-wrap to 160 from default of 120 * Line break at end of all files, to make Unixy systems happy * Keep attributes on their own lines except for methods and records that are themselves single-line * Increase attribute auto-wrap to 60 from default of 38 * Wrap/chop rules for long method signatures and record declarations Chop if either already multi-line or if over 8 parameters. Chop AFTER the left paren and BEFORE the first parameter. * Chop rules for generics For generics with multi-line type parameters or multiple type parameter constraints, chop in a way that has consistent alignment. * Always enforce enum members on their own lines * One-line functions completely on one line They're usually expression-bodied anyway, here, so this is almost irrelevant * Keep control flow statements on their own lines * Follow same chop rules for method invocation as method declaration * Chop long or multi-line method chains or patterns * Wrap rules for binary operators Operator at beginning of new lines Auto-chop if long or already multi-line * Spaces between keywords and their opening parentheses * Add file layout rules for organization of reorderable items like fields, properties, etc. Ugly XML, so load it up in the UI to look at it It's MOSTLY the ReSharper defaults, but with more aggressive sorting, generally by access modifier and name, within each grouping. * Deconstructors use per-member types * Use keywords for built-in types and increase severity of inspection for violations Also apply to IntPtr and similar, which should now be nint and similar * Apply syntax style on completion. * Use var when evident for built-in and simple types, but not elsewhere * Increase severity for some minor redundancy and clarity inspections * Enforce braces always required for blocks, and treat as error * Warn if a local function is not statement-bodied * Increase various inspection severities IF Condition => Severity: Attributes not wrapped property => Suggestion Constructors expression-bodied => Error default doesn't have type when it isn't clear => suggestion Namespaces not file-scoped => error Methods not statement-bodied => hint Null check pattern not the object property pattern => Error * Adjust preference order of null check patterns to make object pattern highest * XmlDoc rules to keep tags and contents aligned and wrapped * Add a few custom profiles for code cleanup and make the full profile default * Remove parts for languages not used in this solution * copied in v2_develop changes * Merged v2_develop * Added Begin/Init unit tests. Removed Application dependencey from AutoSizeFalse tests * TextFormatter.Lines -> GetLines () * Let ReSharper know we intend to localize things * TextFormatter code cleanup * copied in v2_develop changes * Merged v2_develop * Spaces aren't wanted here either. * Fix merge errors. * Fixes ContentBottomRightCorner related with https://github.com/gui-cs/Terminal.Gui/issues/3211#issue-2098878820 * Remove constructors with parameters from ContextMenu. * Remove commented code. * Remove constructors with parameters from OpenDialog. * Remove constructors with parameters from SaveDialog. * Remove constructors with parameters from TextField. * Remove constructors with parameters from TimeField. * Fix unit test. * Remove unnecessary SetInitialProperties method. * Remove unnecessary SetInitialProperties method. * Remove parenthesis on objects initializers from Toplevel and Window. * Remove constructors with parameters from RadioGroup. * Remove constructors with parameters from TextView. * Remove constructors with parameters from MenuBar. * TEMPORARY: Turn everything that was set to error down to warning or lower * Fixes #3219. MenuBar is opened by call OpenMenu even it's disabled. * Remove constructors with parameters from Menu. * Remove constructors with parameters from View. * Change constructor to internal because is mainly useful for testing. * ReSharper Cleanup Code. * Added format only r# config * Fixes #3224. TextFormatter.Lines should return a single string.Empty list even with Width or Height equal to zero. * Remove constructors with parameters from Dialog. * Remove constructors with parameters from TextValidateField. * Fixes https://github.com/gui-cs/Terminal.Gui/issues/3224#issuecomment-1924096038 * Fixes #3225. Press CursorDown on TabView doesn't move to the next view. * Fixes #3229. TextFormatter should have a FillRemaining property. * Testing formatting merge in bdisp * Testing formatting merge * Testing formatting merge bdisp * Testing formatting merge 2 * xmldoc format * R# Full Code Cleanup * R# Full Code Cleanup2 * R# Full Code Cleanup2 * Merged! But broke tests * Refixing... * Refixed DrawTests * Refixed ViewTests * Refixed Text Tests * Refixed more unit tests * Refixed scenarios * Refixed rest of scenarios * Refixed ViewsTests * Refixed rest of tests. All unit tests pass again! * Fixed warnings * Updated R# version. Added new code cleanup settings * Applied latest code cleanup to solution * Another code cleanup pass * Tweaked r# settings. .editorconfig now matches. * r# else on separate line * r# - update * r# - full solution * test commit * test commit * test commit * Removed extra profiles * Full cleanup following cleaning up profiles * Null checking pattern rules/inspections * Tabs and extra whitespace are evil * Attributes on their own lines * Code layout rules to put fields first and to put backing fields with their properties * Merged v2_develop * Full cleanup following dodexahedron's PR --------- Co-authored-by: BDisp <bd.bdisp@gmail.com> Co-authored-by: Brandon Thetford <github@snapsinazfs.com>
2024-02-11 15:54:03 -07:00
}
}