diff --git a/Terminal.Gui/Drivers/WindowsDriver.cs b/Terminal.Gui/Drivers/WindowsDriver.cs index 83be99aa4..89dffe43f 100644 --- a/Terminal.Gui/Drivers/WindowsDriver.cs +++ b/Terminal.Gui/Drivers/WindowsDriver.cs @@ -83,7 +83,7 @@ namespace Terminal.Gui { ReadConsoleOutput (OutputHandle, OriginalStdOutChars, coords, new Coord () { X = 0, Y = 0 }, ref window); } - return WriteConsoleOutput (ScreenBuffer, charInfoBuffer, coords, new Coord () { X = 0, Y = 0 }, ref window); + return WriteConsoleOutput (ScreenBuffer, charInfoBuffer, coords, new Coord () { X = window.Left, Y = window.Top }, ref window); } public bool SetCursorPosition (Coord position) @@ -323,7 +323,7 @@ namespace Terminal.Gui { 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"); + //System.Diagnostics.Debugger.Log (0, "debug", $"damager From Empty {col},{row}\n"); rect.Left = rect.Right = col; rect.Bottom = rect.Top = row; return; @@ -338,7 +338,7 @@ namespace Terminal.Gui { rect.Top = row; if (row > rect.Bottom) rect.Bottom = row; - System.Diagnostics.Debugger.Log (0, "debug", $"Expanding {rect.ToString ()}\n"); + //System.Diagnostics.Debugger.Log (0, "debug", $"Expanding {rect.ToString ()}\n"); } public override string ToString () @@ -826,6 +826,7 @@ namespace Terminal.Gui { UpdateCursor(); winConsole.WriteToConsole (OutputBuffer, bufferCoords, damageRegion); + System.Diagnostics.Debugger.Log(0, "debug", $"Region={damageRegion.Right - damageRegion.Left},{damageRegion.Bottom - damageRegion.Top}\n"); WindowsConsole.SmallRect.MakeEmpty (ref damageRegion); } diff --git a/stash b/stash new file mode 100644 index 000000000..2e8223493 --- /dev/null +++ b/stash @@ -0,0 +1,136 @@ +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()