Commit Graph

8049 Commits

Author SHA1 Message Date
tznind
323c624046 WIP: Add fluent assertions and prototype the kind of things that should be possible 2025-03-21 08:18:46 +01:00
tznind
c511101dfe Investigate fluent assertions for testing v2 2025-03-21 08:18:46 +01:00
BDisp
8b5639e5e5 Using SubViews and letting the top-level handle the key if the TabView doesn't handle it 2025-03-21 08:17:37 +01:00
BDisp
2ed7bb76c3 Fixes #3974. TabView steals keypresses from active ContextMenu 2025-03-21 08:17:37 +01:00
Tonttu
9735d8c584 Consistent kilobyte unit in comments v2.0.0-develop.4376 2025-03-17 16:17:46 +01:00
Tonttu
cf2645fa04 StringExtensions.ToString(IEnumerable<Rune>) use rented array as alternative buffer 2025-03-17 16:17:46 +01:00
Tonttu
9b78961a03 StringExtensions.ToString(IEnumerable<Rune>) remove extra rune chars copy 2025-03-17 16:17:46 +01:00
Tonttu
2e4e73a436 Rewrite TextFormatter.RemoveHotKeySpecifier
Uses stackalloc char buffer with fallback to rented array.
2025-03-17 16:17:46 +01:00
Tonttu
5ab51fc08b StringExtensions.ToString(IEnumerable<Rune>) stackalloc char buffer with StringBuilder fallback 2025-03-17 16:17:46 +01:00
Tonttu
b6a5ca1d4e Rewrite StringExtensions.ToString(IEnumerable<Rune>)
Appends rune chars to StringBuilder avoiding intermediate string allocation for each rune append.
2025-03-17 16:17:46 +01:00
Tonttu
aeffe3e36e Add benchmark category to the TextFormatter benchmarks 2025-03-17 16:17:46 +01:00
Tonttu
662e745395 Rewrite TextFormatter.ReplaceCRLFWithSpace
Almost identical to the StripCRLF implementation.
2025-03-17 16:17:46 +01:00
Tonttu
7d317ba550 StripCRLF early exit when no newline to avoid StringBuilder allocation 2025-03-17 16:17:46 +01:00
Tonttu
40d4cab510 More varied text permutations for the StripCRLF benchmark 2025-03-17 16:17:46 +01:00
Tonttu
6f63dca591 Rewrite TextFormatter.StripCRLF
Uses StringBuilder and char span indexof search to reduce intermediate allocations.

The new implementation behaves slightly different compared to old implementation. In synthetic LFCR scenario it is correctly removed while the old implementation left the CR, which seems like an off-by-one error.
2025-03-17 16:17:46 +01:00
Tonttu
c4502b0741 Add tests for TextFormatter StripCRLF and ReplaceCRLFWithSpace
Also made the helper methods internal so they can be accessed from the test project.
2025-03-17 16:17:46 +01:00
Tig
384cefcdf1 Merge branch 'v2_develop' of tig:gui-cs/Terminal.Gui into v2_develop v2.0.0-develop.4375 2025-03-17 15:59:37 +01:00
BDisp
56c8b20e24 Fixes #3986. ContextMenu crashing with right and left arrows 2025-03-17 07:39:19 +01:00
Tig
726770f6ee Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop v2.0.0-develop.4374 2025-03-16 20:45:34 +01:00
BDisp
76a14d456d Fixes #3986. ContextMenus now broken in v2 net and win drivers (#3987) 2025-03-16 07:51:35 +01:00
Tig
f84c528449 Merge branch 'v2_develop' of tig:gui-cs/Terminal.Gui into v2_develop 2025-03-13 18:18:00 +01:00
Tig
ce7fc04100 Fixes #3984 - Margin w/out shadow should not force draw (#3985)
* shortcut tests

* Generic demos

