Commit Graph

8492 Commits

Author SHA1 Message Date
Tig
eba9bb63c8 Merge pull request #4688 from gui-cs/copilot/fix-mouse-event-routing-issue 2026-02-06 16:35:54 -07:00
Copilot
f2d260a853 Add TryGetSource extension methods for WeakReference<View> access (#4694)
* 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>
2026-02-06 14:44:04 -07:00
Tig
87f4845537 Merge branch 'v2_develop' into copilot/fix-mouse-event-routing-issue 2026-02-06 14:43:21 -07:00
BDisp
83ea4a427d Fixes #4683. DynamicStatusBar is broken (#4684)
* Fixes #4683. DynamicStatusBar is broken

* Replace to Key and avoid clear key button to close dialog
2026-02-06 14:42:29 -07:00
Copilot
b43390a070 Fixes #4677 - Refactors DimAuto for less coupling and improves performance (#4678)
* 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>
2026-02-06 12:33:47 -07:00
Tig
69e14401b9 Use CachedViewsUnderMouse in HandleAutoGrabPress; skip disabled SubViews
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>
2026-02-06 11:31:11 -07:00
Tig
002ce88883 Cleanup 2026-02-06 11:11:40 -07:00
Tig
e8afa96fc9 Merge branch 'v2_develop' into copilot/fix-mouse-event-routing-issue 2026-02-06 10:55:15 -07:00
Tig
35dc4a441a Merge branch 'v2_develop' of tig:gui-cs/Terminal.Gui into v2_develop 2026-02-06 10:54:25 -07:00
Tig
653c1bfe94 Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop 2026-02-06 10:54:07 -07:00
copilot-swe-agent[bot]
bce23ff512 Use existing GetViewsUnderLocation instead of custom GetDeepestSubviewAtPosition
Co-authored-by: tig <585482+tig@users.noreply.github.com>
2026-02-06 17:05:17 +00:00
copilot-swe-agent[bot]
80d7f9e13a Fix code style: use SubView/SuperView terminology and explicit types per AGENTS.md
Co-authored-by: tig <585482+tig@users.noreply.github.com>
2026-02-06 17:00:08 +00:00
copilot-swe-agent[bot]
5084b5a138 Add tests and implement fix for MouseHighlightStates mouse event interception bug
Co-authored-by: tig <585482+tig@users.noreply.github.com>
2026-02-06 16:51:22 +00:00
copilot-swe-agent[bot]
eeb6fa7912 Initial plan 2026-02-06 16:42:59 +00:00
Tig
e9976da95e Reapply "Merge branch 'v2_develop' of tig:gui-cs/Terminal.Gui into v2_develop"
This reverts commit 845c05ff47.
2026-02-06 08:57:29 -07:00
Tig
845c05ff47 Revert "Merge branch 'v2_develop' of tig:gui-cs/Terminal.Gui into v2_develop"
This reverts commit 8c4030aed6, reversing
changes made to 280d6a5c1f.
2026-02-06 08:41:02 -07:00
Tig
8c4030aed6 Merge branch 'v2_develop' of tig:gui-cs/Terminal.Gui into v2_develop 2026-02-06 08:37:12 -07:00
Tig
1f1b109f9f Merge branch 'gui-cs:v2_develop' into v2_develop 2026-02-05 16:26:53 -07:00
Tig
b697cfb421 Merge pull request #4685 from tig/Terminal.Gui-pressed-mousebinding-4674 2026-02-04 21:31:23 -07:00
Tig
95b5bf61a9 Merge branch 'v2_develop' into Terminal.Gui-pressed-mousebinding-4674 2026-02-04 16:28:09 -07:00
Tig
5823ee9203 Merge branch 'gui-cs:v2_develop' into v2_develop 2026-02-04 10:03:39 -07:00
BDisp
78b5623dec Fixes #4672. OptionSelector is not behaving properly with keyboard. (#4673)
* 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>
2026-02-04 10:03:29 -07:00
Tig
861591146c Refactor test code: explicit types, input injection, cleanup
- 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
2026-02-04 09:48:49 -07:00
Tig
83b579ec7b Update default mouse activation to LeftButtonReleased
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.
2026-02-03 18:13:21 -07:00
Tig
d2f7271739 Changes Made:
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!
2026-02-03 12:39:30 -07:00
Tig
d44cf5c6a0 cleanup 2026-02-03 11:42:59 -07:00
Tig
d1b7a8885d Fix MouseBinding for xxxReleased flags and add tests
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.
2026-02-03 11:39:54 -07:00
Tig
e09f591fdd Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop 2026-02-03 10:21:14 -07:00
Tig
fe396332b7 Merge branch 'gui-cs:v2_develop' into v2_develop 2026-02-03 10:09:57 -07:00
Tig
8234e8b4b8 updated plan 2026-02-03 10:04:02 -07:00
Tig
039d09a890 merged 2026-02-03 09:59:59 -07:00
Tig
f221fa122e merged 2026-02-03 09:59:17 -07:00
Tig
26edd99cc4 code cleanup 2026-02-03 09:58:28 -07:00
Tig
b015c5706b Merge branch 'v2_develop' into copilot/remove-coupling-from-dimauto 2026-02-03 09:52:32 -07:00
copilot-swe-agent[bot]
e60ea61b26 Phase 4: Add GetMinimumContribution method to reduce DimAuto coupling
Co-authored-by: tig <585482+tig@users.noreply.github.com>
2026-02-03 16:31:18 +00:00
Copilot
b0243dd780 Add mouse click helper methods to InputInjectionExtensions (#4679)
* 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>
2026-02-03 09:20:18 -07:00
Tig
f25eaba22e Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop 2026-02-03 08:40:43 -07:00
Tig
3b486a92f0 Merge branch 'gui-cs:v2_develop' into v2_develop 2026-02-03 08:40:29 -07:00
Copilot
6c957c678a Skip flaky ProcessQueue_DoesNotReleaseEscape_BeforeTimeout test (#4681)
* Initial plan

* Skip ProcessQueue_DoesNotReleaseEscape_BeforeTimeout test due to flakiness

Co-authored-by: tig <585482+tig@users.noreply.github.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>
2026-02-03 08:40:22 -07:00
Tig
05beb302bd Merge branch 'v2_develop' into copilot/remove-coupling-from-dimauto 2026-02-03 08:35:05 -07:00
Tig
11518929df Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop 2026-02-03 08:34:04 -07:00
Tig
50370af489 Merge branch 'gui-cs:v2_develop' into v2_develop 2026-02-03 08:33:54 -07:00
Copilot
30a1db4b73 Add unit tests for View command behavior documentation (#4670)
* 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>
2026-02-03 08:33:43 -07:00
Tig
b1f9ea4c83 Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop 2026-02-03 08:13:43 -07:00
copilot-swe-agent[bot]
3ae55d9125 Phase 3: Add CanContributeToAutoSizing property and use in DimAuto
Co-authored-by: tig <585482+tig@users.noreply.github.com>
2026-02-03 15:13:02 +00:00
Tig
2a5ef9f8b8 Merge branch 'gui-cs:v2_develop' into v2_develop 2026-02-03 08:12:59 -07:00
Tig
55308023f1 Merge branch 'v2_develop' into copilot/remove-coupling-from-dimauto 2026-02-03 07:55:53 -07:00
Tig
712402632a Add View command behaviors table to command.md (#4669)
* 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>
2026-02-03 07:55:03 -07:00
copilot-swe-agent[bot]
0a675fc557 Use DependsOnSuperViewContentSize in DimAuto and fix PosCenter/PosPercent semantics
Co-authored-by: tig <585482+tig@users.noreply.github.com>
2026-02-03 04:10:00 +00:00
copilot-swe-agent[bot]
8bb1d24947 Add DependsOnSuperViewContentSize property to Dim and Pos base classes
Co-authored-by: tig <585482+tig@users.noreply.github.com>
2026-02-03 04:02:59 +00:00