Debian Codegraph @

current/shared/Colors.java

raw symbols SCIP
1 package shared;
2
3 public class Colors {
4
5 public static void main(String[] args){
6 System.out.println(format("Red", RED, false));
7 System.out.println(format("Blue", BLUE, false));
8 System.out.println(format("Green", GREEN, true));
9 System.out.println(format("Yellow", YELLOW, true));
10 }
11
12 public static String format(String s, String color, boolean underline){
13 // return color+(bold ? "[1m":"")+(bold ? "[4m":"")+s+RESET;
14 return color+(underline ? UNDERLINE : "")+s+RESET;
15 }
16
17 public static byte[] format(byte[] s, String color, boolean underline){
18 return format(new String(s), color, underline).getBytes();
19 }
20
21 public static String[] makeColorArray(){
22 return new String[] {
23 BRIGHT_RED, BRIGHT_GREEN, BRIGHT_YELLOW, BRIGHT_BLUE, BRIGHT_PURPLE, BRIGHT_CYAN, RED, GREEN, YELLOW, PURPLE, CYAN
24 };
25 }
26
27 public static String[] makeDarkArray(){
28 return new String[] {
29 RED, GREEN, YELLOW, BLUE, PURPLE, CYAN,
30 };
31 }
32
33 public static String[] makeBrightArray(){
34 return new String[] {
35 BRIGHT_RED, BRIGHT_GREEN, BRIGHT_YELLOW, BRIGHT_BLUE, BRIGHT_PURPLE, BRIGHT_CYAN
36 };
37 }
38
39 public static boolean windows = Shared.WINDOWS;
40 public static boolean skip = windows;
41 public static String esc = windows ? "<ESC>" : "\u001B"; //Windows only supports colors with Win10+
42
43 public static String RESET = skip ? "" : esc+"[0m";
44 public static String UNDERLINE = skip ? "" : esc+"[4m";
45 public static String BOLD = skip ? "" : esc+"[1m";
46
47 public static String BLACK = skip ? "" : esc+"[30m";
48 public static String RED = skip ? "" : esc+"[31m";
49 public static String GREEN = skip ? "" : esc+"[32m";
50 public static String YELLOW = skip ? "" : esc+"[33m";
51 public static String BLUE = skip ? "" : esc+"[34m";
52 public static String PURPLE = skip ? "" : esc+"[35m";
53 public static String CYAN = skip ? "" : esc+"[36m";
54 public static String WHITE = skip ? "" : esc+"[37m";
55
56 public static String BRIGHT_BLACK = skip ? "" : esc+"[30;1m";
57 public static String BRIGHT_RED = skip ? "" : esc+"[31;1m";
58 public static String BRIGHT_GREEN = skip ? "" : esc+"[32;1m";
59 public static String BRIGHT_YELLOW = skip ? "" : esc+"[33;1m";
60 public static String BRIGHT_BLUE = skip ? "" : esc+"[34;1m";
61 public static String BRIGHT_PURPLE = skip ? "" : esc+"[35;1m";
62 public static String BRIGHT_CYAN = skip ? "" : esc+"[36;1m";
63 public static String BRIGHT_WHITE = skip ? "" : esc+"[37;1m";
64
65 public static String[] colorArray=makeColorArray();
66 public static String[] darkArray=makeDarkArray();
67 public static String[] BrightArray=makeBrightArray();
68
69 }