Commit Graph

93 Commits

Author SHA1 Message Date
Tonttu
9735d8c584 Consistent kilobyte unit in comments 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
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
98f70b2632 Adds ViewportSettings.Transparent (#3886) 2025-03-01 15:22:23 -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
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
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
Tig
ee57f41b9f Fixed @bdisp noted error 2024-07-19 15:42:04 -06:00
Tig
7733a69e8a Code cleanup 2024-07-19 08:08:52 -06:00
Cam Sinclair
952fc49709 Fix typos 2024-07-19 13:16:48 +10:00
Tig
c4de9fe4f4 Code cleanup 2024-07-18 15:56:38 -06:00
Tig
b4e1b3ec5e All unit tests pass.
Made TextFormatter have independent Width/Height.
2024-07-18 15:24:11 -06:00
Tig
2cecc7762a WIP - Trying to make TextFormatter have indepdentent width/height 2024-07-17 16:18:58 -06:00
Tig
b528ba8bc7 Fixed Vertical FormatAndGetSize Fill issue 2024-07-17 10:15:09 -06:00
Tig
e566dce521 Fixed Horizontal FormatAndGetSize Fill issue; Vertical is still broken 2024-07-17 09:07:54 -06:00
Tig
e93eebb708 Fixed little things. 2024-07-16 18:40:51 -06:00
Tig
ce5fc1c81e Fixed ShadowTests 2024-07-16 09:43:34 -06:00
Tig
f51e38d25e Fixed TextFormatter.FormatAndGetSize for wide vertical text 2024-07-16 09:35:45 -06:00
Tig
a3b606fe6e New unit tests. Lots of fixes 2024-07-15 16:36:05 -06:00
Tig
4ba8f04998 Rebased with v2_develop 2024-05-23 10:12:15 -06:00
Tig
c7039a6658 Removed debug code.
Added [GenerateEnumExtensionMethods] to DimAutoStyle.
Reordered DimAutoStyle.
2024-05-22 13:42:33 -06:00
Tig
c877c1844d Simplified Alignment enum 2024-05-18 10:39:14 -07:00
Tig
c8690af514 Fixed AnchorEnd issue 2024-05-13 12:10:12 -06:00
Tig
ba4139f5f6 WIP fixing 3469 2024-05-13 09:50:23 -06:00
Tig
a8b9ddb2aa Partial fix 2024-05-13 09:50:21 -06:00
Tig
ce28b2ab40 WIP fixing 3469 2024-05-12 21:55:43 -06:00
Tig
bc40c9de22 Partial fix 2024-05-12 20:47:03 -06:00
Tig
175c2fc0dd Changed Alignment enum to have distinct values. Updated related code. 2024-05-11 07:29:26 -06:00
Tig
ce1e243df2 Justification->Alignment 2024-05-10 11:27:02 -06:00
Tig
c5a6c907a4 Justifier->Aligner 2024-05-10 10:35:49 -06:00
Tig
37073d29b5 Alignment->Justification 2024-05-10 09:56:14 -06:00