mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 00:46:39 +01:00
Fixed TextFormatter.FormatAndGetSize for wide vertical text
This commit is contained in:
@@ -667,7 +667,8 @@ public class TextFormatter
|
||||
|
||||
if (IsVerticalDirection (Direction))
|
||||
{
|
||||
return new (height, width);
|
||||
height = GetColumnsRequiredForVerticalText(lines, 0, lines.Count, TabWidth);
|
||||
return new (height, lines.Max (static line => line.Length));
|
||||
}
|
||||
|
||||
return new (width, height);
|
||||
|
||||
@@ -70,7 +70,7 @@ public class DimAuto () : Dim
|
||||
{
|
||||
if (dimension == Dimension.Width)
|
||||
{
|
||||
us.TextFormatter.Size = new (autoMax, 2048);
|
||||
us.TextFormatter.Size = new (superviewContentSize, 2048);
|
||||
textSize = us.TextFormatter.FormatAndGetSize ().Width;
|
||||
us.TextFormatter.Size = new Size (textSize, 2048);
|
||||
}
|
||||
|
||||
@@ -472,8 +472,8 @@ Y
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void AutoSize_True_View_IsEmpty_False_Minimum_Width_Wide_Rune ()
|
||||
[SetupFakeDriver]
|
||||
public void DimAuto_Vertical_TextDirection_Wide_Rune ()
|
||||
{
|
||||
var text = "界View";
|
||||
|
||||
@@ -484,69 +484,26 @@ Y
|
||||
Width = Dim.Auto (),
|
||||
Height = Dim.Auto ()
|
||||
};
|
||||
var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () };
|
||||
win.Add (view);
|
||||
var top = new Toplevel ();
|
||||
top.Add (win);
|
||||
Application.Begin (top);
|
||||
((FakeDriver)Application.Driver).SetBufferSize (4, 10);
|
||||
|
||||
view.SetRelativeLayout (new Size (4, 10));
|
||||
|
||||
Assert.Equal (5, text.Length);
|
||||
|
||||
// Vertical text - 2 wide, 5 down
|
||||
Assert.Equal (new (0, 0, 2, 5), view.Frame);
|
||||
Assert.Equal (new (2, 5), view.TextFormatter.Size);
|
||||
Assert.Equal (new () { "界View" }, view.TextFormatter.GetLines ());
|
||||
Assert.Equal (new (0, 0, 4, 10), win.Frame);
|
||||
Assert.Equal (new (0, 0, 4, 10), Application.Top.Frame);
|
||||
|
||||
view.Draw ();
|
||||
|
||||
var expected = @"
|
||||
┌──┐
|
||||
│界│
|
||||
│V │
|
||||
│i │
|
||||
│e │
|
||||
│w │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
└──┘
|
||||
";
|
||||
界
|
||||
V
|
||||
i
|
||||
e
|
||||
w ";
|
||||
|
||||
Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
|
||||
Assert.Equal (new (0, 0, 4, 10), pos);
|
||||
|
||||
text = "0123456789";
|
||||
Assert.Equal (10, text.Length);
|
||||
|
||||
//view.Height = Dim.Fill () - text.Length;
|
||||
Application.Refresh ();
|
||||
|
||||
Assert.Equal (new (0, 0, 2, 5), view.Frame);
|
||||
Assert.Equal (new (2, 5), view.TextFormatter.Size);
|
||||
|
||||
Exception exception = Record.Exception (
|
||||
() => Assert.Equal (
|
||||
new () { "界View" },
|
||||
view.TextFormatter.GetLines ()
|
||||
)
|
||||
);
|
||||
Assert.Null (exception);
|
||||
|
||||
expected = @"
|
||||
┌──┐
|
||||
│界│
|
||||
│V │
|
||||
│i │
|
||||
│e │
|
||||
│w │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
└──┘
|
||||
";
|
||||
|
||||
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
|
||||
Assert.Equal (new (0, 0, 4, 10), pos);
|
||||
top.Dispose ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -778,7 +735,7 @@ Y
|
||||
Application.End (rs);
|
||||
top.Dispose ();
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[AutoInitShutdown]
|
||||
[InlineData (true)]
|
||||
|
||||
Reference in New Issue
Block a user