]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/default_colors.3x
ncurses 6.0 - patch 20170304
[ncurses.git] / man / default_colors.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2011,2016 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.25 2016/10/15 17:16:48 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. So init_pair(x,COLOR_RED,\-1)
64 will initialize pair x as red on default background and init_pair(x,\-1,COLOR_BLUE) will
65 initialize pair x as default foreground on blue.
66 .PP
67 The other, \fBassume_default_colors\fP
68 is a refinement which tells which colors to paint for color pair 0.
69 This function recognizes a special color number \-1,
70 which denotes the default terminal color.
71 .PP
72 The following are equivalent:
73 .RS
74 .br
75 .I use_default_colors();
76 .br
77 .I assume_default_colors(\-1,\-1);
78 .RE
79 .PP
80 These are ncurses extensions.
81 For other curses implementations, color
82 number \-1 does not mean anything, just as for ncurses before a
83 successful call of \fBuse_default_colors\fP or \fBassume_default_colors\fP.
84 .PP
85 Other curses implementations do not allow an application to modify color pair 0.
86 They assume that the background is COLOR_BLACK,
87 but do not ensure that the color pair 0 is painted to match the
88 assumption.
89 If your application does not use either
90 .B use_default_colors
91 or
92 .B assume_default_colors
93 ncurses will paint a white foreground (text) with black background
94 for color pair 0.
95 .SH RETURN VALUE
96 These functions return the integer \fBERR\fP upon failure and \fBOK\fP on success.
97 They will fail if either the terminal does not support
98 the \fBorig_pair\fP or \fBorig_colors\fP capability.
99 If the \fBinitialize_pair\fP capability is not found, this causes an
100 error as well.
101 .SH NOTES
102 Associated with this extension, the \fBinit_pair\fR function accepts
103 negative arguments to specify default foreground or background colors.
104 .PP
105 The \fBuse_default_colors\fP function was added to support \fIded\fP.
106 This is a full-screen application which uses curses to manage only part
107 of the screen.  The bottom portion of the screen, which is of adjustable
108 size, is left uncolored to display the results from shell commands.
109 The top portion of the screen colors filenames using a scheme like the
110 "color ls" programs.
111 Attempting to manage the background color of the screen for this application
112 would give unsatisfactory results for a variety of reasons.
113 This extension was devised after
114 noting that color xterm (and similar programs) provides a background color
115 which does not necessarily correspond to any of the ANSI colors.
116 While a special terminfo entry could be constructed using nine colors,
117 there was no mechanism provided within curses to account for the related
118 \fBorig_pair\fP and \fBback_color_erase\fP capabilities.
119 .PP
120 The \fBassume_default_colors\fP function was added to solve
121 a different problem: support for applications which would use
122 environment variables and other configuration to bypass curses'
123 notion of the terminal's default colors, setting specific values.
124 .SH PORTABILITY
125 These routines are specific to ncurses.  They were not supported on
126 Version 7, BSD or System V implementations.  It is recommended that
127 any code depending on them be conditioned using NCURSES_VERSION.
128 .SH SEE ALSO
129 \fBcurs_color\fR(3X),
130 \fBded\fP(1).
131 .SH AUTHOR
132 Thomas Dickey (from an analysis of the requirements for color xterm
133 for XFree86 3.1.2C, February 1996).