Sorta fixed vertical. Broke wide runes

This commit is contained in:
Tig
2024-04-21 11:05:27 -06:00
parent 91e3e75dc0
commit c65596b2d0
2 changed files with 10 additions and 5 deletions

View File

@@ -304,6 +304,7 @@ public class TextFormatter
{
if (isVertical)
{
// BUGBUG: This works with a very limited set of wide-char scenarios.
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);
@@ -319,8 +320,11 @@ public class TextFormatter
{
if (isVertical)
{
int runesWidth = runes.Length == 0 ? 0 : runes.Max (r => GetRuneWidth (r, TabWidth));
x = screen.Left + runesWidth + line - 1;
// BUGBUG: This works only if a) all lines have only single-wide chars and b) only one line has wide chars
int runesWidth = line > 0
? GetColumnsRequiredForVerticalText (linesFormatted, 0, line, TabWidth)
: 0;
x = screen.Left + runesWidth;
}
else
{
@@ -333,8 +337,9 @@ public class TextFormatter
{
if (isVertical)
{
int runesWidth = runes.Length == 0 ? 0 : runes.Max (r => GetRuneWidth (r, TabWidth));
x = screen.Left + (screen.Width / 2) - (_lines.Count / 2) + (runesWidth + line - 1);
// BUGBUG: This works with a very limited set of wide-char scenarios.
int runesWidth = GetColumnsRequiredForVerticalText (linesFormatted, tabWidth: TabWidth);
x = screen.Left + line + (screen.Width - runesWidth) / 2;
CursorPosition = (screen.Width - runesWidth) / 2 + (_hotKeyPos > -1 ? _hotKeyPos : 0);
}

View File

@@ -3482,7 +3482,7 @@ ssb
[InlineData ("A", 2, false, "A")]
[InlineData ("AB12", 5, false, "AB12")]
[InlineData ("AB\n12", 5, false, "A1\nB2")]
[InlineData ("デモエ", 1, false, "")]
[InlineData ("", 1, false, "")]
public void Draw_Vertical_TopBottom_LeftRight (string text, int width, bool autoSize, string expectedText)
{