Browse Source

Renamed Width/Height/Size

Tig 1 year ago
parent
commit
0e70444e08

+ 2 - 2
Terminal.Gui/Drawing/Thickness.cs

@@ -196,8 +196,8 @@ public record struct Thickness
                 Text = text,
                 Alignment = Alignment.Center,
                 VerticalAlignment = Alignment.End,
-                Width = text.GetColumns (),
-                Height = 1
+                ConstrainToWidth = text.GetColumns (),
+                ConstrainToHeight = 1
             };
             tf.Draw (rect, Application.Driver.CurrentAttribute, Application.Driver.CurrentAttribute, rect);
         }

+ 149 - 161
Terminal.Gui/Text/TextFormatter.cs

@@ -21,10 +21,6 @@ public class TextFormatter
     private Alignment _textVerticalAlignment = Alignment.Start;
     private bool _wordWrap = true;
 
-    private int? _width;
-
-    private int? _height;
-
     /// <summary>Get or sets the horizontal text alignment.</summary>
     /// <value>The text alignment.</value>
     public Alignment Alignment
@@ -44,10 +40,7 @@ public class TextFormatter
     public TextDirection Direction
     {
         get => _textDirection;
-        set
-        {
-            _textDirection = EnableNeedsFormat (value);
-        }
+        set => _textDirection = EnableNeedsFormat (value);
     }
 
     /// <summary>Draws the text held by <see cref="TextFormatter"/> to <see cref="ConsoleDriver"/> using the colors specified.</summary>
@@ -450,7 +443,7 @@ public class TextFormatter
     /// </summary>
     public bool FillRemaining { get; set; }
 
-    /// <summary>Returns the formatted text, constrained to <see cref="Size"/>.</summary>
+    /// <summary>Returns the formatted text, constrained to <see cref="ConstrainToSize"/>.</summary>
     /// <remarks>
     ///     If <see cref="NeedsFormat"/> is <see langword="true"/>, causes a format, resetting <see cref="NeedsFormat"/>
     ///     to <see langword="false"/>.
@@ -469,9 +462,12 @@ public class TextFormatter
         return sb.ToString ().TrimEnd (Environment.NewLine.ToCharArray ());
     }
 
-    /// <summary>Gets the size required to hold the formatted text, given the constraints placed by <see cref="Size"/>.</summary>
+    /// <summary>Gets the size required to hold the formatted text, given the constraints placed by <see cref="ConstrainToSize"/>.</summary>
     /// <remarks>Causes a format, resetting <see cref="NeedsFormat"/> to <see langword="false"/>.</remarks>
-    /// <param name="constrainSize">If provided, will cause the text to be constrained to the provided size instead of <see cref="Width"/> and <see cref="Height"/>.</param>
+    /// <param name="constrainSize">
+    ///     If provided, will cause the text to be constrained to the provided size instead of <see cref="ConstrainToWidth"/> and
+    ///     <see cref="ConstrainToHeight"/>.
+    /// </param>
     /// <returns>The size required to hold the formatted text.</returns>
     public Size FormatAndGetSize (Size? constrainSize = null)
     {
@@ -480,13 +476,13 @@ public class TextFormatter
             return System.Drawing.Size.Empty;
         }
 
-        int? prevWidth = _width;
-        int? prevHeight = _height;
+        int? prevWidth = _constrainToWidth;
+        int? prevHeight = _constrainToHeight;
 
         if (constrainSize is { })
         {
-            _width = constrainSize?.Width;
-            _height = constrainSize?.Height;
+            _constrainToWidth = constrainSize?.Width;
+            _constrainToHeight = constrainSize?.Height;
         }
 
         // HACK: Fill normally will fill the entire constraint size, but we need to know the actual size of the text.
@@ -513,8 +509,8 @@ public class TextFormatter
 
         if (constrainSize is { })
         {
-            _width = prevWidth ?? null;
-            _height = prevHeight ?? null;
+            _constrainToWidth = prevWidth ?? null;
+            _constrainToHeight = prevHeight ?? null;
         }
 
         if (lines.Count == 0)
@@ -569,7 +565,7 @@ public class TextFormatter
                    : 0;
     }
 
-    /// <summary>Gets a list of formatted lines, constrained to <see cref="Size"/>.</summary>
+    /// <summary>Gets a list of formatted lines, constrained to <see cref="ConstrainToSize"/>.</summary>
     /// <remarks>
     ///     <para>
     ///         If the text needs to be formatted (if <see cref="NeedsFormat"/> is <see langword="true"/>)
@@ -577,14 +573,14 @@ public class TextFormatter
     ///         <see cref="NeedsFormat"/> will be <see langword="false"/>.
     ///     </para>
     ///     <para>
-    ///         If either of the dimensions of <see cref="Size"/> are zero, the text will not be formatted and no lines will
+    ///         If either of the dimensions of <see cref="ConstrainToSize"/> are zero, the text will not be formatted and no lines will
     ///         be returned.
     ///     </para>
     /// </remarks>
     public List<string> GetLines ()
     {
-        int width = _width.GetValueOrDefault ();
-        int height = _height.GetValueOrDefault ();
+        int width = _constrainToWidth.GetValueOrDefault ();
+        int height = _constrainToHeight.GetValueOrDefault ();
 
         // With this check, we protect against subclasses with overrides of Text
         if (string.IsNullOrEmpty (Text) || width == 0 || height == 0)
@@ -657,6 +653,40 @@ public class TextFormatter
         return _lines;
     }
 
+    private int? _constrainToWidth;
+
+    /// <summary>Gets or sets the width <see cref="Text"/> will be constrained to when formatted.</summary>
+    /// <remarks>
+    ///     <para>
+    ///         Does not return the width of the formatted text but the width that will be used to constrain the text when
+    ///         formatted.
+    ///     </para>
+    ///     <para>
+    ///         If <see langword="null"/> the height will be unconstrained. if both <see cref="ConstrainToWidth"/> and <see cref="ConstrainToHeight"/> are <see langword="null"/> the text will be formatted to the size of the text.
+    ///     </para>
+    ///     <para>
+    ///         Use <see cref="FormatAndGetSize"/> to get the size of the formatted text.
+    ///     </para>
+    ///     <para>When set, <see cref="NeedsFormat"/> is set to <see langword="true"/>.</para>
+    /// </remarks>
+    public int? ConstrainToWidth
+    {
+        get => _constrainToWidth;
+        set
+        {
+            if (_constrainToWidth == value)
+            {
+                return;
+            }
+
+            ArgumentOutOfRangeException.ThrowIfNegative (value.GetValueOrDefault (), nameof (ConstrainToWidth));
+
+            _constrainToWidth = EnableNeedsFormat (value);
+        }
+    }
+
+    private int? _constrainToHeight;
+
     /// <summary>Gets or sets the height <see cref="Text"/> will be constrained to when formatted.</summary>
     /// <remarks>
     ///     <para>
@@ -664,31 +694,65 @@ public class TextFormatter
     ///         formatted.
     ///     </para>
     ///     <para>
