-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib stuff (use ansi colors instead of console.foreground)
- Loading branch information
Showing
3 changed files
with
40 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
using System; | ||
|
||
class Terminal { | ||
public static void WriteLine(ConsoleColor color = ConsoleColor.Gray, string text = "") { | ||
Write(color, text + "\n"); | ||
} | ||
public static void Write(ConsoleColor color = ConsoleColor.Gray, string text = "") { | ||
|
||
Console.Write($"\u001b[{ToAnsiColorCode(color)}"); | ||
Console.Write(text); | ||
Console.Write("\u001b[0m"); | ||
} | ||
|
||
private static string ToAnsiColorCode(ConsoleColor color) { | ||
switch(color) { | ||
case ConsoleColor.Black: return "30m"; | ||
case ConsoleColor.DarkRed: return "31m"; | ||
case ConsoleColor.DarkGreen: return "32m"; | ||
case ConsoleColor.DarkYellow: return "33m"; | ||
case ConsoleColor.DarkBlue: return "34m"; | ||
case ConsoleColor.DarkMagenta: return "35m"; | ||
case ConsoleColor.DarkCyan: return "36m"; | ||
case ConsoleColor.DarkGray: return "37m"; | ||
case ConsoleColor.Gray: return "90m"; | ||
case ConsoleColor.Red: return "91m"; | ||
case ConsoleColor.Green: return "92m"; | ||
case ConsoleColor.Yellow: return "93m"; | ||
case ConsoleColor.Blue: return "94m"; | ||
case ConsoleColor.Magenta: return "95m"; | ||
case ConsoleColor.Cyan: return "96m"; | ||
case ConsoleColor.White: return "97m"; | ||
} | ||
throw new Exception($"unhandled color code {color}"); | ||
} | ||
} |