-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
executable file
·110 lines (98 loc) · 3 KB
/
test.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/python
import colorsys
from clicolor.cli import CLI, CLI256, CLIT
# Test modifiers
print()
modifiers = [
("Bold", CLI.BOLD, CLI.RESET_BOLD),
("Dark", CLI.DARK, CLI.RESET_DARK),
("Underline", CLI.UNDERLINE, CLI.RESET_UNDERLINE),
("Blink", CLI.BLINK, CLI.RESET_BLINK),
("Reverse", CLI.REVERSE, CLI.RESET_REVERSE),
("Hidden", CLI.HIDDEN, CLI.RESET_HIDDEN),
]
for disp, set_mod, unset_mod in modifiers:
print(f"Normal {set_mod}{disp:<10}{unset_mod} Reset {disp}{CLI.RESET}")
print()
header = " "
for disp, set_a, _ in modifiers:
header += f" {disp[:4]} {CLI.RESET}"
print(header)
for disp, set_a, _ in modifiers:
line = f" {disp[:4]} {CLI.RESET}"
for _, set_b, _ in modifiers:
line += f"{set_a}{set_b} Text {CLI.RESET}"
print(line)
# Test clear
print()
print((f"{' ' * 46}SHOULDN'T SEE ME \r{CLI.CLEAR_LINE}Line clear test."
f" Should see nothing after me."))
# Test 8/16 colors
print()
foreground = [(i, CLI.from_val(i)) for i in range(30, 38)]
foreground.extend((i, CLI.from_val(i)) for i in range(90, 98))
background = [(i, CLI.from_val(i)) for i in range(40, 48)]
background.extend((i, CLI.from_val(i)) for i in range(100, 108))
for i, code in foreground:
print(f"{code}{i:<3}{CLI.RESET}", end='')
print()
for i, code in background:
print(f"{code}{i:<3}{CLI.RESET}", end='')
print()
print()
header = " "
for i, f in foreground:
header += f"{f}{i:<3}{CLI.RESET}"
print(header)
for bi, b in background:
line = f"{b}{bi:<3}{CLI.RESET}"
for fi, f in foreground:
line += f"{f}{b}LoL{CLI.RESET}"
print(line)
# Test 256 colors
print()
c256 = [(i, CLI256.fg(i)) for i in range(0, 256)]
for i, code in c256:
s = f"{code}{i:<3}"
if i % 6 == 3:
s += f"{CLI.RESET}\n"
print(s, end='')
print()
c256b = [(i, CLI256.bg(i)) for i in range(0, 256)]
for i, code in c256b:
s = f"{code}{i:<3}"
if i % 6 == 3:
s += f"{CLI.RESET}\n"
print(s, end='')
print()
for i in [16, 52, 88, 124, 160, 196]:
print(CLI256.bg(i) + " ", end='')
for i in reversed([16, 52, 88, 124, 160, 196]):
print(CLI256.bg(i) + " ", end='')
print(f"{CLI.RESET}")
for i in [16, 22, 28, 34, 40, 46]:
print(CLI256.bg(i) + " ", end='')
for i in reversed([16, 22, 28, 34, 40, 46]):
print(CLI256.bg(i) + " ", end='')
print(f"{CLI.RESET}")
for i in range(16, 22):
print(CLI256.bg(i) + " ", end='')
for i in range(21, 15, -1):
print(CLI256.bg(i) + " ", end='')
print(f"{CLI.RESET}")
# Test truecolors
print()
print(''.join(f"{CLIT.bg(i, 0, 0)} " for i in range(0, 256, 2)), end='')
print(f"{CLI.RESET}")
print(''.join(f"{CLIT.bg(0, i, 0)} " for i in range(0, 256, 2)), end='')
print(f"{CLI.RESET}")
print(''.join(f"{CLIT.bg(0, 0, i)} " for i in range(0, 256, 2)), end='')
print(f"{CLI.RESET}")
print()
line = ""
for i in range(4096):
r, g, b = colorsys.hsv_to_rgb(i / 4096.0 * 0.85, 1.0, 1.0)
line += CLIT.bg(int(r * 255), int(g * 255), int(b * 255)) + " "
if i % 128 == 127:
line += CLI.RESET + "\n"
print(f"{line}{CLI.RESET}")