| 1 |
.\"*************************************************************************** |
| 2 |
.\" Copyright 2018-2023,2024 Thomas E. Dickey * |
| 3 |
.\" Copyright 2000-2011,2016 Free Software Foundation, Inc. * |
| 4 |
.\" * |
| 5 |
.\" Permission is hereby granted, free of charge, to any person obtaining a * |
| 6 |
.\" copy of this software and associated documentation files (the * |
| 7 |
.\" "Software"), to deal in the Software without restriction, including * |
| 8 |
.\" without limitation the rights to use, copy, modify, merge, publish, * |
| 9 |
.\" distribute, distribute with modifications, sublicense, and/or sell * |
| 10 |
.\" copies of the Software, and to permit persons to whom the Software is * |
| 11 |
.\" furnished to do so, subject to the following conditions: * |
| 12 |
.\" * |
| 13 |
.\" The above copyright notice and this permission notice shall be included * |
| 14 |
.\" in all copies or substantial portions of the Software. * |
| 15 |
.\" * |
| 16 |
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * |
| 17 |
.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * |
| 18 |
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * |
| 19 |
.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * |
| 20 |
.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * |
| 21 |
.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * |
| 22 |
.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. * |
| 23 |
.\" * |
| 24 |
.\" Except as contained in this notice, the name(s) of the above copyright * |
| 25 |
.\" holders shall not be used in advertising or otherwise to promote the * |
| 26 |
.\" sale, use or other dealings in this Software without prior written * |
| 27 |
.\" authorization. * |
| 28 |
.\"*************************************************************************** |
| 29 |
.\" |
| 30 |
.\" Author: Thomas E. Dickey 1997,1999,2000,2005 |
| 31 |
.\" |
| 32 |
.\" $Id: default_colors.3x,v 1.52 2024/04/13 22:17:22 tom Exp $ |
| 33 |
.TH default_colors 3NCURSES 2024-04-13 "ncurses 6.6" "Library calls" |
| 34 |
.ie \n(.g \{\ |
| 35 |
.ds `` \(lq |
| 36 |
.ds '' \(rq |
| 37 |
.\} |
| 38 |
.el \{\ |
| 39 |
.ie t .ds `` `` |
| 40 |
.el .ds `` "" |
| 41 |
.ie t .ds '' '' |
| 42 |
.el .ds '' "" |
| 43 |
.\} |
| 44 |
.SH NAME |
| 45 |
\fB\%use_default_colors\fP, |
| 46 |
\fB\%assume_default_colors\fP \- |
| 47 |
use terminal's default colors in \fIcurses\fP |
| 48 |
.SH SYNOPSIS |
| 49 |
.nf |
| 50 |
\fB#include <curses.h> |
| 51 |
.PP |
| 52 |
\fBint use_default_colors(void); |
| 53 |
\fBint assume_default_colors(int \fIfg\fP, int \fIbg\fP); |
| 54 |
.fi |
| 55 |
.SH DESCRIPTION |
| 56 |
The \fBuse_default_colors\fP and \fBassume_default_colors\fP |
| 57 |
functions are extensions to the curses library. |
| 58 |
They are used with terminals that support ISO 6429 color, or equivalent. |
| 59 |
These terminals allow the application to reset color to an unspecified |
| 60 |
default value (e.g., with SGR 39 or SGR 49). |
| 61 |
.PP |
| 62 |
Applications that paint a colored background over the whole screen |
| 63 |
do not take advantage of SGR 39 and SGR 49. |
| 64 |
Some applications are designed to work with the default background, |
| 65 |
using colors only for text. |
| 66 |
For example, there are several implementations of the \fBls\fP program |
| 67 |
which use colors to denote different file types or permissions. |
| 68 |
These \*(``color ls\*('' programs do not necessarily |
| 69 |
modify the background color, |
| 70 |
typically using only the \fBsetaf\fP terminfo capability to set the |
| 71 |
foreground color. |
| 72 |
Full-screen applications that use default colors can achieve similar |
| 73 |
visual effects. |
| 74 |
.PP |
| 75 |
The first function, \fBuse_default_colors\fP |
| 76 |
tells the curses library to assign terminal default |
| 77 |
foreground/background colors to color number \-1. |
| 78 |
So init_pair(x,COLOR_RED,\-1) |
| 79 |
will initialize pair x as red on default background |
| 80 |
and init_pair(x,\-1,COLOR_BLUE) will |
| 81 |
initialize pair x as default foreground on blue. |
| 82 |
.PP |
| 83 |
The other, \fBassume_default_colors\fP |
| 84 |
is a refinement which tells which colors to paint for color pair 0. |
| 85 |
This function recognizes a special color number \-1, |
| 86 |
which denotes the default terminal color. |
| 87 |
.PP |
| 88 |
The following are equivalent: |
| 89 |
.RS |
| 90 |
.br |
| 91 |
.I use_default_colors(); |
| 92 |
.br |
| 93 |
.I assume_default_colors(\-1,\-1); |
| 94 |
.RE |
| 95 |
.PP |
| 96 |
These are \fI\%ncurses\fP extensions. |
| 97 |
For other curses implementations, color |
| 98 |
number \-1 does not mean anything, just as for \fI\%ncurses\fP before a |
| 99 |
successful call of \fBuse_default_colors\fP or \fBassume_default_colors\fP. |
| 100 |
.PP |
| 101 |
Other curses implementations do not allow an application to modify color pair 0. |
| 102 |
They assume that the background is COLOR_BLACK, |
| 103 |
but do not ensure that the color pair 0 is painted to match the |
| 104 |
assumption. |
| 105 |
If your application does not use either |
| 106 |
.B use_default_colors |
| 107 |
or |
| 108 |
.B assume_default_colors |
| 109 |
\fI\%ncurses\fP will paint a white foreground (text) with black background |
| 110 |
for color pair 0. |
| 111 |
.SH RETURN VALUE |
| 112 |
These functions return the integer \fBERR\fP upon failure |
| 113 |
and \fBOK\fP on success. |
| 114 |
They will fail if either the terminal does not support |
| 115 |
the \fBorig_pair\fP or \fBorig_colors\fP capability. |
| 116 |
If the \fBinitialize_pair\fP capability is not found, this causes an |
| 117 |
error as well. |
| 118 |
.SH NOTES |
| 119 |
Associated with this extension, the \fBinit_pair\fP function accepts |
| 120 |
negative arguments to specify default foreground or background colors. |
| 121 |
.PP |
| 122 |
The \fBuse_default_colors\fP function was added to support \fBded\fP. |
| 123 |
This is a full-screen application which uses curses to manage only part |
| 124 |
of the screen. |
| 125 |
The bottom portion of the screen, which is of adjustable |
| 126 |
size, is left uncolored to display the results from shell commands. |
| 127 |
The top portion of the screen colors filenames using a scheme like the |
| 128 |
\*(``color ls\*('' programs. |
| 129 |
Attempting to manage the background color of the screen for this application |
| 130 |
would give unsatisfactory results for a variety of reasons. |
| 131 |
This extension was devised after |
| 132 |
noting that color xterm (and similar programs) provides a background color |
| 133 |
which does not necessarily correspond to any of the ANSI colors. |
| 134 |
While a special terminfo entry could be constructed using nine colors, |
| 135 |
there was no mechanism provided within curses to account for the related |
| 136 |
\fBorig_pair\fP and \fBback_color_erase\fP capabilities. |
| 137 |
.PP |
| 138 |
The \fBassume_default_colors\fP function was added to solve |
| 139 |
a different problem: support for applications which would use |
| 140 |
environment variables and other configuration to bypass curses' |
| 141 |
notion of the terminal's default colors, setting specific values. |
| 142 |
.SH PORTABILITY |
| 143 |
These routines are specific to \fI\%ncurses\fP. |
| 144 |
They were not supported on |
| 145 |
Version 7, BSD or System V implementations. |
| 146 |
It is recommended that |
| 147 |
any code depending on them be conditioned using NCURSES_VERSION. |
| 148 |
.SH AUTHORS |
| 149 |
Thomas Dickey (from an analysis of the requirements for color xterm |
| 150 |
for XFree86 3.1.2C, February 1996). |
| 151 |
.SH SEE ALSO |
| 152 |
\fB\%ded\fP(1), |
| 153 |
\fB\%color\fP(3NCURSES) |