2010-07-07 15 views
4

我試圖讓標準的終端顏色而不是黑色的背景,但我似乎無法弄清楚。當我使用use_default_colors()標準就像不使用顏色,但我想改變前景色而不是背景色。我使用init_color_pair(1, COLOR_RED, COLOR_BLACK);但這給了我一個黑色的背景,我不想要的。如何使用Perl和Curses指定透明背景?

回答

1

爲了讓背景透明,應用的用戶應該在他們的.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 
+0

我只需要知道-1是默認值。非常非常感謝你。 – vincentkriek 2010-07-21 11:52:05