+    ///         If <see langword="null"/> the height will be unconstrained. if both <see cref="ConstrainToWidth"/> and <see cref="ConstrainToHeight"/> are <see langword="null"/> the text will be formatted to the size of the text.
+    ///     </para>
+    ///     <para>
     ///         Use <see cref="FormatAndGetSize"/> to get the size of the formatted text.
     ///     </para>
     ///     <para>When set, <see cref="NeedsFormat"/> is set to <see langword="true"/>.</para>
     /// </remarks>
 
-    public int? Height
+    public int? ConstrainToHeight
     {
-        get => _height;
+        get => _constrainToHeight;
         set
         {
-            if (_height == value)
+            if (_constrainToHeight == value)
             {
                 return;
             }
 
-            ArgumentOutOfRangeException.ThrowIfNegative (value.GetValueOrDefault (), nameof (Height));
+            ArgumentOutOfRangeException.ThrowIfNegative (value.GetValueOrDefault (), nameof (ConstrainToHeight));
 
-            _height = value;
+            _constrainToHeight = EnableNeedsFormat (value);
+        }
+    }
 
-            if (_width is null || _height is null)
+    /// <summary>Gets or sets the width and height <see cref="Text"/> will be constrained to when formatted.</summary>
+    /// <remarks>
+    ///     <para>
+    ///         Does not return the size of the formatted text but the size that will be used to constrain the text when
+    ///         formatted.
+    ///     </para>
+    ///     <para>
+    ///         Use <see cref="FormatAndGetSize"/> to get the size of the formatted text.
+    ///     </para>
+    ///     <para>When set, <see cref="NeedsFormat"/> is set to <see langword="true"/>.</para>
+    /// </remarks>
+    public Size? ConstrainToSize
+    {
+        get
+        {
+            if (_constrainToWidth is null || _constrainToHeight is null)
             {
-                return;
+                return null;
             }
 
-            _height = EnableNeedsFormat (value);
+            return new Size (_constrainToWidth.Value, _constrainToHeight.Value);
+        }
+        set
+        {
+            if (value is null)
+            {
+                _constrainToWidth = null;
+                _constrainToHeight = null;
+                EnableNeedsFormat (true);
+            }
+            else
+            {
+                _constrainToWidth = EnableNeedsFormat (value.Value.Width);
+                _constrainToHeight = EnableNeedsFormat (value.Value.Height);
+            }
         }
     }
 
@@ -751,45 +815,6 @@ public class TextFormatter
         set => _preserveTrailingSpaces = EnableNeedsFormat (value);
     }
 
-    /// <summary>Gets or sets the width and height <see cref="Text"/> will be constrained to when formatted.</summary>
-    /// <remarks>
-    ///     <para>
-    ///         Does not return the size of the formatted text but the size that will be used to constrain the text when
-    ///         formatted.
-    ///     </para>
-    ///     <para>
-    ///         Use <see cref="FormatAndGetSize"/> to get the size of the formatted text.
-    ///     </para>
-    ///     <para>When set, <see cref="NeedsFormat"/> is set to <see langword="true"/>.</para>
-    /// </remarks>
-    public Size? Size
-    {
-        get
-        {
-            if (_width is null || _height is null)
-            {
-                return null;
-            }
-
-            return new Size (_width.Value, _height.Value);
-        }
-        set
-        {
-            if (value is null)
-            {
-                _width = null;
-                _height = null;
-                EnableNeedsFormat (true);
-            }
-            else
-            {
-                Size size = EnableNeedsFormat (value.Value);
-                _width = size.Width;
-                _height = size.Height;
-            }
-        }
-    }
-
     /// <summary>Gets or sets the number of columns used for a tab.</summary>
     public int TabWidth
     {
@@ -812,41 +837,7 @@ public class TextFormatter
         set => _textVerticalAlignment = EnableNeedsFormat (value);
     }
 
-    /// <summary>Gets or sets the width <see cref="Text"/> will be constrained to when formatted.</summary>
-    /// <remarks>
-    ///     <para>
-    ///         Does not return the width of the formatted text but the width that will be used to constrain the text when
-    ///         formatted.
-    ///     </para>
-    ///     <para>
-    ///         Use <see cref="FormatAndGetSize"/> to get the size of the formatted text.
-    ///     </para>
-    ///     <para>When set, <see cref="NeedsFormat"/> is set to <see langword="true"/>.</para>
-    /// </remarks>
-    public int? Width
-    {
-        get => _width;
-        set
-        {
-            if (_width == value)
-            {
-                return;
-            }
-
-            ArgumentOutOfRangeException.ThrowIfNegative (value.GetValueOrDefault (), nameof (Width));
-
-            _width = value;
-
-            if (_width is null || _height is null)
-            {
-                return;
-            }
-
-            _width = EnableNeedsFormat (value);
-        }
-    }
-
-    /// <summary>Gets or sets whether word wrap will be used to fit <see cref="Text"/> to <see cref="Size"/>.</summary>
+    /// <summary>Gets or sets whether word wrap will be used to fit <see cref="Text"/> to <see cref="ConstrainToSize"/>.</summary>
     public bool WordWrap
     {
         get => _wordWrap;
@@ -870,48 +861,48 @@ public class TextFormatter
     public static bool IsHorizontalDirection (TextDirection textDirection)
     {
         return textDirection switch
-        {
-            TextDirection.LeftRight_TopBottom => true,
-            TextDirection.LeftRight_BottomTop => true,
-            TextDirection.RightLeft_TopBottom => true,
-            TextDirection.RightLeft_BottomTop => true,
-            _ => false
-        };
+               {
+                   TextDirection.LeftRight_TopBottom => true,
+                   TextDirection.LeftRight_BottomTop => true,
+                   TextDirection.RightLeft_TopBottom => true,
+                   TextDirection.RightLeft_BottomTop => true,
+                   _ => false
+               };
     }
 
     /// <summary>Check if it is a vertical direction</summary>
     public static bool IsVerticalDirection (TextDirection textDirection)
     {
         return textDirection switch
-        {
-            TextDirection.TopBottom_LeftRight => true,
-            TextDirection.TopBottom_RightLeft => true,
-            TextDirection.BottomTop_LeftRight => true,
-            TextDirection.BottomTop_RightLeft => true,
-            _ => false
-        };
+               {
+                   TextDirection.TopBottom_LeftRight => true,
+                   TextDirection.TopBottom_RightLeft => true,
+                   TextDirection.BottomTop_LeftRight => true,
+                   TextDirection.BottomTop_RightLeft => true,
+                   _ => false
+               };
     }
 
     /// <summary>Check if it is Left to Right direction</summary>
     public static bool IsLeftToRight (TextDirection textDirection)
     {
         return textDirection switch
-        {
-            TextDirection.LeftRight_TopBottom => true,
-            TextDirection.LeftRight_BottomTop => true,
-            _ => false
-        };
+               {
+                   TextDirection.LeftRight_TopBottom => true,
+                   TextDirection.LeftRight_BottomTop => true,
+                   _ => false
+               };
     }
 
     /// <summary>Check if it is Top to Bottom direction</summary>
     public static bool IsTopToBottom (TextDirection textDirection)
     {
         return textDirection switch
-        {
-            TextDirection.TopBottom_LeftRight => true,
-            TextDirection.TopBottom_RightLeft => true,
-            _ => false
-        };
+               {
+                   TextDirection.TopBottom_LeftRight => true,
+                   TextDirection.TopBottom_RightLeft => true,
+                   _ => false
+               };
     }
 
     // TODO: Move to StringExtensions?
@@ -1300,21 +1291,21 @@ public class TextFormatter
                     case ' ':
                         return GetNextWhiteSpace (to + 1, cWidth, out incomplete, length);
                     case '\t':
-                        {
-                            length += tabWidth + 1;
-
-                            if (length == tabWidth && tabWidth > cWidth)
-                            {
-                                return to + 1;
-                            }
+                    {
+                        length += tabWidth + 1;
 
-                            if (length > cWidth && tabWidth > cWidth)
-                            {
-                                return to;
-                            }
+                        if (length == tabWidth && tabWidth > cWidth)
+                        {
+                            return to + 1;
+                        }
 
-                            return GetNextWhiteSpace (to + 1, cWidth, out incomplete, length);
+                        if (length > cWidth && tabWidth > cWidth)
+                        {
+                            return to;
                         }
+
+                        return GetNextWhiteSpace (to + 1, cWidth, out incomplete, length);
+                    }
                     default:
                         to++;
 
@@ -1323,11 +1314,11 @@ public class TextFormatter
             }
 
             return cLength switch
-            {
-                > 0 when to < runes.Count && runes [to].Value != ' ' && runes [to].Value != '\t' => from,
-                > 0 when to < runes.Count && (runes [to].Value == ' ' || runes [to].Value == '\t') => from,
-                _ => to
-            };
+                   {
+                       > 0 when to < runes.Count && runes [to].Value != ' ' && runes [to].Value != '\t' => from,
+                       > 0 when to < runes.Count && (runes [to].Value == ' ' || runes [to].Value == '\t') => from,
+                       _ => to
+                   };
         }
 
         if (start < text.GetRuneCount ())
