mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
137 lines
3.8 KiB
Plaintext
137 lines
3.8 KiB
Plaintext
diff --git a/Example/demo.cs b/Example/demo.cs
|
|
index 1413f9b..1df6170 100644
|
|
--- a/Example/demo.cs
|
|
+++ b/Example/demo.cs
|
|
@@ -90,7 +90,7 @@ static class Demo {
|
|
return true;
|
|
}
|
|
|
|
- Application.MainLoop.AddTimeout (TimeSpan.FromMilliseconds (300), timer);
|
|
+ //Application.MainLoop.AddTimeout (TimeSpan.FromMilliseconds (300), timer);
|
|
|
|
|
|
// A little convoluted, this is because I am using this to test the
|
|
diff --git a/Terminal.Gui/Drivers/WindowsDriver.cs b/Terminal.Gui/Drivers/WindowsDriver.cs
|
|
index 229931a..a3ab2bd 100644
|
|
--- a/Terminal.Gui/Drivers/WindowsDriver.cs
|
|
+++ b/Terminal.Gui/Drivers/WindowsDriver.cs
|
|
@@ -323,6 +323,10 @@ namespace Terminal.Gui {
|
|
this.X = X;
|
|
this.Y = Y;
|
|
}
|
|
+
|
|
+ public override string ToString() {
|
|
+ return $"(X={X},Y={Y}";
|
|
+ }
|
|
};
|
|
|
|
[StructLayout(LayoutKind.Explicit, CharSet=CharSet.Unicode)]
|
|
@@ -346,6 +350,34 @@ namespace Terminal.Gui {
|
|
public short Top;
|
|
public short Right;
|
|
public short Bottom;
|
|
+
|
|
+ public static void MakeEmpty (ref SmallRect rect) {
|
|
+ rect.Left = -1;
|
|
+ }
|
|
+
|
|
+ public static void Update (ref SmallRect rect, short col, short row) {
|
|
+ if (rect.Left == -1) {
|
|
+ System.Diagnostics.Debugger.Log(0, "debug", $"damager From Empty {col},{row}\n");
|
|
+ rect.Left = rect.Right = col;
|
|
+ rect.Bottom = rect.Top = row;
|
|
+ return;
|
|
+ }
|
|
+ if (col >= rect.Left && col <= rect.Right && row >= rect.Top && row <= rect.Bottom)
|
|
+ return;
|
|
+ if (col < rect.Left)
|
|
+ rect.Left = col;
|
|
+ if (col > rect.Right)
|
|
+ rect.Right = col;
|
|
+ if (row < rect.Top)
|
|
+ rect.Top = row;
|
|
+ if (row > rect.Bottom)
|
|
+ rect.Bottom = row;
|
|
+ System.Diagnostics.Debugger.Log(0, "debug", $"Expanding {rect.ToString()}\n");
|
|
+ }
|
|
+
|
|
+ public override string ToString() {
|
|
+ return $"Left={Left},Top={Top},Right={Right},Bottom={Bottom}";
|
|
+ }
|
|
}
|
|
|
|
[DllImport ("kernel32.dll", SetLastError = true)]
|
|
@@ -410,7 +442,7 @@ namespace Terminal.Gui {
|
|
WindowsConsole WinConsole;
|
|
|
|
WindowsConsole.CharInfo[] OutputBuffer;
|
|
-
|
|
+ WindowsConsole.SmallRect damageRegion;
|
|
int cols, rows;
|
|
|
|
public override int Cols => cols;
|
|
@@ -424,6 +456,7 @@ namespace Terminal.Gui {
|
|
WinConsole = new WindowsConsole();
|
|
cols = Console.WindowWidth;
|
|
rows = Console.WindowHeight - 1;
|
|
+ WindowsConsole.SmallRect.MakeEmpty(ref damageRegion);
|
|
ResizeScreen ();
|
|
UpdateOffScreen ();
|
|
}
|
|
@@ -649,6 +682,12 @@ namespace Terminal.Gui {
|
|
{
|
|
OutputBuffer = new WindowsConsole.CharInfo[Rows * Cols];
|
|
Clip = new Rect (0, 0, Cols, Rows);
|
|
+ damageRegion = new WindowsConsole.SmallRect() {
|
|
+ Top = 0,
|
|
+ Left = 0,
|
|
+ Bottom = (short)Rows,
|
|
+ Right = (short) Cols
|
|
+ };
|
|
}
|
|
|
|
void UpdateOffScreen ()
|
|
@@ -675,6 +714,7 @@ namespace Terminal.Gui {
|
|
if (Clip.Contains (ccol, crow)){
|
|
OutputBuffer[position].Attributes = (ushort)currentAttribute;
|
|
OutputBuffer[position].Char.UnicodeChar = (char)rune;
|
|
+ WindowsConsole.SmallRect.Update(ref damageRegion, (short)ccol, (short)crow);
|
|
}
|
|
|
|
ccol++;
|
|
@@ -709,6 +749,8 @@ namespace Terminal.Gui {
|
|
|
|
public override void Refresh()
|
|
{
|
|
+ UpdateScreen();
|
|
+#if false
|
|
var bufferCoords = new WindowsConsole.Coord (){
|
|
X = (short)Clip.Width,
|
|
Y = (short)Clip.Height
|
|
@@ -723,10 +765,14 @@ namespace Terminal.Gui {
|
|
|
|
UpdateCursor();
|
|
WinConsole.WriteToConsole (OutputBuffer, bufferCoords, window);
|
|
+#endif
|
|
}
|
|
|
|
public override void UpdateScreen ()
|
|
{
|
|
+ if (damageRegion.Left == -1)
|
|
+ return;
|
|
+
|
|
var bufferCoords = new WindowsConsole.Coord (){
|
|
X = (short)Clip.Width,
|
|
Y = (short)Clip.Height
|
|
@@ -740,7 +786,9 @@ namespace Terminal.Gui {
|
|
};
|
|
|
|
UpdateCursor();
|
|
- WinConsole.WriteToConsole (OutputBuffer, bufferCoords, window);
|
|
+
|
|
+ WinConsole.WriteToConsole (OutputBuffer, bufferCoords, damageRegion);
|
|
+ WindowsConsole.SmallRect.MakeEmpty(ref damageRegion);
|
|
}
|
|
|
|
public override void UpdateCursor()
|