Merge branch 'gui-cs:develop' into splitcontainer

This commit is contained in:
Thomas Nind
2023-01-15 10:35:47 +00:00
committed by GitHub
2 changed files with 18 additions and 4 deletions

View File

@@ -613,8 +613,9 @@ namespace Terminal.Gui {
}
nx = Math.Max (x, 0);
nx = nx + top.Frame.Width > l ? Math.Max (l - top.Frame.Width, 0) : nx;
if (nx + (top.Border != null && top.Border.DrawMarginFrame ? 2 : 1) > top.Frame.X + top.Frame.Width) {
nx = Math.Max (top.Frame.Right - (top.Border.DrawMarginFrame ? 2 : 1), 0);
var mfLength = top.Border?.DrawMarginFrame == true ? 2 : 1;
if (nx + mfLength > top.Frame.X + top.Frame.Width) {
nx = Math.Max (top.Frame.Right - mfLength, 0);
}
//System.Diagnostics.Debug.WriteLine ($"nx:{nx}, rWidth:{rWidth}");
bool m, s;
@@ -653,8 +654,8 @@ namespace Terminal.Gui {
}
ny = Math.Min (ny, l);
ny = ny + top.Frame.Height >= l ? Math.Max (l - top.Frame.Height, m ? 1 : 0) : ny;
if (ny + (top.Border != null && top.Border.DrawMarginFrame ? 2 : 1) > top.Frame.Y + top.Frame.Height) {
ny = Math.Max (top.Frame.Bottom - (top.Border.DrawMarginFrame ? 2 : 1), 0);
if (ny + mfLength > top.Frame.Y + top.Frame.Height) {
ny = Math.Max (top.Frame.Bottom - mfLength, 0);
}
//System.Diagnostics.Debug.WriteLine ($"ny:{ny}, rHeight:{rHeight}");

View File

@@ -967,5 +967,18 @@ namespace Terminal.Gui.Core {
Application.Run ();
}
[Fact, AutoInitShutdown]
public void EnsureVisibleBounds_With_Border_Null_Not_Throws ()
{
var top = new Toplevel ();
Application.Begin (top);
var exception = Record.Exception (() => ((FakeDriver)Application.Driver).SetBufferSize (0, 10));
Assert.Null (exception);
exception = Record.Exception (() => ((FakeDriver)Application.Driver).SetBufferSize (10, 0));
Assert.Null (exception);
}
}
}