about summary refs log tree commit diff stats
path: root/doc/tools/print_colors.py
blob: b3eba7498d1aabc93a605ffe3a92daa8ec6eff53 (plain) (blame)
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
#!/usr/bin/env python
"""
You can use this tool to display all supported colors and their color number.
It will exit after a keypress.
"""

import curses
from curses import *

@wrapper
def main(win):
    def print_all_colors(attr):
        for c in range(-1, curses.COLORS):
            try:
                init_pair(c, c, 0)
            except:
                pass
            else:
                win.addstr(str(c) + ' ', color_pair(c) | attr)
    start_color()
    try:
        use_default_colors()
    except:
        pass
    win.addstr("available colors: %d\n\n" % curses.COLORS)
    print_all_colors(0)
    win.addstr("\n\n")
    print_all_colors(A_BOLD)
    win.refresh()
    win.getch()