diff --git a/DTLib/Console/ColoredConsole.cs b/DTLib/Console/ColoredConsole.cs index 77cc0f7..6d91053 100644 --- a/DTLib/Console/ColoredConsole.cs +++ b/DTLib/Console/ColoredConsole.cs @@ -14,6 +14,9 @@ public static class ColoredConsole [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void ResetColor() => System.Console.ResetColor(); + /// + /// Clears console buffer and resets color + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Clear() { @@ -21,26 +24,15 @@ public static class ColoredConsole System.Console.Clear(); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Write(char c) => System.Console.Write(c); - public static void Write(string msg, ConsoleColor? fg = null, ConsoleColor? bg = null) { if(fg != null) Fg(fg.Value); if(bg != null) Bg(bg.Value); -#if NETSTANDARD2_0 - var chars = msg.ToCharArray(); -#else - var chars = msg.AsSpan(); -#endif - for (int i = 0; i < chars.Length; ++i) - { - Write(chars[i]); - } + System.Console.Write(msg); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void WriteLine() => Write('\n'); + public static void WriteLine() => System.Console.Write('\n'); public static void WriteLine(string msg, ConsoleColor? fg = null, ConsoleColor? bg = null) { @@ -48,19 +40,16 @@ public static class ColoredConsole WriteLine(); } - public static string? ReadLine(string query, ConsoleColor? fg = null, ConsoleColor? bg = null) + public static string ReadLine(ConsoleColor? fg = null, ConsoleColor? bg = null) { - Write(query, fg, bg); - Write(':'); - Write(' '); - return System.Console.ReadLine(); + if(fg != null) Fg(fg.Value); + if(bg != null) Bg(bg.Value); + return System.Console.ReadLine() ?? string.Empty; } - public static void WriteHLine(char c, ConsoleColor? fg = null, ConsoleColor? bg = null) - { + public static void WriteHLine(char c, ConsoleColor? fg = null, ConsoleColor? bg = null) => WriteLine(c.Multiply(Width - 1), fg, bg); - } - + public static void WriteTitle(string title, char spacing = '-', string left_framing = "[", string right_framing = "]", ConsoleColor? fg = null, ConsoleColor? bg = null) @@ -82,8 +71,6 @@ public static class ColoredConsole } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void WriteCentred(string title, ConsoleColor? fg = null, ConsoleColor? bg = null) - { - WriteTitle(title, ' ', "", "", fg, bg); - } + public static void WriteCentred(string title, ConsoleColor? fg = null, ConsoleColor? bg = null) + => WriteTitle(title, ' ', "", "", fg, bg); } diff --git a/DTLib/DTLib.csproj b/DTLib/DTLib.csproj index e346cd4..81f0e3d 100644 --- a/DTLib/DTLib.csproj +++ b/DTLib/DTLib.csproj @@ -2,7 +2,7 @@ DTLib - 1.6.5 + 1.7.0 Timerix Library for all my C# projects GIT