]> ncurses.scripts.mit.edu Git - ncurses.git/blob - doc/html/man/default_colors.3x.html
ncurses 6.2 - patch 20201024
[ncurses.git] / doc / html / man / default_colors.3x.html
1 <!-- 
2   ****************************************************************************
3   * Copyright 2018-2019,2020 Thomas E. Dickey                                *
4   * Copyright 2000-2011,2016 Free Software Foundation, Inc.                  *
5   *                                                                          *
6   * Permission is hereby granted, free of charge, to any person obtaining a  *
7   * copy of this software and associated documentation files (the            *
8   * "Software"), to deal in the Software without restriction, including      *
9   * without limitation the rights to use, copy, modify, merge, publish,      *
10   * distribute, distribute with modifications, sublicense, and/or sell       *
11   * copies of the Software, and to permit persons to whom the Software is    *
12   * furnished to do so, subject to the following conditions:                 *
13   *                                                                          *
14   * The above copyright notice and this permission notice shall be included  *
15   * in all copies or substantial portions of the Software.                   *
16   *                                                                          *
17   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
18   * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
19   * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
20   * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
21   * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
22   * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
23   * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
24   *                                                                          *
25   * Except as contained in this notice, the name(s) of the above copyright   *
26   * holders shall not be used in advertising or otherwise to promote the     *
27   * sale, use or other dealings in this Software without prior written       *
28   * authorization.                                                           *
29   ****************************************************************************
30   * Author: Thomas E. Dickey 1997,1999,2000,2005
31   * @Id: default_colors.3x,v 1.30 2020/10/24 09:52:16 tom Exp @
32 -->
33 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
34 <HTML>
35 <HEAD>
36 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
37 <meta name="generator" content="Manpage converted by man2html - see https://invisible-island.net/scripts/readme.html#others_scripts">
38 <TITLE>default_colors 3x</TITLE>
39 <link rel="author" href="mailto:bug-ncurses@gnu.org">
40 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
41 </HEAD>
42 <BODY>
43 <H1 class="no-header">default_colors 3x</H1>
44 <PRE>
45 <STRONG><A HREF="default_colors.3x.html">default_colors(3x)</A></STRONG>                                          <STRONG><A HREF="default_colors.3x.html">default_colors(3x)</A></STRONG>
46
47
48
49
50 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
51        <STRONG>use_default_colors</STRONG>, <STRONG>assume_default_colors</STRONG> - use terminal's default col-
52        ors
53
54
55 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
56        <STRONG>#include</STRONG> <STRONG>&lt;curses.h&gt;</STRONG>
57
58        <STRONG>int</STRONG> <STRONG>use_default_colors(void);</STRONG>
59        <STRONG>int</STRONG> <STRONG>assume_default_colors(int</STRONG> <EM>fg</EM><STRONG>,</STRONG> <STRONG>int</STRONG> <EM>bg</EM><STRONG>);</STRONG>
60
61
62 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
63        The <STRONG>use_default_colors</STRONG> and <STRONG>assume_default_colors</STRONG> functions  are  exten-
64        sions to the curses library.  They are used with terminals that support
65        ISO 6429 color, or equivalent.  These terminals allow  the  application
66        to  reset  color  to an unspecified default value (e.g., with SGR 39 or
67        SGR 49).
68
69        Applications that paint a colored background over the whole  screen  do
70        not  take  advantage  of  SGR  39  and  SGR  49.  Some applications are
71        designed to work with the default background,  using  colors  only  for
72        text.  For example, there are several implementations of the <STRONG>ls</STRONG> program
73        which use colors to denote different file types or permissions.   These
74        "color  ls"  programs  do  not necessarily modify the background color,
75        typically using only the <STRONG>setaf</STRONG> terminfo capability  to  set  the  fore-
76        ground  color.   Full-screen  applications  that use default colors can
77        achieve similar visual effects.
78
79        The first function, <STRONG>use_default_colors</STRONG>  tells  the  curses  library  to
80        assign  terminal  default  foreground/background colors to color number
81        -1.  So init_pair(x,COLOR_RED,-1) will initialize  pair  x  as  red  on
82        default  background and init_pair(x,-1,COLOR_BLUE) will initialize pair
83        x as default foreground on blue.
84
85        The other, <STRONG>assume_default_colors</STRONG> is a refinement which tells which col-
86        ors  to  paint  for  color  pair 0.  This function recognizes a special
87        color number -1, which denotes the default terminal color.
88
89        The following are equivalent:
90               <EM>use</EM><STRONG>_</STRONG><EM>default</EM><STRONG>_</STRONG><EM>colors();</EM>
91               <EM>assume</EM><STRONG>_</STRONG><EM>default</EM><STRONG>_</STRONG><EM>colors(-1,-1);</EM>
92
93        These are ncurses extensions.  For other curses implementations,  color
94        number -1 does not mean anything, just as for ncurses before a success-
95        ful call of <STRONG>use_default_colors</STRONG> or <STRONG>assume_default_colors</STRONG>.
96
97        Other curses implementations do not  allow  an  application  to  modify
98        color  pair  0.  They assume that the background is COLOR_BLACK, but do
99        not ensure that the color pair 0 is painted to  match  the  assumption.
100        If   your   application  does  not  use  either  <STRONG>use_default_colors</STRONG>  or
101        <STRONG>assume_default_colors</STRONG> ncurses will paint a white foreground (text) with
102        black background for color pair 0.
103
104
105 </PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
106        These  functions return the integer <STRONG>ERR</STRONG> upon failure and <STRONG>OK</STRONG> on success.
107        They will fail if either the terminal does not support the <STRONG>orig_pair</STRONG> or
108        <STRONG>orig_colors</STRONG>  capability.   If  the  <STRONG>initialize_pair</STRONG>  capability  is not
109        found, this causes an error as well.
110
111
112 </PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE>
113        Associated with this extension, the <STRONG>init_pair</STRONG> function accepts negative
114        arguments to specify default foreground or background colors.
115
116        The  <STRONG>use_default_colors</STRONG>  function  was added to support <EM>ded</EM>.  This is a
117        full-screen application which uses curses to manage only  part  of  the
118        screen.  The bottom portion of the screen, which is of adjustable size,
119        is left uncolored to display the results from shell commands.  The  top
120        portion  of  the screen colors filenames using a scheme like the "color
121        ls" programs.  Attempting to manage the background color of the  screen
122        for this application would give unsatisfactory results for a variety of
123        reasons.  This extension was devised after noting that color xterm (and
124        similar  programs) provides a background color which does not necessar-
125        ily correspond to any of the ANSI colors.   While  a  special  terminfo
126        entry  could  be  constructed using nine colors, there was no mechanism
127        provided within  curses  to  account  for  the  related  <STRONG>orig_pair</STRONG>  and
128        <STRONG>back_color_erase</STRONG> capabilities.
129
130        The <STRONG>assume_default_colors</STRONG> function was added to solve a different prob-
131        lem: support for applications which would use environment variables and
132        other  configuration to bypass curses' notion of the terminal's default
133        colors, setting specific values.
134
135
136 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
137        These routines are specific to ncurses.  They  were  not  supported  on
138        Version 7, BSD or System V implementations.  It is recommended that any
139        code depending on them be conditioned using NCURSES_VERSION.
140
141
142 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
143        <STRONG><A HREF="curs_color.3x.html">curs_color(3x)</A></STRONG>, <STRONG>ded(1)</STRONG>.
144
145
146 </PRE><H2><a name="h2-AUTHOR">AUTHOR</a></H2><PRE>
147        Thomas Dickey (from an analysis of the requirements for color xterm for
148        XFree86 3.1.2C, February 1996).
149
150
151
152                                                             <STRONG><A HREF="default_colors.3x.html">default_colors(3x)</A></STRONG>
153 </PRE>
154 <div class="nav">
155 <ul>
156 <li><a href="#h2-NAME">NAME</a></li>
157 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
158 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a></li>
159 <li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
160 <li><a href="#h2-NOTES">NOTES</a></li>
161 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
162 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>
163 <li><a href="#h2-AUTHOR">AUTHOR</a></li>
164 </ul>
165 </div>
166 </BODY>
167 </HTML>