-
Notifications
You must be signed in to change notification settings - Fork 4
/
namedcolors.py
executable file
·32 lines (25 loc) · 1005 Bytes
/
namedcolors.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
#!/usr/bin/env python3
"""
Demonstration of all the ANSI colors.
"""
from prompt_toolkit import print_formatted_text as pft
from prompt_toolkit import HTML
from prompt_toolkit.output import ColorDepth
from prompt_toolkit.formatted_text import FormattedText
from prompt_toolkit.styles.named_colors import NAMED_COLORS
def main():
tokens = FormattedText(
[('fg:' + name, name + ' ') for name in NAMED_COLORS]
)
pft(HTML('\n<u>Named colors, hex codes.</u>'))
print(", ".join([f"{k}: {v}" for k, v in NAMED_COLORS.items()]))
pft(HTML('\n<u>Named colors, using 16 color output.</u>'))
pft('(Note that it doesn\'t really make sense to use named colors ')
pft('with only 16 color output.)')
pft(tokens, color_depth=ColorDepth.DEPTH_4_BIT)
pft(HTML('\n<u>Named colors, use 256 colors.</u>'))
pft(tokens)
pft(HTML('\n<u>Named colors, using True color output.</u>'))
pft(tokens, color_depth=ColorDepth.TRUE_COLOR)
if __name__ == '__main__':
main()