def colors_init():
"""
Initializes all color pairs possible into the dictionary CURSES_COLORPAIRS.
Thus, getting an attribute for a black foreground and a green background
would look like:
>>> curses_color.colors_init()
>>> green_black_attr = curses_color.CURSES_COLORPAIRS['black-green']
>>> stdscr.addstr(0, 0, "test", curses.color_pair(green_black_attr))
"""
if len(CURSES_COLORPAIRS): return
assert curses.has_colors(
), "Curses wasn't configured to support colors. Call curses.start_color()"
start_number = 120
for fg in BASE_CURSES_COLORS.keys():
for bg in BASE_CURSES_COLORS.keys():
pair_num = len(CURSES_COLORPAIRS) + start_number
curses.init_pair(pair_num, BASE_CURSES_COLORS[fg],
BASE_CURSES_COLORS[bg])
pair_name = "{}-{}".format(fg, bg)
CURSES_COLORPAIRS[pair_name] = pair_num
评论列表
文章目录