-
Notifications
You must be signed in to change notification settings - Fork 2
/
GAP_Colors.py
78 lines (71 loc) · 1.77 KB
/
GAP_Colors.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
#-*- coding:utf-8 -*-
fontColors = {
'black': 30,
'red': 31,
'green': 32,
'yellow': 33,
'blue': 34,
'magenta': 35,
'cyan': 36,
'lightgray': 37,
'default': 39,
'darkgray': 90,
'lightred': 91,
'lightgreen': 92,
'lightyellow': 93,
'lightblue': 94,
'lightmagenta': 95,
'lightcyan': 96,
'white': 97
}
backgroundColors = {
'black': 40,
'red': 41,
'green': 42,
'yellow': 43,
'blue': 44,
'magenta': 45,
'cyan': 46,
'lightgray': 47,
'default': 49,
'darkgray': 100,
'lightred': 101,
'lightgreen': 102,
'lightyellow': 103,
'lightblue': 104,
'lightmagenta': 105,
'lightcyan': 106,
'white': 107
}
formatting = {
'normal': 0,
'bold': 1,
'light': 2,
'italic': 3,
'underline': 4,
'blink': 5,
'reverse': 7
}
def format(text, fc='red', bc='default', ft='normal'):
"""
fc: font color
bc: background color
ft: formatting
Colors:
blue, lightgray, lightyellow, default, darkgray, yellow, lightred, lightcyan, black, lightmagenta, lightblue, cyan, green, magenta, lightgreen, white, red
Formattings:
bold, normal, light, blink, italic, underline, reverse
"""
code = "%d;%d;%d" % (formatting[ft], fontColors[fc], backgroundColors[bc])
return "\x1b["+code+"m"+text+"\x1b[0m"
def f(text, fc='red', bc='default', ft='normal'):
"""
fc: font color
bc: background color
ft: formatting
Colors:
blue, lightgray, lightyellow, default, darkgray, yellow, lightred, lightcyan, black, lightmagenta, lightblue, cyan, green, magenta, lightgreen, white, red
Formattings:
bold, normal, light, blink, italic, underline, reverse
"""
return format(text, fc=fc, bc=bc, ft=ft)