@@ -2992,11 +2992,33 @@ command scriptFormat pScope, pDontGroup
29922992 local tOldText
29932993 put the text of field "Script" of me into tOldText
29942994
2995+ local tFirstLine , tLastLine , tCharsAboveFirstLineOld , tCharsAboveLastLineOld
2996+ get the selectedLine
2997+ put word 2 of it into tFirstLine
2998+ if word 4 of it is a number then put word 4 of it into tLastLine else put tFirstLine into tLastLine
2999+
3000+ put the number of chars of line 1 to tFirstLine of tOldText into tCharsAboveFirstLineOld
3001+ put the number of chars of line 1 to tLastLine of tOldText into tCharsAboveLastLineOld
3002+
29953003 local tNewText
29963004 put textFormatSelection(tOldText ) into tNewText
3005+
3006+ local tCharsAboveFirstLineNew , tCharsAboveLastLineNew , tDiffFirstLine , tDiffLastLine
3007+ put the number of chars of line 1 to tFirstLine of tNewText into tCharsAboveFirstLineNew
3008+ put the number of chars of line 1 to tLastLine of tNewText into tCharsAboveLastLineNew
3009+
3010+ put tCharsAboveFirstLineOld - tCharsAboveFirstLineNew into tDiffFirstLine
3011+ put tCharsAboveLastLineOld - tCharsAboveLastLineNew into tDiffLastLine
3012+
3013+ local tFirstLineChar
3014+ put (the number of chars of line 1 to tFirstLine - 1 of tNewText ) + 2 into tFirstLineChar
3015+
29973016 textReplace tStartChar , tOldText , tNewText , empty , pDontGroup
29983017
29993018 if tStart is not empty then
3019+ subtract tDiffFirstLine from tStart
3020+ put max (tStart , tFirstLineChar ) into tStart # dont let selection go into previous line
3021+ subtract tDiffLastLine from tEnd
30003022 select char tStart to tEnd of field "Script" of me
30013023 end if
30023024
0 commit comments