Skip to content

Commit a6092ae

Browse files
committed
Merges in gui-cs#3019 changes. Makes OnResizeNeeded non-virtual. If we find a use-case where someone wants to override it we can change this back.
1 parent a740ef0 commit a6092ae

22 files changed

+9471
-9207
lines changed

Terminal.Gui/Text/Autocomplete/AppendAutocomplete.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public override bool ProcessKey (Key a)
8383
public override void GenerateSuggestions (AutocompleteContext context)
8484
{
8585
if (_suspendSuggestions) {
86+
_suspendSuggestions = false;
8687
return;
8788
}
8889
base.GenerateSuggestions (context);

Terminal.Gui/Text/TextFormatter.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ public virtual string Text {
11021102
_text = EnableNeedsFormat (value);
11031103

11041104
if ((AutoSize && Alignment != TextAlignment.Justified && VerticalAlignment != VerticalTextAlignment.Justified) || (textWasNull && Size.IsEmpty)) {
1105-
Size = CalcRect (0, 0, _text, _textDirection, TabWidth).Size;
1105+
Size = CalcRect (0, 0, _text, Direction, TabWidth).Size;
11061106
}
11071107

11081108
//if (_text != null && _text.GetRuneCount () > 0 && (Size.Width == 0 || Size.Height == 0 || Size.Width != _text.GetColumns ())) {
@@ -1129,7 +1129,7 @@ public bool AutoSize {
11291129
set {
11301130
_autoSize = EnableNeedsFormat (value);
11311131
if (_autoSize && Alignment != TextAlignment.Justified && VerticalAlignment != VerticalTextAlignment.Justified) {
1132-
Size = CalcRect (0, 0, Text, _textDirection, TabWidth).Size;
1132+
Size = CalcRect (0, 0, _text, Direction, TabWidth).Size;
11331133
}
11341134
}
11351135
}
@@ -1169,7 +1169,12 @@ public VerticalTextAlignment VerticalAlignment {
11691169
/// <value>The text vertical alignment.</value>
11701170
public TextDirection Direction {
11711171
get => _textDirection;
1172-
set => _textDirection = EnableNeedsFormat (value);
1172+
set {
1173+
_textDirection = EnableNeedsFormat (value);
1174+
if (AutoSize && Alignment != TextAlignment.Justified && VerticalAlignment != VerticalTextAlignment.Justified) {
1175+
Size = CalcRect (0, 0, Text, Direction, TabWidth).Size;
1176+
}
1177+
}
11731178
}
11741179

11751180
/// <summary>
@@ -1250,7 +1255,7 @@ public Size Size {
12501255
get => _size;
12511256
set {
12521257
if (AutoSize && Alignment != TextAlignment.Justified && VerticalAlignment != VerticalTextAlignment.Justified) {
1253-
_size = EnableNeedsFormat (CalcRect (0, 0, Text, _textDirection, TabWidth).Size);
1258+
_size = EnableNeedsFormat (CalcRect (0, 0, Text, Direction, TabWidth).Size);
12541259
} else {
12551260
_size = EnableNeedsFormat (value);
12561261
}
@@ -1329,7 +1334,7 @@ public List<string> Lines {
13291334
shown_text = ReplaceHotKeyWithTag (shown_text, _hotKeyPos);
13301335
}
13311336

1332-
if (IsVerticalDirection (_textDirection)) {
1337+
if (IsVerticalDirection (Direction)) {
13331338
var colsWidth = GetSumMaxCharWidth (shown_text, 0, 1, TabWidth);
13341339
_lines = Format (shown_text, Size.Height, VerticalAlignment == VerticalTextAlignment.Justified, Size.Width > colsWidth && WordWrap,
13351340
PreserveTrailingSpaces, TabWidth, Direction, MultiLine);
@@ -1434,7 +1439,7 @@ public void Draw (Rect bounds, Attribute normalColor, Attribute hotColor, Rect c
14341439
// Use "Lines" to ensure a Format (don't use "lines"))
14351440

14361441
var linesFormated = Lines;
1437-
switch (_textDirection) {
1442+
switch (Direction) {
14381443
case TextDirection.TopBottom_RightLeft:
14391444
case TextDirection.LeftRight_BottomTop:
14401445
case TextDirection.RightLeft_BottomTop:
@@ -1443,7 +1448,7 @@ public void Draw (Rect bounds, Attribute normalColor, Attribute hotColor, Rect c
14431448
break;
14441449
}
14451450

1446-
var isVertical = IsVerticalDirection (_textDirection);
1451+
var isVertical = IsVerticalDirection (Direction);
14471452
var maxBounds = bounds;
14481453
if (driver != null) {
14491454
maxBounds = containerBounds == default
@@ -1475,7 +1480,7 @@ public void Draw (Rect bounds, Attribute normalColor, Attribute hotColor, Rect c
14751480

14761481
var runes = _lines [line].ToRunes ();
14771482

1478-
switch (_textDirection) {
1483+
switch (Direction) {
14791484
case TextDirection.RightLeft_BottomTop:
14801485
case TextDirection.RightLeft_TopBottom:
14811486
case TextDirection.BottomTop_LeftRight:
@@ -1488,7 +1493,7 @@ public void Draw (Rect bounds, Attribute normalColor, Attribute hotColor, Rect c
14881493

14891494
int x, y;
14901495
// Horizontal Alignment
1491-
if (_textAlignment == TextAlignment.Right || (_textAlignment == TextAlignment.Justified && !IsLeftToRight (_textDirection))) {
1496+
if (_textAlignment == TextAlignment.Right || (_textAlignment == TextAlignment.Justified && !IsLeftToRight (Direction))) {
14921497
if (isVertical) {
14931498
var runesWidth = GetSumMaxCharWidth (Lines, line, TabWidth);
14941499
x = bounds.Right - runesWidth;
@@ -1521,7 +1526,7 @@ public void Draw (Rect bounds, Attribute normalColor, Attribute hotColor, Rect c
15211526
}
15221527

15231528
// Vertical Alignment
1524-
if (_textVerticalAlignment == VerticalTextAlignment.Bottom || (_textVerticalAlignment == VerticalTextAlignment.Justified && !IsTopToBottom (_textDirection))) {
1529+
if (_textVerticalAlignment == VerticalTextAlignment.Bottom || (_textVerticalAlignment == VerticalTextAlignment.Justified && !IsTopToBottom (Direction))) {
15251530
if (isVertical) {
15261531
y = bounds.Bottom - runes.Length;
15271532
} else {

Terminal.Gui/View/Layout/ViewLayout.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -569,14 +569,14 @@ Dim VerifyIsInitialized (Dim dim, string member)
569569
/// </summary>
570570
/// <remarks>
571571
/// <para>
572-
/// Sets the <see cref="Frame"/>.
573-
/// </para>
574-
/// <para>
575-
/// Can be overridden if the view resize behavior is different than the default.
572+
/// Determines the relative bounds of the <see cref="View"/> and its <see cref="Frame"/>s, and then calls
573+
/// <see cref="SetRelativeLayout(Rect)"/> to update the view.
576574
/// </para>
577575
/// </remarks>
578-
protected virtual void OnResizeNeeded ()
576+
internal void OnResizeNeeded ()
579577
{
578+
// TODO: Identify a real-world use-case where this API should be virtual.
579+
// TODO: Until then leave it `internal` and non-virtual
580580
// First try SuperView.Bounds, then Application.Top, then Driver.Bounds.
581581
// Finally, if none of those are valid, use int.MaxValue (for Unit tests).
582582
var relativeBounds = SuperView is { IsInitialized: true } ? SuperView.Bounds :

0 commit comments

Comments
 (0)