问题
How to init a color pair with light grey background, and bright white foregraound?
init_pair(number, COLOR_WHITE, COLOR_WHITE) creates a color pair with light grey foreground and backround, but I need foreground to be really white. I tried combining COLOR_WHITE with A_BLINK (through bitwise OR) but that doesn't work. Ncurses howto's/examples/documentaion couldn't help me either.
回答1:
You need to set the bold attribute. Call attron(A_BOLD) before you write and attroff(A_BOLD) after.
回答2:
I had similar problem with python + curses. The solution is to enable use_default_colors and then use -1 as background color.
This is python example, but I hope it would be usefull:
stdscr = curses.initscr()
curses.start_color()
curses.use_default_colors()
curses.noecho()
curses.cbreak()
curses.init_pair(1, curses.COLOR_WHITE, -1)
回答3:
WINDOW *w = newwin(...);
wattron(w,A_BOLD);
<Your statements for mvwprintw, box, etc>
回答4:
This is just a stab in the dark, I'm not very knowledgeable about ncurses:
If there's a function/parameter for turning text bold, give that a try! Some implementations of text color mapping use brighter colors in place of a bold font.
来源:https://stackoverflow.com/questions/1896162/how-to-get-a-brightwhite-color-in-ncurses