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

  1.  
  2. /* ------------------------------------------------------------------ */
  3. /* Macro:        TABS.AML                                             */
  4. /* Written by:   nuText Systems                                       */
  5. /*                                                                    */
  6. /* Description:  Converts tabs to spaces in the current file (detab), */
  7. /*               or converts spaces to tabs (entab) The conversion is */
  8. /*               limited to a marked block if it exists in the        */
  9. /*               current file. The current value of the _TabWidth     */
  10. /*               configuration variable is used as the tab width.     */
  11. /*                                                                    */
  12. /* Usage:        Select this macro from the Macro List (on the Macro  */
  13. /*               menu), or run it from the macro picklist <shift f12> */
  14. /*               This macro will run faster if Undo is turned OFF.    */
  15. /* ------------------------------------------------------------------ */
  16.  
  17.   // compile time macros and function definitions
  18.   include  bootpath "define.aml"
  19.  
  20.   if not objtype? "edit" then
  21.     msgbox "Edit windows only!"
  22.     return
  23.   end
  24.  
  25.   // mark beginning of undoable group
  26.   undobegin
  27.  
  28.   // test for a mark in the current window
  29.   if mark? then
  30.     if getmarkbuf <> getcurrbuf then
  31.       msgbox "Block not marked in current window"
  32.       return
  33.     end
  34.   // create a temporary mark covering the entire file
  35.   else
  36.     markline 1 (getlines)
  37.     temp_mark = TRUE
  38.   end
  39.  
  40.   // check if entab was specified
  41.   entab = (arg 2) == 'e'
  42.  
  43.   // use built-in tabblock function for both detab and entab
  44.   tabblock (if? entab -_TabWidth _TabWidth)
  45.   if temp_mark then
  46.     destroymark
  47.   end
  48.  
  49.   undoend
  50.  
  51.   display
  52.   say  (if? entab "Entab " "Detab ") +
  53.        (if? not temp_mark "block ") + "done."
  54.  
  55.