-
Notifications
You must be signed in to change notification settings - Fork 745
Fixes #4595 - Refactors View.Command, CommandContext, and InputBinding to simplify
#4596
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
Open
tig
wants to merge
14
commits into
gui-cs:v2_develop
Choose a base branch
from
tig:fix/commandcontext_refactor
base: v2_develop
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.
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
Co-authored-by: tig <585482+tig@users.noreply.github.com>
- Added `Source` to `KeyBinding` and `MouseBinding` - Renamed `MouseBinding.MouseEventArgs` → `MouseEvent` - Updated 15+ files with call site changes - Updated documentation (mouse.md, events.md)
…, Source, MouseEvent, pattern matching - `KeyBindingTests.cs` - 17 tests covering constructor, properties, Source, Target, Key, pattern matching - `CommandContextTests.cs` - 13 tests covering ICommandContext, pattern matching, Source propagation
- [x] Create `InputBinding` record struct - [x] Add `Binding` property to `ICommandContext` - [x] Rename `CommandContext<T>.Binding` → `TypedBinding` (strongly-typed access) - [x] Add computed `Binding` property to `CommandContext<T>` for interface compliance - [x] Update all call sites from `.Binding` to `.TypedBinding`
…inding.cs`
- Added `IInputBinding? Binding { get; }` property to `ICommandContext` interface
- Renamed `CommandContext<T>.Binding` to `TypedBinding` for strongly-typed access
- Added computed `Binding` property: `IInputBinding? Binding => TypedBinding`
- Updated 20+ files to use `.TypedBinding` instead of `.Binding`
- Created `InputBindingTests.cs` - 19 tests covering constructor, properties, IInputBinding, pattern matching
- Updated `CommandContextTests.cs` - added 6 tests for new `Binding` property
- All 34 binding-related tests pass
This comment was marked as outdated.
This comment was marked as outdated.
View.Command, CommandContext, and InputBinding` to simplify View.Command, CommandContext, and InputBinding to simplify
10 tasks
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.
Fixes
View.Command,CommandContext, andInputBindingto simplify #4595Menuetc. withSelectorsare broken - Formalize/FixCommandpropagation #4473This pull request refactors Terminal.Gui's command and input binding system to simplify the API by removing generic type parameters from
CommandContextand introducing polymorphic access to bindings through pattern matching. The refactoring eliminates the complexCommandContext<TBindingType>generic in favor of a simpler non-genericCommandContextwith anIInputBinding? Bindingproperty that can be pattern-matched.Changes:
CommandContext<TBindingType>generic with non-genericCommandContextcontainingIInputBinding? BindingInputBindingrecord struct for programmatic command invocations alongside existingKeyBindingandMouseBindingMouseBinding.MouseEventArgstoMouseBinding.MouseEventfor consistencyCommandContext<MouseBinding>toctx?.Binding is MouseBindingSee #4595