Skip to content

Conversation

@tig
Copy link
Collaborator

@tig tig commented Oct 29, 2025

tig added 30 commits October 7, 2025 09:24
Terminal.Gui v2 introduces a transformative redesign, simplifying the library's architecture and improving maintainability. Key changes include:

- Added TrueColor support with 24-bit RGB handling.
- Introduced `Adornment` framework for borders, padding, and margins.
- Enhanced Unicode and wide character support for internationalization.
- Added `LineCanvas` for drawing lines and shapes with box-drawing characters.
- Simplified API by consolidating redundant methods and aligning with modern .NET standards.
- Introduced `ConfigurationManager` for user-customizable themes and text styles.
- Improved scrolling with `Viewport` and integrated `ScrollBar`.
- Added new layout features like `Dim.Auto`, `Pos.AnchorEnd`, and `Pos.Align`.
- Overhauled keyboard and mouse APIs for better input handling.
- Introduced new views (e.g., `DatePicker`, `ColorPicker`, `GraphView`) and enhanced existing ones.
- Added Sixel image support for rendering graphics in compatible terminals.
- Ensured AOT compatibility for improved deployment and performance.

This update lays the foundation for building modern, user-friendly terminal applications.
tig and others added 2 commits October 30, 2025 16:51
Refactored `UncheckNone` and `UncheckAll` methods in `FlagSelector` to improve clarity and prevent concurrent modifications using a new `_updatingChecked` flag. Removed the old `UncheckNone` implementation and reorganized logic for maintainability.

Added extensive unit tests in `FlagSelectorTests` to validate functionality, including edge cases and generic implementations. Tests cover flag combination, toggling, "None" flag behavior, and enum-based generic handling.

Improved overall maintainability and test coverage for the `FlagSelector` class.
@tig
Copy link
Collaborator Author

tig commented Oct 30, 2025

@BDisp what do you think of deleting RadioGroup now? It's just alias to optionselector.

@BDisp
Copy link
Collaborator

BDisp commented Oct 30, 2025

I agree, the less redundancy, the better.

tig and others added 11 commits October 30, 2025 17:30
The `RadioGroup` class has been refactored to inherit from the `OptionSelector` class instead of `View`, marking it as `[Obsolete]` and recommending the use of `OptionSelector`.

The previous implementation of `RadioGroup` has been entirely removed, including its properties, methods, events, and internal logic. This includes initialization logic, key bindings, layout management, and event handling.

The new `RadioGroup` is now a thin wrapper around `OptionSelector` and implements the `IDesignable` interface. The `EnableForDesign` method has been simplified to set default options for design purposes.

This change simplifies the codebase and encourages the use of `OptionSelector` for managing mutually exclusive options.
Refactored `AdvanceFocusTests` to improve assertion clarity by replacing `Assert.True`/`Assert.False` with `Assert.Equal`. Enhanced test documentation with detailed view hierarchy comments for better readability.

Added a new test case, `FocusNavigation_Should_Cycle_Back_To_Top_Level_Views`, which exposes a bug in focus navigation logic where focus does not cycle back to top-level views after traversing nested views.

Updated existing tests to ensure consistent handling of `TabBehavior` and made minor adjustments for improved validation of focus navigation logic.
The `RadioGroupTests.cs` file has been completely cleared of all test cases and associated code. This includes the removal of unit tests that validated the `RadioGroup` component's functionality, behavior, and edge cases.

The deleted tests covered:
- Default constructor behavior and initialization.
- Handling of the `SelectedItem` property, including edge cases.
- Hotkey bindings and their behavior under different focus states.
- Command handling for focus, selection, and acceptance.
- Orientation changes and their impact on layout.
- Event handling for `SelectedItemChanged`, `Selecting`, and `Accepting`.
- Mouse interactions, including single-click and double-click events.

This removal eliminates all automated validation for the `RadioGroup` component, leaving it untested and increasing the risk of regressions or undetected issues in future changes.
Updated XML documentation in `FakeConsole.cs` to replace `<see cref="FakeDriver"/>` with `<exception cref="FakeDriver"></exception>` for clarity.

