2 ****************************************************************************
3 * Copyright (c) 1998-2016,2018 Free Software Foundation, Inc. *
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: *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
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. *
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 *
28 ****************************************************************************
29 * Author: Thomas E. Dickey 1997,1999,2000,2005
30 * @Id: default_colors.3x,v 1.27 2018/07/28 22:08:59 tom Exp @
32 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
35 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
36 <meta name="generator" content="Manpage converted by man2html - see https://invisible-island.net/scripts/readme.html#others_scripts">
37 <TITLE>default_colors 3x</TITLE>
38 <link rev=made href="mailto:bug-ncurses@gnu.org">
39 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
42 <H1 class="no-header">default_colors 3x</H1>
44 <STRONG><A HREF="default_colors.3x.html">default_colors(3x)</A></STRONG> <STRONG><A HREF="default_colors.3x.html">default_colors(3x)</A></STRONG>
49 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
50 <STRONG>use_default_colors</STRONG>, <STRONG>assume_default_colors</STRONG> - use terminal's default col-
54 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
55 <STRONG>#include</STRONG> <STRONG><curses.h></STRONG>
57 <STRONG>int</STRONG> <STRONG>use_default_colors(void);</STRONG>
58 <STRONG>int</STRONG> <STRONG>assume_default_colors(int</STRONG> <STRONG>fg,</STRONG> <STRONG>int</STRONG> <STRONG>bg);</STRONG>
61 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
62 The <STRONG>use_default_colors</STRONG> and <STRONG>assume_default_colors</STRONG> functions are exten-
63 sions to the curses library. They are used with terminals that support
64 ISO 6429 color, or equivalent. These terminals allow the application
65 to reset color to an unspecified default value (e.g., with SGR 39 or
68 Applications that paint a colored background over the whole screen do
69 not take advantage of SGR 39 and SGR 49. Some applications are
70 designed to work with the default background, using colors only for
71 text. For example, there are several implementations of the <STRONG>ls</STRONG> program
72 which use colors to denote different file types or permissions. These
73 "color ls" programs do not necessarily modify the background color,
74 typically using only the <STRONG>setaf</STRONG> terminfo capability to set the fore-
75 ground color. Full-screen applications that use default colors can
76 achieve similar visual effects.
78 The first function, <STRONG>use_default_colors</STRONG> tells the curses library to
79 assign terminal default foreground/background colors to color number
80 -1. So init_pair(x,COLOR_RED,-1) will initialize pair x as red on
81 default background and init_pair(x,-1,COLOR_BLUE) will initialize pair
82 x as default foreground on blue.
84 The other, <STRONG>assume_default_colors</STRONG> is a refinement which tells which col-
85 ors to paint for color pair 0. This function recognizes a special
86 color number -1, which denotes the default terminal color.
88 The following are equivalent:
89 <EM>use</EM><STRONG>_</STRONG><EM>default</EM><STRONG>_</STRONG><EM>colors();</EM>
90 <EM>assume</EM><STRONG>_</STRONG><EM>default</EM><STRONG>_</STRONG><EM>colors(-1,-1);</EM>
92 These are ncurses extensions. For other curses implementations, color
93 number -1 does not mean anything, just as for ncurses before a success-
94 ful call of <STRONG>use_default_colors</STRONG> or <STRONG>assume_default_colors</STRONG>.
96 Other curses implementations do not allow an application to modify
97 color pair 0. They assume that the background is COLOR_BLACK, but do
98 not ensure that the color pair 0 is painted to match the assumption.
99 If your application does not use either <STRONG>use_default_colors</STRONG> or
100 <STRONG>assume_default_colors</STRONG> ncurses will paint a white foreground (text) with
101 black background for color pair 0.
104 </PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
105 These functions return the integer <STRONG>ERR</STRONG> upon failure and <STRONG>OK</STRONG> on success.
106 They will fail if either the terminal does not support the <STRONG>orig_pair</STRONG> or
107 <STRONG>orig_colors</STRONG> capability. If the <STRONG>initialize_pair</STRONG> capability is not
108 found, this causes an error as well.
111 </PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE>
112 Associated with this extension, the <STRONG>init_pair</STRONG> function accepts negative
113 arguments to specify default foreground or background colors.
115 The <STRONG>use_default_colors</STRONG> function was added to support <EM>ded</EM>. This is a
116 full-screen application which uses curses to manage only part of the
117 screen. The bottom portion of the screen, which is of adjustable size,
118 is left uncolored to display the results from shell commands. The top
119 portion of the screen colors filenames using a scheme like the "color
120 ls" programs. Attempting to manage the background color of the screen
121 for this application would give unsatisfactory results for a variety of
122 reasons. This extension was devised after noting that color xterm (and
123 similar programs) provides a background color which does not necessar-
124 ily correspond to any of the ANSI colors. While a special terminfo
125 entry could be constructed using nine colors, there was no mechanism
126 provided within curses to account for the related <STRONG>orig_pair</STRONG> and
127 <STRONG>back_color_erase</STRONG> capabilities.
129 The <STRONG>assume_default_colors</STRONG> function was added to solve a different prob-
130 lem: support for applications which would use environment variables and
131 other configuration to bypass curses' notion of the terminal's default
132 colors, setting specific values.
135 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
136 These routines are specific to ncurses. They were not supported on
137 Version 7, BSD or System V implementations. It is recommended that any
138 code depending on them be conditioned using NCURSES_VERSION.
141 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
142 <STRONG><A HREF="curs_color.3x.html">curs_color(3x)</A></STRONG>, <STRONG>ded(1)</STRONG>.
145 </PRE><H2><a name="h2-AUTHOR">AUTHOR</a></H2><PRE>
146 Thomas Dickey (from an analysis of the requirements for color xterm for
147 XFree86 3.1.2C, February 1996).
151 <STRONG><A HREF="default_colors.3x.html">default_colors(3x)</A></STRONG>
155 <li><a href="#h2-NAME">NAME</a></li>
156 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
157 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a></li>
158 <li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
159 <li><a href="#h2-NOTES">NOTES</a></li>
160 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
161 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>
162 <li><a href="#h2-AUTHOR">AUTHOR</a></li>