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