Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ncurses transparent console background

Tags:

c

ncurses

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

like image 308
Josh Avatar asked Mar 08 '10 17:03

Josh


1 Answers

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
like image 160
Thomas Dickey Avatar answered Sep 20 '22 13:09

Thomas Dickey