mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 00:07:58 +01:00
Merge pull request #2283 from BDisp/hotKeyPos-fix_2282
Fixes #2282. HotKeyPos is causing black cell on center and right/bottom alignments.
This commit is contained in:
@@ -1212,11 +1212,11 @@ namespace Terminal.Gui {
|
||||
if (isVertical) {
|
||||
var runesWidth = GetSumMaxCharWidth (Lines, line);
|
||||
x = bounds.Right - runesWidth;
|
||||
CursorPosition = bounds.Width - runesWidth + hotKeyPos;
|
||||
CursorPosition = bounds.Width - runesWidth + (hotKeyPos > -1 ? hotKeyPos : 0);
|
||||
} else {
|
||||
var runesWidth = GetTextWidth (ustring.Make (runes));
|
||||
x = bounds.Right - runesWidth;
|
||||
CursorPosition = bounds.Width - runesWidth + hotKeyPos;
|
||||
CursorPosition = bounds.Width - runesWidth + (hotKeyPos > -1 ? hotKeyPos : 0);
|
||||
}
|
||||
} else if (textAlignment == TextAlignment.Left || textAlignment == TextAlignment.Justified) {
|
||||
if (isVertical) {
|
||||
@@ -1225,16 +1225,16 @@ namespace Terminal.Gui {
|
||||
} else {
|
||||
x = bounds.Left;
|
||||
}
|
||||
CursorPosition = hotKeyPos;
|
||||
CursorPosition = hotKeyPos > -1 ? hotKeyPos : 0;
|
||||
} else if (textAlignment == TextAlignment.Centered) {
|
||||
if (isVertical) {
|
||||
var runesWidth = GetSumMaxCharWidth (Lines, line);
|
||||
x = bounds.Left + line + ((bounds.Width - runesWidth) / 2);
|
||||
CursorPosition = (bounds.Width - runesWidth) / 2 + hotKeyPos;
|
||||
CursorPosition = (bounds.Width - runesWidth) / 2 + (hotKeyPos > -1 ? hotKeyPos : 0);
|
||||
} else {
|
||||
var runesWidth = GetTextWidth (ustring.Make (runes));
|
||||
x = bounds.Left + (bounds.Width - runesWidth) / 2;
|
||||
CursorPosition = (bounds.Width - runesWidth) / 2 + hotKeyPos;
|
||||
CursorPosition = (bounds.Width - runesWidth) / 2 + (hotKeyPos > -1 ? hotKeyPos : 0);
|
||||
}
|
||||
} else {
|
||||
throw new ArgumentOutOfRangeException ();
|
||||
@@ -1291,7 +1291,7 @@ namespace Terminal.Gui {
|
||||
rune = runes [idx];
|
||||
}
|
||||
}
|
||||
if (idx == HotKeyPos) {
|
||||
if (HotKeyPos > -1 && idx == HotKeyPos) {
|
||||
if ((isVertical && textVerticalAlignment == VerticalTextAlignment.Justified) ||
|
||||
(!isVertical && textAlignment == TextAlignment.Justified)) {
|
||||
CursorPosition = idx - start;
|
||||
|
||||
@@ -4259,5 +4259,46 @@ This TextFormatter (tf2) is rewritten.
|
||||
0111000000
|
||||
0000000000", expectedColors);
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void Colors_On_TextAlignment_Right_And_Bottom ()
|
||||
{
|
||||
var labelRight = new Label ("Test") {
|
||||
Width = 6,
|
||||
Height = 1,
|
||||
TextAlignment = TextAlignment.Right,
|
||||
ColorScheme = Colors.Base
|
||||
};
|
||||
var labelBottom = new Label ("Test", TextDirection.TopBottom_LeftRight) {
|
||||
Y = 1,
|
||||
Width = 1,
|
||||
Height = 6,
|
||||
VerticalTextAlignment = VerticalTextAlignment.Bottom,
|
||||
ColorScheme = Colors.Base
|
||||
};
|
||||
var top = Application.Top;
|
||||
top.Add (labelRight, labelBottom);
|
||||
|
||||
Application.Begin (top);
|
||||
((FakeDriver)Application.Driver).SetBufferSize (7, 7);
|
||||
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
Test
|
||||
|
||||
|
||||
T
|
||||
e
|
||||
s
|
||||
t ", output);
|
||||
|
||||
TestHelpers.AssertDriverColorsAre (@"
|
||||
000000
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0", new Attribute [] { Colors.Base.Normal });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user