-
Notifications
You must be signed in to change notification settings - Fork 68
Updates OCGV and SHOT to Terminal.Gui v2 #267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
tig
wants to merge
19
commits into
PowerShell:main
Choose a base branch
from
tig:terminal_gui_v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WIP: Builds but doesn't run
Refactored `ConsoleGui.cs` to improve modularity, readability, and maintainability. Added dynamic layout handling, improved filtering logic, and enhanced status bar functionality. Simplified data loading and display string updates. Updated `GridViewHelpers.cs` to handle nullable column widths and improve robustness. Replaced `Terminal.Gui` package reference with a local project reference in `Microsoft.PowerShell.ConsoleGuiTools.csproj` to facilitate debugging. Added `<CopyLocalLockFileAssemblies>` for better build handling. Added new launch profiles in `launchSettings.json` for streamlined debugging with preloaded `Out-ConsoleGridView` module. Upgraded Visual Studio version in `GraphicalTools.sln` to 18.3.11206.111.
Collaborator
Author
Enhanced the filtering functionality by introducing `_filterErrorView` to display filter-related errors and updated the `ApplyFilter` method to handle `RegexParseException` gracefully. Adjusted `_header` positioning dynamically based on `_filterErrorView` and ensured `ListView` selection defaults to the first item if none is selected. Refactored `ListViewSource_MarkChanged` to handle null `_inputSource` safely. Simplified `StatusBar` creation and improved `filterErrorView` behavior with `Dim.Auto` for dynamic height and error-specific styling. Updated `launchSettings.json` with new configurations (`OCGV -Filter`, `OCGV`, `OCGV -MinUi`) for better debugging flexibility. Cleaned up redundant code, improved null safety, and adjusted `Window` dimensions for `MinUI` mode.
Refactored `OnWinSubViewLayout` to add null checks for `_header` to ensure safety and prevent runtime exceptions. Simplified "Select All" and "Select None" logic by replacing manual iteration with `_listView?.MarkAll` calls and added comments to address a `Terminal.Gui` bug requiring explicit redraws. Removed default `Ctrl-A` keybinding from `_listView` to allow custom handling in the status bar. Updated `LangVersion` in `Microsoft.PowerShell.ConsoleGuiTools.csproj` to `preview` to enable preview language features. Fixed formatting in the `ProjectReference` element for consistency.
Add SOT launch config and update Esc shortcut description Added a new "SOT" launch configuration in `launchSettings.json` to run the `Show-ObjectTree` command using PowerShell 7-preview. Updated the "Esc" key shortcut description in `ShowObjectView.cs` from `"~ESC~ Close"` to `"Close"` for improved clarity.
Refactored `ConsoleGui` and `ShowObjectView` classes to improve readability, maintainability, and adherence to modern C# conventions. Key changes include: - Updated `FILTER_LABEL` to `_Filter` for UI consistency. - Simplified `ConsoleGui` initialization logic and removed redundant `SetNeedsDraw` call. - Rewrote `ShowObjectView` to use nullable fields, modern syntax, and dynamic regex validation. - Refactored `GetChildren` to handle nested objects with a `while` loop. - Improved `CachedMemberResult` and `CachedMemberResultElement` with better encapsulation and naming conventions. - Enhanced `RegexTreeViewTextFilter` with a primary constructor and better regex error handling. - Simplified `Run` method in `ShowObjectView` for cleaner application lifecycle management. - Fixed typos in comments and replaced redundant comments with concise explanations. - General cleanup using modern C# features like expression-bodied methods, pattern matching, and `null`-coalescing operators.
Refactored namespaces to align with `Microsoft.PowerShell` conventions, replacing `OutGridView.Cmdlet` and `OutGridView.Models`. Updated the module version to `0.9.0` to reflect significant changes. Improved code readability and maintainability by adding XML documentation, enforcing consistent naming conventions, and removing redundant code. Enhanced null safety with nullable annotations and null checks. Refactored key classes (`ConsoleGui`, `GridViewDataSource`, `GridViewDetails`, `GridViewHelpers`, `OutConsoleGridviewCmdletCommand`, `ShowObjectTreeCmdletCommand`, etc.) to simplify logic, improve error handling, and ensure modern C# practices. Updated `launchSettings.json` to rename the `SOT` profile to `SHOT` for consistency with the `Show-ObjectTree` cmdlet. Enhanced serialization logic in `Serializers.cs` and improved type handling in `TypeGetter.cs`. These changes improve the maintainability, safety, and usability of the module while aligning with modern development standards.
Refactored the `ConsoleGui` class into a new class named `OutConsoleGridView` to improve modularity and maintainability. The `ConsoleGui` class was removed, and its functionality was moved to `OutConsoleGridView`, which is now implemented in a separate file (`OutConsoleGridView.cs`). Updated all references to `ConsoleGui` in `OutConsoleGridViewCmdletCommand`: - Replaced `_consoleGui` with `_outConsoleGridView`. - Updated method calls to use `OutConsoleGridView` methods. - Updated the `Dispose` method to dispose of `_outConsoleGridView`. This change reorganizes the codebase for better readability and separation of concerns without introducing any functional changes.
The `Cmdlet` attribute for the `OutConsoleGridViewCmdletCommand` class
was updated to rename the cmdlet from `Out-ConsoleGridView` to
`ConsoleGridView`. This change simplifies the cmdlet name and may align
with a new naming convention.
The alias `[Alias("ocgv")]` remains unchanged, ensuring backward
compatibility for users familiar with the shorthand.
… unit testing. Refactored `OutConsoleGridView` and `ShowObjectTree` for improved maintainability and performance: - Introduced `OutGridViewWindow` and `ShowObjectTreeWindow` to encapsulate UI logic. - Added `CachedMemberResult` and `CachedMemberResultElement` for better object hierarchy handling. - Implemented `RegexTreeViewTextFilter` for regex-based filtering in tree views. Enhanced data handling and UI: - Replaced `DataTable` with direct `PSObjects` handling in `ApplicationData`. - Improved grid view filtering, column width calculations, and status bar shortcuts. - Enhanced tree view to display object hierarchies with filtering and status bar updates. Refactored `TypeGetter`: - Added caching for `FormatViewDefinition` lookups. - Made `CastObjectsToTableView` static for reusability. Updated dependencies and removed legacy code: - Updated `Directory.Packages.props` to use `System.Management.Automation`. - Removed redundant and outdated code from `OutConsoleGridView`. Bug fixes and documentation: - Fixed column width calculation issues and concurrency in `TypeGetter`. - Improved error handling for invalid regex patterns. - Added XML documentation for all new and modified classes.
Added a null check in `GetFormatViewDefinitionForObject` to handle cases where `typeName` is null, returning early if necessary. Introduced a caching mechanism using `_formatCache.TryGetValue` to improve performance by reusing cached format view definitions. Refactored object-to-data-table conversion code for better readability by reformatting inline initializations of `DecimalValue` and `StringValue`. Improved clarity in data type assignment logic by wrapping nested loops in braces and adopting modern C# syntax (`is not`) for type checks.
Updated `GetFormatViewDefinitionForType` to create a runspace with the default initial session state, ensuring proper loading of format data. Removed redundant fallback logic for `Get-FormatData` invocation. Added `Debug.Assert` to validate non-null results. Updated comments to reflect the new behavior. Included `System.Diagnostics` for debugging utilities.
Enhanced object formatting and display logic in the `Out-ConsoleGridView` cmdlet: - Added `GetFormatDataForObjects` to retrieve format data for PowerShell objects. - Updated `EndProcessing` to include format data in `ApplicationData`. - Improved `DataTable` construction to use format data and added dynamic column formatting. - Introduced `IsIdentifierProperty` to handle identifier-specific formatting. - Added `FormatString` and `FormatValue` to `DataTableColumn` for flexible value formatting. - Enhanced `IValue` interface with `OriginalValue` for raw data access. Refactored `TypeGetter` to simplify format data retrieval and object-to-table conversion. Updated `launchSettings.json` to include new profiles and simplify commands. Performed general code cleanup, removed legacy methods, and improved documentation for better maintainability.
Refactored `Render` method in `GridViewDataSource` to improve alignment handling. Enhanced column width management in `OutGridViewWindow` by introducing natural width calculations, truncation safeguards, and scrollbar support. Simplified layout handling with dynamic content size adjustments. Removed deprecated `GetFormatDataForObjects` method and `FormatData` property, transitioning to dynamic column definitions using `TypeGetter`. Improved type handling with caching, ANSI escape sequence stripping, and better fallback logic for primitive types. Updated launch configurations for testing new scenarios. Performed general code cleanup, improving readability, maintainability, and error handling.
Refactored the AddHeaders method to be an inline local function within AddListView, improving modularity and encapsulation. Removed the original AddHeaders implementation and its call from the constructor. The new AddHeaders method is conditionally invoked when _applicationData.MinUI is false. Updated the Y positioning of _listView to use _filterErrorView instead of _filterLabel. Adjusted _listView padding and scrollbar position to integrate the header. Changed MARGIN_LEFT constant from 1 to 0 to refine UI layout.
Add AllProperties toggle to Out-ConsoleGridView cmdlet Introduced a new `AllProperties` parameter to the `Out-ConsoleGridView` cmdlet, allowing users to display all object properties instead of default display properties. Key changes: - Added `AllProperties` as a `SwitchParameter` in `OutConsoleGridViewCmdletCommand`. - Updated `ApplicationData` to store the `AllProperties` state. - Enhanced `OutGridViewWindow` with a `CheckBox` for toggling `AllProperties` and dynamic updates to the grid view and status bar. - Added `ReloadDataWithAllProperties` and `UpdateStatusBar` methods to handle UI updates. - Modified `TypeGetter` to support `AllProperties`, prioritizing format view definitions, default display property sets, and fallback to all properties. - Updated `CastObjectsToTableView` to include an `allProperties` parameter. - Improved compatibility with CIM instances by using the current runspace for format data retrieval. These changes enhance the cmdlet's flexibility and usability, particularly for inspecting all object properties.
Refactored `OutConsoleGridViewCmdletCommand` and `OutGridViewWindow` classes for improved readability, maintainability, and performance. Introduced a new `Header` class for dynamic grid column headers with bold and underlined styles. Simplified logic, removed redundant methods, and optimized nullability handling. Enhanced `TypeGetter` to filter out expensive `PS*` metadata properties, improving performance. Updated `ApplicationData` to clarify `AllProperties` behavior and removed unused imports. Added a new launch configuration in `launchSettings.json` for testing the `-AllProperties` parameter. Improved status bar shortcuts and event handling for better user experience. Updated comments and documentation for consistency.
Updated the assignment of `dataTableColumns` to explicitly convert the result of `typeGetter.GetDataColumnsForObject` into a `List<DataTableColumn>` using `.ToList()`. This change ensures compatibility and enables list-specific operations, improving code clarity and robustness.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

PR Summary
Phase 1: Port existing
ListViewbased implementation to v2.Remaining Work
Phase 2: Refactor to use
TableViewinstead ofListView.This will both simplify the implementation, but improve usability, perf, and scalability.
PR Context
Terminal.GuiV2 #249