01: package org.incava.qualog;
02:
03: import java.util.*;
04:
05: /**
06: * Provides constants that produce colorized output on ANSI terminals.
07: */
08: public class ANSIColor {
09: public final static ANSIColor NONE = new ANSIColor(0);
10: public final static ANSIColor RESET = new ANSIColor(0);
11: public final static ANSIColor BOLD = new ANSIColor(1);
12: public final static ANSIColor UNDERSCORE = new ANSIColor(4);
13: public final static ANSIColor UNDERLINE = new ANSIColor(4);
14: public final static ANSIColor BLINK = new ANSIColor(5);
15: public final static ANSIColor REVERSE = new ANSIColor(7);
16: public final static ANSIColor CONCEALED = new ANSIColor(8);
17: public final static ANSIColor BLACK = new ANSIColor(30);
18: public final static ANSIColor RED = new ANSIColor(31);
19: public final static ANSIColor GREEN = new ANSIColor(32);
20: public final static ANSIColor YELLOW = new ANSIColor(33);
21: public final static ANSIColor BLUE = new ANSIColor(34);
22: public final static ANSIColor MAGENTA = new ANSIColor(35);
23: public final static ANSIColor CYAN = new ANSIColor(36);
24: public final static ANSIColor WHITE = new ANSIColor(37);
25: public final static ANSIColor ON_BLACK = new ANSIColor(40);
26: public final static ANSIColor ON_RED = new ANSIColor(41);
27: public final static ANSIColor ON_GREEN = new ANSIColor(42);
28: public final static ANSIColor ON_YELLOW = new ANSIColor(43);
29: public final static ANSIColor ON_BLUE = new ANSIColor(44);
30: public final static ANSIColor ON_MAGENTA = new ANSIColor(45);
31: public final static ANSIColor ON_CYAN = new ANSIColor(46);
32: public final static ANSIColor ON_WHITE = new ANSIColor(47);
33:
34: private String str;
35:
36: public ANSIColor(int n) {
37: // this behavior changed in Java 1.4.2-01, so this is a char, not a
38: // byte.
39: str = "" + (char) 27 + "[" + n + "m";
40: }
41:
42: public String toString() {
43: return str;
44: }
45:
46: }
|