curses_colors.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:defuse_division 作者: lelandbatey 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号