home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / CLIB1.ZIP / COLOR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  4.3 KB  |  156 lines

  1. /*------------------------------------------------------------------------
  2.  * filename - color.c
  3.  *
  4.  * function(s)
  5.  *        textcolor      - selects new character color in text mode
  6.  *        textbackground - selects new text background color
  7.  *        textattr       - sets text attributes
  8.  *        highvideo      - selects high intensity text characters
  9.  *        lowvideo       - selects low intensity text characters
  10.  *        normvideo      - selects normal intensity text characters
  11.  *-----------------------------------------------------------------------*/
  12.  
  13. /*[]------------------------------------------------------------[]*/
  14. /*|                                                              |*/
  15. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  16. /*|                                                              |*/
  17. /*|                                                              |*/
  18. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  19. /*|     All Rights Reserved.                                     |*/
  20. /*|                                                              |*/
  21. /*[]------------------------------------------------------------[]*/
  22.  
  23.  
  24. #include <_video.h>
  25. #include <conio.h>
  26.  
  27. #define INTENSE 0x08
  28.  
  29.  
  30. /*------------------------------------------------------------------------*
  31.  
  32. Name            textcolor - selects new character color in text mode
  33.  
  34. Usage           void textcolor(int newcolor);
  35.  
  36. Prototype in  conio.h
  37.  
  38. Description selects the foreground character color.
  39.  
  40. Return value  None
  41.  
  42. *--------------------------------------------------------------------------*/
  43. void textcolor(int newcolor)
  44. {
  45.   _video.attribute = (_video.attribute & 0x70) | (newcolor & 0x8F);
  46. }
  47.  
  48.  
  49.  
  50. /*------------------------------------------------------------------------*
  51.  
  52. Name            textbackground - selects new text background color
  53.  
  54. Usage           void textbackground(int newcolor);
  55.  
  56. Prototype in  conio.h
  57.  
  58. Description textbackground selects the background text color.
  59.  
  60. Return value  None
  61.  
  62. *--------------------------------------------------------------------------*/
  63. void textbackground(int newcolor)
  64. {
  65.   _video.attribute = (_video.attribute & 0x8F) | ((newcolor<<4) & 0x7f);
  66. }
  67.  
  68.  
  69.  
  70. /*------------------------------------------------------------------------*
  71.  
  72. Name            textattr - sets text attributes
  73.  
  74. Usage           void textattr(int newattr);
  75.  
  76. Prototype in  conio.h
  77.  
  78. Description lets you set both the foreground and background
  79.                 colors in a single call.
  80.  
  81. Return value  None
  82.  
  83. *--------------------------------------------------------------------------*/
  84.  
  85. void textattr(int newattr)
  86. {
  87.   _video.attribute = newattr;
  88. }
  89.  
  90.  
  91.  
  92. /*------------------------------------------------------------------------*
  93.  
  94. Name            highvideo - selects high intensity text characters
  95.  
  96. Usage           void highvideo(void);
  97.  
  98. Prototype in  conio.h
  99.  
  100. Description selects high intensity characters by setting
  101.                 the high intensity bit of the currently selected
  102.     foreground color.
  103.  
  104. Return value  None
  105.  
  106. *--------------------------------------------------------------------------*/
  107. void highvideo(void)
  108. {
  109.   _video.attribute |= INTENSE;
  110. }
  111.  
  112.  
  113.  
  114. /*------------------------------------------------------------------------*
  115.  
  116. Name            lowvideo - selects low intensity text characters
  117.  
  118. Usage           void lowvideo(void);
  119.  
  120. Prototype in  conio.h
  121.  
  122. Description     selects low intensity characters by clearing the
  123.                 high intensity bit of the currently selected
  124.     foreground color.
  125.  
  126.  
  127. Return value  None
  128.  
  129. *--------------------------------------------------------------------------*/
  130. void lowvideo(void)
  131. {
  132.   _video.attribute &= ~INTENSE;
  133. }
  134.  
  135.  
  136.  
  137. /*------------------------------------------------------------------------*
  138.  
  139. Name            normvideo - selects normal intensity text characters
  140.  
  141. Usage           void normvideo(void);
  142.  
  143. Prototype in  conio.h
  144.  
  145. Description selects normal characters by returning the text attribute
  146.                 (foreground and background) to the value it had when the
  147.     program started.
  148.  
  149. Return value  None
  150.  
  151. *--------------------------------------------------------------------------*/
  152. void normvideo(void)
  153. {
  154.   _video.attribute = _video.normattr;
  155. }
  156.