@@ -1511,7 +1502,6 @@ public class TextFormatter
     {
         ArgumentOutOfRangeException.ThrowIfNegative (width, nameof (width));
 
-
         if (string.IsNullOrEmpty (text))
         {
             return text;
@@ -1655,7 +1645,6 @@ public class TextFormatter
     {
         ArgumentOutOfRangeException.ThrowIfNegative (width, nameof (width));
 
-
         List<string> lineResult = new ();
 
         if (string.IsNullOrEmpty (text) || width == 0)
@@ -1765,13 +1754,13 @@ public class TextFormatter
     private static string PerformCorrectFormatDirection (TextDirection textDirection, string line)
     {
         return textDirection switch
-        {
-            TextDirection.RightLeft_BottomTop
-                or TextDirection.RightLeft_TopBottom
-                or TextDirection.BottomTop_LeftRight
-                or TextDirection.BottomTop_RightLeft => StringExtensions.ToString (line.EnumerateRunes ().Reverse ()),
-            _ => line
-        };
+               {
+                   TextDirection.RightLeft_BottomTop
+                       or TextDirection.RightLeft_TopBottom
+                       or TextDirection.BottomTop_LeftRight
+                       or TextDirection.BottomTop_RightLeft => StringExtensions.ToString (line.EnumerateRunes ().Reverse ()),
+                   _ => line
+               };
     }
 
     private static List<Rune> PerformCorrectFormatDirection (TextDirection textDirection, List<Rune> runes)
@@ -1782,13 +1771,13 @@ public class TextFormatter
     private static List<string> PerformCorrectFormatDirection (TextDirection textDirection, List<string> lines)
     {
         return textDirection switch
-        {
-            TextDirection.TopBottom_RightLeft
-                or TextDirection.LeftRight_BottomTop
-                or TextDirection.RightLeft_BottomTop
-                or TextDirection.BottomTop_RightLeft => lines.ToArray ().Reverse ().ToList (),
-            _ => lines
-        };
+               {
+                   TextDirection.TopBottom_RightLeft
+                       or TextDirection.LeftRight_BottomTop
+                       or TextDirection.RightLeft_BottomTop
+                       or TextDirection.BottomTop_RightLeft => lines.ToArray ().Reverse ().ToList (),
+                   _ => lines
+               };
     }
 
     /// <summary>
@@ -1998,7 +1987,6 @@ public class TextFormatter
     /// <param name="tabWidth">The number of columns used for a tab.</param>
     /// <returns></returns>
     [Obsolete ("CalcRect is deprecated, FormatAndGetSize instead.")]
-
     internal static Rectangle CalcRect (
         int x,
         int y,

+ 1 - 1
Terminal.Gui/View/Adornment/Adornment.cs

@@ -165,7 +165,7 @@ public class Adornment : View
         {
             if (TextFormatter is { })
             {
-                TextFormatter.Size = Frame.Size;
+                TextFormatter.ConstrainToSize = Frame.Size;
                 TextFormatter.NeedsFormat = true;
             }
         }

+ 1 - 1
Terminal.Gui/View/Adornment/Border.cs

@@ -421,7 +421,7 @@ public class Border : Adornment
                                                )
                                      );
 
-        Parent.TitleTextFormatter.Size = new (maxTitleWidth, 1);
+        Parent.TitleTextFormatter.ConstrainToSize = new (maxTitleWidth, 1);
 
         int sideLineLength = borderBounds.Height;
         bool canDrawBorder = borderBounds is { Width: > 0, Height: > 0 };

+ 7 - 7
Terminal.Gui/View/Layout/DimAuto.cs

@@ -88,27 +88,27 @@ public class DimAuto : Dim
         {
             if (dimension == Dimension.Width)
             {
-                if (us.TextFormatter.Width is null)
+                if (us.TextFormatter.ConstrainToWidth is null)
                 {
                     // Set BOTH width and height (by setting Size). We do this because we will be called again, next
                     // for Dimension.Height. We need to know the width to calculate the height.
-                    us.TextFormatter.Size = us.TextFormatter.FormatAndGetSize (new (int.Min (autoMax, screenX4), screenX4));
+                    us.TextFormatter.ConstrainToSize = us.TextFormatter.FormatAndGetSize (new (int.Min (autoMax, screenX4), screenX4));
                 }
 
-                textSize = us.TextFormatter.Width!.Value;
+                textSize = us.TextFormatter.ConstrainToWidth!.Value;
             }
             else
             {
-                if (us.TextFormatter.Height is null)
+                if (us.TextFormatter.ConstrainToHeight is null)
                 {
                     // Set just the height. It is assumed that the width has already been set.
                     // TODO: There may be cases where the width is not set. We may need to set it here.
-                    textSize = us.TextFormatter.FormatAndGetSize (new (us.TextFormatter.Width ?? screenX4, int.Min (autoMax, screenX4))).Height;
-                    us.TextFormatter.Height = textSize;
+                    textSize = us.TextFormatter.FormatAndGetSize (new (us.TextFormatter.ConstrainToWidth ?? screenX4, int.Min (autoMax, screenX4))).Height;
+                    us.TextFormatter.ConstrainToHeight = textSize;
                 }
                 else
                 {
-                    textSize = us.TextFormatter.Height.Value;
+                    textSize = us.TextFormatter.ConstrainToHeight.Value;
                 }
             }
         }

+ 6 - 6
Terminal.Gui/View/Layout/ViewLayout.cs

@@ -481,7 +481,7 @@ public partial class View
             _height = value ?? throw new ArgumentNullException (nameof (value), @$"{nameof (Height)} cannot be null");
 
             // Reset TextFormatter - Will be recalculated in SetTextFormatterSize
-            TextFormatter.Height = null;
+            TextFormatter.ConstrainToHeight = null;
 
             OnResizeNeeded ();
         }
@@ -530,7 +530,7 @@ public partial class View
             _width = value ?? throw new ArgumentNullException (nameof (value), @$"{nameof (Width)} cannot be null");
 
             // Reset TextFormatter - Will be recalculated in SetTextFormatterSize
-            TextFormatter.Width = null;
+            TextFormatter.ConstrainToWidth = null;
 
             OnResizeNeeded ();
         }
