home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxdecode.zip / ScrColor.cmd < prev    next >
OS/2 REXX Batch file  |  1993-09-20  |  10KB  |  224 lines

  1. /*
  2. program: ScrColor.cmd
  3. type:    REXXSAA-OS/2
  4. purpose: set default ANSI screen colors and allow REXX-programs to query them
  5.          (used e.g. by SHOWINI, CRONRGF, ATRGF)
  6. version: 1.0
  7. date:    1993-09-20
  8. author:  Rony G. Flatscher,
  9.          Wirtschaftsuniversität/Vienna
  10.          RONY@AWIWUW11.BITNET
  11.          Rony.Flatscher@wu-wien.ac.at
  12.  
  13. usage:   ScrColor [some string]
  14.          - if called from the command line the default background and 
  15.            foreground colors are set, additionally all defined colors
  16.            are shown; if any argument is given on the command line, the
  17.            ANSI-escape-sequences are shown in addition;
  18.  
  19.            e.g. add to your OS/2-CMD-WPS-objects the parameter: "/K ScrColor.CMD" 
  20.            or change systemwide (change CONFIG.SYS):
  21.  
  22.                SET OS2_SHELL=C:\OS2\CMD.EXE /K SCRCOLOR.CMD
  23.  
  24.          - if called as a function, the entire set of defined colors is
  25.            returned in a parsable string
  26.  
  27. All rights reserved, copyrighted 1993 no guarantee that it works without
  28. errors, etc. etc.
  29.  
  30. donated to the public domain granted that you are not charging anything
  31. (money etc.) for it and derivates based upon it, as you did not write it,
  32. etc. if that holds you may bundle it with commercial programs too
  33.  
  34. Please, if you find an error, post me a message describing it, I will
  35. try to fix and rerelease it to the net.
  36.  
  37. **************
  38.  
  39. An excerpt from ANSI-escape-sequences as explained in:
  40.  
  41.  OS/2 Frequently Asked Questions List 
  42.  User's Edition 
  43.  Release 2.1C
  44.  August 28, 1993 
  45.  Compiled by Timothy F. Sipples 
  46.  
  47. For changes, suggestions, or additions please mail 
  48. sip1@kimbark.uchicago.edu or write:
  49.  
  50.   ESC[#;#;....;#m               Set display attributes where # is 
  51.                                 0 for normal display 
  52.                                 1 bold on 
  53.                                 4 underline (mono only) 
  54.                                 5 blink on 
  55.                                 7 reverse video on 
  56.                                 8 nondisplayed (invisible) 
  57.                                 30 black foreground 
  58.                                 31 red foreground 
  59.                                 32 green foreground 
  60.                                 33 yellow foreground 
  61.                                 34 blue foreground 
  62.                                 35 magenta foreground 
  63.                                 36 cyan foreground 
  64.                                 37 white foreground 
  65.                                 40 black background 
  66.                                 41 red background 
  67.                                 42 green background 
  68.                                 43 yellow background 
  69.                                 44 blue background 
  70.                                 45 magenta background 
  71.                                 46 cyan background 
  72.                                 47 white background 
  73.  
  74. remark: one can set a list of screen-attributes; if so, they need to be
  75.         delmited by a semi-colon (;); after the last sequence a little "m"
  76.         has to be attached to tell ANSI.SYS that colors are meant
  77. */
  78.  
  79. ESC    = '1B'x || "["   /* define ANSI-ESCape character */
  80.  
  81. /* ANSI-values for colors */
  82.  
  83. black   = 0
  84. red     = 1
  85. green   = 2
  86. yellow  = 3
  87. blue    = 4
  88. magenta = 5
  89. cyan    = 6
  90. white   = 7
  91.  
  92. /* ANSI-values for fore-/background */
  93. foreground = 30         /* add color, e.g. 30 + 2 = 32 ==> green foreground */
  94. background = 40         /* add color, e.g. 40 + 7 = 47 ==> white background */
  95.  
  96. /* additional ANSI-values which work on VGA */
  97. normal    = 0           /* reset screen to white on black */
  98. bold      = 1
  99. /************************** end of ANSI-information **************************/
  100.  
  101.  
  102.  
  103. /*******************************************************/
  104. /* default settings for WHITE TEXT on BLACK BACKGROUND */
  105. /*******************************************************/
  106.  
  107. screen_normal  = normal || ";" || foreground + white  || ";" || background + black
  108. screen_inverse = normal || ";" || foreground + black  || ";" || background + white
  109. text_normal    = screen_normal
  110. text_info      = screen_normal || ";" ||                foreground + cyan
  111. text_highlight = screen_normal || ";" ||                foreground + yellow
  112. text_alarm     = screen_normal || ";" || bold || ";" || foreground + red
  113. /* inverse colors */
  114. text_normal_inverse    = screen_inverse
  115. text_info_inverse      = screen_inverse || ";" ||                foreground + cyan
  116. text_highlight_inverse = screen_inverse || ";" ||                foreground + green
  117. text_alarm_inverse     = screen_inverse || ";" || bold || ";" || foreground + red
  118. /*******************************************************/
  119.  
  120.  
  121.  
  122. /*******************************************************/
  123. /* default settings for BLACK TEXT on WHITE BACKGROUND */
  124. /*******************************************************/
  125.  
  126. screen_normal  = normal || ";" || foreground + black  || ";" || background + white
  127. screen_inverse = normal || ";" || foreground + white  || ";" || background + black
  128. text_normal    = screen_normal
  129. text_info      = screen_normal || ";" || bold || ";" || foreground + blue
  130. text_highlight = screen_normal || ";" ||                foreground + green
  131. text_alarm     = screen_normal || ";" || bold || ";" || foreground + red
  132. /* inverse colors */
  133. text_normal_inverse    = screen_inverse
  134. text_info_inverse      = screen_inverse || ";" || bold || ";" || foreground + green
  135. text_highlight_inverse = screen_inverse || ";" || bold || ";" || foreground + cyan
  136. text_alarm_inverse     = screen_inverse || ";" || bold || ";" || foreground + red
  137. /*******************************************************/
  138.  
  139.  
  140.  
  141.  
  142. /*                        CHANGE COLORS FROM HERE                            */
  143. /*                                                                           */
  144. /*                  ||||||||||||||||||||||||||||||||||||                     */
  145. /*                  VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV                     */
  146.  
  147. /****************** change according to your preferences *********************/
  148. /* attention: the following settings take effect !                           */
  149. /*            just copy the default you wish and change the colors           */
  150. /*****************************************************************************/
  151.  
  152. /*******************************************************/
  153. /* default settings for WHITE TEXT on BLACK BACKGROUND */
  154. /*******************************************************/
  155.  
  156. screen_normal  = normal || ";" || foreground + white  || ";" || background + black  
  157. screen_inverse = normal || ";" || foreground + black  || ";" || background + white  
  158. text_normal    = screen_normal
  159. text_info      = screen_normal || ";" ||                foreground + cyan
  160. text_highlight = screen_normal || ";" ||                foreground + yellow
  161. text_alarm     = screen_normal || ";" || bold || ";" || foreground + red
  162. /* inverse colors */
  163. text_normal_inverse    = screen_inverse 
  164. text_info_inverse      = screen_inverse || ";" ||                foreground + cyan
  165. text_highlight_inverse = screen_inverse || ";" ||                foreground + green
  166. text_alarm_inverse     = screen_inverse || ";" || bold || ";" || foreground + red   
  167. /*******************************************************/
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175. /*******************************************************************************/
  176. /* add ESCape to begin and "m" to the end to complete the ANSI-Escape-sequence */
  177. screen_normal      = ESC || screen_normal       || "m"
  178. screen_inverse     = ESC || screen_inverse      || "m"
  179. text_normal        = ESC || text_normal         || "m"
  180. text_info          = ESC || text_info           || "m"
  181. text_highlight     = ESC || text_highlight      || "m"
  182. text_alarm         = ESC || text_alarm          || "m"
  183. text_normal_inverse    = ESC || text_normal_inverse     || "m"
  184. text_info_inverse      = ESC || text_info_inverse       || "m"
  185. text_highlight_inverse = ESC || text_highlight_inverse  || "m"
  186. text_alarm_inverse     = ESC || text_alarm_inverse      || "m"
  187.  
  188. PARSE SOURCE . called_as .
  189.  
  190. IF called_as = "COMMAND" THEN           /* called from command-line ? */
  191. DO
  192.    CALL CHAROUT ,screen_normal          /* set screen */
  193.    "Cls"                                /* Clear Screen via OS/2's CMD.EXE */
  194.    IF ARG(1) <> "" THEN                 /* if argument given, then show escape sequences */
  195.    DO
  196.       SAY
  197.       CALL CHAROUT ,screen_normal          /* set screen */
  198.       SAY RIGHT("screen_normal <ESC", 40)  || SUBSTR(screen_normal, 2)  || ">"
  199.       CALL CHAROUT ,text_normal    
  200.       SAY RIGHT("text_normal <ESC", 40)    || SUBSTR(text_normal, 2)    || ">"
  201.       CALL CHAROUT ,text_info      
  202.       SAY RIGHT("text_info <ESC", 40)      || SUBSTR(text_info, 2)      || ">"
  203.       CALL CHAROUT ,text_highlight 
  204.       SAY RIGHT("text_highlight <ESC", 40) || SUBSTR(text_highlight, 2) || ">"
  205.       CALL CHAROUT ,text_alarm     
  206.       SAY RIGHT("text_alarm <ESC", 40)     || SUBSTR(text_alarm, 2)     || ">"
  207.       CALL CHAROUT ,screen_inverse 
  208.       SAY RIGHT("screen_inverse <ESC", 40) || SUBSTR(screen_inverse, 2) || ">"
  209.       CALL CHAROUT ,screen_normal
  210.  
  211.       CALL CHAROUT ,text_normal_inverse
  212.       SAY RIGHT("text_normal_inverse <ESC", 40) || SUBSTR(text_normal_inverse, 2) || ">"
  213.       CALL CHAROUT ,text_info_inverse
  214.       SAY RIGHT("text_info_inverse <ESC", 40) || SUBSTR(text_info_inverse, 2) || ">"
  215.       CALL CHAROUT ,text_highlight_inverse
  216.       SAY RIGHT("text_highlight_inverse <ESC", 40) || SUBSTR(text_highlight_inverse, 2) || ">"
  217.       CALL CHAROUT ,text_alarm_inverse
  218.       SAY RIGHT("text_alarm_inverse <ESC", 40) || SUBSTR(text_alarm_inverse, 2) || ">"
  219.    END
  220.    CALL CHAROUT ,screen_normal          /* set screen */
  221. END
  222. ELSE RETURN screen_normal screen_inverse text_normal text_info text_highlight text_alarm text_normal_inverse text_info_inverse text_highlight_inverse text_alarm_inverse     
  223.  
  224.