1default_colors(3X)                                          default_colors(3X)
2
3
4

NAME

6       use_default_colors, assume_default_colors - use terminal's default col‐
7       ors
8

SYNOPSIS

10       #include <curses.h>
11
12       int use_default_colors(void);
13       int assume_default_colors(int fg, int bg);
14

DESCRIPTION

16       The use_default_colors and assume_default_colors functions  are  exten‐
17       sions to the curses library.  They are used with terminals that support
18       ISO 6429 color, or equivalent.  These terminals allow  the  application
19       to  reset  color  to an unspecified default value (e.g., with SGR 39 or
20       SGR 49).
21
22       Applications that paint a colored background over the whole  screen  do
23       not  take  advantage  of  SGR  39  and  SGR  49.  Some applications are
24       designed to work with the default background,  using  colors  only  for
25       text.  For example, there are several implementations of the ls program
26       which use colors to denote different file types or permissions.   These
27       "color  ls"  programs  do  not necessarily modify the background color,
28       typically using only the setaf terminfo capability  to  set  the  fore‐
29       ground  color.   Full-screen  applications  that use default colors can
30       achieve similar visual effects.
31
32       The first function, use_default_colors  tells  the  curses  library  to
33       assign  terminal  default  foreground/background colors to color number
34       -1. So init_pair(x,COLOR_RED,-1) will  initialize  pair  x  as  red  on
35       default  background and init_pair(x,-1,COLOR_BLUE) will initialize pair
36       x as default foreground on blue.
37
38       The other, assume_default_colors is a refinement which tells which col‐
39       ors  to  paint  for  color  pair 0.  This function recognizes a special
40       color number -1, which denotes the default terminal color.
41
42       The following are equivalent:
43              use_default_colors();
44              assume_default_colors(-1,-1);
45
46       These are ncurses extensions.  For other curses implementations,  color
47       number -1 does not mean anything, just as for ncurses before a success‐
48       ful call of use_default_colors or assume_default_colors.
49
50       Other curses implementations do not  allow  an  application  to  modify
51       color  pair  0.  They assume that the background is COLOR_BLACK, but do
52       not ensure that the color pair 0 is painted to  match  the  assumption.
53       If   your   application  does  not  use  either  use_default_colors  or
54       assume_default_colors ncurses will paint a white foreground (text) with
55       black background for color pair 0.
56

RETURN VALUE

58       These  functions return the integer ERR upon failure and OK on success.
59       They will fail if either the terminal does not support the orig_pair or
60       orig_colors  capability.   If  the  initialize_pair  capability  is not
61       found, this causes an error as well.
62

NOTES

64       Associated with this extension, the init_pair function accepts negative
65       arguments to specify default foreground or background colors.
66
67       The  use_default_colors  function  was added to support ded.  This is a
68       full-screen application which uses curses to manage only  part  of  the
69       screen.  The bottom portion of the screen, which is of adjustable size,
70       is left uncolored to display the results from shell commands.  The  top
71       portion  of  the screen colors filenames using a scheme like the "color
72       ls" programs.  Attempting to manage the background color of the  screen
73       for this application would give unsatisfactory results for a variety of
74       reasons.  This extension was devised after noting that color xterm (and
75       similar  programs) provides a background color which does not necessar‐
76       ily correspond to any of the ANSI colors.   While  a  special  terminfo
77       entry  could  be  constructed using nine colors, there was no mechanism
78       provided within  curses  to  account  for  the  related  orig_pair  and
79       back_color_erase capabilities.
80
81       The assume_default_colors function was added to solve a different prob‐
82       lem: support for applications which would use environment variables and
83       other  configuration to bypass curses' notion of the terminal's default
84       colors, setting specific values.
85

PORTABILITY

87       These routines are specific to ncurses.  They  were  not  supported  on
88       Version 7, BSD or System V implementations.  It is recommended that any
89       code depending on them be conditioned using NCURSES_VERSION.
90

SEE ALSO

92       curs_color(3X), ded(1).
93

AUTHOR

95       Thomas Dickey (from an analysis of the requirements for color xterm for
96       XFree86 3.1.2C, February 1996).
97
98
99
100                                                            default_colors(3X)
Impressum