Corrected a parameter name in `WindowsOutput.cs`'s `WriteConsole` method from `numberOfCharsToWritten` to `numberOfCharsToWrite` to fix a typo and improve readability.
Replaced all instances of `RadioGroup` with `OptionSelector` across the codebase to standardize the control for mutually exclusive options. Updated associated properties, methods, and event handlers to align with the `OptionSelector` API, including replacing `RadioLabels` with `AssignHotKeys` and `SelectedItemChanged` with `ValueChanged`.

Removed the `RadioGroup` class, marking it as obsolete. Updated documentation, comments, and test cases to reflect the new control. Adjusted layout and positioning logic in various scenarios to ensure UI consistency.

Refactored scenarios such as `Buttons`, `ColorPickers`, `DynamicMenuBar`, `FileDialogExamples`, `Images`, `PosAlignDemo`, `ProgressBarStyles`, `RegionScenario`, `Themes`, and others to use `OptionSelector`. Updated `Glyphs` and `View` classes to reflect the terminology change. Cleaned up redundant code and ensured compatibility across the application.
@tig
Copy link
Collaborator Author

tig commented Oct 31, 2025

Ok, RadioGroup is gone.

I have these work items left for this PR:

  • I don't like that OptionSelector has both SelectedItem/SelectedItemChanged and Value/ValueChanged. I left SelectedItem in there for backwards compat with RadioGroup, but now that RG is actually gone, and I've updated most uses of SelectedItem to use Value instead I'm going to remove it.
  • OptionsSelector<T>.Value is an int?. It should be T?; without that, part of the value of having this be generic is lost and it makes consuming code awkward. FlagSelector<T>.Value is already of type T?.
  • ValueChanged should have a ValueChanaged<T> as well.
  • OptionSelector<T> needs a Show.None option that will set Value to null.

tig added 13 commits October 31, 2025 10:06
Replaced the SelectedItem property with a nullable Value property across the codebase to simplify the API and improve consistency. Updated event handlers from SelectedItemChanged to ValueChanged and adjusted logic accordingly.

Refactored UI scenarios (e.g., Buttons, CharacterMap, ColorPickers) and dependent classes (e.g., BorderEditor, DimEditor, PosEditor) to use the new Value property. Improved null handling and streamlined initialization of controls.

Updated tests to validate the Value property and renamed test methods for clarity. Removed the RegionOpSelector class as it was no longer needed. Performed general code cleanup, including formatting and removal of redundant code.
Updated the `OptionSelector` class and its derived classes to replace the `RadioLabels` property with a more generic `Labels` property, aligning with the base class `SelectorBase`. This change standardizes the API and simplifies label-related functionality.

Refactored all instances of `RadioLabels` across the codebase, including property assignments, method calls, and references in scenarios, tests, and examples. Updated classes include `ColorPickers`, `Dialogs`, `DimAutoDemo`, `DynamicMenuBar`, `FileDialogExamples`, `Images`, `PosAlignDemo`, `Selectors`, `Shortcuts`, `TextAlignmentAndDirection`, `Themes`, `UnicodeInMenu`, `Wizards`, `UICatalogTop`, and `ScenarioTests`.

Modified `OptionSelector<TEnum>` to initialize `Labels` directly using `Enum.GetValues<TEnum>()`. Removed the `RadioLabels` property from `OptionSelector`, consolidating functionality under `Labels`.

Verified functionality through updated tests and scenarios to ensure consistent behavior with the previous implementation.
Updated terminology across multiple classes to replace "radio group" with "option selector" for improved clarity and consistency.

- Removed unused `OptionSelector` in `ColorPickers`.
- Renamed `Title` in `DimAutoDemo` to "Options" and updated `BorderStyle`.
- Replaced `_radioItems` with `_optionLabels` in `DimEditor` and `PosEditor`.
- Renamed `styleRadioGroup` to `styleOptionSelector` in `MessageBoxes`.
- Renamed `radioGroup` to `optionSelector` in `UnicodeInMenu` and `OrientationTests`.
- Adjusted related references, event handlers, and UI properties.

These changes align the codebase with updated terminology and improve readability.
The `RadioGroup` control has been replaced or renamed to `OptionSelector`. Documentation has been updated to reflect this change, including the behavior of raising the `Selecting` event when an option is selected.

