small changes in ColoredConsole
This commit is contained in:
parent
c461418185
commit
26c118195c
@ -14,6 +14,9 @@ public static class ColoredConsole
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void ResetColor() => System.Console.ResetColor();
|
public static void ResetColor() => System.Console.ResetColor();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clears console buffer and resets color
|
||||||
|
/// </summary>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Clear()
|
public static void Clear()
|
||||||
{
|
{
|
||||||
@ -21,26 +24,15 @@ public static class ColoredConsole
|
|||||||
System.Console.Clear();
|
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)
|
public static void Write(string msg, ConsoleColor? fg = null, ConsoleColor? bg = null)
|
||||||
{
|
{
|
||||||
if(fg != null) Fg(fg.Value);
|
if(fg != null) Fg(fg.Value);
|
||||||
if(bg != null) Bg(bg.Value);
|
if(bg != null) Bg(bg.Value);
|
||||||
#if NETSTANDARD2_0
|
System.Console.Write(msg);
|
||||||
var chars = msg.ToCharArray();
|
|
||||||
#else
|
|
||||||
var chars = msg.AsSpan();
|
|
||||||
#endif
|
|
||||||
for (int i = 0; i < chars.Length; ++i)
|
|
||||||
{
|
|
||||||
Write(chars[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[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)
|
public static void WriteLine(string msg, ConsoleColor? fg = null, ConsoleColor? bg = null)
|
||||||
{
|
{
|
||||||
@ -48,18 +40,15 @@ public static class ColoredConsole
|
|||||||
WriteLine();
|
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);
|
if(fg != null) Fg(fg.Value);
|
||||||
Write(':');
|
if(bg != null) Bg(bg.Value);
|
||||||
Write(' ');
|
return System.Console.ReadLine() ?? string.Empty;
|
||||||
return System.Console.ReadLine();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
WriteLine(c.Multiply(Width - 1), fg, bg);
|
||||||
}
|
|
||||||
|
|
||||||
public static void WriteTitle(string title, char spacing = '-',
|
public static void WriteTitle(string title, char spacing = '-',
|
||||||
string left_framing = "[", string right_framing = "]",
|
string left_framing = "[", string right_framing = "]",
|
||||||
@ -83,7 +72,5 @@ public static class ColoredConsole
|
|||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void WriteCentred(string title, ConsoleColor? fg = null, ConsoleColor? bg = null)
|
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>
|
<PropertyGroup>
|
||||||
<!--package info-->
|
<!--package info-->
|
||||||
<PackageId>DTLib</PackageId>
|
<PackageId>DTLib</PackageId>
|
||||||
<Version>1.6.5</Version>
|
<Version>1.7.0</Version>
|
||||||
<Authors>Timerix</Authors>
|
<Authors>Timerix</Authors>
|
||||||
<Description>Library for all my C# projects</Description>
|
<Description>Library for all my C# projects</Description>
|
||||||
<RepositoryType>GIT</RepositoryType>
|
<RepositoryType>GIT</RepositoryType>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user