diff --git a/Terminal.Gui/Application.cs b/Terminal.Gui/Application.cs
index 7ef986d40..5e17af95f 100644
--- a/Terminal.Gui/Application.cs
+++ b/Terminal.Gui/Application.cs
@@ -882,7 +882,7 @@ public static partial class Application
}
else
{
- Driver.UpdateCursor ();
+ //Driver.UpdateCursor ();
}
if (state.Toplevel != Top && !state.Toplevel.Modal && (Top.NeedsDisplay || Top.SubViewNeedsDisplay || Top.LayoutNeeded))
diff --git a/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs b/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs
index bafbe9589..142d305c2 100644
--- a/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs
+++ b/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs
@@ -314,28 +314,23 @@ public abstract class ConsoleDriver
// TODO: This method is really "Clear Contents" now and should not be abstract (or virtual)
Contents = new Cell [Rows, Cols];
//CONCURRENCY: Unsynchronized access to Clip isn't safe.
- Clip = new (0, 0, Cols, Rows);
+ // TODO: ClearContents should not clear the clip; it should only clear the contents. Move clearing it elsewhere.
+ Clip = Screen;
_dirtyLines = new bool [Rows];
lock (Contents)
{
- // Can raise an exception while is still resizing.
- try
+ for (var row = 0; row < Rows; row++)
{
- for (var row = 0; row < Rows; row++)
+ for (var c = 0; c < Cols; c++)
{
- for (var c = 0; c < Cols; c++)
+ Contents [row, c] = new Cell
{
- Contents [row, c] = new Cell
- {
- Rune = (Rune)' ', Attribute = new Attribute (Color.White, Color.Black), IsDirty = true
- };
- _dirtyLines [row] = true;
- }
+ Rune = (Rune)' ', Attribute = new Attribute (Color.White, Color.Black), IsDirty = true
+ };
+ _dirtyLines [row] = true;
}
}
- catch (IndexOutOfRangeException)
- { }
}
}
@@ -343,18 +338,27 @@ public abstract class ConsoleDriver
/// upon success
public abstract bool EnsureCursorVisibility ();
- // TODO: Move FillRect to ./Drawing
- /// Fills the specified rectangle with the specified rune.
- ///
- ///
+ /// Fills the specified rectangle with the specified rune, using
+ ///
+ /// The value of is honored. Any parts of the rectangle not in the clip will not be drawn.
+ ///
+ /// The Screen-relative rectangle.
+ /// The Rune used to fill the rectangle
public void FillRect (Rectangle rect, Rune rune = default)
{
- for (int r = rect.Y; r < rect.Y + rect.Height; r++)
+ rect = Rectangle.Intersect (rect, Clip);
+ lock (Contents)
{
- for (int c = rect.X; c < rect.X + rect.Width; c++)
+ for (int r = rect.Y; r < rect.Y + rect.Height; r++)
{
- Move (c, r);
- AddRune (rune == default (Rune) ? new Rune (' ') : rune);
+ for (int c = rect.X; c < rect.X + rect.Width; c++)
+ {
+ Contents [r, c] = new Cell
+ {
+ Rune = (Rune)' ', Attribute = CurrentAttribute, IsDirty = true
+ };
+ _dirtyLines [r] = true;
+ }
}
}
}
diff --git a/UICatalog/Scenarios/Scrolling.cs b/UICatalog/Scenarios/Scrolling.cs
index 082e9f4af..f2f77292d 100644
--- a/UICatalog/Scenarios/Scrolling.cs
+++ b/UICatalog/Scenarios/Scrolling.cs
@@ -24,6 +24,7 @@ public class Scrolling : Scenario
Y = 3,
Width = Dim.Fill (3),
Height = Dim.Fill (3),
+ BorderStyle = LineStyle.None
};
var label = new Label { X = 0, Y = 0 };
@@ -37,13 +38,13 @@ public class Scrolling : Scenario
Width = 60,
Height = 20,
ColorScheme = Colors.ColorSchemes ["TopLevel"],
- ContentSize = new (200, 100),
+ ContentSize = new (120, 40),
//ContentOffset = Point.Empty,
ShowVerticalScrollIndicator = true,
ShowHorizontalScrollIndicator = true
};
- scrollView.Padding.Thickness = new (1);
+ // scrollView.Padding.Thickness = new (1);
label.Text = $"{scrollView}\nContentSize: {scrollView.ContentSize}\nContentOffset: {scrollView.ContentOffset}";
@@ -58,6 +59,7 @@ public class Scrolling : Scenario
Height = 2,
ColorScheme = Colors.ColorSchemes ["Error"]
};
+ horizontalRuler.Visible = false;
scrollView.Add (horizontalRuler);
const string vrule = "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n";
@@ -71,9 +73,11 @@ public class Scrolling : Scenario
Height = Dim.Fill (),
ColorScheme = Colors.ColorSchemes ["Error"]
};
+ horizontalRuler.Visible = false;
scrollView.Add (verticalRuler);
var pressMeButton = new Button { X = 3, Y = 3, Text = "Press me!" };
+ pressMeButton.Visible = false;
pressMeButton.Accept += (s, e) => MessageBox.Query (20, 7, "MessageBox", "Neat?", "Yes", "No");
scrollView.Add (pressMeButton);
@@ -85,6 +89,7 @@ public class Scrolling : Scenario
Width = Dim.Fill (3),
Text = "A very long button. Should be wide enough to demo clipping!"
};
+ aLongButton.Visible = false;
aLongButton.Accept += (s, e) => MessageBox.Query (20, 7, "MessageBox", "Neat?", "Yes", "No");
scrollView.Add (aLongButton);
@@ -95,7 +100,8 @@ public class Scrolling : Scenario
Y = 5,
Width = 50,
ColorScheme = Colors.ColorSchemes ["Dialog"],
- Text = "This is a test of..."
+ Text = "This is a test of...",
+ //Visible = false
}
);
@@ -106,7 +112,8 @@ public class Scrolling : Scenario
Y = 10,
Width = 50,
ColorScheme = Colors.ColorSchemes ["Dialog"],
- Text = "... the emergency broadcast system."
+ Text = "... the emergency broadcast system.",
+ Visible = false
}
);
@@ -117,7 +124,8 @@ public class Scrolling : Scenario
Y = 99,
Width = 50,
ColorScheme = Colors.ColorSchemes ["Dialog"],
- Text = "Last line"
+ Text = "Last line",
+ Visible = false
}
);
@@ -223,6 +231,7 @@ public class Scrolling : Scenario
// Add a progress bar to cause constant redraws
var progress = new ProgressBar { X = Pos.Right (scrollView) + 1, Y = Pos.AnchorEnd (2), Width = 50 };
+
app.Add (progress);
var pulsing = true;