@@ -647,14 +647,14 @@ public partial class View
             SetNeedsDisplay ();
         }
 
-        if (TextFormatter.Width is null)
+        if (TextFormatter.ConstrainToWidth is null)
         {
-            TextFormatter.Width = GetContentSize ().Width;
+            TextFormatter.ConstrainToWidth = GetContentSize ().Width;
         }
 
-        if (TextFormatter.Height is null)
+        if (TextFormatter.ConstrainToHeight is null)
         {
-            TextFormatter.Height = GetContentSize ().Height;
+            TextFormatter.ConstrainToHeight = GetContentSize ().Height;
         }
     }
 

+ 1 - 1
Terminal.Gui/View/View.cs

@@ -479,7 +479,7 @@ public partial class View : Responder, ISupportInitializeNotification
 
     private void SetTitleTextFormatterSize ()
     {
-        TitleTextFormatter.Size = new (
+        TitleTextFormatter.ConstrainToSize = new (
                                        TextFormatter.GetWidestLineLength (TitleTextFormatter.Text)
                                        - (TitleTextFormatter.Text?.Contains ((char)HotKeySpecifier.Value) == true
                                               ? Math.Max (HotKeySpecifier.GetColumns (), 0)

+ 9 - 9
Terminal.Gui/View/ViewText.cs

@@ -158,15 +158,15 @@ public partial class View
     protected virtual void UpdateTextFormatterText ()
     {
         TextFormatter.Text = _text;
-        TextFormatter.Width = null;
-        TextFormatter.Height = null;
+        TextFormatter.ConstrainToWidth = null;
+        TextFormatter.ConstrainToHeight = null;
     }
 
     /// <summary>
     ///     Internal API. Sets <see cref="TextFormatter"/>.Width/Height.
     /// </summary>
     /// <remarks>
-    ///     Use this API to set <see cref="TextFormatter.Width"/>/Height when the view has changed such that the
+    ///     Use this API to set <see cref="Gui.TextFormatter.ConstrainToWidth"/>/Height when the view has changed such that the
     ///     size required to fit the text has changed.
     ///     changes.
     /// </remarks>
@@ -186,25 +186,25 @@ public partial class View
 
         if (widthAuto is { } && widthAuto.Style.FastHasFlags (DimAutoStyle.Text))
         {
-            TextFormatter.Width = null;
+            TextFormatter.ConstrainToWidth = null;
         }
         else
         {
             if (size is { })
             {
-                TextFormatter.Width = size?.Width;
+                TextFormatter.ConstrainToWidth = size?.Width;
             }
         }
 
         if (heightAuto is { } && heightAuto.Style.FastHasFlags (DimAutoStyle.Text))
         {
-            TextFormatter.Height = null;
+            TextFormatter.ConstrainToHeight = null;
         }
         else
         {
             if (size is { })
             {
-                TextFormatter.Height = size?.Height;
+                TextFormatter.ConstrainToHeight = size?.Height;
             }
         }
     }
@@ -227,8 +227,8 @@ public partial class View
 
         if (directionChanged)
         {
-            TextFormatter.Width = null;
-            TextFormatter.Height = null;
+            TextFormatter.ConstrainToWidth = null;
+            TextFormatter.ConstrainToHeight = null;
             OnResizeNeeded ();
         }
 

+ 2 - 2
Terminal.Gui/Views/Menu/Menu.cs

@@ -489,8 +489,8 @@ internal sealed class Menu : View
                 {
                     var tf = new TextFormatter
                     {
-                        Width = Frame.Width - 3,
-                        Height = 1,
+                        ConstrainToWidth = Frame.Width - 3,
+                        ConstrainToHeight = 1,
                         Alignment = Alignment.Center, HotKeySpecifier = MenuBar.HotKeySpecifier, Text = textToDraw
                     };
 

+ 43 - 70
UnitTests/Text/TextFormatterTests.cs

@@ -383,7 +383,7 @@ ssb
 
         Assert.True (tf.WordWrap);
 
-        tf.Size = new (width, height);
+        tf.ConstrainToSize = new (width, height);
 
         tf.Draw (
                  new (0, 0, width, height),
@@ -408,7 +408,7 @@ ssb
             Attribute.Default, new (ColorName.Green, ColorName.BrightMagenta),
             new (ColorName.Blue, ColorName.Cyan)
         };
-        var tf = new TextFormatter { Size = new (14, 3), Text = "Test\nTest long\nTest long long\n", MultiLine = true };
+        var tf = new TextFormatter { ConstrainToSize = new (14, 3), Text = "Test\nTest long\nTest long long\n", MultiLine = true };
 
         tf.Draw (
                  new (1, 1, 19, 3),
@@ -1164,7 +1164,7 @@ ssb
     {
         var tf = new TextFormatter
         {
-            Text = text, Size = new (maxWidth, maxHeight), WordWrap = false, MultiLine = multiLine
+            Text = text, ConstrainToSize = new (maxWidth, maxHeight), WordWrap = false, MultiLine = multiLine
         };
 
         Assert.False (tf.WordWrap);
@@ -1247,7 +1247,7 @@ ssb
         var tf = new TextFormatter
         {
             Text = text,
-            Size = new (maxWidth, maxHeight),
+            ConstrainToSize = new (maxWidth, maxHeight),
             WordWrap = false,
             MultiLine = multiLine,
             Direction = TextDirection.TopBottom_LeftRight
@@ -1277,7 +1277,7 @@ ssb
         tf.Draw (testBounds, new (), new ());
         Assert.False (tf.NeedsFormat);
 
-        tf.Size = new (1, 1);
+        tf.ConstrainToSize = new (1, 1);
         Assert.True (tf.NeedsFormat);
         Assert.NotEmpty (tf.GetLines ());
         Assert.False (tf.NeedsFormat); // get_Lines causes a Format
@@ -2034,8 +2034,8 @@ ssb
         tf.Direction = textDirection;
         tf.TabWidth = tabWidth;
         tf.Text = text;
-        tf.Width = 20;
-        tf.Height = 20;
+        tf.ConstrainToWidth = 20;
+        tf.ConstrainToHeight = 20;
 
         Assert.True (tf.WordWrap);
         Assert.False (tf.PreserveTrailingSpaces);
@@ -2075,8 +2075,8 @@ ssb
         tf.TabWidth = tabWidth;
         tf.PreserveTrailingSpaces = true;
         tf.Text = text;
-        tf.Width = 20;
-        tf.Height = 20;
+        tf.ConstrainToWidth = 20;
+        tf.ConstrainToHeight = 20;
 
         Assert.True (tf.WordWrap);
 
@@ -2115,8 +2115,8 @@ ssb
         tf.TabWidth = tabWidth;
         tf.WordWrap = true;
         tf.Text = text;
-        tf.Width = 20;
-        tf.Height = 20;
+        tf.ConstrainToWidth = 20;
+        tf.ConstrainToHeight = 20;
 
         Assert.False (tf.PreserveTrailingSpaces);
 
@@ -2158,8 +2158,8 @@ ssb
     public void Text_Set_SizeIsCorrect (string text, TextDirection textDirection, int expectedWidth, int expectedHeight)
     {
         var tf = new TextFormatter { Direction = textDirection, Text = text };
-        tf.Width = 10;
-        tf.Height = 10;
+        tf.ConstrainToWidth = 10;
+        tf.ConstrainToHeight = 10;
 
         Assert.Equal (new (expectedWidth, expectedHeight), tf.FormatAndGetSize ());
     }
@@ -3071,14 +3071,6 @@ ssb
     [InlineData ("ABC", 3, "ABC")]
     [InlineData ("ABC", 4, "ABC")]
     [InlineData ("ABC", 6, "ABC")]
-    [InlineData ("A", 0, "")]
-    [InlineData ("A", 1, "A")]
-    [InlineData ("A", 2, "A")]
-    [InlineData ("AB", 1, "A")]
-    [InlineData ("AB", 2, "AB")]
-    [InlineData ("ABC", 3, "ABC")]
-    [InlineData ("ABC", 4, "ABC")]
-    [InlineData ("ABC", 6, "ABC")]
     public void Draw_Horizontal_Left (string text, int width, string expectedText)
 
     {
@@ -3088,8 +3080,8 @@ ssb
             Alignment = Alignment.Start
         };
 
-        tf.Width = width;
-        tf.Height = 1;
+        tf.ConstrainToWidth = width;
+        tf.ConstrainToHeight = 1;
         tf.Draw (new (0, 0, width, 1), Attribute.Default, Attribute.Default);
 
         TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
@@ -3105,14 +3097,6 @@ ssb
     [InlineData ("ABC", 3, "ABC")]
     [InlineData ("ABC", 4, " ABC")]
     [InlineData ("ABC", 6, "   ABC")]
-    [InlineData ("A", 0, "")]
-    [InlineData ("A", 1, "A")]
-    [InlineData ("A", 2, " A")]
-    [InlineData ("AB", 1, "B")]
-    [InlineData ("AB", 2, "AB")]
-    [InlineData ("ABC", 3, "ABC")]
-    [InlineData ("ABC", 4, " ABC")]
-    [InlineData ("ABC", 6, "   ABC")]
     public void Draw_Horizontal_Right (string text, int width, string expectedText)
     {
         TextFormatter tf = new ()
@@ -3121,8 +3105,8 @@ ssb
             Alignment = Alignment.End
         };
 
-        tf.Width = width;
-        tf.Height = 1;
+        tf.ConstrainToWidth = width;
+        tf.ConstrainToHeight = 1;
 
         tf.Draw (new (Point.Empty, new (width, 1)), Attribute.Default, Attribute.Default);
         TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
@@ -3141,17 +3125,6 @@ ssb
     [InlineData ("ABC", 5, " ABC")]
     [InlineData ("ABC", 6, " ABC")]
     [InlineData ("ABC", 9, "   ABC")]
-    [InlineData ("A", 0, "")]
-    [InlineData ("A", 1, "A")]
-    [InlineData ("A", 2, "A")]
-    [InlineData ("A", 3, " A")]
-    [InlineData ("AB", 1, "A")]
-    [InlineData ("AB", 2, "AB")]
-    [InlineData ("ABC", 3, "ABC")]
-    [InlineData ("ABC", 4, "ABC")]
-    [InlineData ("ABC", 5, " ABC")]
-    [InlineData ("ABC", 6, " ABC")]
-    [InlineData ("ABC", 9, "   ABC")]
     public void Draw_Horizontal_Centered (string text, int width, string expectedText)
     {
         TextFormatter tf = new ()
@@ -3160,8 +3133,8 @@ ssb
             Alignment = Alignment.Center
         };
 
-        tf.Width = width;
-        tf.Height = 1;
+        tf.ConstrainToWidth = width;
+        tf.ConstrainToHeight = 1;
         tf.Draw (new (0, 0, width, 1), Attribute.Default, Attribute.Default);
 
         TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
@@ -3188,8 +3161,8 @@ ssb
             Alignment = Alignment.Fill
         };
 
-        tf.Width = width;
-        tf.Height = 1;
+        tf.ConstrainToWidth = width;
+        tf.ConstrainToHeight = 1;
         tf.Draw (new (0, 0, width, 1), Attribute.Default, Attribute.Default);
 
         TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
@@ -3258,8 +3231,8 @@ s")]
             Direction = TextDirection.TopBottom_LeftRight
         };
 
-        tf.Width = width;
-        tf.Height = height;
+        tf.ConstrainToWidth = width;
+        tf.ConstrainToHeight = height;
         tf.Draw (new (0, 0, 20, 20), Attribute.Default, Attribute.Default);
 
         TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
@@ -3289,7 +3262,7 @@ Nice       Work")]
         {
             Text = text,
             Alignment = Alignment.Fill,
-            Size = new Size (width, height),
+            ConstrainToSize = new Size (width, height),
             MultiLine = true
         };
 
@@ -3349,7 +3322,7 @@ ek")]
             Text = text,
             Direction = TextDirection.TopBottom_LeftRight,
             VerticalAlignment = Alignment.Fill,
-            Size = new Size (width, height),
+            ConstrainToSize = new Size (width, height),
             MultiLine = true
         };
 
@@ -3389,8 +3362,8 @@ ek")]
             VerticalAlignment = Alignment.End
         };
 
-        tf.Width = width;
-        tf.Height = height;
+        tf.ConstrainToWidth = width;
+        tf.ConstrainToHeight = height;
 
         tf.Draw (new (Point.Empty, new (width, height)), Attribute.Default, Attribute.Default);
         Rectangle rect = TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
@@ -3449,8 +3422,8 @@ B  ")]
             Direction = TextDirection.TopBottom_LeftRight
         };
 
-        tf.Width = 5;
-        tf.Height = height;
+        tf.ConstrainToWidth = 5;
+        tf.ConstrainToHeight = height;
         tf.Draw (new (0, 0, 5, height), Attribute.Default, Attribute.Default);
 
         TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
@@ -3498,8 +3471,8 @@ B  ")]
             width++;
         }
 
-        tf.Width = width;
-        tf.Height = height;
+        tf.ConstrainToWidth = width;
+        tf.ConstrainToHeight = height;
         tf.Draw (new (0, 0, 5, height), Attribute.Default, Attribute.Default);
 
         Rectangle rect = TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
@@ -3527,8 +3500,8 @@ B  ")]
             Direction = TextDirection.RightLeft_TopBottom
         };
 
