home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************
- * TEXTRA AREXX script -- Mike Haas, 1991, All Rights Reserved. *
- * Freely distributable ONLY as a component of the TEXTRA package. *
- * This banner may not be removed or altered (improvements to the *
- * actual program welcome). Please document and send to me. *
- *******************************************************************/
-
- /* Usage: DoubleSpace
- *
- * This script inserts a blank line between each text-bearing line
- * in the select range. No parameters are required.
- *
- */
-
-
- /* 00001 mdh 10-nov-92 Added ability to cancel script */
- /* 00002 mdh 20-nov-92 check version (cause of 'CheckCancel') */
-
- OPTIONS results
-
- rex = 0; result = "NOTSUPPORTED" /*00002*/
- textraversion
- parse var result maj min rex
- if (result == "NOTSUPPORTED") | (rex < 3) then do
- notify "Textra V1.13 or later required for this script."
- exit
- end
-
-
- /* temporarily make sure auto indent is off */
- prefs autoindent read; autoistate = result
- prefs autoindent off
-
- get select position /* get the select boundary, if any */
-
- if (result == "NO SELECT") then /* is nothing selected? */
-
- do
- get cursor position /* nothing selected, get cursor pos */
- parse var result cursx ' ' cursy
- LinesSelected = 0 /* means 'just cursor' */
-
- end
-
- else
-
- do
- /* yes, there is a selection, get it's boundaries */
- parse var result startx ' ' starty ' ' endx ' ' endy
- LinesSelected = (endy - starty)
-
- /* if only the 'eol' of the previous line is selected
- (nothing on this line is actually included, i.e. x==0),
- then don't include it.
- */
- if (endx > 0) then LinesSelected = LinesSelected + 1
-
- end
-
-
- if (LinesSelected == 0) then
-
- do
- gotoxy 0 cursy+1
- newline
- up 1
- end
-
- else
-
- do
- currline = starty; numLeft = LinesSelected
- do while (numLeft > 0)
- do
- CheckCancel; if (result == CANCEL) then exit
- call CheckDoCurrLine
- if (DoCurrLine == 1) then
- do
- gotoxy 0 currline + 1
- left 1
- newline
- currline = currline + 2
- end
- else
- currline = currline + 1
- numLeft = numLeft - 1
- end
- end
-
- /* gotoxy 0 starty
- selectto 0 starty+LinesSelected */
-
- gotoxy 0 currline
- end
-
- /* restore autoindent */
- prefs autoindent autoistate
-
- exit
-
-
-
- CheckDoCurrLine:
- DoCurrLine = 0
- ThisLine = currline + 1
- call CheckThisLine
- lineplusone = DoCurrLine
- DoCurrLine = 0
- ThisLine = currline
- call CheckThisLine
- DoCurrLine = BITAND(lineplusone,DoCurrLine)
- return
-
- CheckThisLine:
- gotoxy 0 ThisLine
- get cursor char
- do while (result ~= -1)
- do
- if ((result ~= ' ') & (result ~= ' ')) /*TAB*/ then
- do
- DoCurrLine = 1
- leave
- end
- right 1
- get cursor char
- end
- end
- return
-