default_colors(3X)
π default_colors β bestie, let's talk about the manual page default_colors(3X) π
okay so this is default_colors(3X) from the library calls girlies, and it's literally about using your terminal's default colors in curses. let's get into it π
β¨ NAME β¨
use_default_colors, assume_default_colors β use terminal's default colors in curses π¦
β¨ SYNOPSIS β¨
#include <curses.h>
int use_default_colors(void);
int assume_default_colors(int fg, int bg);
β¨ DESCRIPTION β¨
so use_default_colors and assume_default_colors are extensions to the curses library, periodt. they're for terminals that support ISO 6429 color, or the equivalent vibe. these terminals let the app reset color to an unspecified default value β like, with SGR 39 or SGR 49 π
apps that just paint a colored background over the whole entire screen? they're not taking advantage of SGR 39 and SGR 49 at all, no cap. some apps are designed to work with the default background, using colors only for text. for example, there are several implementations of the ls program which use colors to denote different file types or permissions. these βcolor lsβ programs don't necessarily modify the background color β typically they're only using the setaf terminfo capability to set the foreground color. and full-screen applications that use default colors can achieve similar visual effects β¨
the first function, use_default_colors, tells the curses library to assign terminal default foreground/background colors to color number -1. so init_pair(x,COLOR_RED,-1) will initialize pair x as red on default background, and init_pair(x,-1,COLOR_BLUE) will initialize pair x as default foreground on blue. iconic π
the other one, assume_default_colors, is a refinement which tells which colors to paint for color pair 0. this function recognizes a special color number -1, which denotes the default terminal color π
the following are equivalent:
use_default_colors();
assume_default_colors(-1,-1);
these are ncurses extensions. for other curses implementations, color number -1 does not mean anything β just as for ncurses before a successful call of use_default_colors or assume_default_colors.
other curses implementations do not allow an application to modify color pair 0. they assume that the background is COLOR_BLACK, but they do not ensure that the color pair 0 is painted to match the assumption. so if your application does not use either use_default_colors or assume_default_colors, ncurses will paint a white foreground (text) with black background for color pair 0 π
β¨ RETURN VALUE β¨
these functions return the integer ERR upon failure and OK on success π
they will fail if either the terminal does not support the orig_pair or orig_colors capability. and if the initialize_pair capability is not found, that causes an error as well π
β¨ NOTES β¨
associated with this extension, the init_pair function accepts negative arguments to specify default foreground or background colors π
the use_default_colors function was added to support ded. this is a full-screen application which uses curses to manage only part of the screen. the bottom portion of the screen, which is of adjustable size, is left uncolored to display the results from shell commands. the top portion of the screen colors filenames using a scheme like the βcolor lsβ programs. attempting to manage the background color of the screen for this application would give unsatisfactory results for a variety of reasons. this extension was devised after noting that color xterm (and similar programs) provides a background color which does not necessarily correspond to any of the ANSI colors. while a special terminfo entry could be constructed using nine colors, there was no mechanism provided within curses to account for the related orig_pair and back_color_erase capabilities π«Ά
the assume_default_colors function was added to solve a different problem: support for applications which would use environment variables and other configuration to bypass curses' notion of the terminal's default colors, setting specific values πΈ
β¨ PORTABILITY β¨
these routines are specific to ncurses. they were not supported on Version 7, BSD or System V implementations. it is recommended that any code depending on them be conditioned using NCURSES_VERSION β
ngl bestie, if you're writing portable code, wrap that stuff in NCURSES_VERSION or you're gonna have a bad time π
β¨ AUTHORS β¨
Thomas Dickey (from an analysis of the requirements for color xterm for XFree86 3.1.2C, February 1996). π
β¨ SEE ALSO β¨
ded(1), curs_color(3X) π
and that's the whole page, bestie!! go forth and let your terminal have its default-color main character moment π β¨
this was ncurses 6.6, dated 2024-04-13 β mwah, sending you a lil sign-off kiss π«Άπ
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright 2018-2023,2024 Thomas E. Dickey
- Copyright 2000-2011,2016 Free Software Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms