|
24 | 24 |
|
25 | 25 |
|
26 | 26 | FG_ANSI_COLORS = { |
27 | | - 'black': 30, |
28 | | - 'default': 39, |
29 | | - 'white': 97, |
| 27 | + 'ansiblack': 30, |
| 28 | + 'ansidefault': 39, |
| 29 | + 'ansiwhite': 97, |
30 | 30 |
|
31 | 31 | # Low intensity. |
32 | | - 'red': 31, |
33 | | - 'green': 32, |
34 | | - 'yellow': 33, |
35 | | - 'blue': 34, |
36 | | - 'magenta': 35, |
37 | | - 'cyan': 36, |
38 | | - 'gray': 37, |
| 32 | + 'ansired': 31, |
| 33 | + 'ansigreen': 32, |
| 34 | + 'ansiyellow': 33, |
| 35 | + 'ansiblue': 34, |
| 36 | + 'ansifuchsia': 35, |
| 37 | + 'ansiturquoise': 36, |
| 38 | + 'ansilightgray': 37, |
39 | 39 |
|
40 | 40 |
|
41 | 41 | # High intensity. |
42 | | - 'dark-gray': 90, # Bright black. |
43 | | - 'bright-red': 91, |
44 | | - 'bright-green': 92, |
45 | | - 'bright-yellow': 93, |
46 | | - 'bright-blue': 94, |
47 | | - 'bright-magenta': 95, |
48 | | - 'bright-cyan': 96, |
| 42 | + 'ansidarkgray': 90, # Bright black. |
| 43 | + 'ansidarkred': 91, |
| 44 | + 'ansidarkgreen': 92, |
| 45 | + 'ansibrown': 93, |
| 46 | + 'ansidarkblue': 94, |
| 47 | + 'ansipurple': 95, |
| 48 | + 'ansiteal': 96, |
49 | 49 | } |
50 | 50 |
|
51 | 51 | BG_ANSI_COLORS = { |
52 | | - 'black': 40, |
53 | | - 'default': 49, |
54 | | - 'white': 107, |
| 52 | + 'ansiblack': 40, |
| 53 | + 'ansidefault': 49, |
| 54 | + 'ansiwhite': 107, |
55 | 55 |
|
56 | 56 | # Low intensity. |
57 | | - 'red': 41, |
58 | | - 'green': 42, |
59 | | - 'yellow': 43, |
60 | | - 'blue': 44, |
61 | | - 'magenta': 45, |
62 | | - 'cyan': 46, |
63 | | - 'gray': 47, |
| 57 | + 'ansired': 41, |
| 58 | + 'ansigreen': 42, |
| 59 | + 'ansiyellow': 43, |
| 60 | + 'ansiblue': 44, |
| 61 | + 'ansifuchsia': 45, |
| 62 | + 'ansiturquoise': 46, |
| 63 | + 'ansilightgray': 47, |
64 | 64 |
|
65 | 65 | # High intensity. |
66 | | - 'dark-gray': 100, # bright black. |
67 | | - 'bright-red': 101, |
68 | | - 'bright-green': 102, |
69 | | - 'bright-yellow': 103, |
70 | | - 'bright-blue': 104, |
71 | | - 'bright-magenta': 105, |
72 | | - 'bright-cyan': 106, |
| 66 | + 'ansidarkgray': 100, # bright black. |
| 67 | + 'ansidarkred': 101, |
| 68 | + 'ansidarkgreen': 102, |
| 69 | + 'ansibrown': 103, |
| 70 | + 'ansidarkblue': 104, |
| 71 | + 'ansipurple': 105, |
| 72 | + 'ansiteal': 106, |
73 | 73 | } |
74 | 74 |
|
| 75 | + |
75 | 76 | ANSI_COLORS_TO_RGB = { |
76 | | - 'black': (0x00, 0x00, 0x00), |
77 | | - 'default': (0x00, 0x00, 0x00), # Don't use, 'default' doesn't really have a value. |
78 | | - 'white': (0xff, 0xff, 0xff), |
| 77 | + 'ansiblack': (0x00, 0x00, 0x00), |
| 78 | + 'ansidefault': (0x00, 0x00, 0x00), # Don't use, 'default' doesn't really have a value. |
| 79 | + 'ansiwhite': (0xff, 0xff, 0xff), |
79 | 80 |
|
80 | 81 | # Low intensity. |
81 | | - 'red': (0xcd, 0x00, 0x00), |
82 | | - 'green': (0x00, 0xcd, 0x00), |
83 | | - 'yellow': (0xcd, 0xcd, 0x00), |
84 | | - 'blue': (0x00, 0x00, 0xcd), |
85 | | - 'magenta': (0xcd, 0x00, 0xcd), |
86 | | - 'cyan': (0x00, 0xcd, 0xcd), |
87 | | - 'gray': (0xe5, 0xe5, 0xe5), |
| 82 | + 'ansired': (0xcd, 0x00, 0x00), |
| 83 | + 'ansigreen': (0x00, 0xcd, 0x00), |
| 84 | + 'ansiyellow': (0xcd, 0xcd, 0x00), |
| 85 | + 'ansiblue': (0x00, 0x00, 0xcd), |
| 86 | + 'ansifuchsia': (0xcd, 0x00, 0xcd), |
| 87 | + 'ansiturquoise': (0x00, 0xcd, 0xcd), |
| 88 | + 'ansilightgray': (0xe5, 0xe5, 0xe5), |
88 | 89 |
|
89 | 90 |
|
90 | 91 | # High intensity. |
91 | | - 'dark-gray': (0x7f, 0x7f, 0x7f), # Bright black. |
92 | | - 'bright-red': (0xff, 0x00, 0x00), |
93 | | - 'bright-green': (0x00, 0xff, 0x00), |
94 | | - 'bright-yellow': (0xff, 0xff, 0x00), |
95 | | - 'bright-blue': (0x00, 0x00, 0xff), |
96 | | - 'bright-magenta': (0xff, 0x00, 0xff), |
97 | | - 'bright-cyan': (0x00, 0xff, 0xff), |
| 92 | + 'ansidarkgray': (0x7f, 0x7f, 0x7f), # Bright black. |
| 93 | + 'ansidarkred': (0xff, 0x00, 0x00), |
| 94 | + 'ansidarkgreen': (0x00, 0xff, 0x00), |
| 95 | + 'ansibrown': (0xff, 0xff, 0x00), |
| 96 | + 'ansidarkblue': (0x00, 0x00, 0xff), |
| 97 | + 'ansipurple': (0xff, 0x00, 0xff), |
| 98 | + 'ansiteal': (0x00, 0xff, 0xff), |
98 | 99 | } |
99 | 100 |
|
| 101 | + |
100 | 102 | assert set(FG_ANSI_COLORS) == set(ANSI_COLOR_NAMES) |
101 | 103 | assert set(BG_ANSI_COLORS) == set(ANSI_COLOR_NAMES) |
102 | 104 | assert set(ANSI_COLORS_TO_RGB) == set(ANSI_COLOR_NAMES) |
@@ -219,7 +221,6 @@ def __init__(self, true_color=False, term='xterm'): |
219 | 221 |
|
220 | 222 | def __missing__(self, attrs): |
221 | 223 | fgcolor, bgcolor, bold, underline, italic, blink, reverse = attrs |
222 | | - |
223 | 224 | parts = [] |
224 | 225 |
|
225 | 226 | if fgcolor: |
@@ -268,7 +269,7 @@ def _color_to_code(self, color, bg=False): |
268 | 269 | # RGB colors. (Defined as 'ffffff'.) |
269 | 270 | else: |
270 | 271 | try: |
271 | | - rgb = self._color_name_to_rgb(color) |
| 272 | + rgb = self._color_name_to_rgb(color) |
272 | 273 | except ValueError: |
273 | 274 | return () |
274 | 275 |
|
|
0 commit comments