Clear lines on certain console printouts.

This commit is contained in:
2019-05-03 00:24:08 +01:00
parent a8af980b3f
commit 69fda84fc1

View File

@@ -45,12 +45,14 @@ namespace DiscImageChef
internal static void UpdateProgress(string text, long current, long maximum) internal static void UpdateProgress(string text, long current, long maximum)
{ {
DicConsole.Write("\r" + text); ClearCurrentConsoleLine();
DicConsole.Write(text);
} }
internal static void PulseProgress(string text) internal static void PulseProgress(string text)
{ {
DicConsole.Write("\r" + text); ClearCurrentConsoleLine();
DicConsole.Write(text);
} }
internal static void InitProgress2() { } internal static void InitProgress2() { }
@@ -62,7 +64,8 @@ namespace DiscImageChef
internal static void UpdateProgress2(string text, long current, long maximum) internal static void UpdateProgress2(string text, long current, long maximum)
{ {
DicConsole.Write("\r" + text); ClearCurrentConsoleLine();
DicConsole.Write(text);
} }
internal static void InitTwoProgress() { } internal static void InitTwoProgress() { }
@@ -75,11 +78,13 @@ namespace DiscImageChef
internal static void UpdateTwoProgress(string text, long current, long maximum, string text2, long current2, internal static void UpdateTwoProgress(string text, long current, long maximum, string text2, long current2,
long maximum2) long maximum2)
{ {
DicConsole.Write("\r" + text + ": " + text2); ClearCurrentConsoleLine();
DicConsole.Write(text + ": " + text2);
} }
internal static void UpdateStatus(string text) internal static void UpdateStatus(string text)
{ {
ClearCurrentConsoleLine();
DicConsole.WriteLine(text); DicConsole.WriteLine(text);
} }
@@ -87,5 +92,13 @@ namespace DiscImageChef
{ {
DicConsole.ErrorWriteLine(text); DicConsole.ErrorWriteLine(text);
} }
static void ClearCurrentConsoleLine()
{
int currentLineCursor = System.Console.CursorTop;
System.Console.SetCursorPosition(0, System.Console.CursorTop);
System.Console.Write(new string(' ', System.Console.WindowWidth));
System.Console.SetCursorPosition(0, currentLineCursor);
}
} }
} }