Ncurses and white-on-black

I can't get white on black to work in curses in color mode. If I do not call start_color , I get white-on-black. As soon as I call start_color , everything starts to start_color gray.

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 are likely to see many beautiful flowers. I want and can not get, this is the last line: "... and this is normal." By setting the color pair to 0 or by requesting COLOR_WHITE, COLOR_BLACK will deliver me a non-bright # 37 from the script.

For reference, this is what I see in the Gnome terminal:

http://rpi.edu/~wellir/random/colors.png

I am programming in Python (using the curses library), so my code looks something like this:

 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.

+7
python ncurses curses
source share
3 answers

curses.use_default_colors()

+4
source share

Your gnome terminal may have its own color scheme, which changes the default white color to white or bright white, except when in curse mode. Make sure that the gnome terminal does not change colors, because this will make it difficult to test colors.

+1
source share

I was also on gnome terminal with the same problem.

I managed to solve this problem with

right click on the screen> profile> profile settings> color> palette

I think this is what each of the 8 colors will be displayed to.

for some reason, the built-in Default scheme that has been selected displays the first color in gray, not black!

changing the circuit to XTerm or changing the first color to black solved my problem.

I do not use curses.use_default_colors .

0
source share

All Articles