File: named-colors.py

package info (click to toggle)
prompt-toolkit 3.0.51-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,232 kB
  • sloc: python: 30,894; makefile: 151; sh: 6
file content (30 lines) | stat: -rwxr-xr-x 884 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env python
"""
Demonstration of all the ANSI colors.
"""

from prompt_toolkit import HTML, print_formatted_text
from prompt_toolkit.formatted_text import FormattedText
from prompt_toolkit.output import ColorDepth
from prompt_toolkit.styles.named_colors import NAMED_COLORS

print = print_formatted_text


def main():
    tokens = FormattedText([("fg:" + name, name + "  ") for name in NAMED_COLORS])

    print(HTML("\n<u>Named colors, using 16 color output.</u>"))
    print("(Note that it doesn't really make sense to use named colors ")
    print("with only 16 color output.)")
    print(tokens, color_depth=ColorDepth.DEPTH_4_BIT)

    print(HTML("\n<u>Named colors, use 256 colors.</u>"))
    print(tokens)

    print(HTML("\n<u>Named colors, using True color output.</u>"))
    print(tokens, color_depth=ColorDepth.TRUE_COLOR)


if __name__ == "__main__":
    main()