* Optimize Margin to not defer draw if there's no shadow
2025-03-13 18:16:53 +01:00
Tonttu
b09b4e78bd Fix Cell.CombiningMarks property getter rune list allocation (#3980)
* Skip rune list allocation from accessing Cell.CombiningMarks property

The getter would every time allocate a new list when the backing field was not assigned, which is most of the time.

* Fix comment about performance

I accidentally word. Is this dangerous?
2025-03-13 18:15:49 +01:00
BDisp
7aae0c2ad5 Fixes #3968. Menu appears in wrong place when opened in a subview (#3979)
* Fixes #3968. Menu appears in wrong place when opened in a subview

* Fixes #3965. Cannot exit a Window with a CanFocus true MenuBar

* Fixes #3981. Drivers crash when middle or right click on a ContextMenu item

---------

Co-authored-by: Tig <tig@users.noreply.github.com>
2025-03-13 18:15:14 +01:00
Tonttu
ef20ff68a9 Reduce string allocations in IConsoleOutput implementations (#3978)
* Change IConsoleOutput.Write(string) overload parameter to ReadOnlySpan<char>

Allows the caller more flexibility about choosing a buffer per use case.

* NetOutput: Write StringBuilder directly to the std out text stream

* Add EscSeqUtils.CSI_WriteCursorPosition

Writes cursor position sequence to text writer without string allocation.

* NetOutput: Skip cursor position escape sequence string allocation

* Replace CSI_(Enable|Disable)MouseEvents static properties with readonly fields

Changed for the sake of consistency with rest of the EscSegutils fields rather than performance. Also prevents bugs from accidentally setting the properties.

* Use EscSeqUtils.CSI_Append(Foreground|Background)ColorRGB in v2 drivers

* WindowsOutput SetCursorVisibility: Remove intermediate string builder

* WindowsOutput.WriteToConsole: Use rented array as intermediate write buffer

The large intermediate string builder remains a challenge. :)

* NetOutput: Console.Out for the sake of consistency

Also might have missed one of the Console.Out.Write(StringBuilder) calls...

* Avoid Rune.ToString() in NetOutput.Write(IOutputBuffer)

---------

Co-authored-by: Tig <tig@users.noreply.github.com>
2025-03-13 18:14:22 +01:00
Tig
0831b162a1 Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop 2025-03-13 08:00:30 +01:00
BDisp
af633fc4fc Fixes #3976. SixLabors.ImageSharp nuget package is reporting as vulnerable (#3977)
* Fixes #3976. SixLabors.ImageSharp nuget package is reporting as vulnerable

* Upgrade all nuget packages
2025-03-09 20:08:26 -06:00
Tig
7c89a3a176 Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop 2025-03-09 13:46:41 -06:00
Tig
3794c34d30 shortcut tests 2025-03-09 13:46:35 -06:00
Tig
e0f61abf8a Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop 2025-03-09 09:57:43 -06:00
Tig
f29ec60176 Merge branch 'gui-cs:v2_develop' into v2_develop 2025-03-09 08:48:15 -06:00
BDisp
e76ec720a5 Fixes #3964. Null Reference in DoDrawBorderAndPadding (#3971)
* Fixes #3964. Null Reference in DoDrawBorderAndPadding

* Fix unit test.

* Ensures closing all opened menus that belong to another top when a new modal top is opened.

* Reformat

---------

Co-authored-by: Tig <tig@users.noreply.github.com>
2025-03-09 07:46:09 -06:00
Tig
3da22f8c70 Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop 2025-03-08 17:12:11 -07:00
Tig
4af7d06b37 Merge branch 'gui-cs:v2_develop' into v2_develop 2025-03-08 17:12:05 -07:00
Tig
4ad866eb26 Refactored to be thread safe. (#3973) 2025-03-08 17:11:30 -07:00
Tig
80f98878ee Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop 2025-03-08 15:50:09 -07:00
BDisp
f26fd285ce Fixes #3941. v2win/v2net: UICatalog full benchmark suite crashes in Dialogs scenario (#3963)
Co-authored-by: Tig <tig@users.noreply.github.com>
2025-03-08 15:49:54 -07:00
Tig
e01a98d852 Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop 2025-03-08 15:43:04 -07:00
Tig
acb5979e6c Cleans up/Refactors View.Subviews (#3962)
* Subview clean up

* New Add/Remove event pattern

* Using Logging

* cleanup

* Subview -> SubView

* Test code cleanup. Killed many warnings.

* Fix tznind feedback

* Refactored AllViewTest helpers

* Moved keyboard tests to parallel

* Moved mouse tests to parallel

* Moved view tests to parallel

* Test code cleanup. Killed many warnings.

* dupe test

* Some mouse tests can't run in parallel because MouseGrabView

* Made SpinnerView more testable

* Moved more tests

* SubViews to IReadOnlyCollection<View>

* SubViews to IReadOnlyCollection<View> 2

* scrollbar tests

* shortcut tests

* Use InternalSubViews vs. _subviews

* Nuked View.IsAdded.
Added View.SuperViewChanged.

* API doc updats

* Unit Test tweak

* Unit Test tweak
2025-03-08 15:42:17 -07:00
Tig
58610dedbc Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop 2025-03-08 13:48:53 -07:00
Tig
30fafb4625 Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop 2025-03-06 14:08:03 -07:00
BDisp
85cf6619ed Fixes #3956. MessageBox doesn't return the index of IsDefault button (#3958)
* Fixes #3956. MessageBox doesn't return the index of IsDefault button

* Change to Theory test.

* Fix unit test 'Error opening terminal: unknown.'

* Remove RunningUnitTests = true because constructor already set it.

---------

Co-authored-by: Tig <tig@users.noreply.github.com>
2025-03-06 14:06:51 -07:00
Thomas Nind
7162ed850c Fix v2 not raising closing events (#3961) 2025-03-06 13:14:15 -07:00
Tig
fe18c81dc9 Fixed gitversion 2025-03-06 12:48:44 -07:00
Tig
63e99d2ceb Fixed gitversion 2025-03-06 12:45:49 -07:00
Tig
aea90eb0b4 upgraded to gitversion 6 3 2025-03-06 12:37:23 -07:00
Tig
bfa95ac1db Remove invalid prevent-increment property 2025-03-06 11:57:30 -07:00
Tig
a5c38fd0c9 upgraded to gitversion 6 2 2025-03-06 11:42:13 -07:00
Tig
73e230b877 upgraded to gitversion 6 v2.0.0-prealpha.1 v2.0.0-prealpha.1830 2025-03-06 11:17:57 -07:00
Tig
e805023c1c upgraded to gitversion 6 2025-03-06 11:00:51 -07:00