home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 626a.lha / Textra_v1.12 / Scripts / SingleSpace.textra < prev    next >
Text File  |  1991-12-18  |  3KB  |  119 lines

  1.     /*******************************************************************
  2.      *   TEXTRA AREXX script -- Mike Haas, 1991, All Rights Reserved.  *
  3.      * Freely distributable ONLY as a component of the TEXTRA package. *
  4.      * This banner may not be removed or altered (improvements to the  *
  5.      *    actual program welcome).  Please document and send to me.    *
  6.      *******************************************************************/
  7.  
  8. /* Usage:  SingleSpace
  9.  *
  10.  * This script deletes any blank lines between each text-bearing line
  11.  * in the select range.  No parameters are required.
  12.  *
  13.  */
  14.  
  15. OPTIONS results
  16.  
  17. /* temporarily make sure auto indent is off */
  18. prefs autoindent read; autoistate = result
  19. prefs autoindent off
  20.  
  21. get select position   /* get the select boundary, if any */
  22.  
  23. if (result == "NO SELECT") then   /* is nothing selected? */
  24.  
  25.     do
  26.         get cursor position   /* nothing selected, get cursor pos */
  27.         parse var result   cursx ' ' cursy
  28.         LinesSelected = 0   /* means 'just cursor' */
  29.     
  30.     end
  31.     
  32. else
  33.  
  34.     do
  35.         /* yes, there is a selection, get it's boundaries */
  36.         parse var result   startx ' ' starty ' ' endx ' ' endy
  37.         LinesSelected = (endy - starty)
  38.     
  39.         /* if only the 'eol' of the previous line is selected
  40.            (nothing on this line is actually included, i.e. x==0),
  41.            then don't include it.
  42.         */
  43.         if (endx > 0) then  LinesSelected = LinesSelected + 1
  44.     
  45.     end
  46.  
  47.  
  48. if (LinesSelected == 0) then
  49.     do
  50.         currline = cursy
  51.         call CheckDoCurrLine
  52.         if (DoCurrLine == 1) then
  53.             do
  54.                 selectline cursy+1
  55.                 del
  56.             end
  57.     end
  58.  
  59. else
  60.  
  61.     do
  62.         currline = starty; numLeft = LinesSelected
  63.         do while (numLeft > 0)
  64.             do
  65.                 call CheckDoCurrLine
  66.                 if (DoCurrLine == 1) then
  67.                     do
  68.                         selectline currline+1
  69.                         del
  70.                         /*numLeft = numLeft - 1*/
  71.                     end
  72.                 else
  73.                     currline = currline + 1
  74.                 numLeft = numLeft - 1
  75.             end
  76.         end
  77.         
  78.         /* gotoxy 0 starty
  79.            selectto 0 starty+LinesSelected  */
  80.         
  81.         gotoxy 0 currline
  82.     end
  83.  
  84. /* restore autoindent */
  85. prefs autoindent autoistate
  86.  
  87. exit
  88.  
  89.  
  90.  
  91. CheckDoCurrLine:                
  92. ThisLine = currline + 1
  93. call CheckThisLine
  94. lineplusone = DoCurrLine
  95. ThisLine = currline
  96. call CheckThisLine
  97. if  ((DoCurrLine == 1) & (lineplusone == 0)) then
  98.     DoCurrLine = 1
  99. else
  100.     DoCurrLine = 0
  101. return
  102.  
  103. CheckThisLine:  /*DoCurrLine set to 1 if non-white there*/
  104. DoCurrLine = 0
  105. gotoxy 0 ThisLine
  106. get cursor char
  107. do while (result ~= -1)
  108.     do
  109.         if ((result ~= ' ') & (result ~= '    ')) /*TAB*/ then
  110.             do
  111.                 DoCurrLine = 1
  112.                 leave
  113.             end
  114.         right 1
  115.         get cursor char
  116.     end
  117. end
  118. return
  119.