ncurses transparent console background

社会主义新天地 提交于 2019-12-23 07:28:46

问题


My console has transparency enabled, when I run other ncurses apps, I see the the background stays transparent. I'm trying to make my app keep the transparency and not apply a dark black opaque background.

This is what I'm doing so far

start_color();
init_pair(1, COLOR_GREEN, COLOR_BLACK);

attron(COLOR_PAIR(1));
mvprintw(10,10, "Hello");

refresh();
attroff(COLOR_PAIR(1));

Any ideas?

Thanks


回答1:


If your application calls use_default_colors, ncurses (and NetBSD curses) provide an extension based on ECMA-48 SGR 39 and 49 "default colors". When you do this, ncurses refrains from explicitly coloring cells whose foreground and/or background color match its assumption about the terminal colors.

There is an additional function assume_default_colors which can be used to improve the default-colors feature where the terminal is (for example) using black text on a white background.

Most of the color-capable terminals you use support the SGR 39/49 codes, so the feature can be used most of the time.

Further reading:

  • Default Colors


来源:https://stackoverflow.com/questions/2403399/ncurses-transparent-console-background

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!