home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / ansicd.zip / ansicode.cmd < prev    next >
OS/2 REXX Batch file  |  1994-12-30  |  4KB  |  134 lines

  1. /* rexx */
  2.  
  3. /*
  4. A:*
  5. Set of routines to control the cursor with Ansi escape sequences.     :*
  6. For a quick index, Grep -i "^[A-z]" <this_file> | grep ":" | grep "\*"
  7. A:*
  8. */
  9. /* since this file was [accidentally?] launched, display index */
  10. Call Cls
  11. Call Locate 5,1
  12. Say "This is a file of Rexx Procedures to control display I/O with"
  13. Call CsrAttrib "High"
  14. Call Charout ,"ANSII"
  15. Call Csrattrib "Normal"
  16. Say " codes."
  17. Say " "
  18. Call Charout ,"If you have the "
  19. Call Color "RED"
  20. Call Charout ,"EGREP"
  21. Call Color "White"
  22. Say " program, this will display a quick index of it's "
  23. Say "procedures."
  24. Say " "
  25. Call Charout ,"I can be reached at: "
  26. Call Csrattrib "Reverse"
  27. Say "jhoglund@cscns.com"
  28. Call Csrattrib "Normal"
  29. Call Charout ,"Or through compuserve:"
  30. Call Csrattrib "Reverse"
  31. Call Charout ,"70244,3234"
  32. Call Csrattrib "Normal"
  33. Call Charout ,"  If you have any questions"
  34.  
  35. Say ""
  36. Say ""
  37. Say "Jamie Hoglund"
  38. Say ""
  39. Say "Press 'Y' if you have the egrep program, and wish to view an index"
  40. Pull Q
  41. If Q = "Y" then do
  42. PARSE SOURCE J1 J2 FIL Garbage
  43. Say "File: "Fil
  44. '@EGrep -i "^[A-z]" 'FIL' | Egrep ":" | Egrep "\*" | more '
  45. end
  46. Exit
  47.  
  48. /* ---------------- Cut Here -------------------------*/
  49. /* Ansi Procedures for moving the cursor */
  50. Locate: Procedure   /*  Call Locate Row,Col */
  51. Row = arg(1)
  52. Col = Arg(2)
  53. Rc = Charout(,D2C(27)"["Row";"col"H")
  54. return ""
  55.  
  56. CsrUp: Procedure  /* CsrUp(Rows) */
  57. Arg u
  58. Rc = Charout(,D2C(27)"["u"A")
  59. return ""
  60.  
  61. CsrDown: Procedure /* CsrDn(Rows) */
  62. Arg d
  63. Rc = Charout(,D2C(27)"["d"B")
  64. return ""
  65.  
  66. CsrRight: Procedure  /* CsrRight(Cols) */
  67. arg r
  68. Rc = Charout(,D2C(27)"["r"C")
  69. Return ""
  70.  
  71. CsrLeft: procedure  /* CsrLeft(Cols) */
  72. arg l
  73. Rc = Charout(,D2C(27)"["l"D")
  74. Return ""
  75.  
  76.  
  77. /*
  78. A------------------------------------------------------------:*
  79. SaveCsr and PutCsr are meant to be used together for saving  :*
  80. and restoring the cursor location. Do not confuse            :*
  81. with Locate, CsrRow, CsrCol, these are different routines.   :*
  82. SaveCsr Returns a string that PutCsr can use.                :*
  83. A:*/
  84. SaveCsr: procedure  /* cursor_location = SaveCsr() (for PutCsr(x))*/
  85. Rc = Charout(,D2C(27)"[6n")
  86. Pull Q
  87. Call CsrUp
  88. return Q
  89.  
  90. PutCsr: procedure  /* Call PutCsr <Previous_Location>  (From SaveCsr() ) */
  91. Where = arg(1)
  92. Rc = Charout(,substr(Where,1,7)"H")
  93. return ""
  94. /*
  95. A:*/
  96. /* clear screen :*/
  97. Cls: Procedure      /* cls() Call Cls */
  98. Rc = CharOut(,D2C(27)"[2J")
  99. return ""
  100.  
  101.     /* get cursors Line */
  102. CsrRow: Procedure      /* Row = CsrRow()*/
  103. Rc = Charout(,D2C(27)"[6n")
  104. Pull Q
  105. Return substr(Q,3,2)
  106.  
  107.    /* get cursors column */    
  108. CsrCol: Procedure          /*  Col = CsrCol()  */
  109. Rc = Charout(,D2C(27)"[6n")
  110. Pull Q
  111. return Substr(Q,6,2)
  112.  
  113. /* procedure to color screen 
  114. A:--------------------------------------------------------------*
  115. accepts colors: BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE  *
  116. */
  117. Color: Procedure /* Call Color <ForeGround>,<BackGround> */
  118. arg F,B
  119. Colors = "BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE"  
  120. return CHAROUT(,D2C(27)"["WORDPOS(F,COLORS)+29";"WORDPOS(B,COLORS)+39";m")
  121.  
  122. /*  change screen attributes
  123. A:---------------------------------------------------------------*
  124. attributes: NORMAL HIGH LOW ITALIC UNDERLINE BLINK RAPID REVERSE *
  125. */
  126. CsrAttrib: Procedure  /* call CsrAttrib <Attrib> */
  127. Arg A
  128. attr = "NORMAL HIGH LOW ITALIC UNDERLINE BLINK RAPID REVERSE"
  129. return CHAROUT(,D2C(27)"["WORDPOS(A,ATTR) - 1";m")
  130.  
  131. EndAll:
  132. Call Color "White","Black"
  133. CALL CsrAttrib "Normal"
  134.