home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / DOS / TEKST / AURORA2 / DRAWBOX.AML < prev    next >
Text File  |  1995-04-28  |  4KB  |  117 lines

  1.  
  2. /* ------------------------------------------------------------------ */
  3. /* Macro:        DRAWBOX.AML                                          */
  4. /* Written by:   nuText Systems                                       */
  5. /*                                                                    */
  6. /* Description:  This macro draws a box around a column mark in the   */
  7. /*               current window. The box style can be passed to this  */
  8. /*               macro. If nothing is passed, the user is prompted    */
  9. /*               for the box style. The following box styles are      */
  10. /*               available:                                           */
  11. /*                                                                    */
  12. /*                 1 - single line                                    */
  13. /*                 2 - double horizontal line                         */
  14. /*                 3 - double vertical line                           */
  15. /*                 4 - double horizontal and vertical line            */
  16. /*                 5 - spaces                                         */
  17. /*                 6 - shaded characters                              */
  18. /*                                                                    */
  19. /* Usage:        Select this macro from the Macro List (on the Macro  */
  20. /*               menu), or run it from the macro picklist <shift f12> */
  21. /* ------------------------------------------------------------------ */
  22.  
  23.   // compile time macros and function definitions
  24.   include  bootpath "define.aml"
  25.  
  26.   // test for edit windows
  27.   if not wintype? "edit" then
  28.     msgbox "Edit windows only!"
  29.     return
  30.   end
  31.  
  32.   // test for mark in current window and column mark
  33.   if getcurrbuf <> getmarkbuf or getmarktype <> 'k' then
  34.     msgbox "Column block not marked in current window"
  35.     return
  36.   end
  37.  
  38.   // get box style based on first argument (arg 2) passed to this
  39.   // macro (arg 1 is the macro filename)
  40.   boxstyle = arg 2
  41.  
  42.   // if nothing is passed, then prompt the user
  43.   if not boxstyle then
  44.  
  45.     // create a boxstyle menu
  46.     menu "boxstyle"
  47.       item " &Single"               1
  48.       item " Double &Horizontal"    2
  49.       item " Double &Vertical"      3
  50.       item " &Double"               4
  51.       item " &Eraser"               5
  52.       item " Shaded &Character"     6
  53.     end
  54.  
  55.     // display the popup menu and get the boxstyle
  56.     boxstyle = popup "boxstyle" "Select the box style:" 35
  57.  
  58.     // destroy the menu
  59.     destroybuf "boxstyle"
  60.  
  61.     // exit macro if no box style is selected
  62.     if not boxstyle then
  63.       return
  64.     end
  65.  
  66.   end
  67.  
  68.   // get the box style character string
  69.   style = "─│┌┐┘└═│╒╕╛╘─║╓╖╜╙═║╔╗╝╚      ▒▒▒▒▒▒" [(boxstyle - 1) * 6 + 1 : 6]
  70.  
  71.   topside = getmarktop
  72.   botside = getmarkbot
  73.   leftside = getmarkleft
  74.   rightside = getmarkright
  75.  
  76.   undobegin
  77.   usemark 'T'
  78.  
  79.   // right side
  80.   column = rightside + 1
  81.   markcolumn  column column topside botside
  82.   fillblock  style [2]
  83.  
  84.   // left side
  85.   if leftside > 1 then
  86.     column = leftside - 1
  87.     markcolumn  column column topside botside
  88.     fillblock  style [2]
  89.     left_ok = 1
  90.   end
  91.  
  92.   destroymark
  93.   usemark
  94.  
  95.   // top side
  96.   if topside > 1 then
  97.     topside = topside - 1
  98.     ovltext (copystr style [1] (getmarkcols)) leftside topside
  99.     ovltext style [4]  rightside + 1  topside
  100.     if left_ok then
  101.       ovltext style [3]  leftside - 1  topside
  102.     end
  103.   end
  104.  
  105.   // bottom side
  106.   if botside < getlines then
  107.     botside = botside + 1
  108.     ovltext (copystr style [1] (getmarkcols)) leftside botside
  109.     ovltext style [5]  rightside + 1  botside
  110.     if left_ok then
  111.       ovltext style [6]  leftside - 1  botside
  112.     end
  113.   end
  114.  
  115.   undoend
  116.  
  117.