我试图让背景成为标准的终端颜色而不是黑色,但我似乎无法弄明白.当我使用use_default_colors()时,标准就像不使用颜色,但我想改变前景色而不是背景色.我使用init_color_pair(1,COLOR_RED,COLOR_BLACK);但这给了我一个黑色的背景,我不想要的.
解决方法
为了拥有透明背景,您的应用的用户应该在.Xdefaults或类似的东西中指定它.如果用户已经具有透明背景,那么您只需要使用默认背景,如下所示:
use Curses; #...some init here... # colors: use_default_colors; # mandatory,we want to use the default background which is transparent init_pair 1,COLOR_BLUE,-1; # -1 mandatory,again,we want *default* background init_pair 2,-1,COLOR_WHITE; # you can use the default foreground color if you like