Browse Source

Merge pull request #982 from BDisp/unix-mouse-sc-clear-screen-fix

Fixes #976. Mouse prints sequence characters on the terminal and the screen is not fully cleared. Only for netcoreapp3.1.
Charlie Kindel 4 years ago
parent
commit
177bf40dd7
1 changed files with 14 additions and 1 deletions
  1. 14 1
      Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

+ 14 - 1
Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

@@ -74,7 +74,20 @@ namespace Terminal.Gui {
 			}
 		}
 		public override void UpdateCursor () => Refresh ();
-		public override void End () => Curses.endwin ();
+
+		public override void End ()
+		{
+			if (reportableMouseEvents.HasFlag (Curses.Event.ReportMousePosition)) {
+				StopReportingMouseMoves ();
+			}
+			Curses.endwin ();
+			// Clear and reset entire screen.
+			Console.Out.Write ("\x1b[2J");
+			Console.Out.Flush ();
+			Console.Out.Write ("\x1b[1;25r");
+			Console.Out.Flush ();
+		}
+
 		public override void UpdateScreen () => window.redrawwin ();
 		public override void SetAttribute (Attribute c) => Curses.attrset (c.value);
 		public Curses.Window window;