Attribute Description A_BLINK Blinking text A_BOLD Extra bright or bold text A_DIM Half bright text A_REVERSE Reverse-video text A_STANDOUT The best highlighting mode available A_UNDERLINE Underlined text So, to display a reverse-video status line on the top line of the screen, you could code: The curses library also supports color on those terminals that provide it. The most common such terminal is probably the Linux console, followed by color xterms. To use color, you must call the$_{start_color()}$ function soon after calling$_{initscr()}$ , to initialize the default color set (the$_{curses.wrapper()}$ function does this automatically). Once that’s done, the$_{has_colors()}$ function returns TRUE if the terminal in use can actually display color. (Note: curses uses the American spelling ‘color’, instead of the Canadian/British spelling ‘colour’. If you’re used to the British spelling, you’ll have to resign yourself to misspelling it for the sake of these functions.) The curses library maintains a finite number of color pairs, containing a foreground (or text) color and a background color. You can get the attribute value corresponding to a color pair with the$_{color_pair()}$ function; this can be bitwise-OR’ed with other attributes such as$_{A_REVERSE}$, but again, such combinations are not guaranteed to work on all terminals. An example, which displays a line of text using color pair 1: stdscr.addstr("Pretty text", curses.color_pair( 1)) stdscr.refresh() As I said before, a color pair consists of a foreground and background color. The$_{init_pair(n, f, b)}$ function changes the definition of color pair n , to foreground color f and background color b. Color pair 0 is hard-wired to white on black, and cannot be changed. Colors are numbered, and start_color() initializes 8 basic colors when it activates color mode. They are: 0:black, 1:red, 2:green, 3:yellow, 4:blue, 5:magenta, 6:cyan, and 7:white. The$_{curses}$module defines named con- stants for each of these colors: curses.COLOR_BLACK ,$_{curses.COLOR_RED}$ , and so forth. Let’s put all this together. To change color 1 to red text on a white background, you would call: curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE) When you change a color pair, any text already displayed using that color pair will change to the new colors. You can also display new text in this color with: stdscr.addstr(0,0,"RED ALERT!", curses.color_pair( 1)) Very fancy terminals can change the definitions of the actual colors to a given RGB value. This lets you change color 1, which is usually red, to purple or blue or any other color you like. Unfortunately, the Linux console doesn’t support this, so I’m unable to try it out, and can’t provide any examples. You can check if your terminal can do this by calling can_change_color() , which returns$_{True}$ if the capability is there. If you’re lucky enough to have such a talented terminal, consult your system’s man pages for more information. stdscr.addstr(0,0,"Current mode: Typing mode ", curses.A_REVERSE) stdscr.refresh() 6