How to use terminal color palette with curses

后端 未结 6 1707
名媛妹妹
名媛妹妹 2021-01-30 13:45

I can\'t get the terminal color palette to work with curses.

import curses

def main(stdscr):
    curses.use_default_colors()
    for i in range(0,7):
        st         


        
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-30 14:33

    The terminal 'color palette' is set by the terminal application itself to map default curses colours to application-specific 'interpretations'. If you use red, the terminal can choose to display that as burgundy or cherry red, or if the user so desires, something completely different.

    In other words, just use the curses colours (combined with or without the bright or blink modifiers) and things should Just Work.

    I believe that the curses.use_default_colors() call merely makes transparency available; it is a direct call to the use_default_colors() ncurses API function. ncurses colors are otherwise palette based; you need to set your own color attributes per pair number with curses.init_pair() calls, then select a color pair with curses.color_pair() from the palette to display text with that specific pair; or build text attributes directly for a given addstr() call.

提交回复
热议问题