* Initial plan
* CommandContext infrastructure: WeakReference and extension methods
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Align CommandContext infrastructure with PR #4620
- Update ViewExtensions.cs to use Terminal.Gui.ViewBase namespace
- Update WeakReferenceExtensions.cs to match PR #4620 format
- Change CommandContext constructor to take WeakReference<View>? directly
- Add CommandContext.ToString() implementation
- Update ICommandContext.Source documentation
- Update View.Command.cs to explicitly create WeakReference
- Update Shortcut.cs to handle WeakReference Source
- Update ComboBox.cs Source comparison
- Update Dialog.cs and DialogTResult.cs pattern matching
- Update MenuBar.cs and PopoverMenu.cs to work with WeakReference
- Update ScrollSlider.cs and OptionSelector.cs
Remaining: Fix Examples code and tests
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Fix Examples code for WeakReference Source
- Update UICatalogRunnable.cs to use TryGetTarget for Data access
- Update Menus.cs to use ToIdentifyingString() and TryGetTarget
- Update MouseTester.cs to use ToIdentifyingString() for all Source.Id access
All Examples now build successfully
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Update tests for WeakReference Source
- Fix CommandContextTests.cs to wrap Source in WeakReference
- Fix InputBindingTests.cs to wrap Source in WeakReference
- Update assertions to use TryGetTarget for safe access
- All CommandContext and InputBinding tests pass
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Add TryGetSource extension methods and replace usage
- Add TryGetSource extension to WeakReferenceExtensions.cs
- Add CommandContextExtensions.cs with TryGetSource for ICommandContext
- Replace 14 instances of Source?.TryGetTarget pattern across codebase
- Updated Terminal.Gui files: ComboBox, Dialog, DialogTResult, MenuBar, PopoverMenu, OptionSelector, Shortcut
- Updated Examples files: UICatalogRunnable, Menus
- All files build successfully
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Add tests for TryGetSource extension methods
- Add 6 tests for TryGetSource extension methods
- Test WeakReference<View>.TryGetSource with valid/null references
- Test ICommandContext.TryGetSource with valid/null contexts
- Test pattern matching usage with TryGetSource
- All 23 CommandContext tests pass
- Full test suite: 15,094 passed
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* code cleanup
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tig <585482+tig@users.noreply.github.com>
Co-authored-by: Tig <tig@users.noreply.github.com>
* Phase 5: Add IsFixed and RequiresTargetLayout categorization properties
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Further simplify DimAuto.Calculate using IsFixed property
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Refactor for-loops to foreach and clarify DimFill logic
Refactored multiple for-loops iterating over view lists to use foreach loops for improved readability and reduced boilerplate. Removed unused variables such as viewsNeedingLayout and index counters. Clarified DimFill handling by continuing early if the DimFill is not valid or lacks a To property, reducing nesting and improving intent. Made minor formatting and code style improvements for consistency.
* Refactor subview filtering and sizing logic
Refactored repeated LINQ queries for subview filtering into reusable helper methods (`GetViewsThatMatch`, `GetViewsThatHavePos<TPos>`, `GetViewsThatHaveDim<TDim>`), reducing duplication and improving readability. Moved max content size calculations for various subview types into new helper methods (`GetMaxSizePos<TPos>`, `GetMaxSizeDim<TDim>`). Updated main logic to use these helpers. Adornment thickness calculation now uses a switch expression. These changes improve modularity and maintainability.
* Refactor subview categorization for layout calculation
Refactored layout calculation to use a single-pass CategorizeSubViews method, grouping subviews by relevant Pos/Dim types into a new CategorizedViews struct. This replaces multiple helper methods and reduces redundant iterations. Updated main logic to use these categorized lists, and unified size calculation helpers to further reduce code duplication. Improves performance and maintainability by consolidating subview processing and removing obsolete methods.
* Revert perf POC commits and add missing overrides to Combine types
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Add helper methods and simplify DimAuto.Calculate with foreach loops
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Refactor layout calculation in DimAuto.cs
Removed commented-out code and unnecessary list declarations to clean up the layout calculation logic.
* removed old plan file
* Code cleanup
* Add performance analysis and improvement plan for DimAuto.Calculate
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Add DimAuto benchmarks and benchmark documentation
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Implement Phase 1 & 2 performance optimizations for DimAuto.Calculate
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Code cleanup
* Delete plans/dimauto-perf-plan.md
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tig <585482+tig@users.noreply.github.com>
Co-authored-by: Tig <tig@users.noreply.github.com>
Replace the redundant GetViewsUnderLocation call with a read from the
already-populated CachedViewsUnderMouse. Walk the cache backwards to
find the deepest *enabled* view, so disabled SubViews don't block the
SuperView from grabbing the mouse.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* menu deep dive
* Fixes#4672. OptionSelector is not behaving properly.
* Add NoStop to CheckBox and TextField. Replace commands for Down, Right, Up and Left
* Using navigation based on orientation
* Fixed ShowValue issue and code cleanup
* Refactor selector navigation tests, remove arrow key tests
Renamed the Tab/Shift+Tab navigation test for clarity and switched to using the ANSI driver. Removed cleanup code involving SessionToken. Deleted the test covering arrow key navigation within OptionSelector, so tests now only verify focus movement into and out of the selector using Tab and Shift+Tab. Arrow key navigation within the selector is no longer tested.
---------
Co-authored-by: Tig <tig@users.noreply.github.com>
- Consolidate ColorPicker16 tests into ColorPickerTests.cs
- Replace target-typed new and tuple-style constructors with explicit types (e.g., new Mouse, new Rectangle)
- Refactor mouse event simulation to use Mouse objects and Application input injection methods
- Improve test setup with VirtualTimeProvider and IApplication for isolation
- Remove redundant Clicking_On_Border_Is_Ignored test from ListViewTests
- Use new string(' ', n) for string construction
- Make variable initializations more explicit for clarity
- Modernize and clarify test code for maintainability and compatibility
Changed default Activate binding from LeftButtonPressed to LeftButtonReleased (issue #4674). Updated all affected tests to reflect new behavior: Activating now fires on release, not press. Adjusted assertions, test names, and mouse event simulation. Custom binding logic now uses ReplaceCommands for Released. Comments clarify new default; focus still set on press, activation on release.
1. Terminal.Gui/ViewBase/Mouse/View.Mouse.cs (Core Change)
- Changed default binding from LeftButtonPressed to LeftButtonReleased (lines 17-19)
- Updated MouseHoldRepeat logic to restore Released binding when disabled (line 268)
- Updated HandleAutoGrabRelease to support cancellation (only invoke commands if released inside viewport)
- Updated command invocation logic to prevent double-invocation
2. docfx/docs/command.md (Documentation)
- Updated Mouse → Command Pipeline table to reflect new default
- Updated View Command Behaviors table (Released column now shows Command.Activate)
- Added comprehensive note (#11) explaining cancellation behavior and how to revert to old behavior
3. Tests/UnitTestsParallelizable/ViewBase/Mouse/DefaultActivationTests.cs (New Tests)
- Created 13 comprehensive tests (all passing ✅)
- Tests cover: default behavior, cancellation, auto-grab, MouseHoldRepeat, backward compatibility
Test Results:
- ✅ 13/13 new DefaultActivationTests pass
- ⚠️ 6 existing MouseTests need updating (they test old Pressed behavior)
- These are expected failures due to the breaking change
Next Steps:
The implementation is functionally complete. To finish:
1. Update the 6 failing tests in MouseTests.cs to expect Released instead of Pressed
2. Run full test suite to identify any other affected tests
3. Manual testing with UICatalog recommended
The new behavior is working correctly - buttons now activate on release (with cancellation support), matching industry
standards!
Fixes issue #4674 where MouseBinding for xxxReleased (e.g., LeftButtonReleased) did not invoke bound commands due to logic in HandleAutoGrabRelease. Now, custom Released bindings are properly invoked regardless of MouseHoldRepeat. Refactored MouseTester demo for clarity and explicit command binding. Added a detailed test plan (PLAN.md) and new MouseReleasedBindingTests covering basic, AutoGrab, and multiple-command Released scenarios. Improves reliability and test coverage for mouse Released event handling in Terminal.Gui.
* Initial plan
* Add mouse click helper methods to InputInjectionExtensions with tests
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Update existing tests to use new mouse click helpers
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Add issue scenario validation test
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Document mouse click helper methods in input-injection.md and mouse.md
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Refactor input injection helpers and consolidate tests
Refactored InputInjectionExtensions methods to use expression-bodied members for conciseness. Simplified object initializations and variable declarations in test files. Consolidated and restored all input injection helper tests into a new InputInjectionExtensionsTests.cs under the InputTests namespace, removing redundant and duplicate test files. Added targeted tests for GitHub issue #4675. These changes improve code clarity, maintainability, and test coverage.
* add ref to input docs
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tig <585482+tig@users.noreply.github.com>
Co-authored-by: Tig <tig@users.noreply.github.com>
* Add View command behaviors table to command.md
Documents how each View subclass handles Activate, Accept, and HotKey
commands. The table provides a reference for understanding what user
actions trigger each command/event in specific views.
Includes:
- 27 View subclasses documented
- User actions mapped to commands (Space/Click, Enter/Double-Click, Alt+Key)
- Notes explaining composite views, display-only views, and special cases
https://claude.ai/code/session_01YX1NAzjQFB6Yii4V1Y6GXM
* Add test plan for View command behavior unit tests
Creates a comprehensive plan for adding/improving unit tests to verify
current Activate, Accept, and HotKey command behaviors for all View
subclasses.
Key features:
- Documents 26 Views with specific test cases for each
- Includes test templates with required comments referencing command.md
- Organized by implementation priority (5 phases)
- Each test must reference the View Command Behaviors table in command.md
- Tests serve as behavioral specifications before upcoming changes (#4473)
https://claude.ai/code/session_01YX1NAzjQFB6Yii4V1Y6GXM
* Initial plan
* Add Phase 1 command behavior tests (Button, CheckBox, TextField, ListView, TableView)
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Remove accidental TestPattern directory
* Add TreeView and TextView command behavior tests
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Add Phase 2 and 3 command behavior tests (Shortcut, Selectors, Dialog, Label, ProgressBar)
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Add Phase 4 command behavior tests (Wizard, HexView, NumericUpDown, DatePicker, ColorPicker, ScrollBar, Bar)
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Add final remaining command behavior tests (Menu, MenuItem, MenuBar, ComboBox, TabView, SpinnerView)
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Code cleanup
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tig <585482+tig@users.noreply.github.com>
Co-authored-by: Tig <tig@users.noreply.github.com>
* Add View command behaviors table to command.md
Documents how each View subclass handles Activate, Accept, and HotKey
commands. The table provides a reference for understanding what user
actions trigger each command/event in specific views.
Includes:
- 27 View subclasses documented
- User actions mapped to commands (Space/Click, Enter/Double-Click, Alt+Key)
- Notes explaining composite views, display-only views, and special cases
https://claude.ai/code/session_01YX1NAzjQFB6Yii4V1Y6GXM
* Add test plan for View command behavior unit tests
Creates a comprehensive plan for adding/improving unit tests to verify
current Activate, Accept, and HotKey command behaviors for all View
subclasses.
Key features:
- Documents 26 Views with specific test cases for each
- Includes test templates with required comments referencing command.md
- Organized by implementation priority (5 phases)
- Each test must reference the View Command Behaviors table in command.md
- Tests serve as behavioral specifications before upcoming changes (#4473)
https://claude.ai/code/session_01YX1NAzjQFB6Yii4V1Y6GXM
---------
Co-authored-by: Claude <noreply@anthropic.com>