C语言 用颜色填充 ncurses 窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6835912/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Fill an ncurses window with a color
提问by The Bearded Strangler
I only have a basic knowledge of ncurses, and I was unable to find an answer to this question in the man pages.
我只有 ncurses 的基本知识,我无法在手册页中找到这个问题的答案。
When you set the foreground and background color for a window, is there a way to fill the whole window with the background color?
当您为窗口设置前景色和背景色时,有没有办法用背景色填充整个窗口?
回答by Marcin Zaluski
Please try bkgd, or wbkgdfor specifying a window.
请尝试bkgd,或wbkgd指定一个窗口。
First you have to enable color support with start_color().
首先,您必须使用start_color().
And then define color pair.
Example:init_pair(1,COLOR_BLUE, COLOR_RED)
然后定义颜色对。例子:init_pair(1,COLOR_BLUE, COLOR_RED)
The order is pair_number, foreground, background
顺序是pair_number, foreground,background
Finally, set colors: wbkgd(WindowName, COLOR_PAIR(1)).
最后,设置颜色:wbkgd(WindowName, COLOR_PAIR(1)).

