mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
50 lines
1.9 KiB
C#
50 lines
1.9 KiB
C#
using System;
|
|
|
|
namespace AssetStudioCLI
|
|
{
|
|
// Represents set with 16 base colors using ANSI escape codes, which should be supported in most terminals
|
|
// (well, except for windows editions before windows 10)
|
|
public static class CLIAnsiColors
|
|
{
|
|
public static readonly string
|
|
Black = "\u001b[30m",
|
|
Red = "\u001b[31m",
|
|
Green = "\u001b[32m",
|
|
Yellow = "\u001b[33m", //remapped to ~BrightWhite in Windows PowerShell 6
|
|
Blue = "\u001b[34m",
|
|
Magenta = "\u001b[35m", //remapped to ~Blue in Windows PowerShell 6
|
|
Cyan = "\u001b[36m",
|
|
White = "\u001b[37m",
|
|
BrightBlack = "\u001b[30;1m",
|
|
BrightRed = "\u001b[31;1m",
|
|
BrightGreen = "\u001b[32;1m",
|
|
BrightYellow = "\u001b[33;1m",
|
|
BrightBlue = "\u001b[34;1m",
|
|
BrightMagenta = "\u001b[35;1m",
|
|
BrightCyan = "\u001b[36;1m",
|
|
BrightWhite = "\u001b[37;1m";
|
|
private static readonly string Reset = "\u001b[0m";
|
|
|
|
public static string Color(this string str, string ansiColor)
|
|
{
|
|
if (!CLIWinAnsiFix.isAnsiSupported)
|
|
{
|
|
return str;
|
|
}
|
|
|
|
return $"{ansiColor}{str}{Reset}";
|
|
}
|
|
|
|
public static void ANSICodesTest()
|
|
{
|
|
Console.WriteLine("ANSI escape codes test");
|
|
Console.WriteLine($"Supported: {CLIWinAnsiFix.isAnsiSupported}");
|
|
Console.WriteLine("\u001b[30m A \u001b[31m B \u001b[32m C \u001b[33m D \u001b[0m");
|
|
Console.WriteLine("\u001b[34m E \u001b[35m F \u001b[36m G \u001b[37m H \u001b[0m");
|
|
Console.WriteLine("\u001b[30;1m A \u001b[31;1m B \u001b[32;1m C \u001b[33;1m D \u001b[0m");
|
|
Console.WriteLine("\u001b[34;1m E \u001b[35;1m F \u001b[36;1m G \u001b[37;1m H \u001b[0m");
|
|
}
|
|
}
|
|
|
|
}
|