- Timestamp:
- 02/19/08 13:54:27 (4 years ago)
- Location:
- trunk/lingosource/castlib1
- Files:
-
- 3 edited
-
alexUtilities.ls (modified) (1 diff)
-
bbedit_Utilities.ls (modified) (7 diffs)
-
svn_Utilities.ls (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lingosource/castlib1/alexUtilities.ls
r148 r151 216 216 on mSaveTextToTempFile me, theText, pfad 217 217 218 if ilk(pfad) <> #string then 219 pfad = mConvertUnix2HFS("/tmp/tmpfile.txt") 220 end if 221 if length(pfad) < 1 then 222 pfad = mConvertUnix2HFS("/tmp/tmpfile.txt") 223 end if 218 pfad = string(pfad) 219 220 if length(pfad) < 1 then pfad = mGetTempFilePath(me, "tmpfile.txt") 224 221 225 222 return mSaveToTextFile(me, theText, pfad) -
trunk/lingosource/castlib1/bbedit_Utilities.ls
r148 r151 108 108 --------------------- 109 109 -- create a temporary file from scripttext: 110 -- tempSrcPath = shell_cmd_list("mktemp -t temp_BBEdit_file.ls") 111 -- tempSrcPath = tempSrcPath[1] 112 tempSrcPath = "/tmp/temp_BBEdit_file.ls" 113 114 -- tempSrcHFSPath = mDoShellCmd(me, "osascript -e" && QUOTE & "return POSIX file \" & QUOTE & tempSrcPath & "\" & QUOTE & " as string" & QUOTE, 1) 115 -- tempSrcHFSPath = tempSrcHFSPath[1] 116 tempSrcHFSPath = mConvertUnix2Hfs(me, tempSrcPath) 110 tempSrcHFSPath = mGetTempFilePath(me, "temp_BBEdit_file.ls") 111 tempSrcPath = mConvertHfs2Unix(me, tempSrcHFSPath) 117 112 118 113 … … 120 115 --------------------- 121 116 122 mDoShellCmd(me, "bbedit --wait --resume " & tempSrcPath) 123 124 theText = mGetTextFromFile(me, tempSrcHFSPath) 125 126 if theType = #script then 127 memref.scripttext = theText 128 else if theType = #text then 129 memref.html = theText 130 else if theType = #field then 131 memref.text = theText 117 if theResult = 0 then 118 alert "Unable to save file:" && tempSrcHFSPath 119 else 120 mDoShellCmd(me, "bbedit --wait --resume " & tempSrcPath) 121 122 theText = mGetTextFromFile(me, tempSrcHFSPath) 123 124 if length(theText) < 1 then 125 alert "Something seems wrong: the length of the new text is 0, nating changed. If this was puprosely an empty text, please delete by hand." 126 else 127 if theType = #script then 128 memref.scripttext = theText 129 else if theType = #text then 130 memref.html = theText 131 else if theType = #field then 132 memref.text = theText 133 end if 134 end if 132 135 end if 133 134 136 135 137 else … … 139 141 theName = "member_" & memref.membernum & "_" & memref.castlibnum 140 142 end if 141 --------------------- 142 -- create a temporary file from scripttext: 143 if mCheckForXtra(me, "BudAPI") then 144 145 resetUNames = 0 146 if baSysFolder("prefs") starts "/" then 147 baReturnUnixNames(0) 148 resetUNames = 1 149 end if 150 tempSrcHFSPath = basysfolder("temp") & theName & ".ls" 151 baReturnUnixNames(1) 152 tempSrcPath = basysfolder("temp") & theName & ".ls" 153 if resetUNames = 0 then 154 baReturnUnixNames(0) 155 end if 156 else 157 tempSrcPath = "/tmp/" & theName & ".ls" 158 tempSrcHFSPath = mConvertUnix2Hfs(me, tempSrcPath) 159 end if 143 144 tempSrcPath = mGetTempFilePath(me, theName & ".ls") 145 tempSrcHFSPath = mConvertUnix2Hfs(me, tempSrcPath) 160 146 161 147 … … 356 342 end if 357 343 358 if not(the platform contains "mac") then 359 if mCheckForXtra(me, "BudAPI") then 360 tempSrcPath = basysfolder("temp") 361 put theName & ".ls" after tempSrcPath 362 else 363 alert "You need the buddyApi xtra for this operation" 364 exit 365 end if 366 else 367 delim = the last char of the moviepath 368 olddelim = the itemdelimiter 369 the itemdelimiter = delim 370 hd = item 1 of getosdirectory() 371 372 tempSrcPath = hd & delim & "tmp" & delim & theName & ".ls" 373 the itemdelimiter = olddelim 374 end if 344 tempSrcPath = mGetTempFilePath(me, theName & ".ls") 375 345 376 346 theText = mGetTextFromFile(me, tempSrcPath) … … 642 612 --------------------- 643 613 -- create a temporary file from scripttext: 644 -- tempSrcPath = shell_cmd_list("mktemp -t temp_BBDiff_file1") 645 -- tempSrcPath = tempSrcPath[1] 646 tempSrcPath = "/tmp/temp_BBDiff_file1.ls" 647 648 -- tempSrcHFSPath = mDoShellCmd(me, "osascript -e" && QUOTE & "return POSIX file \" & QUOTE & tempSrcPath & "\" & QUOTE & " as string" & QUOTE, 1) 649 -- tempSrcHFSPath = tempSrcHFSPath[1] 650 tempSrcHFSPath = mConvertUnix2Hfs(me, tempSrcPath) 614 615 tempSrcHFSPath = mGetTempFilePath(me, "temp_BBDiff_file1.ls") 616 tempSrcPath = mConvertHfs2unix(me, tempSrcHFSPath) 651 617 652 618 st1 = memref1.scripttext 653 619 theResult = mSaveTextToTempFile(me, st1, tempSrcHFSPath) 620 621 if theResult = 0 then 622 alert "Problems saving file:" && tempSrcHFSPath && "Can't proceed" 623 exit 624 end if 654 625 --------------------- 655 626 … … 670 641 --------------------- 671 642 -- create a temporary file from scripttext: 672 -- tempSrcPath2 = shell_cmd_list("mktemp -t temp_BBDiff_file2") 673 -- tempSrcPath2 = tempSrcPath2[1] 674 tempSrcPath2 = "/tmp/temp_BBDiff_file2.ls" 675 676 -- tempSrcHFSPath2 = mDoShellCmd(me, "osascript -e" && QUOTE & "return POSIX file \" & QUOTE & tempSrcPath2 & "\" & QUOTE & " as string" & QUOTE, 1) 677 -- tempSrcHFSPath2 = tempSrcHFSPath2[1] 678 tempSrcHFSPath2 = mConvertUnix2Hfs(me, tempSrcPath2) 643 tempSrcHFSPath2 = mGetTempFilePath(me, "temp_BBDiff_file2.ls") 644 tempSrcPath2 = mConvertHfs2unix(me, tempSrcHFSPath2) 679 645 680 646 comm = tempSrcPath2 681 647 682 648 theResult = mSaveTextToTempFile(me, st2, tempSrcHFSPath2) 649 if theResult = 0 then 650 alert "Problems saving file:" && tempSrcHFSPath && "Can't proceed" 651 exit 652 end if 683 653 --------------------- 684 654 … … 1411 1381 else 1412 1382 1413 tempSrc Path = "/tmp/temp_BBEdit_file.ls"1414 tempSrc HFSPath = mConvertUnix2Hfs(me, tempSrcPath)1383 tempSrcHFSPath = mGetTempFilePath(me, "temp_BBEdit_file.ls") 1384 tempSrcPath = mConvertHfs2unix(me, tempSrcHFSPath) 1415 1385 1416 mSaveTextToTempFile(me, memref.scripttext, tempSrcHFSPath) 1386 theResult = mSaveTextToTempFile(me, memref.scripttext, tempSrcHFSPath) 1387 if theResult <> 0 then 1388 1389 if char 1 of comm = "~" then put "$HOME" into char 1 of comm 1390 1391 mDoShellCmd(me, bbdiffpath & " --ignore-curly-quotes --ignore-spaces --wait --resume " "E& tempSrcPath "E&"E& comm "E) 1392 1393 newscripttext = mGetTextFromFile(me, tempSrcHFSPath) 1394 if length(newscripttext) then 1395 memref.scripttext = mGetTextFromFile(me, tempSrcHFSPath) 1396 else 1397 alert "Something seems wrong: the length of the new text is 0, nothing was changed now. If this was puprosely an empty text, please delete by hand." 1398 end if 1399 1400 end if 1417 1401 1418 if char 1 of comm = "~" then put "$HOME" into char 1 of comm1419 1420 mDoShellCmd(me, bbdiffpath & " --ignore-curly-quotes --ignore-spaces --wait --resume " "E& tempSrcPath "E&"E& comm "E)1421 1422 memref.scripttext = mGetTextFromFile(me, tempSrcHFSPath)1423 1402 1424 1403 end if -
trunk/lingosource/castlib1/svn_Utilities.ls
r148 r151 90 90 91 91 92 tempSrcHFSPath = mGetTempFilePath(me, "temp_SVN_Diff_file1.ls") 93 92 94 if isMac then 93 94 --------------------- 95 -- create a temporary file from scripttext: 96 -- tempSrcPath = mDoShellCmd(me, "mktemp -t temp_BBDiff_file1", 1) 97 -- tempSrcPath = tempSrcPath[1] 98 tempSrcPath = "/tmp/temp_BBEdit_file1.ls" 99 100 tempSrcHFSPath = mConvertUnix2Hfs(me, tempSrcPath) 101 95 tempSrcPath = mConvertHfs2unix(me, tempSrcHFSPath) 102 96 else 103 104 tmpfolder = baSysFolder("temp") 105 tempSrcPath = tmpfolder & "temp_SVN_Diff_file1.ls" 106 tempSrcHFSPath = tempSrcPath 97 tempSrcPath = tempSrcHFSPath 107 98 end if 108 99 … … 145 136 146 137 147 148 149 if isMac then 150 151 comm = mConvertHFS2Unix(me, thePath) 152 153 theResult = mDoShellCmd(me, bbdiffpath & " --ignore-curly-quotes --ignore-spaces --wait --resume " "E& tempSrcPath "E&"E& comm "E && "2>&1", RETURN, 0, 1) 154 155 -- since we used the --wait and the --resume switch, we will only come to this line AFTER the diff process in bbedit is finished 156 157 if count(theResult) > 0 then 158 if theResult[1] contains "no such file or directory" then 159 put theResult[1] 160 else 161 put "No differences found for member: " & memref.name && "(" & memref & ")" 162 end if 163 writeBack = 0 164 165 else 166 167 -------- now write the results of the BBEdit diff back into the script members 168 scrText = mGetTextFromFile(me, tempSrcHFSPath) 169 170 writeBack = 1 171 172 173 end if 174 175 176 ---------------------- windows 177 else 178 179 180 theResult = mDoShellCmd(me, QUOTE & bbdiffpath & QUOTE && QUOTE & tempSrcPath "E&"E& thePath "E, RETURN, 0, 0, 0) 181 182 -------- now write the results of the BBEdit diff back into the script members 183 scrText = mGetTextFromFile(me, tempSrcHFSPath) 184 185 writeBack = 1 186 end if 187 188 189 if writeBack = 1 then 190 191 192 if convertLineBreaksToUnix = 1 then 193 ------------------------------------------ trac subversion support works better with unix linebreaks... 194 if mCheckForXtra(me, "Pregex") = 1 then 195 196 scrTextLi = [scrText] 197 ----------- always convert to mac linebreaks as director internally uses mac linebreaks 198 -- if the platform contains "mac" then 199 pregex_replace(scrTextLi, "\x0D?\x0A", "g", "\x0D") 200 -- else 201 -- pregex_replace(scrTextLi, "\x0D([^\x0A])", "g", "\x0D\x0A\1") 202 -- pregex_replace(scrTextLi, "([^\x0D])\x0A", "g", "\1\x0D\x0A") 203 -- end if 204 scrText = scrTextLi[1] 138 if theResult <> 0 then 139 140 141 142 143 if isMac then 144 145 comm = mConvertHFS2Unix(me, thePath) 146 147 theResult = mDoShellCmd(me, bbdiffpath & " --ignore-curly-quotes --ignore-spaces --wait --resume " "E& tempSrcPath "E&"E& comm "E && "2>&1", RETURN, 0, 1) 148 149 -- since we used the --wait and the --resume switch, we will only come to this line AFTER the diff process in bbedit is finished 150 151 if count(theResult) > 0 then 152 if theResult[1] contains "no such file or directory" then 153 put theResult[1] 154 else 155 put "No differences found for member: " & memref.name && "(" & memref & ")" 156 end if 157 writeBack = 0 205 158 206 159 else 207 160 208 -------- --- always convert to mac linebreaks as director internally uses mac linebreaks209 -- if the platform contains "mac" then161 -------- now write the results of the BBEdit diff back into the script members 162 scrText = mGetTextFromFile(me, tempSrcHFSPath) 210 163 211 -- first convert windows to mac 212 fndStr = numToChar(13) & numToChar(10) 213 offs = offset(fndStr, scrText) 214 repeat while offs > 0 215 put numToChar(13) into char offs to offs+1 of scrText 216 offs = offset(fndStr, scrText) 217 end repeat 164 writeBack = 1 218 165 219 -- now convert unix to mac220 fndStr = numToChar(10)221 offs = offset(fndStr, scrText)222 repeat while offs > 0223 put numToChar(13) into char offs of scrText224 offs = offset(fndStr, scrText)225 end repeat226 227 -- else228 --229 -- fndStr = numToChar(13) & numToChar(10)230 -- offs = offset(fndStr, scrText)231 -- repeat while offs > 0232 -- put "ÀÀÀ" into char offs+1 of scrText233 -- offs = offset(fndStr, scrText)234 -- end repeat235 --236 --237 -- fndStr = numToChar(10)238 -- offs = offset(fndStr, scrText)239 -- repeat while offs > 0240 -- put "ÀÀÀ" into char offs of scrText241 -- offs = offset(fndStr, scrText)242 -- end repeat243 --244 --245 --246 -- fndStr = numToChar(13) & "ÀÀÀ"247 -- offs = offset(fndStr, scrText)248 -- repeat while offs > 0249 -- put numToChar(13) & numToChar(10) into char offs to offs+3 of scrText250 -- offs = offset(fndStr, scrText)251 -- end repeat252 --253 --254 --255 -- fndStr = "ÀÀÀ"256 -- offs = offset(fndStr, scrText)257 -- repeat while offs > 0258 -- put numToChar(13) & numToChar(10) into char offs to offs+2 of scrText259 -- offs = offset(fndStr, scrText)260 -- end repeat261 --262 -- end if263 166 264 167 end if 265 ----------------------------------------- 168 169 170 ---------------------- windows 171 else 172 173 174 theResult = mDoShellCmd(me, QUOTE & bbdiffpath & QUOTE && QUOTE & tempSrcPath "E&"E& thePath "E, RETURN, 0, 0, 0) 175 176 -------- now write the results of the BBEdit diff back into the script members 177 scrText = mGetTextFromFile(me, tempSrcHFSPath) 178 179 writeBack = 1 266 180 end if 267 181 268 182 269 270 case memtype of 271 272 ----------------------- 273 #script: 274 memref.scripttext = scrText 275 276 ----------------------- 277 #field: 278 memref.text = scrText 279 280 ----------------------- 281 #text: 282 memref.html = scrText 283 284 ----------------------- 285 otherwise: 286 memref.text = scrText 287 288 end case 183 if writeBack = 1 then 184 185 186 if convertLineBreaksToUnix = 1 then 187 ------------------------------------------ trac subversion support works better with unix linebreaks... 188 if mCheckForXtra(me, "Pregex") = 1 then 189 190 scrTextLi = [scrText] 191 ----------- always convert to mac linebreaks as director internally uses mac linebreaks 192 pregex_replace(scrTextLi, "\x0D?\x0A", "g", "\x0D") 193 scrText = scrTextLi[1] 194 195 else 196 197 ----------- always convert to mac linebreaks as director internally uses mac linebreaks 198 -- if the platform contains "mac" then 199 200 -- first convert windows to mac 201 fndStr = numToChar(13) & numToChar(10) 202 offs = offset(fndStr, scrText) 203 repeat while offs > 0 204 put numToChar(13) into char offs to offs+1 of scrText 205 offs = offset(fndStr, scrText) 206 end repeat 207 208 -- now convert unix to mac 209 fndStr = numToChar(10) 210 offs = offset(fndStr, scrText) 211 repeat while offs > 0 212 put numToChar(13) into char offs of scrText 213 offs = offset(fndStr, scrText) 214 end repeat 215 216 217 end if 218 ----------------------------------------- 219 end if 220 221 222 223 case memtype of 224 225 ----------------------- 226 #script: 227 memref.scripttext = scrText 228 229 ----------------------- 230 #field: 231 memref.text = scrText 232 233 ----------------------- 234 #text: 235 memref.html = scrText 236 237 ----------------------- 238 otherwise: 239 memref.text = scrText 240 241 end case 242 243 end if 289 244 290 245 end if
Note: See TracChangeset
for help on using the changeset viewer.