-        tf.Width = width;
-        tf.Height = height;
+        tf.ConstrainToWidth = width;
+        tf.ConstrainToHeight = height;
         tf.Draw (new (0, 0, width, height), Attribute.Default, Attribute.Default);
 
         TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
@@ -3555,8 +3528,8 @@ B  ")]
             Direction = TextDirection.RightLeft_BottomTop
         };
 
-        tf.Width = width;
-        tf.Height = height;
+        tf.ConstrainToWidth = width;
+        tf.ConstrainToHeight = height;
         tf.Draw (new (0, 0, width, height), Attribute.Default, Attribute.Default);
 
         TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
@@ -3583,8 +3556,8 @@ B  ")]
             Direction = TextDirection.BottomTop_LeftRight
         };
 
-        tf.Width = width;
-        tf.Height = height;
+        tf.ConstrainToWidth = width;
+        tf.ConstrainToHeight = height;
         tf.Draw (new (0, 0, width, height), Attribute.Default, Attribute.Default);
 
         TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
@@ -3611,8 +3584,8 @@ B  ")]
             Direction = TextDirection.BottomTop_RightLeft
         };
 
-        tf.Width = width;
-        tf.Height = height;
+        tf.ConstrainToWidth = width;
+        tf.ConstrainToHeight = height;
         tf.Draw (new (0, 0, width, height), Attribute.Default, Attribute.Default);
 
         TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
