mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-29 01:07:58 +01:00
TextFormater.AutoSize fixes
This commit is contained in:
@@ -233,7 +233,8 @@ public class Thickness : IEquatable<Thickness>
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public partial class View
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="Gui.TextFormatter"/> used to format <see cref="Text"/>.
|
||||
/// </summary>
|
||||
public TextFormatter TextFormatter { get; init; } = new ();
|
||||
public TextFormatter TextFormatter { get; init; } = new () {};
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets how the View's <see cref="Text"/> is aligned vertically when drawn. Changing this property will
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user