The Bearded Strangler
The Bearded Strangler

Reputation: 463

Fill an ncurses window with a color

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?

Upvotes: 41

Views: 33039

Answers (3)

ayuval
ayuval

Reputation: 81

If you're simply trying to go back to normal background:

By default, start_color imposes using the first black in your color scheme - 0. Named also COLOR_BLACK.

To change that, call use_default_colors() to have ncurses use the default background instead.

Upvotes: 2

Danilo
Danilo

Reputation: 51

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

Upvotes: 2

Marcin Zaluski
Marcin Zaluski

Reputation: 725

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

Upvotes: 46

Related Questions