@@ -7063,7 +7036,7 @@ B  ")]
             Alignment = horizontalTextAlignment,
             VerticalAlignment = alignment,
             Direction = textDirection,
-            Size = new (7, 7),
+            ConstrainToSize = new (7, 7),
             Text = text
         };
 
@@ -7217,8 +7190,8 @@ B  ")]
         TextFormatter tf = new ()
         {
             Direction = direction,
-            Width = width,
-            Height = height,
+            ConstrainToWidth = width,
+            ConstrainToHeight = height,
             Text = text
         };
         Assert.True (tf.WordWrap);
@@ -7301,7 +7274,7 @@ B  ")]
         TextFormatter tf = new ()
         {
             Direction = direction,
-            Size = new (width, height),
+            ConstrainToSize = new (width, height),
             Text = text,
             WordWrap = false
         };

+ 6 - 6
UnitTests/View/Layout/Dim.AutoTests.cs

@@ -936,8 +936,8 @@ public partial class DimAutoTests (ITestOutputHelper output)
             Height = 1,
             Width = Auto ()
         };
-        Assert.Equal (expected, view.TextFormatter.Width);
-        Assert.Equal (1, view.TextFormatter.Height);
+        Assert.Equal (expected, view.TextFormatter.ConstrainToWidth);
+        Assert.Equal (1, view.TextFormatter.ConstrainToHeight);
     }
 
     [Theory]
@@ -952,8 +952,8 @@ public partial class DimAutoTests (ITestOutputHelper output)
             Width = Auto (),
             Height = 1
         };
-        Assert.Equal (expected, view.TextFormatter.Width);
-        Assert.Equal (1, view.TextFormatter.Height);
+        Assert.Equal (expected, view.TextFormatter.ConstrainToWidth);
+        Assert.Equal (1, view.TextFormatter.ConstrainToHeight);
 
         view = new ()
         {
@@ -963,8 +963,8 @@ public partial class DimAutoTests (ITestOutputHelper output)
             Width = 1,
             Height = Auto ()
         };
-        Assert.Equal (1, view.TextFormatter.Width);
-        Assert.Equal (expected, view.TextFormatter.Height);
+        Assert.Equal (1, view.TextFormatter.ConstrainToWidth);
+        Assert.Equal (expected, view.TextFormatter.ConstrainToHeight);
     }
 
     // Test variations of Frame

+ 26 - 26
UnitTests/View/TextTests.cs

@@ -18,7 +18,7 @@ public class TextTests (ITestOutputHelper output)
     {
         var view = new View ();
         view.Text = text;
-        Assert.Equal (new (expectedW, expectedH), view.TextFormatter.Size);
+        Assert.Equal (new (expectedW, expectedH), view.TextFormatter.ConstrainToSize);
     }
 
     // TextFormatter.Size should track ContentSize (without DimAuto)
@@ -31,7 +31,7 @@ public class TextTests (ITestOutputHelper output)
         var view = new View ();
         view.SetContentSize (new (1, 1));
         view.Text = text;
-        Assert.Equal (new (expectedW, expectedH), view.TextFormatter.Size);
+        Assert.Equal (new (expectedW, expectedH), view.TextFormatter.ConstrainToSize);
     }
 
     [Fact]
@@ -276,9 +276,9 @@ Y
 
         view.Width = 12;
         view.Height = 1;
-        view.TextFormatter.Size = new (12, 1);
+        view.TextFormatter.ConstrainToSize = new (12, 1);
         win.LayoutSubviews ();
-        Assert.Equal (new (12, 1), view.TextFormatter.Size);
+        Assert.Equal (new (12, 1), view.TextFormatter.ConstrainToSize);
         Assert.Equal (new (0, 0, 12, 1), view.Frame);
         top.Clear ();
         view.Draw ();
@@ -420,7 +420,7 @@ Y
         Assert.Equal (5, text.Length);
 
         Assert.Equal (new (0, 0, 1, 5), view.Frame);
-        Assert.Equal (new (1, 5), view.TextFormatter.Size);
+        Assert.Equal (new (1, 5), view.TextFormatter.ConstrainToSize);
         Assert.Equal (new () { "Views" }, view.TextFormatter.GetLines ());
         Assert.Equal (new (0, 0, 4, 10), win.Frame);
         Assert.Equal (new (0, 0, 4, 10), Application.Top.Frame);
@@ -448,7 +448,7 @@ Y
         Application.Refresh ();
 
         Assert.Equal (new (0, 0, 1, 5), view.Frame);
-        Assert.Equal (new (1, 5), view.TextFormatter.Size);
+        Assert.Equal (new (1, 5), view.TextFormatter.ConstrainToSize);
         Exception exception = Record.Exception (() => Assert.Single (view.TextFormatter.GetLines ()));
         Assert.Null (exception);
 
