mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Sorta fixed vertical. Broke wide runes
This commit is contained in:
@@ -304,8 +304,8 @@ public class TextFormatter
|
||||
{
|
||||
if (isVertical)
|
||||
{
|
||||
int runesWidth = GetColumnsRequiredForVerticalText (linesFormatted, tabWidth: TabWidth);
|
||||
x = screen.Right - runesWidth;
|
||||
int runesWidth = runes.Length == 0 ? 0 : runes.Max (r => GetRuneWidth (r, TabWidth));
|
||||
x = screen.Left + (screen.Width - _lines.Count - 1) + (runesWidth + line);
|
||||
CursorPosition = screen.Width - runesWidth + (_hotKeyPos > -1 ? _hotKeyPos : 0);
|
||||
}
|
||||
else
|
||||
@@ -319,10 +319,8 @@ public class TextFormatter
|
||||
{
|
||||
if (isVertical)
|
||||
{
|
||||
int runesWidth = line > 0
|
||||
? GetColumnsRequiredForVerticalText (linesFormatted, tabWidth: TabWidth)
|
||||
: 0;
|
||||
x = screen.Left + runesWidth;
|
||||
int runesWidth = runes.Length == 0 ? 0 : runes.Max (r => GetRuneWidth (r, TabWidth));
|
||||
x = screen.Left + runesWidth + line - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -335,8 +333,8 @@ public class TextFormatter
|
||||
{
|
||||
if (isVertical)
|
||||
{
|
||||
int runesWidth = GetColumnsRequiredForVerticalText (linesFormatted, tabWidth: TabWidth);
|
||||
x = screen.Left + line + (screen.Width - runesWidth) / 2;
|
||||
int runesWidth = runes.Length == 0 ? 0 : runes.Max (r => GetRuneWidth (r, TabWidth));
|
||||
x = screen.Left + (screen.Width / 2) - (_lines.Count / 2) + (runesWidth + line - 1);
|
||||
|
||||
CursorPosition = (screen.Width - runesWidth) / 2 + (_hotKeyPos > -1 ? _hotKeyPos : 0);
|
||||
}
|
||||
@@ -410,7 +408,7 @@ public class TextFormatter
|
||||
|
||||
if (lastZeroWidthPos is null)
|
||||
{
|
||||
if (idx < 0 || x + current + colOffset < 0)
|
||||
if (idx < 0)
|
||||
{
|
||||
current++;
|
||||
|
||||
|
||||
@@ -3366,7 +3366,7 @@ ssb
|
||||
[InlineData ("A", 0, true, "")]
|
||||
[InlineData ("A", 1, true, "A")]
|
||||
[InlineData ("A", 2, true, " A")]
|
||||
[InlineData ("AB", 1, true, "")] // BUGBUG: This is wrong, it should be "A"
|
||||
[InlineData ("AB", 1, true, "B")]
|
||||
[InlineData ("AB", 2, true, "AB")]
|
||||
[InlineData ("ABC", 3, true, "ABC")]
|
||||
[InlineData ("ABC", 4, true, " ABC")]
|
||||
@@ -3476,4 +3476,30 @@ ssb
|
||||
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
|
||||
}
|
||||
|
||||
[SetupFakeDriver]
|
||||
[Theory]
|
||||
[InlineData ("A", 2, false, "A")]
|
||||
[InlineData ("AB12", 5, false, "AB12")]
|
||||
[InlineData ("AB\n12", 5, false, "A1\nB2")]
|
||||
[InlineData ("デモエ", 1, false, "")]
|
||||
|
||||
public void Draw_Vertical_TopBottom_LeftRight (string text, int width, bool autoSize, string expectedText)
|
||||
{
|
||||
TextFormatter tf = new ()
|
||||
{
|
||||
Text = text,
|
||||
AutoSize = autoSize,
|
||||
Direction = TextDirection.TopBottom_LeftRight,
|
||||
VerticalAlignment = VerticalTextAlignment.Top
|
||||
};
|
||||
|
||||
if (!autoSize)
|
||||
{
|
||||
tf.Size = new Size (width, 1);
|
||||
}
|
||||
tf.Draw (new Rectangle (0, 0, width, 5), Attribute.Default, Attribute.Default);
|
||||
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user