Fill an ncurses window with a color
26,339
Solution 1
Please try bkgd
, or wbkgd
for specifying a window.
First you have to enable color support with start_color()
.
And then define color pair.
Example:init_pair(1,COLOR_BLUE, COLOR_RED)
The order is pair_number
, foreground
, background
Finally, set colors: wbkgd(WindowName, COLOR_PAIR(1))
.
Solution 2
You can also use wbkgd(stdscr, COLOR_PAIR(1))
to change the main window color.
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on November 04, 2020Comments
-
Admin over 3 years
I only have a basic knowledge of ncurses, and I was unable to find an answer to this question in the man pages.
When you set the foreground and background color for a window, is there a way to fill the whole window with the background color?
-
Mike about 3 yearsWARNING! Don't forget to use COLOR_PAIR(n) and not simply n. I did and spent 2 days trying to figure out why ncurses was not displaying the spaces in my output. (That should contain the search terms so the next poor soul who does the same thing can figure it out faster!)