small changes in ColoredConsole
This commit is contained in:
parent
c461418185
commit
26c118195c
@ -14,6 +14,9 @@ public static class ColoredConsole
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ResetColor() => System.Console.ResetColor();
|
||||
|
||||
/// <summary>
|
||||
/// Clears console buffer and resets color
|
||||
/// </summary>
|
||||
[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,18 +40,15 @@ 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 = "]",
|
||||
@ -83,7 +72,5 @@ public static class ColoredConsole
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void WriteCentred(string title, ConsoleColor? fg = null, ConsoleColor? bg = null)
|
||||
{
|
||||
WriteTitle(title, ' ', "", "", fg, bg);
|
||||
}
|
||||
=> WriteTitle(title, ' ', "", "", fg, bg);
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<!--package info-->
|
||||
<PackageId>DTLib</PackageId>
|
||||
<Version>1.6.5</Version>
|
||||
<Version>1.7.0</Version>
|
||||
<Authors>Timerix</Authors>
|
||||
<Description>Library for all my C# projects</Description>
|
||||
<RepositoryType>GIT</RepositoryType>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user