diff --git a/Terminal.Gui/Drawing/Thickness.cs b/Terminal.Gui/Drawing/Thickness.cs index ffe8b3f70..40a30d590 100644 --- a/Terminal.Gui/Drawing/Thickness.cs +++ b/Terminal.Gui/Drawing/Thickness.cs @@ -233,7 +233,8 @@ public class Thickness : IEquatable { Text = label is null ? string.Empty : $"{label} {this}", Alignment = TextAlignment.Centered, - VerticalAlignment = VerticalTextAlignment.Bottom + VerticalAlignment = VerticalTextAlignment.Bottom, + AutoSize = true }; tf.Draw (rect, Application.Driver.CurrentAttribute, Application.Driver.CurrentAttribute, rect); } diff --git a/Terminal.Gui/View/ViewText.cs b/Terminal.Gui/View/ViewText.cs index be599f061..d7a754207 100644 --- a/Terminal.Gui/View/ViewText.cs +++ b/Terminal.Gui/View/ViewText.cs @@ -118,7 +118,7 @@ public partial class View /// /// Gets or sets the used to format . /// - public TextFormatter TextFormatter { get; init; } = new (); + public TextFormatter TextFormatter { get; init; } = new () {}; /// /// Gets or sets how the View's is aligned vertically when drawn. Changing this property will diff --git a/UnitTests/Text/TextFormatterTests.cs b/UnitTests/Text/TextFormatterTests.cs index 640d84d71..b0937cefc 100644 --- a/UnitTests/Text/TextFormatterTests.cs +++ b/UnitTests/Text/TextFormatterTests.cs @@ -3502,18 +3502,48 @@ ssb [SetupFakeDriver] [Theory] - [InlineData ("A", 5, false, "A")] - [InlineData ("AB12", 5, false, @" + [InlineData ("A", 5, 5, false, "A")] + [InlineData ("AB12", 5, 5, false, @" A B 1 2")] - [InlineData ("AB\n12", 5, false, @" + [InlineData ("AB\n12", 5, 5, false, @" A1 B2")] - [InlineData ("", 1, false, "")] + [InlineData ("", 5, 1, false, "")] - public void Draw_Vertical_TopBottom_LeftRight (string text, int height, bool autoSize, string expectedText) + [InlineData ("Hello Worlds", 1, 12, true, @" +H +e +l +l +o + +W +o +r +l +d +s")] + + [InlineData ("Hello Worlds", 1, 12, false, @" +H +e +l +l +o + +W +o +r +l +d +s")] + + [InlineData ("Hello Worlds", 12, 1, false, @"HelloWorlds")] + + public void Draw_Vertical_TopBottom_LeftRight (string text, int width, int height, bool autoSize, string expectedText) { TextFormatter tf = new () { @@ -3524,9 +3554,9 @@ B2")] if (!autoSize) { - tf.Size = new Size (5, height); + tf.Size = new Size (width, height); } - tf.Draw (new Rectangle (0, 0, 5, height), Attribute.Default, Attribute.Default); + tf.Draw (new Rectangle (0, 0, 20, 20), Attribute.Default, Attribute.Default); TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output); } diff --git a/UnitTests/View/Text/AutoSizeTrueTests.cs b/UnitTests/View/Text/AutoSizeTrueTests.cs index 8ca2e4651..9cd91199d 100644 --- a/UnitTests/View/Text/AutoSizeTrueTests.cs +++ b/UnitTests/View/Text/AutoSizeTrueTests.cs @@ -1750,10 +1750,16 @@ Y view.Width = 12; view.Height = 1; -// Assert.Equal (new Size (12, 1), view.TextFormatter.Size); view.TextFormatter.Size = new (12, 1); + win.LayoutSubviews (); Assert.Equal (new Size (12, 1), view.TextFormatter.Size); Assert.Equal (new Rectangle (0, 0, 12, 1), view.Frame); + top.Clear (); + view.Draw (); + expected = @" HelloWorlds"; + + TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); + Application.Refresh (); // TextDirection.TopBottom_LeftRight - Height of 1 and Width of 12 means