I can't seem to get white-on-black to work in curses when in color mode. If I don't call start_color
, I get white-on-black. As soon as I call start_color
, things start outputting in grey-on-black.
If you run this script:
import sys
for i in xrange(30, 38):
print '\x1b[0;' + str(i) + 'm' + str(i) + ': Shiny colors \x1b[1m(bright)'
print '\x1b[0m...and this is normal.'
...you'll probably see a lot of pretty colors. The one I want, and can't get, is the last line: '...and this is normal.' Asking for color pair 0 or asking for COLOR_WHITE, COLOR_BLACK gets me the non-bright #37 from the script.
For reference, this is what I see in Gnome Terminal:
http://rpi.edu/~wellir/random/colors.png
I'm programming in Python (using the curses library), so my code is something like:
import curses
screen = curses.initscr()
curses.start_color()
curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK)
screen.clear()
screen.attrset(0)
screen.addstr('Hello')
screen.attrset(curses.A_BOLD)
screen.addstr('Hello')
screen.attrset(curses.color_pair(1))
screen.addstr('Hello')
screen.refresh()
curses.napms(5000)
curses.endwin()
...which gets me 37, 37-bright, and 37.
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.
curses.use_default_colors()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With