home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 197_01 / boxmac.cmd < prev    next >
OS/2 REXX Batch file  |  1979-12-31  |  12KB  |  590 lines

  1. ;    BOXMAC.CMD:    Standard Micro Startup Box drawing macroes
  2. ;            for MicroEMACS 3.9
  3. ;            (C)opyright 1987 by Suresh Konda and Daniel M Lawrence
  4. ;            Last Update: 07/12/87
  5.  
  6. write-message "[Loading Box Macroes]"
  7.  
  8. ;this macro inserts enough characters at the end of line to lineup with point
  9. store-procedure mvtopcol
  10. ;set $debug TRUE
  11.     end-of-line
  12.     set %temp &sub %pcol $curcol
  13.     !if &less $curcol %pcol
  14.     ;;    current position to left of point -- blank fill to point
  15.     ;    !if &gre %temp 0
  16.             %temp    insert-string " "
  17.     ;    !endif
  18.     !else
  19.         !if &less %temp 0
  20.             set %temp &neg %temp
  21.             %temp backward-character
  22.         !else
  23.             %temp forward-character
  24.         !endif
  25.     !endif
  26. !endm
  27. ;this macro inserts enough characters at the end of line to lineup with mark
  28. store-procedure mvtomcol
  29. ;set $debug TRUE
  30.     end-of-line
  31.     !if &less %mcol $curcol
  32.     ;;    current position to right of mark -- move to mark
  33. ;        insert-string &cat &cat %mcol " " $curcol
  34.         beginning-of-line
  35.         %mcol forward-character
  36.     !else
  37.     ;;      current position is to left of mark -- blank fill
  38.         set %temp &sub %mcol $curcol
  39.         !if &gre %temp 0
  40.             %temp insert-string " "
  41.         !endif
  42.     !endif
  43. !endm
  44.  
  45. store-procedure inschar
  46.     !if &equal %char 205
  47.         insert-string &chr %c1
  48.     !else
  49.         !if &equal %char 196
  50.             insert-string &chr %c2
  51.         !else
  52.             insert-string &chr %c3
  53.         !endif
  54.     !endif
  55. !endm
  56. store-procedure box2
  57. ;remember point
  58.     set %pcol &add $curcol 1
  59.     set %pline $curline
  60.     exchange-point-and-mark
  61. ;remember mark
  62. ;    set %mcol &add $curcol 1
  63.     set %mcol $curcol
  64.     set %mline $curline
  65. ;draw top horizontal line
  66.     insert-string "╔"
  67.     set %width &sub &sub %pcol %mcol 1
  68.     %width insert-string "═"
  69.      insert-string "╗"
  70.     newline-and-indent
  71. ;    insert-string " "
  72. ;draw bottom horizontal line
  73.     %pline goto-line
  74. ; we are now one line above old last line because of insertion of top line
  75.     next-line
  76.     end-of-line
  77.     newline
  78.     run mvtomcol
  79.     insert-string "╚"
  80.     %width insert-string "═"
  81.     insert-string "╝"
  82. ; bump pline 
  83. set %pline &add %pline 1
  84. ;draw verticals
  85.     %mline goto-line
  86. ;we are at top -- draw verticals
  87. *lp1
  88.     next-line
  89.     run mvtomcol
  90.     insert-string "║"
  91.     run mvtopcol
  92.     insert-string "║"
  93.     !if &less $curline %pline
  94.         !goto lp1
  95.     !endif
  96. ;return to point
  97.     %pline goto-line
  98.     next-line
  99.     beginning-of-line
  100.     %width forward-character
  101.     2 forward-character
  102. !endm
  103. store-procedure setpoints
  104. ;; procedure will set pcol, pline, mcol and mline
  105. set %pcol $curcol
  106. set %pline $curline
  107. exchange-point-and-mark
  108. set %mcol $curcol
  109. set %mline $curline
  110. exchange-point-and-mark
  111. !endm
  112.  
  113. ;; user procedure to draw a double line from mark to point making spaces for
  114. ;; the characters.
  115. store-procedure line2
  116. run setpoints
  117. !if &equal %pcol %mcol
  118.     run vert2
  119. !else
  120.     !if &equal %pline %mline
  121.         run hor2
  122.     !else
  123.         write-message "Illegal point and mark for lines"
  124.     !endif
  125. !endif
  126. !endm
  127.  
  128. ;; user procedure to draw line from mark to point making spaces for
  129. ;; the characters.
  130. store-procedure line1
  131. run setpoints
  132. !if &equal %pcol %mcol
  133.     run vert1
  134. !else
  135.     !if &equal %pline %mline
  136.         run hor1
  137.     !else
  138.         write-message "Illegal point and mark for lines"
  139.     !endif
  140. !endif
  141. !endm
  142.  
  143. store-procedure hor2
  144. ;; procedure to draw a double line from beginning of line to point
  145. ;; assume that the current line is to be double underlined.  pcol,mcol,pline,
  146. ;; mline already set by calling macro
  147. !if &equal %mcol %pcol
  148.     write-message "in hor equal cols"
  149.     !return
  150. !endif
  151. !if &less %pcol %mcol
  152. ;    then point was to left of mark.  exchange and reset variables
  153.     exchange-point-and-mark
  154.     run setpoints
  155. !endif
  156. end-of-line
  157. newline
  158. ;; move to under mark
  159. !if &greater %mcol 1
  160.     %mcol insert-string " "
  161. !endif
  162. ;; see if first char is a vertical line
  163. previous-line
  164. set %char  $curchar
  165. next-line
  166. !if &equ %char 186
  167.         insert-string "╠"
  168. !else
  169.     !if &equ %char 179 
  170.         insert-string "╞"
  171.     !else
  172.         insert-string "═"
  173.     !endif
  174. !endif
  175.  
  176. ; now for all chars but the last character i.e., char at point
  177. *lp1
  178.     previous-line
  179.     set %char  $curchar
  180.     next-line
  181.     !if &equ %char 186
  182.         insert-string "╬"
  183.         !else 
  184.         !if &equ %char 179
  185.             insert-string "╪"
  186.         !else
  187.             insert-string "═"
  188.         !endif
  189.     !endif
  190.     !if &less $curcol %pcol
  191.         !goto lp1
  192.     !endif
  193. ;; see if last char is a vertical line
  194. previous-line
  195. set %char  $curchar
  196. next-line
  197. !if &equ %char 186
  198.         insert-string "╣"
  199. !else
  200.     !if &equ %char 179 
  201.         insert-string "╡"
  202.     !else
  203.         insert-string "═"
  204.     !endif
  205. !endif
  206. !endm
  207.  
  208. store-procedure hor1
  209. ;; procedure to draw a single line from beginning of line to point
  210. !if &equal %mcol %pcol
  211.     write-message "in hor equal cols"
  212.     !return
  213. !endif
  214. !if &less %pcol %mcol
  215. ;    then point was to left of mark.  exchange and reset variables
  216.     exchange-point-and-mark
  217.     run setpoints
  218. !endif
  219. end-of-line
  220. newline
  221. ;; move to under mark
  222. !if &greater %mcol 1
  223.     %mcol insert-string " "
  224. !endif
  225. ;; see if first char is a vertical line
  226. previous-line
  227. set %char  $curchar
  228. next-line
  229. !if &equ %char 186
  230.         insert-string "╟"
  231. !else
  232.     !if &equ %char 179 
  233.         insert-string "├"
  234.     !else
  235.         insert-string "─"
  236.     !endif
  237. !endif
  238.  
  239. ; now for all chars but the last character i.e., char at point
  240. *lp1
  241.     previous-line
  242.     set %char  $curchar
  243.     next-line
  244.     !if &equ %char 186
  245.         insert-string "╫"
  246.         !else 
  247.         !if &equ %char 179
  248.             insert-string "┼"
  249.         !else
  250.             insert-string "─"
  251.         !endif
  252.     !endif
  253.     !if &less $curcol %pcol
  254.         !goto lp1
  255.     !endif
  256. ;; see if last char is a vertical line
  257. previous-line
  258. set %char  $curchar
  259. next-line
  260. !if &equ %char 186
  261.         insert-string "╢"
  262. !else
  263.     !if &equ %char 179 
  264.         insert-string "┤"
  265.     !else
  266.         insert-string "─"
  267.     !endif
  268. !endif
  269. !endm
  270.  
  271. store-procedure vert2
  272. ;; procedure to draw a line from mark to point.  mark should be above point
  273. ;; this will insert a column of double lines
  274. !if &equal %mline %pline
  275.     !return
  276. !endif
  277. !if &less %pline %mline
  278. ;    then point was above mark.  exchange and reset variables
  279.     exchange-point-and-mark
  280.     run setpoints
  281. !endif
  282. ;top line
  283. %mline goto-line
  284. beginning-of-line
  285. run mvtopcol
  286. backward-character
  287. set %char $curchar
  288. forward-character
  289.  
  290. !if &equal %char 205
  291.     insert-string "╦"
  292. !else
  293.     !if &equal %char 196
  294.         insert-string "╥"
  295.     !else
  296.         insert-string "║"
  297.     !endif
  298. !endif
  299. ;all but pline
  300. *lp1
  301.     next-line
  302.     beginning-of-line
  303.     run mvtopcol
  304.     backward-character
  305.     set %char $curchar
  306.     forward-character
  307.     !if &equal %char 205
  308.         insert-string "╬"
  309.     !else
  310.         !if &equal %char 196
  311.             insert-string "╫"
  312.         !else
  313.             insert-string "║"
  314.         !endif
  315.     !endif
  316.     !if &less $curline &sub %pline 1
  317.         !goto lp1
  318.     !endif
  319. ; bottom line
  320. next-line
  321. beginning-of-line
  322. run mvtopcol
  323. backward-character
  324. set %char $curchar
  325. forward-character
  326. !if &equal %char 205
  327.     insert-string "╩"
  328. !else
  329.     !if &equal %char 196
  330.         insert-string "╨"
  331.     !else
  332.         insert-string "║"
  333.     !endif
  334. !endif
  335. !if &less $curcol &sub %pcol 1
  336.     !goto lp1
  337. !endif
  338. !endm
  339.  
  340. store-procedure vert1
  341. ;; procedure to draw a line from mark to point.  mark should be above point
  342. ;; this will insert a column of double lines
  343. !if &equal %mline %pline
  344.     !return
  345. !endif
  346. !if &less %pline %mline
  347. ;    then point was above mark.  exchange and reset variables
  348.     exchange-point-and-mark
  349.     run setpoints
  350. !endif
  351. ;top line
  352. %mline goto-line
  353. beginning-of-line
  354. run mvtopcol
  355. backward-character
  356. set %char $curchar
  357. forward-character
  358.  
  359. !if &equal %char 205
  360.     insert-string "╤"
  361. !else
  362.     !if &equal %char 196
  363.         insert-string "┬"
  364.     !else
  365.         insert-string "│"
  366.     !endif
  367. !endif
  368. ;all but pline
  369. *lp1
  370.     next-line
  371.     beginning-of-line
  372.     run mvtopcol
  373.     backward-character
  374.     set %char $curchar
  375.     forward-character
  376.     !if &equal %char 205
  377.         insert-string "╪"
  378.     !else
  379.         !if &equal %char 196
  380.             insert-string "┼"
  381.         !else
  382.             insert-string "│"
  383.         !endif
  384.     !endif
  385.     !if &less $curline &sub %pline 1
  386.         !goto lp1
  387.     !endif
  388. ; bottom line
  389. next-line
  390. beginning-of-line
  391. run mvtopcol
  392. backward-character
  393. set %char $curchar
  394. forward-character
  395. !if &equal %char 205
  396.     insert-string "╧"
  397. !else
  398.     !if &equal %char 196
  399.         insert-string "┴"
  400.     !else
  401.         insert-string "│"
  402.     !endif
  403. !endif
  404. !if &less $curcol &sub %pcol 1
  405.     !goto lp1
  406. !endif
  407. !endm
  408.  
  409.  
  410. ;; user procedure to insert blanks from mark to point making spaces for
  411. store-procedure blank
  412. run setpoints
  413. !if &equal %pcol %mcol
  414.     run vblank
  415. !else
  416.     !if &equal %pline %mline
  417.         run hblank
  418.     !else
  419.         write-message "Illegal point and mark for blanking"
  420.     !endif
  421. !endif
  422. !endm
  423.  
  424. store-procedure chkh2
  425. ;; procedure to check if the horizontal blanking routine should insert a
  426. ;; double vertical line.  Sets a global variable yes to true if yes
  427.     set %yes &greater &sindex "╢╖╣║╗╟╔╦╠╬╥╓╫" %char 1
  428. !endm
  429.  
  430. store-procedure chkh1
  431. ;; procedure to check if the horizontal blanking routine should insert a
  432. ;; single vertical line.  Sets a global variable yes to true if yes
  433.     !if &greater &sindex %temp "│┤╡╕┐┬┼╞╒╪┌╤" 1
  434.         set %yes TRUE
  435.     !else
  436.         set %yes FALSE
  437. !endm
  438.  
  439. store-procedure hblank
  440. ;; procedure to insert blanks horizontally from mark to point
  441. ;; assume that the current line is to be double underlined.  pcol,mcol,pline,
  442. ;; mline already set by calling macro
  443. !if &equal %mcol %pcol
  444.     write-message "NULL Space to Fill"
  445.     !return
  446. !endif
  447. !if &less %pcol %mcol
  448. ;    then point was to left of mark.  exchange and reset variables
  449.     exchange-point-and-mark
  450.     run setpoints
  451. !endif
  452. end-of-line
  453. newline
  454. ;; move to under mark
  455. !if &greater %mcol 1
  456.     %mcol insert-string " "
  457. !endif
  458. ;; increment %pcol for loop counter
  459. set %pcol &add %pcol 1
  460. ;; loop through to point
  461. *lp1
  462.     previous-line
  463.     set %char &chr $curchar
  464.     next-line
  465.     execute-procedure chkh2
  466.     !if %yes
  467.         insert-string "║"
  468.         !else 
  469.         execute-procedure chkh1
  470.         !if %yes
  471.             insert-string "│"
  472.         !else
  473.             insert-string " "
  474.         !endif
  475.     !endif
  476.     !if &less $curcol %pcol
  477.         !goto lp1
  478.     !endif
  479. !endm
  480.  
  481. store-procedure chkv2
  482. ;; procedure to check if the vertical blanking routine should insert a
  483. ;; double horizontal line.  Sets a global variable yes to true if yes
  484.     set %temp 1
  485. *lp1  
  486.     !if &seq &mid "╞╚╔╩╦╠═╬╧╤╘╒╪" %temp 1 %char
  487.         set %yes TRUE
  488.         !return
  489.     !else
  490.         set %temp &add %temp 1
  491. ;    check if %temp is >= 1+ length of check string
  492.         !if &gre %temp 14
  493.             set %yes FALSE
  494.             !return
  495.         !endif
  496.         !goto lp1
  497.     !endif
  498. !endm
  499.  
  500.  
  501. store-procedure chkv1
  502. ;; procedure to check if the vertical blanking routine should insert a
  503. ;; single horizontal line.  Sets a global variable yes to true if yes
  504.     set %temp 1
  505. *lp1  
  506.     !if &seq &mid "└┴┬├─┼╟╨╥╙╓╫" %temp 1 %char
  507.         set %yes TRUE
  508.         !return
  509.     !else
  510.         set %temp &add %temp 1
  511. ;    check if %temp is >= 1+ length of check string
  512.         !if &gre %temp 13
  513.             set %yes FALSE
  514.             !return
  515.         !endif
  516.         !goto lp1
  517.     !endif
  518. !endm
  519.  
  520.  
  521. store-procedure vblank
  522. ;; procedure to vertical blanks from mark to point.  mark should be above point
  523. !if &equal %mline %pline
  524.     !return
  525. !endif
  526. !if &less %pline %mline
  527. ;    then point was above mark.  exchange and reset variables
  528.     exchange-point-and-mark
  529.     run setpoints
  530. !endif
  531. ;top line
  532. %mline goto-line
  533. beginning-of-line
  534. run mvtopcol
  535. backward-character
  536. set %char $curchar
  537. forward-character
  538.  
  539. !if &equal %char 205
  540.     insert-string "═"
  541. !else
  542.     !if &equal %char 196
  543.         insert-string "─"
  544.     !else
  545.         insert-string " "
  546.     !endif
  547. !endif
  548. ;all but pline
  549. *lp1
  550.     next-line
  551.     beginning-of-line
  552.     run mvtopcol
  553.     backward-character
  554.     set %char $curchar
  555.     forward-character
  556.     !if &equal %char 205
  557.         insert-string "═"
  558.     !else
  559.         !if &equal %char 196
  560.             insert-string "─"
  561.         !else
  562.             insert-string " "
  563.         !endif
  564.     !endif
  565.     !if &less $curline &sub %pline 1
  566.         !goto lp1
  567.     !endif
  568. ; bottom line
  569. !if &equal $curline %pline
  570.     !return
  571. !endif
  572. next-line
  573. beginning-of-line
  574. run mvtopcol
  575. backward-character
  576. set %char $curchar
  577. forward-character
  578. !if &equal %char 205
  579.     insert-string "═"
  580. !else
  581.     !if &equal %char 196
  582.         insert-string "─"
  583.     !else
  584.         insert-string " "
  585.     !endif
  586. !endif
  587. !endm
  588.  
  589. clear-message-line
  590.