]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/default_colors.3x
ncurses 6.4 - patch 20231001
[ncurses.git] / man / default_colors.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2022,2023 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.44 2023/09/30 21:38:11 tom Exp $
33 .TH default_colors 3X 2023-09-30 "ncurses 6.4" "Library calls"
34 .ie \n(.g .ds `` \(lq
35 .el       .ds `` ``
36 .ie \n(.g .ds '' \(rq
37 .el       .ds '' ''
38 .SH NAME
39 \fB\%use_default_colors\fP,
40 \fB\%assume_default_colors\fP \-
41 use terminal's default colors
42 .SH SYNOPSIS
43 \fB#include <curses.h>\fP
44 .sp
45 \fBint use_default_colors(void);\fP
46 .br
47 \fBint assume_default_colors(int \fIfg\fB, int \fIbg\fB);\fR
48 .SH DESCRIPTION
49 The \fBuse_default_colors\fP and \fBassume_default_colors\fP
50 functions are extensions to the curses library.
51 They are used with terminals that support ISO 6429 color, or equivalent.
52 These terminals allow the application to reset color to an unspecified
53 default value (e.g., with SGR 39 or SGR 49).
54 .PP
55 Applications that paint a colored background over the whole screen
56 do not take advantage of SGR 39 and SGR 49.
57 Some applications are designed to work with the default background,
58 using colors only for text.
59 For example, there are several implementations of the \fBls\fP program
60 which use colors to denote different file types or permissions.
61 These \*(``color ls\*('' programs do not necessarily
62 modify the background color,
63 typically using only the \fBsetaf\fP terminfo capability to set the
64 foreground color.
65 Full-screen applications that use default colors can achieve similar
66 visual effects.
67 .PP
68 The first function, \fBuse_default_colors\fP
69 tells the curses library to assign terminal default
70 foreground/background colors to color number \-1.
71 So init_pair(x,COLOR_RED,\-1)
72 will initialize pair x as red on default background
73 and init_pair(x,\-1,COLOR_BLUE) will
74 initialize pair x as default foreground on blue.
75 .PP
76 The other, \fBassume_default_colors\fP
77 is a refinement which tells which colors to paint for color pair 0.
78 This function recognizes a special color number \-1,
79 which denotes the default terminal color.
80 .PP
81 The following are equivalent:
82 .RS
83 .br
84 .I use_default_colors();
85 .br
86 .I assume_default_colors(\-1,\-1);
87 .RE
88 .PP
89 These are ncurses extensions.
90 For other curses implementations, color
91 number \-1 does not mean anything, just as for ncurses before a
92 successful call of \fBuse_default_colors\fP or \fBassume_default_colors\fP.
93 .PP
94 Other curses implementations do not allow an application to modify color pair 0.
95 They assume that the background is COLOR_BLACK,
96 but do not ensure that the color pair 0 is painted to match the
97 assumption.
98 If your application does not use either
99 .B use_default_colors
100 or
101 .B assume_default_colors
102 ncurses will paint a white foreground (text) with black background
103 for color pair 0.
104 .SH RETURN VALUE
105 These functions return the integer \fBERR\fP upon failure
106 and \fBOK\fP on success.
107 They will fail if either the terminal does not support
108 the \fBorig_pair\fP or \fBorig_colors\fP capability.
109 If the \fBinitialize_pair\fP capability is not found, this causes an
110 error as well.
111 .SH NOTES
112 Associated with this extension, the \fBinit_pair\fP function accepts
113 negative arguments to specify default foreground or background colors.
114 .PP
115 The \fBuse_default_colors\fP function was added to support \fBded\fP.
116 This is a full-screen application which uses curses to manage only part
117 of the screen.
118 The bottom portion of the screen, which is of adjustable
119 size, is left uncolored to display the results from shell commands.
120 The top portion of the screen colors filenames using a scheme like the
121 \*(``color ls\*('' programs.
122 Attempting to manage the background color of the screen for this application
123 would give unsatisfactory results for a variety of reasons.
124 This extension was devised after
125 noting that color xterm (and similar programs) provides a background color
126 which does not necessarily correspond to any of the ANSI colors.
127 While a special terminfo entry could be constructed using nine colors,
128 there was no mechanism provided within curses to account for the related
129 \fBorig_pair\fP and \fBback_color_erase\fP capabilities.
130 .PP
131 The \fBassume_default_colors\fP function was added to solve
132 a different problem: support for applications which would use
133 environment variables and other configuration to bypass curses'
134 notion of the terminal's default colors, setting specific values.
135 .SH PORTABILITY
136 These routines are specific to ncurses.
137 They were not supported on
138 Version 7, BSD or System V implementations.
139 It is recommended that
140 any code depending on them be conditioned using NCURSES_VERSION.
141 .SH AUTHOR
142 Thomas Dickey (from an analysis of the requirements for color xterm
143 for XFree86 3.1.2C, February 1996).
144 .SH SEE ALSO
145 \fB\%ded\fP(1),
146 \fB\%curs_color\fP(3X)