author | František Kučera <franta-hg@frantovo.cz> |
Tue, 24 Dec 2013 12:05:05 +0100 | |
branch | v_0 |
changeset 52 | e2ba2af0ef40 |
parent 40 | a9db7fb3ce65 |
child 55 | f5ed7c4efacc |
permissions | -rw-r--r-- |
31
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
/** |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
* SQL-DK |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
* Copyright © 2013 František Kučera (frantovo.cz) |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
* |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
* the Free Software Foundation, either version 3 of the License, or |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
* (at your option) any later version. |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
* |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
* |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
*/ |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
package info.globalcode.sql.dk; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
import java.io.File; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
import java.io.FileNotFoundException; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
import java.io.OutputStream; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
import java.io.PrintWriter; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
import java.io.UnsupportedEncodingException; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
import java.io.Writer; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
import java.util.EnumSet; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
/** |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
* |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
* @author Ing. František Kučera (frantovo.cz) |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
*/ |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
public class ColorfulPrintWriter extends PrintWriter { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
public enum TerminalColor { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
Black(30, 40), |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
37 |
Red(31, 41), |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
38 |
Green(32, 42), |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
Yellow(33, 43), |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
40 |
Blue(34, 44), |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
Magenta(35, 45), |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
42 |
Cyan(36, 46), |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
43 |
White(37, 47); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
44 |
private final int foregroundCode; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
45 |
private final int backgroundCode; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
46 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
47 |
private TerminalColor(int foregroundCode, int backgroundCode) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
48 |
this.foregroundCode = foregroundCode; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
49 |
this.backgroundCode = backgroundCode; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
50 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
51 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
52 |
public int getForegroundCode() { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
53 |
return foregroundCode; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
54 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
55 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
56 |
public int getBackgroundCode() { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
57 |
return backgroundCode; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
58 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
59 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
60 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
61 |
public enum TerminalStyle { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
62 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
63 |
Reset(0), |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
64 |
Bright(1), |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
65 |
Dim(2), |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
66 |
Underscore(4), |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
67 |
Blink(5), |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
68 |
Reverse(7), |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
69 |
Hidden(8); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
70 |
private int code; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
71 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
72 |
private TerminalStyle(int code) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
73 |
this.code = code; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
74 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
75 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
76 |
public int getCode() { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
77 |
return code; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
78 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
79 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
80 |
private boolean colorful = true; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
81 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
82 |
public void setStyle(EnumSet<TerminalStyle> styles) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
83 |
printCodes(getStyleCodes(styles)); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
84 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
85 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
86 |
private static int[] getStyleCodes(EnumSet<TerminalStyle> styles) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
87 |
int[] array = new int[styles.size()]; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
88 |
int i = 0; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
89 |
for (TerminalStyle s : styles) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
90 |
array[i++] = s.getCode(); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
91 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
92 |
return array; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
93 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
94 |
|
40
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
95 |
/** |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
96 |
* Print (usually audible) bell code (\007, \a, ^G) |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
97 |
*/ |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
98 |
public void bell() { |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
99 |
print("\007"); |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
100 |
} |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
101 |
|
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
102 |
/** |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
103 |
* Eat the last character |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
104 |
*/ |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
105 |
public void backspace() { |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
106 |
print("\b"); |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
107 |
} |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
108 |
|
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
109 |
/** |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
110 |
* Eat n last characters |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
111 |
* |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
112 |
* @param count n |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
113 |
*/ |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
114 |
public void backspace(int count) { |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
115 |
for (int i = 0; i < count; i++) { |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
116 |
backspace(); |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
117 |
} |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
118 |
} |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
119 |
|
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
120 |
/** |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
121 |
* With 100 ms delay and all colors. |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
122 |
* |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
123 |
* @see #printRainbow(java.lang.String, int, |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
124 |
* info.globalcode.sql.dk.ColorfulPrintWriter.TerminalColor[]) |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
125 |
*/ |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
126 |
public void printRainbow(String string) { |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
127 |
printRainbow(string, 100); |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
128 |
} |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
129 |
|
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
130 |
/** |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
131 |
* With all colors. |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
132 |
* |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
133 |
* @see #printRainbow(java.lang.String, int, |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
134 |
* info.globalcode.sql.dk.ColorfulPrintWriter.TerminalColor[]) |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
135 |
*/ |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
136 |
public void printRainbow(String string, int delay) { |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
137 |
printRainbow(string, delay, TerminalColor.values()); |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
138 |
} |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
139 |
|
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
140 |
/** |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
141 |
* Prints rainbow text – (re)writes same text subsequently in given colors and then in default |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
142 |
* color. |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
143 |
* |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
144 |
* @param string text to be printed, should not contain \n new line (then rainbow does not work |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
145 |
* – use println() after printRainbow() instead) |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
146 |
* @param delay delay between rewrites |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
147 |
* @param colors list of colors to be used |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
148 |
*/ |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
149 |
public void printRainbow(String string, int delay, TerminalColor... colors) { |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
150 |
for (TerminalColor c : colors) { |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
151 |
print(c, string); |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
152 |
try { |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
153 |
Thread.sleep(delay); |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
154 |
} catch (InterruptedException e) { |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
155 |
// no time to sleep |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
156 |
break; |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
157 |
} |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
158 |
backspace(string.length()); |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
159 |
flush(); |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
160 |
} |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
161 |
print(string); |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
162 |
} |
a9db7fb3ce65
TabularFormatter: print colorful tables\!
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
163 |
|
31
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
164 |
public void setForegroundColor(TerminalColor color) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
165 |
printCodes(color.getForegroundCode()); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
166 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
167 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
168 |
public void setBackgroundColor(TerminalColor color) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
169 |
printCodes(color.getBackgroundCode()); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
170 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
171 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
172 |
public void print(TerminalColor foregroundColor, String string) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
173 |
setForegroundColor(foregroundColor); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
174 |
print(string); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
175 |
resetAll(); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
176 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
177 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
178 |
public void println(TerminalColor foregroundColor, String string) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
179 |
print(foregroundColor, string); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
180 |
println(); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
181 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
182 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
183 |
public void print(TerminalColor foregroundColor, TerminalColor backgroundColor, String string) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
184 |
setForegroundColor(foregroundColor); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
185 |
setBackgroundColor(backgroundColor); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
186 |
print(string); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
187 |
resetAll(); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
188 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
189 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
190 |
public void println(TerminalColor foregroundColor, TerminalColor backgroundColor, String string) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
191 |
print(foregroundColor, backgroundColor, string); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
192 |
println(); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
193 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
194 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
195 |
public void print(TerminalColor foregroundColor, TerminalColor backgroundColor, EnumSet<TerminalStyle> styles, String string) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
196 |
setForegroundColor(foregroundColor); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
197 |
setBackgroundColor(backgroundColor); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
198 |
setStyle(styles); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
199 |
print(string); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
200 |
resetAll(); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
201 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
202 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
203 |
public void println(TerminalColor foregroundColor, TerminalColor backgroundColor, EnumSet<TerminalStyle> styles, String string) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
204 |
print(foregroundColor, backgroundColor, styles, string); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
205 |
println(); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
206 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
207 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
208 |
public void print(TerminalColor foregroundColor, TerminalColor backgroundColor, TerminalStyle style, String string) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
209 |
print(foregroundColor, backgroundColor, EnumSet.of(style), string); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
210 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
211 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
212 |
public void println(TerminalColor foregroundColor, TerminalColor backgroundColor, TerminalStyle style, String string) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
213 |
print(foregroundColor, backgroundColor, style, string); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
214 |
println(); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
215 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
216 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
217 |
public void print(TerminalColor foregroundColor, EnumSet<TerminalStyle> styles, String string) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
218 |
setForegroundColor(foregroundColor); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
219 |
setStyle(styles); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
220 |
print(string); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
221 |
resetAll(); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
222 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
223 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
224 |
public void println(TerminalColor foregroundColor, EnumSet<TerminalStyle> styles, String string) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
225 |
print(foregroundColor, styles, string); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
226 |
println(); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
227 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
228 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
229 |
public void print(TerminalColor foregroundColor, TerminalStyle style, String string) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
230 |
print(foregroundColor, EnumSet.of(style), string); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
231 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
232 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
233 |
public void println(TerminalColor foregroundColor, TerminalStyle style, String string) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
234 |
print(foregroundColor, style, string); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
235 |
println(); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
236 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
237 |
|
37
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
238 |
public void print(EnumSet<TerminalStyle> styles, String string) { |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
239 |
setStyle(styles); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
240 |
print(string); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
241 |
resetAll(); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
242 |
} |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
243 |
|
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
244 |
public void println(EnumSet<TerminalStyle> styles, String string) { |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
245 |
print(styles, string); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
246 |
println(); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
247 |
} |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
248 |
|
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
249 |
public void print(TerminalStyle style, String string) { |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
250 |
print(EnumSet.of(style), string); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
251 |
} |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
252 |
|
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
253 |
public void println(TerminalStyle style, String string) { |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
254 |
print(style, string); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
255 |
println(); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
256 |
} |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
257 |
|
31
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
258 |
public void resetAll() { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
259 |
printCodes(0); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
260 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
261 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
262 |
private void printCodes(int... codes) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
263 |
if (colorful) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
264 |
print("\033["); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
265 |
for (int i = 0; i < codes.length; i++) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
266 |
print(codes[i]); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
267 |
if (i < codes.length - 1 && codes.length > 1) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
268 |
print(";"); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
269 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
270 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
271 |
print("m"); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
272 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
273 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
274 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
275 |
public boolean isColorful() { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
276 |
return colorful; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
277 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
278 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
279 |
public void setColorful(boolean colorful) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
280 |
this.colorful = colorful; |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
281 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
282 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
283 |
public ColorfulPrintWriter(File file) throws FileNotFoundException { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
284 |
super(file); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
285 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
286 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
287 |
public ColorfulPrintWriter(OutputStream out) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
288 |
super(out); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
289 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
290 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
291 |
public ColorfulPrintWriter(String fileName) throws FileNotFoundException { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
292 |
super(fileName); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
293 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
294 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
295 |
public ColorfulPrintWriter(Writer out) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
296 |
super(out); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
297 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
298 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
299 |
public ColorfulPrintWriter(File file, String csn) throws FileNotFoundException, UnsupportedEncodingException { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
300 |
super(file, csn); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
301 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
302 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
303 |
public ColorfulPrintWriter(OutputStream out, boolean autoFlush) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
304 |
super(out, autoFlush); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
305 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
306 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
307 |
public ColorfulPrintWriter(String fileName, String csn) throws FileNotFoundException, UnsupportedEncodingException { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
308 |
super(fileName, csn); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
309 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
310 |
|
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
311 |
public ColorfulPrintWriter(Writer out, boolean autoFlush) { |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
312 |
super(out, autoFlush); |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
313 |
} |
ef2fdb55e8ec
ColorfulPrintWriter: colorz, wow
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
314 |
} |