default_colors.3x 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. .\"***************************************************************************
  2. .\" Copyright (c) 1998-2005,2006 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.20 2006/12/24 15:02:53 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
  44. .I use_default_colors()
  45. and
  46. .I assume_default_colors()
  47. functions are extensions to the curses library.
  48. They are used with terminals that support ISO 6429 color, or equivalent.
  49. These terminals allow the application to reset color to an unspecified
  50. default value (e.g., with SGR 39 or SGR 49).
  51. .PP
  52. Applications that paint a colored background over the whole screen
  53. do not take advantage of SGR 39 and SGR 49.
  54. Some applications are designed to work with the default background,
  55. using colors only for text.
  56. For example, there are several implementations of the \fBls\fP program
  57. which use colors to denote different file types or permissions.
  58. These "color ls" programs do not necessarily modify the background color,
  59. typically using only the \fIsetaf\fP terminfo capability to set the
  60. foreground color.
  61. Full-screen applications that use default colors can achieve similar
  62. visual effects.
  63. .PP
  64. The first function,
  65. .I use_default_colors()
  66. tells the curses library to assign terminal default
  67. foreground/background colors to color number -1. So init_pair(x,COLOR_RED,-1)
  68. will initialize pair x as red on default background and init_pair(x,-1,COLOR_BLUE) will
  69. initialize pair x as default foreground on blue.
  70. .PP
  71. The other,
  72. .I assume_default_colors()
  73. is a refinement which tells which colors to paint for color pair 0.
  74. This function recognizes a special color number -1,
  75. which denotes the default terminal color.
  76. .PP
  77. The following are equivalent:
  78. .RS
  79. .br
  80. .I use_default_colors();
  81. .br
  82. .I assume_default_colors(-1,-1);
  83. .RE
  84. .PP
  85. These are ncurses extensions.
  86. For other curses implementations, color
  87. number -1 does not mean anything, just as for ncurses before a
  88. successful call of \fIuse_default_colors()\fP or \fIassume_default_colors()\fP.
  89. .PP
  90. Other curses implementations do not allow an application to modify color pair 0.
  91. They assume that the background is COLOR_BLACK,
  92. but do not ensure that the color pair 0 is painted to match the
  93. assumption.
  94. If your application does not use either
  95. .I use_default_colors()
  96. or
  97. .I assume_default_colors()
  98. ncurses will paint a white foreground (text) with black background
  99. for color pair 0.
  100. .SH RETURN VALUE
  101. These functions return the integer \fBERR\fP upon failure and \fBOK\fP on success.
  102. They will fail if either the terminal does not support
  103. the \fIorig_pair\fP or \fIorig_colors\fP capability.
  104. If the \fIinitialize_pair\fP capability is found, this causes an
  105. error as well.
  106. .SH NOTES
  107. Associated with this extension, the \fBinit_pair\fR function accepts
  108. negative arguments to specify default foreground or background colors.
  109. .PP
  110. The \fIuse_default_colors()\fP function was added to support \fIded\fP.
  111. This is a full-screen application which uses curses to manage only part
  112. of the screen. The bottom portion of the screen, which is of adjustable
  113. size, is left uncolored to display the results from shell commands.
  114. The top portion of the screen colors filenames using a scheme like the
  115. "color ls" programs.
  116. Attempting to manage the background color of the screen for this application
  117. would give unsatisfactory results for a variety of reasons.
  118. This extension was devised after
  119. noting that color xterm (and similar programs) provides a background color
  120. which does not necessarily correspond to any of the ANSI colors.
  121. While a special terminfo entry could be constructed using nine colors,
  122. there was no mechanism provided within curses to account for the related
  123. \fIorig_pair\fP and \fIback_color_erase\fP capabilities.
  124. .PP
  125. The \fIassume_default_colors()\fP function was added to solve
  126. a different problem: support for applications which would use
  127. environment variables and other configuration to bypass curses'
  128. notion of the terminal's default colors, setting specific values.
  129. .SH PORTABILITY
  130. These routines are specific to ncurses. They were not supported on
  131. Version 7, BSD or System V implementations. It is recommended that
  132. any code depending on them be conditioned using NCURSES_VERSION.
  133. .SH SEE ALSO
  134. \fBcurs_color\fR(3X),
  135. \fBded\fP(1).
  136. .SH AUTHOR
  137. Thomas Dickey (from an analysis of the requirements for color xterm
  138. for XFree86 3.1.2C, February 1996).
  139. .\"#
  140. .\"# The following sets edit modes for GNU EMACS
  141. .\"# Local Variables:
  142. .\"# mode:nroff
  143. .\"# fill-column:79
  144. .\"# End: