-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConsoleColor.java
39 lines (35 loc) · 1.87 KB
/
ConsoleColor.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
public class ConsoleColor {
private ConsoleColor(){}
public static void UseColor(boolean useColor)
{
if(useColor){return;}
ANSI_RESET = ANSI_BLACK = ANSI_RED = ANSI_GREEN = ANSI_YELLOW = ANSI_BLUE = ANSI_PURPLE = ANSI_CYAN = ANSI_WHITE = "";
ANSI_BLACK_BACKGROUND = ANSI_RED_BACKGROUND = ANSI_GREEN_BACKGROUND = ANSI_YELLOW_BACKGROUND = ANSI_BLUE_BACKGROUND = ANSI_PURPLE_BACKGROUND = ANSI_CYAN_BACKGROUND = ANSI_WHITE_BACKGROUND = "";
}
// Thank to https://stackoverflow.com/questions/5762491/how-to-print-color-in-console-using-system-out-println
public static String ANSI_RESET = "\u001B[0m";
public static String ANSI_BLACK = "\u001B[30m";
public static String ANSI_RED = "\u001B[31m";
public static String ANSI_GREEN = "\u001B[32m";
public static String ANSI_YELLOW = "\u001B[33m";
public static String ANSI_BLUE = "\u001B[34m";
public static String ANSI_PURPLE = "\u001B[35m";
public static String ANSI_CYAN = "\u001B[36m";
public static String ANSI_WHITE = "\u001B[37m";
public static String ANSI_BLACK_BACKGROUND = "\u001B[40m";
public static String ANSI_RED_BACKGROUND = "\u001B[41m";
public static String ANSI_GREEN_BACKGROUND = "\u001B[42m";
public static String ANSI_YELLOW_BACKGROUND= "\u001B[43m";
public static String ANSI_BLUE_BACKGROUND = "\u001B[44m";
public static String ANSI_PURPLE_BACKGROUND= "\u001B[45m";
public static String ANSI_CYAN_BACKGROUND = "\u001B[46m";
public static String ANSI_WHITE_BACKGROUND = "\u001B[47m";
public static void Set(String color) { System.out.print(color); }
public static void ResetForeground(){ Set(ANSI_WHITE); }
public static void ResetBackground(){ Set(ANSI_BLACK_BACKGROUND); }
public static void Reset()
{
ResetForeground();
ResetBackground();
}
}