diff --git a/Terminal.Gui/Core/TextFormatter.cs b/Terminal.Gui/Core/TextFormatter.cs
index e6e1592e3..727f6566f 100644
--- a/Terminal.Gui/Core/TextFormatter.cs
+++ b/Terminal.Gui/Core/TextFormatter.cs
@@ -1176,24 +1176,35 @@ namespace Terminal.Gui {
}
var isVertical = IsVerticalDirection (textDirection);
- var savedClip = Application.Driver?.Clip;
- var maxBounds = bounds;
- if (Application.Driver != null) {
- Application.Driver.Clip = maxBounds = containerBounds == default
- ? bounds
- : new Rect (Math.Max (containerBounds.X, bounds.X),
+ var maxBounds = containerBounds == default
+ ? bounds
+ : new Rect (Math.Max (containerBounds.X, bounds.X),
Math.Max (containerBounds.Y, bounds.Y),
- Math.Max (Math.Min (containerBounds.Width, containerBounds.Right - bounds.Left), 0),
- Math.Max (Math.Min (containerBounds.Height, containerBounds.Bottom - bounds.Top), 0));
+ Math.Max (Math.Max (containerBounds.Width, containerBounds.Right - bounds.Left), 0),
+ Math.Max (Math.Max (containerBounds.Height, containerBounds.Bottom - bounds.Top), 0));
+
+ int boundsStart = 0;
+ if (isVertical) {
+ if (bounds.X < 0) {
+ boundsStart = bounds.X;
+ }
+ } else {
+ if (bounds.Y < 0) {
+ boundsStart = bounds.Y;
+ }
}
-
for (int line = 0; line < linesFormated.Count; line++) {
- if ((isVertical && line > bounds.Width) || (!isVertical && line > bounds.Height))
+ if (boundsStart < 0) {
+ boundsStart++;
continue;
+ }
+ if ((isVertical && line > bounds.Width) || (!isVertical && line > bounds.Height)) {
+ continue;
+ }
if ((isVertical && line >= maxBounds.Left + maxBounds.Width)
- || (!isVertical && line >= maxBounds.Top + maxBounds.Height))
-
+ || (!isVertical && line >= maxBounds.Top + maxBounds.Height)) {
break;
+ }
var runes = lines [line].ToRunes ();
@@ -1278,8 +1289,9 @@ namespace Terminal.Gui {
} else if (!fillRemaining && idx > runes.Length - 1) {
break;
}
- if ((!isVertical && idx > maxBounds.Left + maxBounds.Width - bounds.X) || (isVertical && idx > maxBounds.Top + maxBounds.Height - bounds.Y))
+ if ((!isVertical && idx >= maxBounds.Left + maxBounds.Width - bounds.X) || (isVertical && idx >= maxBounds.Top + maxBounds.Height - bounds.Y)) {
break;
+ }
var rune = (Rune)' ';
if (isVertical) {
@@ -1316,8 +1328,6 @@ namespace Terminal.Gui {
}
}
}
- if (Application.Driver != null)
- Application.Driver.Clip = (Rect)savedClip;
}
}
}
diff --git a/Terminal.Gui/Core/View.cs b/Terminal.Gui/Core/View.cs
index 371d08bea..129a2b175 100644
--- a/Terminal.Gui/Core/View.cs
+++ b/Terminal.Gui/Core/View.cs
@@ -1128,7 +1128,7 @@ namespace Terminal.Gui {
/// Absolute column; screen-relative.
/// Absolute row; screen-relative.
/// Whether to clip the result of the ViewToScreen method, if set to , the rcol, rrow values are clamped to the screen (terminal) dimensions (0..TerminalDim-1).
- internal void ViewToScreen (int col, int row, out int rcol, out int rrow, bool clipped = true)
+ internal void ViewToScreen (int col, int row, out int rcol, out int rrow, bool clipped = false)
{
// Computes the real row, col relative to the screen.
rrow = row + frame.Y;
@@ -1268,7 +1268,7 @@ namespace Terminal.Gui {
/// Row.
/// Whether to clip the result of the ViewToScreen method,
/// if set to , the col, row values are clamped to the screen (terminal) dimensions (0..TerminalDim-1).
- public void Move (int col, int row, bool clipped = true)
+ public void Move (int col, int row, bool clipped = false)
{
if (Driver.Rows == 0) {
return;
diff --git a/UnitTests/Views/ViewTests.cs b/UnitTests/Views/ViewTests.cs
index 65141c210..b4b8d19bf 100644
--- a/UnitTests/Views/ViewTests.cs
+++ b/UnitTests/Views/ViewTests.cs
@@ -4499,5 +4499,26 @@ At 0,0
222";
TestHelpers.AssertDriverContentsAre (looksLike, output);
}
+
+ [Fact, AutoInitShutdown]
+ public void Move_And_ViewToScreen_Should_Not_Use_Clipped_Parameter_As_True_By_Default_But_Only_For_Cursor ()
+ {
+ var container = new View () { Width = 10, Height = 2 };
+ var top = new View () { Width = 10, Height = 1 };
+ var label = new Label ("Label");
+ top.Add (label);
+ var bottom = new View () { Y = 1, Width = 10, Height = 1 };
+ container.Add (top, bottom);
+ Application.Top.Add (container);
+ Application.Begin (Application.Top);
+
+ TestHelpers.AssertDriverContentsAre (@"
+Label", output);
+
+ ((FakeDriver)Application.Driver).SetBufferSize (10, 1);
+ Application.Refresh ();
+ TestHelpers.AssertDriverContentsAre (@"
+Label", output);
+ }
}
}