Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a brightwhite color in ncurses?

Tags:

c

ncurses

curses

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.

like image 704
dahpgjgamgan Avatar asked Dec 13 '09 10:12

dahpgjgamgan


People also ask

How do you color Ncurses?

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.


3 Answers

You need to set the bold attribute. Call attron(A_BOLD) before you write and attroff(A_BOLD) after.

like image 122
jimrandomh Avatar answered Oct 15 '22 12:10

jimrandomh


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)
like image 30
idavydov Avatar answered Oct 15 '22 12:10

idavydov


WINDOW *w = newwin(...);
wattron(w,A_BOLD);
<Your statements for mvwprintw, box, etc>
like image 21
Siva Avatar answered Oct 15 '22 13:10

Siva