@@ -490,7 +490,7 @@ Y
 
         // 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 (2, 5), view.TextFormatter.ConstrainToSize);
         Assert.Equal (new () { "界View" }, view.TextFormatter.GetLines ());
 
         view.Draw ();
@@ -630,8 +630,8 @@ w ";
         RunState rs = Application.Begin (top);
         ((FakeDriver)Application.Driver).SetBufferSize (22, 22);
 
-        Assert.Equal (new (text.GetColumns (), 1), horizontalView.TextFormatter.Size);
-        Assert.Equal (new (2, 8), verticalView.TextFormatter.Size);
+        Assert.Equal (new (text.GetColumns (), 1), horizontalView.TextFormatter.ConstrainToSize);
+        Assert.Equal (new (2, 8), verticalView.TextFormatter.ConstrainToSize);
 
         //Assert.Equal (new (0, 0, 10, 1), horizontalView.Frame);
         //Assert.Equal (new (0, 3, 10, 9), verticalView.Frame);
@@ -785,10 +785,10 @@ w ";
 
         // frame.Width is width + border wide (20 + 2) and 6 high
         Size expectedSize = new (width, 1);
-        Assert.Equal (expectedSize, lblLeft.TextFormatter.Size);
-        Assert.Equal (expectedSize, lblCenter.TextFormatter.Size);
-        Assert.Equal (expectedSize, lblRight.TextFormatter.Size);
-        Assert.Equal (expectedSize, lblJust.TextFormatter.Size);
+        Assert.Equal (expectedSize, lblLeft.TextFormatter.ConstrainToSize);
+        Assert.Equal (expectedSize, lblCenter.TextFormatter.ConstrainToSize);
+        Assert.Equal (expectedSize, lblRight.TextFormatter.ConstrainToSize);
+        Assert.Equal (expectedSize, lblJust.TextFormatter.ConstrainToSize);
 
         Assert.Equal (new (0, 0, width + 2, 6), frame.Frame);
 
@@ -889,18 +889,18 @@ w ";
 
         if (autoSize)
         {
-            Assert.Equal (new (1, 11), lblLeft.TextFormatter.Size);
-            Assert.Equal (new (1, 11), lblCenter.TextFormatter.Size);
-            Assert.Equal (new (1, 11), lblRight.TextFormatter.Size);
-            Assert.Equal (new (1, 11), lblJust.TextFormatter.Size);
+            Assert.Equal (new (1, 11), lblLeft.TextFormatter.ConstrainToSize);
+            Assert.Equal (new (1, 11), lblCenter.TextFormatter.ConstrainToSize);
+            Assert.Equal (new (1, 11), lblRight.TextFormatter.ConstrainToSize);
+            Assert.Equal (new (1, 11), lblJust.TextFormatter.ConstrainToSize);
             Assert.Equal (new (0, 0, 9, height + 2), frame.Frame);
         }
         else
         {
-            Assert.Equal (new (1, height), lblLeft.TextFormatter.Size);
-            Assert.Equal (new (1, height), lblCenter.TextFormatter.Size);
-            Assert.Equal (new (1, height), lblRight.TextFormatter.Size);
-            Assert.Equal (new (1, height), lblJust.TextFormatter.Size);
+            Assert.Equal (new (1, height), lblLeft.TextFormatter.ConstrainToSize);
+            Assert.Equal (new (1, height), lblCenter.TextFormatter.ConstrainToSize);
+            Assert.Equal (new (1, height), lblRight.TextFormatter.ConstrainToSize);
+            Assert.Equal (new (1, height), lblJust.TextFormatter.ConstrainToSize);
             Assert.Equal (new (0, 0, 9, height + 2), frame.Frame);
         }
 
@@ -974,7 +974,7 @@ w ";
         Assert.Equal ("Hello World ", view.TextFormatter.Text);
 
         view.TextFormatter.WordWrap = true;
-        view.TextFormatter.Size = new (5, 3);
+        view.TextFormatter.ConstrainToSize = new (5, 3);
 
         view.PreserveTrailingSpaces = false;
         Assert.Equal ($"Hello{Environment.NewLine}World", view.TextFormatter.Format ());
@@ -1101,7 +1101,7 @@ w ";
         Assert.Equal (new (0, 0, 10, 1), view.Frame);
         Assert.Equal (new (0, 0, 10, 1), view.Viewport);
 
-        Assert.Equal (new (10, 1), view.TextFormatter.Size);
+        Assert.Equal (new (10, 1), view.TextFormatter.ConstrainToSize);
     }
 
     [Fact]
@@ -1136,7 +1136,7 @@ w ";
         var horizontalView = new View { Width = 20, Height = 1, Text = text };
 
         // Autosize is off, so we have to explicitly set TextFormatter.Size
-        horizontalView.TextFormatter.Size = new (20, 1);
+        horizontalView.TextFormatter.ConstrainToSize = new (20, 1);
 
         var verticalView = new View
         {
@@ -1148,7 +1148,7 @@ w ";
         };
 
         // Autosize is off, so we have to explicitly set TextFormatter.Size
-        verticalView.TextFormatter.Size = new (1, 20);
+        verticalView.TextFormatter.ConstrainToSize = new (1, 20);
 
         var frame = new FrameView { Width = Dim.Fill (), Height = Dim.Fill (), Text = "Window" };
         frame.Add (horizontalView, verticalView);
@@ -1204,7 +1204,7 @@ w ";
         // Autosize is off, so we have to explicitly set TextFormatter.Size
         // We know these glpyhs are 2 cols wide, so we need to widen the view
         verticalView.Width = 2;
-        verticalView.TextFormatter.Size = new (2, 20);
+        verticalView.TextFormatter.ConstrainToSize = new (2, 20);
         Assert.True (verticalView.TextFormatter.NeedsFormat);
 
         top.Draw ();

+ 4 - 4
UnitTests/Views/ButtonTests.cs

@@ -62,7 +62,7 @@ public class ButtonTests (ITestOutputHelper output)
         Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.Frame.Size);
         Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.Viewport.Size);
         Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.GetContentSize ());
-        Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.TextFormatter.Size);
+        Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.TextFormatter.ConstrainToSize);
 
         btn1.Dispose ();
     }
@@ -82,7 +82,7 @@ public class ButtonTests (ITestOutputHelper output)
 
         Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.Frame.Size);
         Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.Viewport.Size);
-        Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.TextFormatter.Size);
+        Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.TextFormatter.ConstrainToSize);
 
         btn1.Dispose ();
     }
@@ -176,7 +176,7 @@ public class ButtonTests (ITestOutputHelper output)
         btn.Dispose ();
 
         btn = new () { Text = "_Test", IsDefault = true };
-        Assert.Equal (new (10, 1), btn.TextFormatter.Size);
+        Assert.Equal (new (10, 1), btn.TextFormatter.ConstrainToSize);
 
 
 
@@ -199,7 +199,7 @@ public class ButtonTests (ITestOutputHelper output)
         // [* Test *]
         Assert.Equal ('_', btn.HotKeySpecifier.Value);
         Assert.Equal (10, btn.TextFormatter.Format ().Length);