The navigation table now describes `OptionSelector` as supporting multiple options with actions like `Advance`, `SetValue+OnAccept`, and `Focus+SetValue`. A new section introduces the `OptionSelector` view, which displays mutually-exclusive items with hotkeys.

Enhancements to `Menuv2` and `MenuBarv2` include setting focus on `MenuItemv2` selections and raising the `SelectedMenuItemChanged` event. Additionally, a progress bar view has been introduced to visually indicate activity progress.
Renamed the `EndAfterFirstIteration` property to `StopAfterFirstIteration` across the codebase for improved clarity and consistency. Updated all references in the `Application`, `ApplicationImpl`, `IApplication`, and `ITimedEvents` classes, as well as related tests and documentation.

Modified the application loop logic to use `StopAfterFirstIteration` for controlling the termination of the application after the first iteration. Set its default value to `false`.

Updated test cases, demo applications, and XML documentation to reflect the new property name. Added a new project, `OutputView`, to the solution with appropriate configuration entries.

Performed minor code cleanup to ensure consistency in naming and behavior.
- Added `args.Handled = true` to `CheckBox` event handlers in `FlagSelector` and `OptionSelector` to mark events as handled.
- Introduced `_value` field in `FlagSelector` and added a `Cycle` method in `OptionSelector` for better value management.
- Updated `OptionSelector` documentation to reference `OptionSelector<TEnum>` for type-safe enum usage.
- Improved `UpdateChecked` method documentation in `OptionSelector` to clarify exception behavior.
- Enabled nullable reference types in `FlagSelectorTests` and `SelectorBaseTests` and moved them to a new namespace.
- Removed outdated auto-generated content from `views.md`.
- Removed `CheckBox.DefaultHighlightStyle` from the default theme configuration in `OutputView.cs`.
Modified `args.Handled` in `FlagSelector` and `OptionSelector` to allow `Accepting` event propagation, improving event handling behavior. Added comments to clarify the changes.

Expanded `views.md` with detailed documentation for built-in views and controls in *Terminal.Gui*, including descriptions, examples, and rendered outputs for components like `Bar`, `Button`, `CheckBox`, and more. This update enhances developer guidance for building terminal-based UIs.
Renamed the `EndAfterFirstIteration` property to `StopAfterFirstIteration` across the codebase for improved clarity. Updated its implementation to use a getter and setter that interact with the `ApplicationImpl.Instance` singleton for centralized management.

Modified the `RunLoop` method to check the new `StopAfterFirstIteration` property. Updated the default value to `false` in the `Application` class.

Added a private `_stopAfterFirstIteration` field and a corresponding public property in the `ApplicationImpl` class. Updated the `Run` method in `ApplicationImpl` to stop after the first iteration if the property is set to `true`, with appropriate logging.

Updated the `IApplication` interface to include the `StopAfterFirstIteration` property and clarified the behavior of the `RequestStop` method. Revised XML documentation comments to reflect these changes.
Refactored `StopAfterFirstIteration` in `ApplicationImpl` to use an auto-property for simplicity. Updated `RunIteration` to call `view.RequestStop()` instead of modifying `view.Running`.

Replaced references to `Application.EndAfterFirstIteration` with `Application.StopAfterFirstIteration` across the codebase, including `ITimedEvents`, `ApplicationTests`, and `GlobalTestSetup`.

Added a new test, `InitRunShutdown_StopAfterFirstIteration_Stops`, to verify the application stops correctly after the first iteration. Updated related documentation and assertions for consistency.
Refactored `Value` handling across multiple classes to use nullable generic types, improving type safety and eliminating unnecessary casting. Simplified `ValueChanged` event handlers with concise lambda expressions.

Enhanced `FlagSelector<TFlagsEnum>` and `OptionSelector<TEnum>` with generic `ValueChanged` events and type-safe event handling. Added nullable reference type annotations to align with modern C# practices.

Improved test code by using null-forgiving operators and more descriptive assertions. Cleaned up redundant code and ensured consistency in `Value` handling. Updated `FlagSelectorTests` and `SelectorBaseTests` for better readability and maintainability.

Added the `System` namespace to `FlagSelectorTEnum.cs` for compatibility. Overall, these changes enhance code readability, maintainability, and robustness.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Genericize FlagSelector/OptionSelector, Replace RadioGroup

2 participants