-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathansi_wraps.py
93 lines (82 loc) · 2.69 KB
/
ansi_wraps.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
import ctypes
import os
kernel32 = ctypes.windll.kernel32
kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
# \033 \x1b - escape character
def clear_not_working():
print('\033[2J')
def clear():
os.system('cls')
class Color:
bold = '\033[1m'
black = '\033[30m'
red = '\033[31m'
green = '\033[32m'
yellow = '\033[33m'
blue = '\033[34m'
magenta = '\033[35m'
cyan = '\033[36m'
white = '\033[37m'
l_black = '\033[30;1m'
l_red = '\033[31;1m'
l_green = '\033[32;1m'
l_yellow = '\033[33;1m'
l_blue = '\033[34;1m'
l_magenta = '\033[35;1m'
l_cyan = '\033[36;1m'
l_white = '\033[37;1m'
reset = '\033[0m'
def print_colored(string, color, end=''):
if color == 'black':
print('\u001b[30m' + string + '\u001b[0m', end=end)
elif color == 'red':
print('\u001b[31m' + string + '\u001b[0m', end=end)
elif color == 'green':
print('\u001b[32m' + string + '\u001b[0m', end=end)
elif color == 'yellow':
print('\u001b[33m' + string + '\u001b[0m', end=end)
elif color == 'blue':
print('\u001b[34m' + string + '\u001b[0m', end=end)
elif color == 'magenta':
print('\u001b[35m' + string + '\u001b[0m', end=end)
elif color == 'cyan':
print('\u001b[36m' + string + '\u001b[0m', end=end)
elif color == 'white':
print('\u001b[37m' + string + '\u001b[0m', end=end)
elif color == 'l_black':
print('\u001b[30;1m' + string + '\u001b[0m', end=end)
elif color == 'l_red':
print('\u001b[31;1m' + string + '\u001b[0m', end=end)
elif color == 'l_green':
print('\u001b[32;1m' + string + '\u001b[0m', end=end)
elif color == 'l_yellow':
print('\u001b[33;1m' + string + '\u001b[0m', end=end)
elif color == 'l_blue':
print('\u001b[34;1m' + string + '\u001b[0m', end=end)
elif color == 'l_magenta':
print('\u001b[35;1m' + string + '\u001b[0m', end=end)
elif color == 'l_cyan':
print('\u001b[36;1m' + string + '\u001b[0m', end=end)
elif color == 'l_white':
print('\u001b[37;1m' + string + '\u001b[0m', end=end)
else:
print('NO SUCH COLOR!')
# TODO: Raise error
'''
print_colored('Hello', 'black')
print_colored('Hello', 'red')
print_colored('Hello', 'green')
print_colored('Hello', 'yellow')
print_colored('Hello', 'blue')
print_colored('Hello', 'magenta')
print_colored('Hello', 'cyan')
print_colored('Hello', 'white')
print_colored('Hello', 'l_black')
print_colored('Hello', 'l_red')
print_colored('Hello', 'l_green')
print_colored('Hello', 'l_yellow')
print_colored('Hello', 'l_blue')
print_colored('Hello', 'l_magenta')
print_colored('Hello', 'l_cyan')
print_colored('Hello', 'l_white')
'''