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