Commit Graph

145 Commits

Author SHA1 Message Date
Tonttu
9735d8c584 Consistent kilobyte unit in comments 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
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
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
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
98f70b2632 Adds ViewportSettings.Transparent (#3886) 2025-03-01 15:22:23 -07:00
Thomas Nind
c88c772462 Fixes #3692++ - Rearchitects drivers (#3837) 2025-02-28 12:09:29 -07:00
BDisp
80306c64c3 Fixes #3885. ableView's CollectionNavigator sometimes doesn't work right. (#3933) 2025-02-27 20:55:38 -07:00
Tonttu
35522cc517 Reduce func allocations (#3919)
* Replace Region.Contains LINQ lambdas with foreach loop

Removes the lambda func allocations caused by captured outer variables.

* Replace LineCanvas.Has LINQ lambda with foreach loop

* Fix LineCanvas.GetMap intersects array nullability

It should be enough to add null-forgiving operator somewhere in the LINQ query to make the final result non-null. No need to shove the nullability further down the line to complicate things. :)

* Replace LineCanvas.All LINQ lambda with foreach loop

* Replace Region.Intersect LINQ lambdas and list allocation with foreach loop and rented array

* Use stackalloc buffer in Region.Intersect when max 8 rectangles

* Fix LineCanvas.GetCellMap intersects array nullability

* Remove leftover LineCanvas.GetRuneForIntersects null-conditional operators

* Remove leftover IntersectionRuneResolver.GetRuneForIntersects null-conditional operators

* PosAlign.CalculateMinDimension: calculate sum during loop

No need to first put the dimensions in a list and then sum the list when you can just add to sum while looping through dimensions.

* PosAlign.CalculateMinDimension: Remove intermediate list and related filter func allocation

* TextFormatter.GetRuneWidth: Remove intermediate list and related sum func allocation

* ReadOnlySpan refactor preparation for GetCellMap rewrite

* LineCanvas.GetCellMap: Reuse intersection list outside nested loops

GetCellMap would not benefit much from array pool because IntersectionDefinition is not struct. This  change eliminates majority of the rest of Func<,> allocations. As a bonus IntersectionDefinition[] allocations dropped nicely.

* Refactor local method UseRounded

* Wrap too long list of method parameters

* Region: Consistent location for #nullable enable

---------

Co-authored-by: Tig <tig@users.noreply.github.com>
2025-02-25 10:18:23 -07:00
Tonttu
e24bd67658 Rune extensions micro-optimizations (#3910)
* Add benchmarks for potentially optimizable RuneExtensions

* Add new RuneExtensions.DecodeSurrogatePair benchmark implementation

Avoids intermediate heap array allocations which is especially nice when the rune is not surrogate pair because then array heap allocations are completely avoided.

* Enable nullable reference types in RuneExtensions

* Make RuneExtensions.MaxUnicodeCodePoint readonly

Makes sure no one can accidentally change the value. Ideally would be const value.

* Optimize RuneExtensions.DecodeSurrogatePair

* Remove duplicate Rune.GetUnicodeCategory call

* Add new RuneExtensions.IsSurrogatePair benchmark implementation

Avoids intermediate heap allocations by using stack allocated buffer.

* Optimize RuneExtensions.IsSurrogatePair

* Add RuneExtensions.GetEncodingLength tests

* Optimize RuneExtensions.GetEncodingLength

* Optimize RuneExtensions.Encode

* Print encoding name in benchmark results

* Rename variable to better match return description

* Add RuneExtensions.EncodeSurrogatePair benchmark

---------

Co-authored-by: Tig <tig@users.noreply.github.com>
2025-02-25 09:42:32 -07:00
Thomas Nind
81ad695ef7 Fix foreach runes bug with unicode surrogate pairs (#3894) 2025-01-12 10:05:52 -07:00
BDisp
dbfe521db3 Fixes #3873. TextFormatter isn't properly handling combining marks on alignments. (#3874)
Co-authored-by: Tig <tig@users.noreply.github.com>
2024-12-05 09:08:11 -07:00
tznind
90d492716a Adds IConsoleDriver 2024-11-24 11:01:51 +00:00
Tig
7e0f60696f WIP: Figuring out how to make margin transparent 2024-10-30 16:17:09 -06:00
Tig
fdeb8e90d1 WIP: Figuring out how to make margin transparent 2024-10-30 15:47:38 -06:00
Tig
17e3fe8c5f Non-rectangular clip reigion support basically works 2024-10-29 16:41:57 -06:00
Tig
e0551f4e4d NeedsDisplay -> NeedsDraw 2024-10-27 19:54:50 -07:00
Tig
606bdf16a6 Added View.Set/GetAtribute. Made Driver.Set/GetAttribute internal 2024-10-26 18:27:16 -07:00
Tig
a93d1ceeb7 better names and API docs 2024-10-24 16:40:47 -06:00
Tig
5e9178b4bd Everything but adornment drawing is working 2024-10-22 20:00:39 -06:00
Tig
1363995326 Merged MouseEvent and MouseEventEventArgs into MouseEventArgs 2024-10-15 07:40:42 -06:00
Tig
a19781c53b View.Mouse cleanup - WIP2 2024-10-14 20:25:24 -06:00
BDisp
ccf2daa024 Change all RuneCell to Cell and move methods to the Cell record struct. 2024-10-05 18:01:29 +01:00
Tig
a097625045 Expanded Navigation Scenario 2024-08-29 09:11:09 -07:00
Tig
6931326686 Fixed Tabview 2024-08-28 11:23:20 -07:00
Tig
20249faa10 Fixed adornment editor scenarios 2024-08-27 16:49:30 -07:00
Tig
bdc60c9490 Got all unit tests passing. Some AdvanceFocus stuff still not right. 2024-08-24 07:27:10 -07:00
Tig
47bb262e2c Code cleanu p: Autocomplete 2024-08-24 06:12:44 -07:00
Tig
04e569aabc Autocomplete 2024-08-24 06:07:35 -07:00
Tig
a935ef83df Merge remote-tracking branch 'refs/remotes/origin/v2_2491-Toplevel-Redesign' into v2_2491-Toplevel-Redesign 2024-07-25 14:50:19 -06:00
Tig
44ce74a5c0 Refactored Application into smaller files.
Made Application #nullable enable
2024-07-22 16:52:02 -06:00
Tig
b2cd779c3c Use .ReplaceLineEndings() in TextFormatter 2024-07-20 18:09:25 -06:00
Tig
6f9fb1a68d Trying to debug @bdisp's About box issue 2024-07-20 15:16:56 -06:00
Tig
c7ae986789 Review feedback 2024-07-20 13:12:31 -06:00
Tig
4bdaef7ad6 Nuked TextFormatter.CalcRect and unit tests 2024-07-20 11:45:55 -06:00
Tig
71e14c8ad1 API doc improvements 2024-07-20 11:40:18 -06:00
Tig
0e70444e08 Renamed Width/Height/Size 2024-07-20 11:36:05 -06:00
Tig
6550cde7b5 Nuked Textformatter.AutoSize.
Removed references to AutoSize throughout.
Updated unit tests.
2024-07-20 11:17:46 -06:00
Tig
3ed30767a0 Addressed review feedback from @dodexahedron. 2024-07-20 10:00:54 -06:00
Tig
4128b515da Merge branch 'v2_develop' into v2_3499-Finish-DimAuto 2024-07-19 17:34:13 -06:00
Tig
fa847f4356 Revert "rebased against v2_develop"
This reverts commit 23737decec.
2024-07-19 17:32:53 -06:00
Tig
23737decec rebased against v2_develop 2024-07-19 17:02:14 -06:00
Tig
c6a9021f2e Fixed error in Textformatter 2024-07-19 16:07:14 -06:00
Tig
153f1015d7 Fixed warnings 2024-07-19 15:59:06 -06:00