Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fill an ncurses window with a color

Tags:

c

ncurses

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?

like image 714
The Bearded Strangler Avatar asked Jul 26 '11 20:07

The Bearded Strangler


2 Answers

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)).

like image 77
Marcin Zaluski Avatar answered Oct 04 '22 00:10

Marcin Zaluski


You can also use wbkgd(stdscr, COLOR_PAIR(1)) to change the main window color.

like image 24
Danilo Avatar answered Oct 03 '22 23:10

Danilo