Commit Graph

247 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
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
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
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
95b5bf61a9 Merge branch 'v2_develop' into Terminal.Gui-pressed-mousebinding-4674 2026-02-04 16:28:09 -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
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
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
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
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
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
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
BDisp
0f56a6c4f9 Replace synchronous with asynchronous unit tests (#4668) 2026-02-02 08:52:43 -07:00
Tig
80766514fd Fixes #4665 - Dim.Fill (to: x) is not working right - CollectDim needs updating (#4666) 2026-02-02 06:49:09 -07:00
Copilot
7f6ec52e1a Fixes #4658 - Extend Dim.Fill to support 'to:' parameter for filling up to another view (#4663)
* Initial plan

* docs: Create implementation plan for DimFill 'to:' parameter feature

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* feat: Add 'to:' parameter to Dim.Fill for filling up to another view

- Modified DimFill record to include optional 'To' parameter
- Updated Calculate method to use To view's position as endpoint
- Added ReferencesOtherViews override for proper dependency tracking
- Added three new Dim.Fill factory method overloads
- Added comprehensive unit tests (14 new tests, all passing)
- Includes test for issue #4656 example code

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* refactor: Address code review feedback

- Use StringBuilder for ToString() for better performance
- Use Dim.Absolute(0) instead of hardcoded 0 for consistency

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* docs: Update implementation plan with completion status

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* fix: Replace var with explicit types in DimFill tests per coding standards

- Changed all var declarations to explicit types (View, Label, Button, TextField)
- Used target-typed new () syntax as per Terminal.Gui coding standards
- Follows rule: Never use var except for built-in types (int, string, bool, etc.)

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* feat: Update DimAuto to handle DimFill with 'To' parameter for auto-sizing

- Modified DimAuto.Calculate to check for DimFill.To and contribute to auto-sizing
- When DimFill has To set, SuperView is sized to accommodate both views
- Updated comment in DimAuto.cs line 425 to mention To parameter
- Updated DimAuto XML docs to mention both MinimumContentDim and To
- Updated Dim.cs API documentation for all Fill methods regarding auto-sizing
- Added 5 comprehensive unit tests in Dim.AutoTests.DimTypes.cs
- All 400 Dim tests passing

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Refactor StatusBar visibility and height management

Replaces direct use of StatusBar.Visible with a static ShowStatusBar property and a StatusBarChanged event. StatusBar height is now set to Dim.Auto() or 0 based on ShowStatusBar, with Layout() called to update the UI. Updates related event handling and adjusts how categoryList and scenarioList heights are calculated. Includes minor formatting and initialization improvements.

* Fixed Config editor

* ViewportSettings

* shortcuts

* Adornments

* charmap

* FileDialog

* deleted plan

---------

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-01 14:32:01 -07:00
Tig
1c47614f45 Fixes #4660 - Scrollbars in TextView now correctly show typing + TextView Code cleanup (#4662) 2026-02-01 11:38:03 -07:00
BDisp
0822a2e6bc Fixes #4645. ListView should have a SourceChanged event (#4649) 2026-01-29 19:54:39 -07:00
Tig
0232ab2092 Merge branch 'v2_develop' into docs/popover-architecture 2026-01-28 12:32:11 -07:00
Tig
56078e5438 Added tests and fixed bugs found. 2026-01-28 12:29:11 -07:00
BDisp
9e7f08ee6d Fixes #4639. Flipping Orientation on Line changes Width/Height but doesn't flip back (#4642)
* On v2_4639_line-orientation-flip-back-fix: Fixes #4639. Flipping Orientation on Line changes Width/Height but doesn't flip back

* Ensuring change Length will update correct dimension based on orientation

* Fix bug by not setting Length when IsInitialized is true

---------

Co-authored-by: Tig <tig@users.noreply.github.com>
2026-01-28 10:07:18 -07:00
BDisp
80e99cdaa7 Fixes #4640. Images scenario is generating sixel data twice. (#4641) 2026-01-27 10:07:47 -07:00
BDisp
e8c1b976d1 Fixes #4625. Ansi and unix drivers doesn't work on macOS 26 ARM64 and x64 (#4630)
* Fixes #4625 - Ansi and unix drivers doesn't work on macOS 26 ARM64

* Using PlatformDetection for uni tests

* Remove IsFreeBSD from IsMac

---------

Co-authored-by: Tig <tig@users.noreply.github.com>
2026-01-26 14:26:01 -07:00
BDisp
040625f94f Fixes #4606. Sixel isn't working in the Images scenario (#4610)
* Fixes #4606. Sixel isn't working in the Images scenario

* Replace 6 with PIXEL_HIGH

* Only subtract if height is grater than 6

* Adjust code to not conflict with unit tests

* GetHeightInPixels only return 0 if maxSizeHeight is lower than 6 and AvoidBottomScroll is true

* Replace test with Theory and using AvoidBottomScroll property

* Add test forSixelToRender.Id property

* Fix GetHeightInPixels to be multiple of 6 after multiply the height by the pixel height.

---------

Co-authored-by: Tig <tig@users.noreply.github.com>
2026-01-26 14:20:59 -07:00
Tig
080b06dfda Fixes #4634 - Update Dim.Auto developer docs with more guidance (#4635)
* Fixes #4634 - Update Dim.Auto developer docs with more guidance

Add "How To" section to dimauto.md with non-trivial recipes drawn from
Shortcut, Dialog, Menu/Bar, and NumericUpDown (pin to natural size,
dynamic minimums, screen-clamped dialogs, uniform-width lists, nested
auto-sizing, and more).

Document the DimFill/DimAuto circular dependency pitfall (SubView gets
size 0) across all relevant XML API docs and the deep dive. Add deep
dive cross-references from DimAuto, Dim.Auto(), and DimAutoStyle XML
docs. Fix outdated claim that Dialog uses Dim.Percent(90). Update
layout.md Dim.Fill bullet with caveat.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Simplify mermaid classDiagram in layout.md for docfx compatibility

Replace `note for` syntax (unsupported by docfx's bundled mermaid) with
class label annotations. Remove empty class body declarations and let
relationships define nodes implicitly. All descriptive text now appears
as class display labels instead of separate notes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Attempt to addres intermittient GH workflow failures

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:42:53 -07:00
Tig
2d6f60cca6 Fixes #4615 - Clamps Dialog Frame size to container (#4632)
* fixed bug

* Refactor DialogTests and add sizing regression tests

- Refactored DialogTests.cs to use concise object and array initializers, improving readability and consistency.
- Added two regression tests to ensure Dialog sizing never exceeds screen/container bounds:
  - Dialog_Frame_Clamped_To_Container
  - Dialog_Height_Never_Exceeds_Screen_Height
- Updated drawing tests to use indented multiline string literals for expected output.
- Improved test output with additional debug info via ITestOutputHelper.
- Made minor code cleanups (e.g., variable declarations, property immutability).
- No changes to Dialog implementation; all updates are to test code only.
2026-01-26 10:18:20 -07:00
Tig
6df5c26784 Fixes #4623 - Makes SetNeedsDraw signal other sessions; fixes focus issue on 2nd runnables (#4626)
* New workflow that will analyze the dmp file on the macos runner.

* Fixes #4629 -

* Update Terminal.Gui/App/Keyboard/KeyboardImpl.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add redraw propagation and arrangement tests, refactor tests

Adds new tests to verify redraw propagation when moving views
and when multiple runnables are stacked, addressing issues
#4623 and #4629. Refactors existing tests in
BorderArrangementTests.cs and NeedsDrawTests.cs for clarity,
resource management, and consistency. Improves object
initialization, assertion messages, and removes unnecessary
code. Ensures redraw logic is robust in complex view
arrangements and improves overall test reliability.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-25 08:19:35 -07:00
Copilot
a4ce6fb4d3 Refactor MouseGrabView to WeakReference-based IsGrabbed() method (#4613)
* Initial plan

* Refactor MouseGrabView to WeakReference - Core implementation complete

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Replace MouseGrabView with IsGrabbed(view) in test files

Updated test files to use the new IsGrabbed(view) method instead of the deprecated MouseGrabView property:
- Assert.Equal(view, mouse.MouseGrabView) → Assert.True(mouse.IsGrabbed(view))
- Assert.Null(mouse.MouseGrabView) → Assert.False(mouse.IsGrabbed(anyView))
- mouse.MouseGrabView == view → mouse.IsGrabbed(view)
- mouse.MouseGrabView != view → !mouse.IsGrabbed(view)
- Updated method names and comments referencing MouseGrabView

Files updated:
- Tests/UnitTests/Application/Mouse/ApplicationMouseTests.cs
- Tests/UnitTestsParallelizable/ViewBase/Mouse/HighlightStatesTests.cs
- Tests/UnitTestsParallelizable/Application/RunTests.cs
- Tests/UnitTestsParallelizable/Application/Runnable/RunnableIntegrationTests.cs
- Tests/UnitTestsParallelizable/Application/ApplicationImplTests.cs
- Tests/UnitTestsParallelizable/Application/InitTests.cs
- Tests/UnitTests/View/Adornment/ShadowStyleTests.cs
- Tests/UnitTests/View/ArrangementTests.cs
- Tests/UnitTests/View/Mouse/MouseTests.cs

All tests pass successfully.

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Complete MouseGrabView refactoring - tests and documentation updated

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Fix mouse grab enter/leave logic - check grab state first

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Improve null-conditional pattern consistency for IsGrabbed calls

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Fix code style - use target-typed new() for WeakReference

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Code clean up and org.

* Code cleanup and better docs.

* Add IMouseGrabHandler.IsGrabbed() and related tests

Introduce a new parameterless IsGrabbed() method to IMouseGrabHandler, allowing checks for any active mouse grab regardless of view. Implement this method in MouseImpl, using WeakReference to determine grab state. Add comprehensive unit tests in ApplicationMouseTests and MouseInterfaceTests to verify correct behavior across grab, ungrab, disposal, and state reset scenarios. Also, perform minor code cleanups in MouseInterfaceTests.cs for clarity and consistency.

* 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-01-25 07:25:02 -07:00
Tig
f4d36ad9a9 Refactor ListView selection/marking logic and tests
- Clarified and unified ListView selection and marking logic for all four ShowMarks/MarkMultiple combinations (standard, hidden marks, radio button, checkbox).
- Moved command and key/mouse binding setup to new SetupBindingsAndCommands method in ListView.Commands.cs.
- Refactored mouse and keyboard event handling to ensure correct marking/selection behavior for all input types and modes.
- Improved and documented marking methods (MarkUnmarkSelectedItem, MarkAll, UnmarkAll, UnmarkAllButSelected) with clear behavior for each mode.
- Updated and expanded unit tests, including new ListViewTests_Combinations.cs for comprehensive coverage of all combinations and transitions.
- Improved code organization, comments, and documentation throughout for maintainability and clarity.
- Result: more robust, predictable, and testable ListView selection/marking system.
2026-01-23 15:57:13 -07:00
Tig
dfcb576a61 Refactor ListView marking API: ShowMarks & MarkMultiple
Renamed AllowsMarking → ShowMarks and AllowsMultipleMarking → MarkMultiple for clarity. ShowMarks now controls mark glyph visibility; MarkMultiple controls checkbox vs radio button behavior. Updated all usages, docs, UI, and tests. Refactored drawing logic for all combinations. IListDataSource and related comments updated for new terminology. Improves API clarity and marking flexibility.
2026-01-23 13:18:40 -07:00
Tig
43e9af77c6 partial progress 2026-01-23 12:06:51 -07:00
Tig
fef282c8f3 Fixed #4617 - Synthesized mouse clicks are not including shift/ctrl keys 2026-01-22 15:37:12 -07:00
Tig
e547b117ae Add viewport overscroll flags and improve clamping logic
Introduce AllowXPlusWidthGreaterThanContentWidth, AllowYPlusHeightGreaterThanContentHeight, and AllowLocationPlusSizeGreaterThanContentSize flags to enable viewport overscroll and blank space beyond content. Update clamping logic in View to respect these flags. Refactor ViewportSettingsFlags enum for clarity. Enable overscroll by default in TextView. Update and expand tests to cover new behaviors and ensure backward compatibility.
2026-01-22 13:23:03 -07:00
Tig
a8d19af804 Merge branch 'v2_develop' into fix/4580_ListView 2026-01-22 10:47:48 -07:00
Tig
aba24a3bc5 Standardize IValue<T> interface across value-bearing Views (#4601)
* New workflow that will analyze the dmp file on the macos runner.

* Add IValue<T> implementation plan document

Documents the plan to standardize IValue<T> interface across all
value-bearing Views, including:
- Non-generic IValue interface for command propagation
- Classification of Views that should/shouldn't implement IValue<T>
- Phased implementation approach
- Testing strategy

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add non-generic IValue interface

Phase 1 of IValue standardization:
- Add IValue interface with GetValue() method for boxed value access
- Update IValue<T> to inherit from IValue
- Add default implementation: IValue.GetValue() => Value
- Add unit tests for GetValue() and polymorphic usage

This enables command propagation to carry values without knowing
the generic type, supporting CommandContext.Value population.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* NumericUpDown implements IValue<T> with CWP events

- NumericUpDown<T> now implements IValue<T>
- Changed events from CancelEventArgs<T>/EventArgs<T> to
  ValueChangingEventArgs<T>/ValueChangedEventArgs<T>
- Added virtual OnValueChanging and OnValueChanged methods
- Updated UICatalog scenarios for new event signatures
  - Changed .Cancel to .Handled
  - Updated event handler type arguments

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Implement IValue on CheckBox, TextField, and SelectorBase

- CheckBox implements IValue with GetValue() returning CheckedState
- TextField implements IValue with GetValue() returning Text
- SelectorBase implements IValue with GetValue() returning Value (int?)
- OptionSelector<TEnum> overrides GetValue() to return typed enum value
- FlagSelector<TFlags> overrides GetValue() to return typed flags value
- Added unit tests for all IValue implementations

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Implement IValue<T> on remaining value-bearing Views

- ScrollBar: IValue<int> mapping to Position
- DateField: IValue<DateTime?> mapping to Date
- TimeField: IValue<TimeSpan> mapping to Time
- DatePicker: IValue<DateTime> mapping to Date
- ListView: IValue<int?> mapping to SelectedItem
- CharMap: IValue<Rune> mapping to SelectedCodePoint

Also updates ValueChangedEventArgs usage from .Value to .NewValue
across UICatalog scenarios and tests.

Updates ivalue-implementation-plan.md with:
- Completion status for all implementations
- Detailed analysis of LinearRange<T> design challenges

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* cleanup

* revised

* 1. CheckBox - Removed CheckedState, CheckedStateChanging, CheckedStateChanged. Now uses Value, ValueChanging, ValueChanged.
  2. ScrollBar - Removed Position, PositionChanging, PositionChanged. Now uses Value, ValueChanging, ValueChanged.
  3. DateField - Removed Date, DateChanged. Now uses Value, ValueChanged.
  4. TimeField - Removed Time, TimeChanged. Now uses Value, ValueChanged.
  5. DatePicker - Removed Date property. Now uses Value.
  6. ListView - Removed SelectedItemChanged. Now uses ValueChanged. SelectedItem is kept as a semantic alias for Value.
  7. CharMap - Removed SelectedCodePointChanged. Now uses ValueChanged. SelectedCodePoint is kept as a semantic alias for Value.
  8. ColorPicker - Removed ColorChanged. Now uses ValueChanged. SelectedColor is kept as a semantic alias for Value.
  9. ColorPicker16 - Added IValue<ColorName16> implementation with Value, ValueChanging, ValueChanged.

  Files Updated Across Codebase

  - Examples: UICatalogRunnable.cs, TimeAndDate.cs, ScrollBarDemo.cs, CharacterMap.cs, Wizards.cs, Scrolling.cs, Themes.cs,
  TextInputControls.cs, PromptExample/Program.cs, and many scenario files
  - Tests: CheckBoxTests.cs, ScrollBarTests.cs, TimeFieldTests.cs, DateFieldTests.cs, DatePickerTests.cs, IValueTests.cs, and
  others

  Event Args Changes

  - CheckedStateChangingEventArgs → ValueChangingEventArgs<CheckState> with NewValue (not Result)
  - CheckedStateChangedEventArgs → ValueChangedEventArgs<CheckState> with NewValue (not Value)
  - Similar pattern for all other views

* Code cleanup

* fixed merge issues

* Fixed regression

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 10:41:17 -07:00