home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / dos / tools / aurora21 / drawbox.aml < prev    next >
Text File  |  1995-08-10  |  4KB  |  116 lines

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