default_colors.3x.html 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
  2. <!--
  3. ****************************************************************************
  4. * Copyright (c) 1998-2005,2006 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.20 2006/12/24 15:02:53 tom Exp @
  32. -->
  33. <HTML>
  34. <HEAD>
  35. <TITLE>default_colors 3x</TITLE>
  36. <link rev=made href="mailto:bug-ncurses@gnu.org">
  37. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  38. </HEAD>
  39. <BODY>
  40. <H1>default_colors 3x</H1>
  41. <HR>
  42. <PRE>
  43. <!-- Manpage converted by man2html 3.0.1 -->
  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>
  45. </PRE>
  46. <H2>NAME</H2><PRE>
  47. <STRONG>use_default_colors</STRONG>, <STRONG>assume_default_colors</STRONG> - use terminal's
  48. default colors
  49. </PRE>
  50. <H2>SYNOPSIS</H2><PRE>
  51. <STRONG>#include</STRONG> <STRONG>&lt;curses.h&gt;</STRONG>
  52. <STRONG>int</STRONG> <STRONG>use_default_colors(void);</STRONG>
  53. <STRONG>int</STRONG> <STRONG>assume_default_colors(int</STRONG> <STRONG>fg,</STRONG> <STRONG>int</STRONG> <STRONG>bg);</STRONG>
  54. </PRE>
  55. <H2>DESCRIPTION</H2><PRE>
  56. The <EM>use</EM><STRONG>_</STRONG><EM>default</EM><STRONG>_</STRONG><EM>colors()</EM> and <EM>assume</EM><STRONG>_</STRONG><EM>default</EM><STRONG>_</STRONG><EM>colors()</EM> func-
  57. tions are extensions to the curses library. They are used
  58. with terminals that support ISO 6429 color, or equivalent.
  59. These terminals allow the application to reset color to an
  60. unspecified default value (e.g., with SGR 39 or SGR 49).
  61. Applications that paint a colored background over the
  62. whole screen do not take advantage of SGR 39 and SGR 49.
  63. Some applications are designed to work with the default
  64. background, using colors only for text. For example,
  65. there are several implementations of the <STRONG>ls</STRONG> program which
  66. use colors to denote different file types or permissions.
  67. These "color ls" programs do not necessarily modify the
  68. background color, typically using only the <EM>setaf</EM> terminfo
  69. capability to set the foreground color. Full-screen
  70. applications that use default colors can achieve similar
  71. visual effects.
  72. The first function, <EM>use</EM><STRONG>_</STRONG><EM>default</EM><STRONG>_</STRONG><EM>colors()</EM> tells the curses
  73. library to assign terminal default foreground/background
  74. colors to color number -1. So init_pair(x,COLOR_RED,-1)
  75. will initialize pair x as red on default background and
  76. init_pair(x,-1,COLOR_BLUE) will initialize pair x as
  77. default foreground on blue.
  78. The other, <EM>assume</EM><STRONG>_</STRONG><EM>default</EM><STRONG>_</STRONG><EM>colors()</EM> is a refinement which
  79. tells which colors to paint for color pair 0. This func-
  80. tion recognizes a special color number -1, which denotes
  81. the default terminal color.
  82. The following are equivalent:
  83. <EM>use</EM><STRONG>_</STRONG><EM>default</EM><STRONG>_</STRONG><EM>colors();</EM>
  84. <EM>assume</EM><STRONG>_</STRONG><EM>default</EM><STRONG>_</STRONG><EM>colors(-1,-1);</EM>
  85. These are ncurses extensions. For other curses implemen-
  86. tations, color number -1 does not mean anything, just as
  87. for ncurses before a successful call of <EM>use</EM><STRONG>_</STRONG><EM>default</EM><STRONG>_</STRONG><EM>col-</EM>
  88. <EM>ors()</EM> or <EM>assume</EM><STRONG>_</STRONG><EM>default</EM><STRONG>_</STRONG><EM>colors()</EM>.
  89. Other curses implementations do not allow an application
  90. to modify color pair 0. They assume that the background
  91. is COLOR_BLACK, but do not ensure that the color pair 0 is
  92. painted to match the assumption. If your application does
  93. not use either <EM>use</EM><STRONG>_</STRONG><EM>default</EM><STRONG>_</STRONG><EM>colors()</EM> or <EM>assume</EM><STRONG>_</STRONG><EM>default</EM><STRONG>_</STRONG><EM>col-</EM>
  94. <EM>ors()</EM> ncurses will paint a white foreground (text) with
  95. black background for color pair 0.
  96. </PRE>
  97. <H2>RETURN VALUE</H2><PRE>
  98. These functions return the integer <STRONG>ERR</STRONG> upon failure and <STRONG>OK</STRONG>
  99. on success. They will fail if either the terminal does
  100. not support the <EM>orig</EM><STRONG>_</STRONG><EM>pair</EM> or <EM>orig</EM><STRONG>_</STRONG><EM>colors</EM> capability. If
  101. the <EM>initialize</EM><STRONG>_</STRONG><EM>pair</EM> capability is found, this causes an
  102. error as well.
  103. </PRE>
  104. <H2>NOTES</H2><PRE>
  105. Associated with this extension, the <STRONG>init_pair</STRONG> function
  106. accepts negative arguments to specify default foreground
  107. or background colors.
  108. The <EM>use</EM><STRONG>_</STRONG><EM>default</EM><STRONG>_</STRONG><EM>colors()</EM> function was added to support
  109. <EM>ded</EM>. This is a full-screen application which uses curses
  110. to manage only part of the screen. The bottom portion of
  111. the screen, which is of adjustable size, is left uncolored
  112. to display the results from shell commands. The top por-
  113. tion of the screen colors filenames using a scheme like
  114. the "color ls" programs. Attempting to manage the back-
  115. ground color of the screen for this application would give
  116. unsatisfactory results for a variety of reasons. This
  117. extension was devised after noting that color xterm (and
  118. similar programs) provides a background color which does
  119. not necessarily correspond to any of the ANSI colors.
  120. While a special terminfo entry could be constructed using
  121. nine colors, there was no mechanism provided within curses
  122. to account for the related <EM>orig</EM><STRONG>_</STRONG><EM>pair</EM> and <EM>back</EM><STRONG>_</STRONG><EM>color</EM><STRONG>_</STRONG><EM>erase</EM>
  123. capabilities.
  124. The <EM>assume</EM><STRONG>_</STRONG><EM>default</EM><STRONG>_</STRONG><EM>colors()</EM> function was added to solve a
  125. different problem: support for applications which would
  126. use environment variables and other configuration to
  127. bypass curses' notion of the terminal's default colors,
  128. setting specific values.
  129. </PRE>
  130. <H2>PORTABILITY</H2><PRE>
  131. These routines are specific to ncurses. They were not
  132. supported on Version 7, BSD or System V implementations.
  133. It is recommended that any code depending on them be con-
  134. ditioned using NCURSES_VERSION.
  135. </PRE>
  136. <H2>SEE ALSO</H2><PRE>
  137. <STRONG><A HREF="curs_color.3x.html">curs_color(3x)</A></STRONG>, <STRONG><A HREF="ded.1.html">ded(1)</A></STRONG>.
  138. </PRE>
  139. <H2>AUTHOR</H2><PRE>
  140. Thomas Dickey (from an analysis of the requirements for
  141. color xterm for XFree86 3.1.2C, February 1996).
  142. <STRONG><A HREF="default_colors.3x.html">default_colors(3x)</A></STRONG>
  143. </PRE>
  144. <HR>
  145. <ADDRESS>
  146. Man(1) output converted with
  147. <a href="http://www.oac.uci.edu/indiv/ehood/man2html.html">man2html</a>
  148. </ADDRESS>
  149. </BODY>
  150. </HTML>