import curses import platform def main(stdscr): curses.start_color() curses.use_default_colors() stdscr.addstr("pairs={}, colors={}\n".format( curses.COLOR_PAIRS, curses.COLORS)) stdscr.addstr("std colors are: {},{},{},{},{},{},{},{}\n".format( curses.COLOR_BLACK, curses.COLOR_BLUE, curses.COLOR_GREEN, curses.COLOR_CYAN, curses.COLOR_RED, curses.COLOR_MAGENTA, curses.COLOR_YELLOW, curses.COLOR_WHITE)) for i in range(8): stdscr.addstr("color {}=({}), ".format(i, curses.color_content(i))) if i == 3: stdscr.addstr("\n") stdscr.addstr("\n") stdscr.addstr(("Attrs=\n"+5*(4 * "{:08X}={},"+"\n")).format( curses.A_ALTCHARSET, "A_ALTCHARSET", # Alternate character set mode curses.A_BLINK , "A_BLINK ", # Blink mode curses.A_BOLD , "A_BOLD ", # Bold mode curses.A_DIM , "A_DIM ", # Dim mode curses.A_INVIS , "A_INVIS ", # Invisible or blank mode curses.A_ITALIC , "A_ITALIC ", # Italic mode curses.A_NORMAL , "A_NORMAL ", # Normal attribute curses.A_PROTECT , "A_PROTECT ", # Protected mode curses.A_REVERSE , "A_REVERSE ", # Reverse background and foreground colors curses.A_STANDOUT , "A_STANDOUT ", # Standout mode curses.A_UNDERLINE , "A_UNDERLINE ", # Underline mode curses.A_HORIZONTAL, "A_HORIZONTAL", # Horizontal highlight curses.A_LEFT , "A_LEFT ", # Left highlight curses.A_LOW , "A_LOW ", # Low highlight curses.A_RIGHT , "A_RIGHT ", # Right highlight curses.A_TOP , "A_TOP ", # Top highlight curses.A_VERTICAL , "A_VERTICAL ", # Vertical highlight curses.A_ATTRIBUTES, "A_ATTRIBUTES", # Bit-mask to extract attributes curses.A_CHARTEXT , "A_CHARTEXT ", # Bit-mask to extract a character curses.A_COLOR , "A_COLOR " # Bit-mask to extract color-pair field information )) fg, bg = curses.pair_content (curses.pair_number(stdscr.inch() & curses.A_ATTRIBUTES)) stdscr.addstr("\nstdscr fg={:08X}={},bg={:08X}={}\n".format(fg, fg, bg, bg)) stdscr.getch() stdscr.erase() for i in range(1, min(curses.COLOR_PAIRS, 256)): curses.init_pair(i, i - 1, -1) #stdscr.addstr("{:03},".format(i), curses.color_pair(i)) #stdscr.getch() try: for i in range(0, min(curses.COLOR_PAIRS, 256)): stdscr.addstr("{:03},".format(i), curses.color_pair(i)) if i > 0 and i % 15 == 14: stdscr.addstr("\n") stdscr.addstr("\n") except: # curses.ERR: # End of screen reached pass y, x = stdscr.getyx() attr = stdscr.inch(6, 0) stdscr.move(y, x) stdscr.addstr("inch(6,0)={:08X}={}\n".format(attr, attr)) pair = curses.pair_number(attr) if platform.system() == "Windows": pair = pair >> 16 stdscr.addstr("pair(6,0)={:08X}={}\n".format(pair, pair)) fg, bg = curses.pair_content (pair) stdscr.addstr("color(6,0) fg={:08X}={},bg={:08X}={}\n".format(fg, fg, bg, bg)) attr = stdscr.getbkgd() stdscr.addstr("scrbkgd={:08X}={}\n".format(attr, attr)) pair = curses.pair_number(attr) if platform.system() == "Windows": pair = pair >> 16 fg, bg = curses.pair_content (pair) stdscr.addstr("color(scrbkgd) fg={:08X}={},bg={:08X}={}\n".format(fg, fg, bg, bg)) stdscr.getch() curses.wrapper(main)