Changeset 148 for trunk/lingosource/castlib1/bbedit_Utilities.ls
- Timestamp:
- 02/18/08 05:09:49 (4 years ago)
- File:
-
- 1 edited
-
trunk/lingosource/castlib1/bbedit_Utilities.ls (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lingosource/castlib1/bbedit_Utilities.ls
r131 r148 6 6 end 7 7 8 8 9 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 9 10 on _______________BBEDIT_SCRIPTS end … … 11 12 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 12 13 13 on mOpen_Linked_Script_With_BBedit me 14 15 if not(the platform contains "mac") then 16 alert "Sorry, BBEdit is a mac application!" & RETURN & "If you change this handler to match something appropriate for Windows, please drop me a note. alex@farbflash.de" 17 exit 18 end if 14 on mOpen_Linked_Script_With_BBedit me, editor 19 15 20 16 if mCheckForXtra(me, "ff_shell") = 0 then … … 28 24 sel = the selection of castlib cl 29 25 30 clistr = "bbedit" 26 editor = string(editor) 27 if length(editor) < 1 then 28 clistr = "bbedit" 29 else 30 clistr = editor 31 end if 31 32 32 33 repeat with sub in sel … … 51 52 52 53 end 54 55 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 56 57 on mOpen_Linked_Script_With_ext_editor me 58 editor = mGetExternalScriptEditor(me) 59 if length(editor) < 1 then exit 60 mOpen_Linked_Script_With_BBedit me, editor 61 end 53 62 54 63 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx … … 132 141 --------------------- 133 142 -- create a temporary file from scripttext: 134 tempSrcPath = "/tmp/" & theName & ".ls" 135 136 -- tempSrcHFSPath = mDoShellCmd(me, "osascript -e" && QUOTE & "return POSIX file \" & QUOTE & tempSrcPath & "\" & QUOTE & " as string" & QUOTE, 1) 137 -- tempSrcHFSPath = tempSrcHFSPath[1] 138 tempSrcHFSPath = mConvertUnix2Hfs(me, tempSrcPath) 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 139 160 140 161 … … 144 165 mDoShellCmd(me, "bbedit " & tempSrcPath) 145 166 146 147 167 end if 148 149 -- neuer = new(#field)150 -- neuer.text = theText151 --152 -- oldclipboardNum = new(#field)153 -- oldclipboardNum.pasteClipBoardInto()154 --155 -- copyToClipBoard(neuer)156 --157 -- shell_cmd("pbpaste | bbedit")158 --159 -- if oldclipboardNum.type <> #empty then copyToClipBoard(oldclipboardNum)160 -- oldclipboardNum.erase()161 -- neuer.erase()162 --163 -- exit164 168 165 169 end if … … 172 176 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 173 177 174 on mReImport_text_Opened_In_BBedit me 175 176 if not(the platform contains "mac") then 177 alert "Sorry, BBEdit is a mac application!" & RETURN & "If you change this handler to match something appropriate for Windows, please drop me a note. alex@farbflash.de" 178 exit 178 on mEdit_text_in_ext_editor me 179 mOpen_text_with_ext_editor me, 1 180 end 181 182 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 183 184 on mGetMacBinary me, editor 185 if not(editor starts "/") then 186 editor = mConvertHFS2Unix(me, editor) 187 end if 188 189 if the last char of editor = "/" then delete the last char of editor 190 191 olddelim = the itemdelimiter 192 the itemdelimiter = "/" 193 194 appname = the last item of editor 195 if offset(".app", appname) = length(appname) - 3 then 196 infoplist = editor & "/Contents/Info.plist" 197 exename = mDoShellCmd(me, "grep -A1 -E '<key>CFBundleExecutable<\/key>'" && QUOTE & infoplist & QUOTE & " | grep -vE '<key>CFBundleExecutable</key>' | cut -d\> -f2 | cut -d\< -f1") 198 if the last char of exename = RETURN then delete the last char of exename 199 if the last char of exename = numToChar(10) then delete the last char of exename 200 editor = editor & "/Contents/MacOS/" & exename 201 end if 202 203 the itemDelimiter = olddelim 204 205 return editor 206 end 207 208 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 209 210 on mOpen_text_with_ext_editor me, doLiveEdit 211 212 if mCheckForXtra(me, "ff_shell") = 0 then 213 if mCheckForXtra(me, "Shell") = 0 then 214 mShellXtraMissing me 215 exit 216 end if 179 217 end if 180 218 … … 182 220 sel = the selection of castlib cl 183 221 222 if mCheckForXtra(me, "BudAPI") then 223 -- tempFolder = basysfolder("temp") 224 225 if the platform contains "mac" then 226 227 isMac = 1 228 resetUNames = 0 229 if baSysFolder("prefs") starts "/" then 230 baReturnUnixNames(0) 231 resetUNames = 1 232 end if 233 tempFolderHFS = basysfolder("temp") 234 baReturnUnixNames(1) 235 tempFolder = basysfolder("temp") 236 if resetUNames = 0 then 237 baReturnUnixNames(0) 238 end if 239 240 else 241 tempFolderHFS = basysfolder("temp") 242 tempFolder = tempFolderHFS 243 end if 244 245 246 else 247 alert "You need the buddyApi xtra for this operation" 248 exit 249 end if 250 251 editor = mGetExternalScriptEditor(me) 252 if length(editor) < 1 then exit 253 184 254 repeat with sub in sel 185 255 repeat with mem = sub[1] to sub[2] … … 187 257 memref = member(mem,cl) 188 258 259 theText = "" 260 theType = memref.type 261 if theType = #script then 262 theText = memref.scripttext 263 else if theType = #text then 264 theText = memref.html 265 else if theType = #field then 266 theText = memref.text 267 end if 268 269 if length(theText) > 0 then 270 271 272 if doLiveEdit then 273 --------------------- 274 tempSrcPath = tempFolder & "temp_LingoScript_file.ls" 275 276 if isMac then 277 waitparam = "" 278 editor = mGetMacBinary(me, editor) 279 tempSrcHFSPath = mConvertUnix2Hfs(me, tempSrcPath) 280 else 281 waitparam = " \w" 282 tempSrcHFSPath = tempSrcPath 283 end if 284 --------------------- 285 286 theResult = mSaveTextToTempFile(me, theText, tempSrcHFSPath) 287 288 mDoShellCmd(me, QUOTE & editor & QUOTE && tempSrcPath & waitparam) 289 290 theText = mGetTextFromFile(me, tempSrcHFSPath) 291 292 theText = mForceMacLineBreaks(me, theText) 293 294 if theType = #script then 295 memref.scripttext = theText 296 else if theType = #text then 297 memref.html = theText 298 else if theType = #field then 299 memref.text = theText 300 end if 301 302 303 else 304 305 theName = memref.name 306 if length(theName) < 1 then 307 theName = "member_" & memref.membernum & "_" & memref.castlibnum 308 end if 309 --------------------- 310 -- create a temporary file from scripttext: 311 tempSrcPath = tempFolder & theName & ".ls" 312 313 if isMac then 314 waitparam = " &" 315 editor = "" 316 tempSrcHFSPath = tempSrcPath 317 else 318 waitparam = "" 319 tempSrcHFSPath = tempSrcPath 320 end if 321 322 theResult = mSaveTextToTempFile(me, theText, tempSrcHFSPath) 323 --------------------- 324 325 mDoShellCmd(me, QUOTE & editor & QUOTE && tempSrcPath & waitparam) 326 327 end if 328 329 end if 330 end repeat 331 end repeat 332 333 end 334 335 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 336 337 on mReImport_text_Opened_In_ext_editor me 338 mReImport_text_Opened_In_BBedit me 339 end 340 341 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 342 343 on mReImport_text_Opened_In_BBedit me 344 345 cl = the activecastlib 346 sel = the selection of castlib cl 347 348 repeat with sub in sel 349 repeat with mem = sub[1] to sub[2] 350 351 memref = member(mem,cl) 189 352 190 353 theName = memref.name … … 193 356 end if 194 357 195 delim = the last char of the moviepath 196 olddelim = the itemdelimiter 197 the itemdelimiter = delim 198 hd = item 1 of getosdirectory() 199 200 tempSrcPath = hd & delim & "tmp" & delim & theName & ".ls" 201 the itemdelimiter = olddelim 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 202 375 203 376 theText = mGetTextFromFile(me, tempSrcPath) 204 377 205 378 if length(theText) > 0 then 379 380 theText = mForceMacLineBreaks(me, theText) 206 381 207 382 case memref.type of … … 216 391 end repeat 217 392 393 end 394 395 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 396 397 on mForceMacLineBreaks me, theText 398 rettext = "" 399 olddelim = the itemdelimiter 400 the itemdelimiter = numToChar(10) 401 thirteen = numToChar(13) 402 num = the number of items of theText 403 repeat with n = num down to 1 404 i = item n of theText 405 put i after rettext 406 if the last char of i <> thirteen then put thirteen after rettext 407 end repeat 408 the itemdelimiter = olddelim 409 return rettext 218 410 end 219 411 … … 544 736 end if 545 737 end 738 739 740 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 741 742 on mLiveCompare_SelectedScript me, convertLineBreaksToUnix 743 744 cl = the activecastlib 745 sel = the selection of castlib cl 746 747 if count(sel) > 0 then 748 memref1 = member(sel[1][1], cl) 749 if sel[1][2] <> sel[1][1] then 750 memref2 = member(sel[1][2], cl) 751 else 752 if count(sel) < 2 then 753 alert "Please select two castmembers!" 754 exit 755 end if 756 memref2 = member(sel[2][1], cl) 757 end if 758 else 759 alert "Please select two castmembers!" 760 exit 761 end if 762 763 memtype = memref1.type 764 if [#script, #field, #text].getPos(memtype) < 1 then 765 alert "The members must be either #script, #field or #text members!" 766 exit 767 else 768 case memtype of 769 770 ----------------------- 771 #script: 772 ext1 = ".ls" 773 st1 = memref1.scripttext 774 775 ----------------------- 776 #text: 777 ext1 = ".html" 778 st1 = memref1.html 779 780 ----------------------- 781 otherwise: 782 ext1 = ".txt" 783 st1 = memref1.text 784 785 end case 786 787 end if 788 789 memtype = memref2.type 790 if [#script, #field, #text].getPos(memtype) < 1 then 791 alert "The members must be either #script, #field or #text members!" 792 exit 793 else 794 case memtype of 795 796 ----------------------- 797 #script: 798 ext2 = ".ls" 799 st2 = memref2.scripttext 800 801 ----------------------- 802 #text: 803 ext2 = ".html" 804 st2 = memref2.html 805 806 ----------------------- 807 otherwise: 808 ext2 = ".txt" 809 st2 = memref2.text 810 811 end case 812 end if 813 814 if not(the platform contains "mac") then 815 816 bbdiffpath = mGetSVNDiffBinaryPath(me) 817 818 if length(bbdiffpath) < 1 then exit 819 820 isMac = 0 821 else 822 isMac = 1 823 bbdiffpath = mFindUnixAppInPath(me, "bbdiff") 824 if length(bbdiffpath) < 1 then 825 alert "This function only works with BBDiff, a command line tool provided by BBEdit. Consider installing BBEdits command line tools, it is really helpful." 826 exit 827 end if 828 829 end if 830 831 832 if mCheckForXtra(me, "ff_shell") = 0 then 833 if mCheckForXtra(me, "Shell") = 0 then 834 mShellXtraMissing me 835 exit 836 end if 837 end if 838 839 840 name1 = memref1.name & "_m" & memref1.memberNum & "_c" & memref1.castlibnum 841 fname1 = mGetTempFilePath(me, name1 & ext1) 842 843 name2 = memref2.name & "_m" & memref2.memberNum & "_c" & memref2.castlibnum 844 fname2 = mGetTempFilePath(me, name2 & ext2) 845 846 ------------------------------------------ trac subversion support works better with unix linebreaks... 847 if voidP(convertLineBreaksToUnix) then convertLineBreaksToUnix = 1 848 if convertLineBreaksToUnix = "" then convertLineBreaksToUnix = 1 849 850 if convertLineBreaksToUnix = 1 then 851 st1 = mConvertLineBreaksToUnix(me, st1) 852 st2 = mConvertLineBreaksToUnix(me, st2) 853 end if 854 ----------------------------------------- 855 856 857 theResult = mSaveTextToTempFile(me, st1, fname1) 858 theResult = mSaveTextToTempFile(me, st2, fname2) 859 --------------------- 860 861 862 if isMac then 863 864 865 theResult = mDoShellCmd(me, bbdiffpath & " --ignore-curly-quotes --ignore-spaces --wait --resume " "E& mConvertHFS2Unix(me, fname1) "E&"E& mConvertHFS2Unix(me, fname2) "E && "2>&1", RETURN, 0, 1) 866 867 -- since we used the --wait and the --resume switch, we will only come to this line AFTER the diff process in bbedit is finished 868 869 if count(theResult) > 0 then 870 if theResult[1] contains "no such file or directory" then 871 put theResult[1] 872 else 873 put "No differences found for member: " & memref1.name && "(" & memref1 & ") and " & memref2.name && "(" & memref2 & ")" 874 end if 875 writeBack = 0 876 877 else 878 879 -------- now write the results of the BBEdit diff back into the script members 880 st1 = mGetTextFromFile(me, fname1) 881 st2 = mGetTextFromFile(me, fname2) 882 883 writeBack = 1 884 885 end if 886 887 ---------------------- windows 888 else 889 890 891 theResult = mDoShellCmd(me, QUOTE & bbdiffpath & QUOTE && QUOTE & fname1 "E&"E& fname2 "E, RETURN, 0, 0, 0) 892 893 -------- now write the results of the BBEdit diff back into the script members 894 st1 = mGetTextFromFile(me, fname1) 895 st2 = mGetTextFromFile(me, fname2) 896 897 writeBack = 1 898 end if 899 900 901 if writeBack = 1 then 902 903 904 if convertLineBreaksToUnix = 1 then 905 st1 = mConvertLineBreaksToMac(me, st1) 906 st2 = mConvertLineBreaksToMac(me, st2) 907 end if 908 909 memtype = memref1.type 910 case memtype of 911 ----------------------- 912 #script: 913 memref1.scripttext = st1 914 915 ----------------------- 916 #text: 917 memref1.html = st1 918 919 ----------------------- 920 otherwise: 921 memref1.text = st1 922 923 end case 924 925 memtype = memref2.type 926 case memtype of 927 ----------------------- 928 #script: 929 memref2.scripttext = st2 930 931 ----------------------- 932 #text: 933 memref2.html = st2 934 935 ----------------------- 936 otherwise: 937 memref2.text = st2 938 939 end case 940 941 end if 942 943 944 end 945 546 946 547 947 … … 891 1291 892 1292 893 -- if not(the platform contains "mac") then894 -- alert "Sorry, BBEdit is a mac application!" & RETURN & "If you change this handler to match something appropriate for Windows, please drop me a note. alex@farbflash.de"895 -- exit896 -- end if897 --898 -- if mCheckForXtra(me, "Shell") = 0 then899 -- mShellXtraMissing me900 -- exit901 -- end if902 903 904 1293 bbdiffpath = "" 905 1294 if the platform contains "mac" then … … 925 1314 926 1315 927 928 929 930 1316 cl = the activecastlib 931 1317 sel = the selection of castlib cl … … 946 1332 memname = memref.name 947 1333 comm = memref.comments 948 if comm.length then 1334 1335 if length(comm) < 1 then 1336 -- put memref.name && "(" & memref & ") has no comments - not linked" 1337 else 949 1338 950 1339 aPath = mGetFilePathFromMemberComments(me, memref, isMac, CurrentOSXUserName) 951 1340 952 if length(aPath) > 0 then 1341 if length(aPath) < 1 then 1342 -- put memref.name && "(" & memref & ") has no comments - not linked" 1343 else 953 1344 954 1345 fio = (xtra "fileio").new() 1346 955 1347 if objectP(fio) then 1348 956 1349 fio.openFile(aPath, 0) 957 if fio.status() = 0 then 1350 1351 if fio.status() <> 0 then 1352 put memref.name && "(" & memref & "): Couldn't open file:" && aPath && "fileIO error:" && fio.error(fio.status()) 1353 else 1354 958 1355 vergText = fio.readFile() 959 1356 fio.closeFile() 960 1357 memscr = memref.scripttext 961 if vergText <> memscr then 1358 1359 if vergText = memscr then 1360 put memref.name && "(" & memref & ") has no changes" 1361 else 962 1362 963 1363 isEqual = 0 … … 975 1375 end if 976 1376 977 if isEqual = 0 then 1377 if isEqual <> 0 then 1378 put memref.name && "(" & memref & ") has no changes" 1379 else 978 1380 979 1381 if length(bbdiffpath) < 1 then … … 1009 1411 else 1010 1412 1011 1012 -- tempSrcPath = mDoShellCmd(me, "mktemp -t temp_BBDiff_file1.ls", 1)1013 -- tempSrcPath = tempSrcPath[1]1014 1413 tempSrcPath = "/tmp/temp_BBEdit_file.ls" 1015 1016 -- tempSrcHFSPath = mDoShellCmd(me, "osascript -e" && QUOTE & "return POSIX file \" & QUOTE & tempSrcPath & "\" & QUOTE & " as string" & QUOTE, 1)1017 -- tempSrcHFSPath = tempSrcHFSPath[1]1018 1414 tempSrcHFSPath = mConvertUnix2Hfs(me, tempSrcPath) 1019 1415 1020 1416 mSaveTextToTempFile(me, memref.scripttext, tempSrcHFSPath) 1021 1022 -- comm = memref.comments1023 -- if comm.length then1024 -- if char 1 of comm = "~" then1025 -- put shell_Cmd("echo -n $HOME") into char 1 of comm1026 -- end if1027 -- end if1028 1029 1417 1030 1418 if char 1 of comm = "~" then put "$HOME" into char 1 of comm
Note: See TracChangeset
for help on using the changeset viewer.
