home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / comm / tm211_1.zip / TOOLBOX1.SCR < prev    next >
Text File  |  1990-05-25  |  10KB  |  331 lines

  1. ;
  2. ; TOOLBOX1.SCR (c) Copyright 1990 by Tsung Hu.  All right reserved.
  3. ; Date written: 10 May 1990
  4. ;
  5. ;
  6. ; This toolbox defines video color, ANSI color code and a set of
  7. ; video procedures which output to local screen and/or remote
  8. ; system.
  9. ;
  10. ; To use this toolbox, you should add the line
  11. ;    #include "toolbox1.scr"
  12. ; at the beginning of your script file.  This will increase the file
  13. ; size of the compiled script file .TMS by about 4K.  To minimum the
  14. ; overhead, you should cut and paste the procedures that you used into
  15. ; your script file.  For example, the <EchoBox> and <EchoBlock>
  16. ; procedures may be excluded.
  17. ;
  18. ; The <EchoToLocol> and <EchoToRemote> variables tell the Echo
  19. ; procedures where the output is to be sent.  If <EchoToLocal>
  20. ; is TRUE, the output is sent to the local screen.  If <EchoToRemote>
  21. ; is TRUE, the output is sent to the remote system.  These variable
  22. ; can both be TRUE.
  23. ;
  24. ; The BLACK, BLUE, GREEN, CYAN, RED, YELLOW and WHITE contains the
  25. ; color value used by IBM PC.  This order is not the same as that
  26. ; of ANSI.  The ANSI color codes with FG prefix denote the foreground
  27. ; color codes while the BK prefix denote the background ones.
  28. ;
  29. ; Summary:
  30. ;
  31. ;   Echo s            ; output <s> to local screen and/or remote system
  32. ;   EchoInt i         ; output integer <i>
  33. ;   EchoColor color   ; set foreground color
  34. ;   EchoBkColor color ; set background color
  35. ;   EchoNormal        ; normal attribute, white on black
  36. ;   EchoHiLite        ; set high intensity
  37. ;   EchoBlink         ; set blink attribute
  38. ;   EchoReverse       ; set reverse attribute
  39. ;   EchoClearScreen   ; clear screen
  40. ;   EchoGotoXY x,y    ; position cursor to (x,y)
  41. ;   EchoBox   left,top,right,bottom,style,hollow   ; draw a box
  42. ;   EchoBlock left,top,right,bottom,style,fillchar ; draw a block
  43. ;
  44. ;
  45.  
  46. integer EchoToLocal,EchoToRemote
  47.  
  48. integer BLACK,BLUE,GREEN,CYAN,RED,YELLOW,WHITE
  49. string  FGBLACK,FGBLUE,FGGREEN,FGCYAN,FGRED,FGYELLOW,FGWHITE
  50. string  BKBLACK,BKBLUE,BKGREEN,BKCYAN,BKRED,BKYELLOW,BKWHITE
  51.  
  52. EchoToLocal = 1               ; TRUE to print string to local screen
  53. EchoToRemote = 1              ; TRUE to send string to remote system
  54.  
  55. BLACK   = 0                   ; define color number in IBM PC order
  56. BLUE    = 1
  57. GREEN   = 2
  58. RED     = 3
  59. CYAN    = 4
  60. MAGENTA = 5
  61. YELLOW  = 6
  62. WHITE   = 7
  63.  
  64. FGBLACK   = "^[[30m"          ; define foreground color code in ANSI order
  65. FGRED     = "^[[31m"
  66. FGGREEN   = "^[[32m"
  67. FGYELLOW  = "^[[33m"
  68. FGBLUE    = "^[[34m"
  69. FGMAGENTA = "^[[35m"
  70. FGCYAN    = "^[[36m"
  71. FGWHITE   = "^[[37m"
  72.  
  73. BKBLACK   = "^[[40m"          ; define background color code in ANSI order
  74. BKRED     = "^[[41m"
  75. BKGREEN   = "^[[42m"
  76. BKYELLOW  = "^[[43m"
  77. BKBLUE    = "^[[44m"
  78. BKMAGENTA = "^[[45m"
  79. BKCYAN    = "^[[46m"
  80. BKWHITE   = "^[[47m"
  81.  
  82.  
  83. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  84. ;
  85. ; Echo s
  86. ; function:  print the string <s> to local screen if <EchoToLocal> is TRUE
  87. ;            and send <s> to remote system if <EchoToRemote> is TRUE
  88. ;
  89. Procedure Echo string s
  90. if EchoToLocal
  91.    print s,                   ; print to local screen
  92. endif
  93. if EchoToRemote
  94.    put s,                     ; put to remote system
  95. endif
  96. EndProc
  97.  
  98.  
  99. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  100. ;
  101. ; EchoInt i
  102. ; funcdtion: print the integer <i> to local screen if <EchoToLocal> is TRUE
  103. ;            and send <i> to remote system if <EchoToRemote> is TRUE
  104. ;
  105. Procedure EchoInt integer i
  106. if EchoToLocal
  107.    print i,                   ; print to local screen
  108. endif
  109. if EchoToRemote
  110.    put i,                     ; put to remote system
  111. endif
  112. EndProc
  113.  
  114.  
  115. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  116. ;
  117. ; EchoColor color
  118. ; function: set foreground color
  119. ;
  120. Procedure EchoColor integer color
  121. string code
  122. Switch color
  123.    case 0: code = FGBLACK     ; ANSI code <esc>[3<x>m
  124.    case 1: code = FGBLUE
  125.    case 2: code = FGGREEN     ; Note: IBM PC attribute is not
  126.    case 3: code = FGRED       ;  in the same order of the ANSI
  127.    case 4: code = FGCYAN      ;  color code.
  128.    case 5: code = FGMAGENTA
  129.    case 6: code = FGYELLOW
  130.    otherwise:
  131.            code = FGWHITE
  132. EndSwitch
  133. Echo code
  134. EndProc
  135.  
  136.  
  137. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  138. ;
  139. ; EchoBkColor bkcolor
  140. ; function: set background color
  141. ;
  142. Procedure EchoBkColor integer bkcolor
  143. string code
  144. Switch bkcolor
  145.    case 1: code = BKBLUE      ; ANSI code <esc>[4<x>m
  146.    case 2: code = BKGREEN
  147.    case 3: code = BKRED
  148.    case 4: code = BKCYAN
  149.    case 5: code = BKMAGENTA
  150.    case 6: code = BKYELLOW
  151.    case 7: code = BKWHITE
  152.    otherwise:
  153.            code = BKBLACK
  154. EndSwitch
  155. Echo code
  156. EndProc
  157.  
  158.  
  159. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  160. ;
  161. ; EchoNormal
  162. ; function: set normal intensity and reset color to white on black
  163. ; remark:   to turn off high intensity only, you must use three
  164. ;           statements, where <foreground> and <background> are
  165. ;           foreground and background colors, because there is
  166. ;           no ANSI code to turn off high intensity.
  167. ;       EchoNomal
  168. ;       EchoColor   foreground
  169. ;       EchoBkColor background
  170. ;
  171. Procedure EchoNormal
  172. Echo "^[[0m"                  ; ANSI code <esc>[0m
  173. EndProc
  174.  
  175.  
  176. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  177. ;
  178. ; EchoHiLite
  179. ; function: set high intensity
  180. ;
  181. Procedure EchoHiLite
  182. Echo "^[[1m"                  ; ANSI code <esc>[1m
  183. EndProc
  184.  
  185.  
  186. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  187. ;
  188. ; EchoBlink
  189. ; function: set blink attribute
  190. ;
  191. Procedure EchoBlink
  192. Echo "^[[5m"                  ; ANSI code <esc>[5m
  193. EndProc
  194.  
  195.  
  196. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  197. ;
  198. ; EchoReverse
  199. ; function: set reverse attribute
  200. ;
  201. Procedure EchoReverse
  202. Echo "^[[7m"                  ; ANSI code <esc>[7m
  203. EndProc
  204.  
  205.  
  206. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  207. ;
  208. ; EchoClearScreen
  209. ; function: clear screen and home cursor
  210. ;
  211. Procedure EchoClearScreen
  212. Echo "^[[2J"                  ; ANSI code <esc>[2J
  213. EndProc
  214.  
  215.  
  216. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  217. ;
  218. ; EchoGotoXY column,row
  219. ; function: set cursor position
  220. ; remark:   top-left corner is (0,0)
  221. ;
  222. Procedure EchoGotoXY integer column,row
  223. string code,subcode
  224. code = "^[["                  ; ANSI code <esc>[<row+1>;<column+1>H
  225. itoa row+1,subcode
  226. concat code,subcode           ; Note: internal commands are used
  227. concat code,";"               ;  to preventint call the procedures
  228. itoa column+1,subcode         ;  Echo and EchoInt many times.  This
  229. concat code,subcode           ;  will speed up the process.
  230. concat code,"H"
  231. Echo code
  232. EndProc
  233.  
  234.  
  235. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  236. ;
  237. ; EchoBox left,top,right,bottom,style,fillchar,hollow
  238. ; function: draw a box
  239. ; remark:   top-left corner is (0,0)
  240. ;           <style> selects the border
  241. ;               0   spaces
  242. ;               1   single lines
  243. ;               2   double lines
  244. ;               3   single vertical lines, double horizontal lines
  245. ;               4   double vertical lines, single horizontal lines
  246. ;               5   user-define fill character <fillchar>
  247. ;           if <hollow> is TRUE, the inside of the box is cleared
  248. ;
  249. Procedure EchoBox integer left,top,right,bottom,style,string fillchar,integer hollow
  250. string border,ch,line,space
  251. integer row
  252. EchoGotoXY left,top
  253. Switch style                  ; define border
  254.    case 1: border = "┌─┐│└┘"  ; single lines
  255.    case 2: border = "╔═╗║╚╝"  ; double lines
  256.    case 3: border = "╒═╕│╘╛"  ; single vertical lines, double horizontal lines
  257.    case 4: border = "╓─╖║╙╜"  ; double vertical lines, single horizontal lines
  258.    case 5: strset border,fillchar,1,6 ; user-defined fill character
  259.    otherwise:
  260.            border = "      "  ; space
  261. EndSwitch
  262. substr border,1,1,ch          ; top-left corner
  263. Echo ch
  264. substr border,2,1,ch          ; top border
  265. strset line,ch,1,right-left-1
  266. Echo line
  267. substr border,3,1,ch          ; top-right corner
  268. Echo ch
  269. if hollow                     ; clear inside of the box if <hollow> is non-zero
  270.    strset space," ",1,right-left-1
  271. endif
  272. substr border,4,1,ch          ; vertical border
  273. row = top+1
  274. While row<=bottom-1
  275.    EchoGotoXY left,row        ; goto left border
  276.    Echo ch                    ; vertical border
  277.    if hollow
  278.       Echo space              ; fill inside of border
  279.    elseif right<>left+1
  280.       EchoGotoXY right,row    ; goto right border
  281.    endif
  282.    Echo ch                    ; vertical border
  283.    row = row+1
  284. EndWhile
  285. EchoGotoXY left,bottom
  286. substr border,5,1,ch          ; bottom-left corner
  287. Echo ch
  288. Echo line                     ; bottom border
  289. substr border,6,1,ch
  290. Echo ch                       ; bottom-right corner
  291. EndProc
  292.  
  293.  
  294. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  295. ;
  296. ; EchoBlock left,top,right,bottom,style,fillchar
  297. ; function: draw a block of character
  298. ; remark:   top-left corner is (0,0)
  299. ;           <style> selects the type of the block
  300. ;               0   space                  ' '
  301. ;               1   widely spaced block    '░'
  302. ;               2   spaced block           '▒'
  303. ;               3   closely spaced block   '▓'
  304. ;               4   solid block            '█'
  305. ;               5   user-defined fill character <fillchar>
  306. ;
  307. Procedure EchoBlock integer left,top,right,bottom,style,string fillchar
  308. string ch,line
  309. integer row
  310. EchoGotoXY left,top
  311. Switch style
  312.    case 1: ch = "░"           ; widely spaced block
  313.    case 2: ch = "▒"           ; spaced block
  314.    case 3: ch = "▓"           ; closely spaced block
  315.    case 4: ch = "█"           ; solid block
  316.    case 5: ch = fillchar      ; user-defined fill character
  317.    otherwise:
  318.            ch = " "           ; space
  319. EndSwitch
  320. strset line,ch,1,right-left+1 ; set line to selected fill char
  321. row = top
  322. While row<=bottom
  323.    EchoGotoXY left,row
  324.    Echo line                  ; one line at a time
  325.    row = row+1
  326. EndWhile
  327. EndProc
  328.  
  329. 
  330.  
  331.