-        Assert.Equal (new (10, 1), btn.TextFormatter.Size);
+        Assert.Equal (new (10, 1), btn.TextFormatter.ConstrainToSize);
         Assert.Equal (new (10, 1), btn.GetContentSize ());
         Assert.Equal (new (0, 0, 10, 1), btn.Viewport);
         Assert.Equal (new (0, 0, 10, 1), btn.Frame);

+ 7 - 7
UnitTests/Views/CheckBoxTests.cs

@@ -38,7 +38,7 @@ public class CheckBoxTests (ITestOutputHelper output)
 
         Assert.Equal (new (expectedWidth, expectedHeight), checkBox.Frame.Size);
         Assert.Equal (new (expectedWidth, expectedHeight), checkBox.Viewport.Size);
-        Assert.Equal (new (expectedWidth, expectedHeight), checkBox.TextFormatter.Size);
+        Assert.Equal (new (expectedWidth, expectedHeight), checkBox.TextFormatter.ConstrainToSize);
 
         checkBox.Dispose ();
     }
@@ -62,7 +62,7 @@ public class CheckBoxTests (ITestOutputHelper output)
 
         Assert.Equal (new (expectedWidth, expectedHeight), checkBox.Frame.Size);
         Assert.Equal (new (expectedWidth, expectedHeight), checkBox.Viewport.Size);
-        Assert.Equal (new (expectedWidth, expectedHeight), checkBox.TextFormatter.Size);
+        Assert.Equal (new (expectedWidth, expectedHeight), checkBox.TextFormatter.ConstrainToSize);
 
         checkBox.Dispose ();
     }
@@ -258,7 +258,7 @@ public class CheckBoxTests (ITestOutputHelper output)
 
         Assert.Equal (Alignment.Center, checkBox.TextAlignment);
         Assert.Equal (new (1, 1, 25, 1), checkBox.Frame);
-        Assert.Equal (_size25x1, checkBox.TextFormatter.Size);
+        Assert.Equal (_size25x1, checkBox.TextFormatter.ConstrainToSize);
 
         var expected = @$"
 ┌┤Test Demo 你├──────────────┐
@@ -335,10 +335,10 @@ public class CheckBoxTests (ITestOutputHelper output)
 
         checkBox1.State = CheckState.Checked;
         Assert.Equal (new (1, 1, 25, 1), checkBox1.Frame);
-        Assert.Equal (_size25x1, checkBox1.TextFormatter.Size);
+        Assert.Equal (_size25x1, checkBox1.TextFormatter.ConstrainToSize);
         checkBox2.State = CheckState.Checked;
         Assert.Equal (new (1, 2, 25, 1), checkBox2.Frame);
-        Assert.Equal (_size25x1, checkBox2.TextFormatter.Size);
+        Assert.Equal (_size25x1, checkBox2.TextFormatter.ConstrainToSize);
         Application.Refresh ();
 
         expected = @$"
@@ -376,7 +376,7 @@ public class CheckBoxTests (ITestOutputHelper output)
 
         Assert.Equal (Alignment.Start, checkBox.TextAlignment);
         Assert.Equal (new (1, 1, 25, 1), checkBox.Frame);
-        Assert.Equal (_size25x1, checkBox.TextFormatter.Size);
+        Assert.Equal (_size25x1, checkBox.TextFormatter.ConstrainToSize);
 
         var expected = @$"
 ┌┤Test Demo 你├──────────────┐
@@ -427,7 +427,7 @@ public class CheckBoxTests (ITestOutputHelper output)
 
         Assert.Equal (Alignment.End, checkBox.TextAlignment);
         Assert.Equal (new (1, 1, 25, 1), checkBox.Frame);
-        Assert.Equal (_size25x1, checkBox.TextFormatter.Size);
+        Assert.Equal (_size25x1, checkBox.TextFormatter.ConstrainToSize);
 
         var expected = @$"
 ┌┤Test Demo 你├──────────────┐

+ 6 - 6
UnitTests/Views/LabelTests.cs

@@ -184,10 +184,10 @@ public class LabelTests (ITestOutputHelper output)
 
         var label = new Label { Text = "This label needs to be cleared before rewritten.", Width = tfSize.Width, Height = tfSize.Height };
 
-        var tf1 = new TextFormatter { Direction = TextDirection.LeftRight_TopBottom, Size = tfSize };
+        var tf1 = new TextFormatter { Direction = TextDirection.LeftRight_TopBottom, ConstrainToSize = tfSize };
         tf1.Text = "This TextFormatter (tf1) without fill will not be cleared on rewritten.";
 
-        var tf2 = new TextFormatter { Direction = TextDirection.LeftRight_TopBottom, Size = tfSize, FillRemaining = true };
+        var tf2 = new TextFormatter { Direction = TextDirection.LeftRight_TopBottom, ConstrainToSize = tfSize, FillRemaining = true };
         tf2.Text = "This TextFormatter (tf2) with fill will be cleared on rewritten.";
 
         var top = new Toplevel ();
@@ -1201,7 +1201,7 @@ e
 
         Assert.Equal (5, text.Length);
         Assert.Equal (new (0, 0, 5, 1), label.Frame);
-        Assert.Equal (new (5, 1), label.TextFormatter.Size);
+        Assert.Equal (new (5, 1), label.TextFormatter.ConstrainToSize);
         Assert.Equal (["Label"], label.TextFormatter.GetLines ());
         Assert.Equal (new (0, 0, 10, 4), win.Frame);
         Assert.Equal (new (0, 0, 10, 4), Application.Top.Frame);
@@ -1223,7 +1223,7 @@ e
         Application.Refresh ();
 
         Assert.Equal (new (0, 0, 5, 1), label.Frame);
-        Assert.Equal (new (5, 1), label.TextFormatter.Size);
+        Assert.Equal (new (5, 1), label.TextFormatter.ConstrainToSize);
         Exception exception = Record.Exception (() => Assert.Single (label.TextFormatter.GetLines ()));
         Assert.Null (exception);
 
@@ -1260,7 +1260,7 @@ e
 
         Assert.Equal (5, text.Length);
         Assert.Equal (new (0, 0, 5, 1), label.Frame);
-        Assert.Equal (new (5, 1), label.TextFormatter.Size);
+        Assert.Equal (new (5, 1), label.TextFormatter.ConstrainToSize);
         Assert.Equal (["Label"], label.TextFormatter.GetLines ());
         Assert.Equal (new (0, 0, 10, 4), win.Frame);
         Assert.Equal (new (0, 0, 10, 4), Application.Top.Frame);
@@ -1282,7 +1282,7 @@ e
         Application.Refresh ();
 
         Assert.Equal (new (0, 0, 5, 1), label.Frame);
-        Assert.Equal (new (5, 1), label.TextFormatter.Size);
+        Assert.Equal (new (5, 1), label.TextFormatter.ConstrainToSize);
         Assert.Single (label.TextFormatter.GetLines ());
 
         expected = @"