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