home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / new / util / edit / polyed / macros / center.ped next >
Text File  |  1994-09-22  |  1KB  |  45 lines

  1. /*
  2. ** $VER: center.ped 1.0 (17.09.1994) written by Robert Brandner
  3. **
  4. ** This macro centers text in current line, according to the
  5. ** linelength specified in the settings.
  6. */
  7.  
  8. OPTIONS RESULTS
  9.  
  10. /*
  11. ** first we get the cursor position, the current line,
  12. ** and the current right border limit.
  13. */
  14.  
  15. 'GETCURSORPOS STEM CPOS.'    /* position in CPOS.LINE and CPOS.COLUMN    */
  16. 'GETLINE VAR LINE'
  17. 'GETATTR APPLICATION FIELD VAR_RIGHTBORDER VAR WIDTH'
  18.  
  19. /*
  20. ** Now we remove leading and trailing spaces and
  21. ** center the remaining text to the demanded width
  22. ** (which is quite easy thanks to Rexx)
  23. */
  24.  
  25. STRIPPED = strip(LINE, 'B')            /* remove trailing and leading spaces    */
  26. CENTRED = center(STRIPPED, WIDTH)    /* center line                             */
  27. NEW = strip(CENTRED, 'T')            /* remove trailing spaces                */
  28.  
  29. /*
  30. ** We clear the current line and insert the centered instead
  31. */
  32.  
  33. 'POSITION SOL'                            /* mark completeline            */
  34. 'BLOCK START'
  35. 'POSITION EOL'
  36. 'ERASE'                                    /* erase marked block            */
  37.  
  38. 'TEXT' TEXT NEW                            /* insert centered line            */
  39.  
  40. /*
  41. ** At last we reset the cursor to the original position
  42. */
  43.  
  44. 'GOTOCOLUMN' CPOS.COLUMN                /* reset cursor                 */
  45.