Farbflash projects: Imaging lingo table | 3-D scene list | Find all | Handler menu | Lingo message window

Changeset 76 for trunk/lingosource


Ignore:
Timestamp:
12/07/07 00:24:27 (4 years ago)
Author:
alex
Message:

added new funcion fro roundtrip bbedit

Location:
trunk/lingosource
Files:
12 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/lingosource/castlib1/OSCmenu_Utilities.ls

    r74 r76  
    3636     
    3737    subli.add("Edit in BBEdit") 
    38     pLookUpCommandList.setaprop("Edit in BBEdit", ["mOpen_text_with_BBedit me", "bbedit_Utilities"]) 
     38    pLookUpCommandList.setaprop("Edit in BBEdit", ["mEdit_text_with_BBedit me", "bbedit_Utilities"]) 
     39     
     40    subli.add("Open in BBEdit") 
     41    pLookUpCommandList.setaprop("Open in BBEdit", ["mOpen_text_with_BBedit me", "bbedit_Utilities"]) 
     42     
     43    subli.add("Refresh members edited in BBEdit") 
     44    pLookUpCommandList.setaprop("Refresh members edited in BBEdit", ["mReImport_text_Opened_In_BBedit me", "bbedit_Utilities"]) 
    3945     
    4046    subli.add("Open linked script") 
  • trunk/lingosource/castlib1/alexUtilities.ls

    r74 r76  
    441441     
    442442    -- currently there is a bug in buddy beta with bafilelist, so we hack here... 
    443      
    444     retval = [] 
    445     n = 1 
    446     this = getnthfilenameinfolder(folderpath, n) 
    447     repeat while length(this) > 0 
    448       if length(getnthfilenameinfolder(folderpath & this, 1)) = 0 then retval.add(this) 
    449       n = n + 1 
     443    if mGetFloatVersionNumber(me, the productversion) < 11 then 
     444       
     445      --  -- budApi version: 
     446      retval = baFileList(folderpath, "*.*") 
     447       
     448    else 
     449       
     450      retval = [] 
     451      n = 1 
    450452      this = getnthfilenameinfolder(folderpath, n) 
    451     end repeat 
    452      
    453     --  -- budApi version: 
    454     -- retval = baFileList(folderpath, "*.*") 
     453      repeat while length(this) > 0 
     454        if length(getnthfilenameinfolder(folderpath & this, 1)) = 0 then retval.add(this) 
     455        n = n + 1 
     456        this = getnthfilenameinfolder(folderpath, n) 
     457      end repeat 
     458       
     459    end if 
     460     
    455461     
    456462  else if mCheckForXtra(me, "FileXtra4") = 1 then -- if not buddy then try filextra 
     
    25262532  end if 
    25272533end 
     2534 
     2535-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
     2536 
     2537on mGetFloatVersionNumber me, prodVers 
     2538    offs = offset(".", prodVers) 
     2539    if offs > 0 then 
     2540      intVers = char 1 to offs of prodVers 
     2541      delete char 1 to offs of prodVers 
     2542    else 
     2543      intVers = "" 
     2544    end if 
     2545    cnt = length(prodVers) 
     2546    repeat with n = 1 to cnt 
     2547      c = prodVers.char[n] 
     2548      if integerP(integer(c)) then 
     2549        put c after intVers 
     2550      else if c <> "." then 
     2551        exit repeat 
     2552      end if 
     2553    end repeat 
     2554     
     2555  return value(intVers) 
     2556end 
  • trunk/lingosource/castlib1/bbedit_Utilities.ls

    r74 r76  
    5151end 
    5252 
    53  
    54 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
    55  
    56 on mOpen_text_with_BBedit me 
     53-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
     54 
     55on mEdit_text_with_BBedit me 
     56  mOpen_text_with_BBedit me, 1 
     57end 
     58 
     59-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
     60 
     61on mOpen_text_with_BBedit me, doLiveEdit 
    5762   
    5863  if not(the platform contains "mac") then 
     
    8994      if length(theText) > 0 then 
    9095         
    91         --------------------- 
    92         -- create a temporary file from scripttext: 
    93         -- tempSrcPath = shell_cmd_list("mktemp -t temp_BBEdit_file.ls") 
    94         -- tempSrcPath = tempSrcPath[1] 
    95         tempSrcPath = "/tmp/temp_BBEdit_file.ls" 
    96         tempSrcHFSPath = mDoShellCmd(me, "osascript -e" && QUOTE & "return POSIX file \" & QUOTE & tempSrcPath & "\" & QUOTE & " as string" & QUOTE, 1) 
    97         tempSrcHFSPath = tempSrcHFSPath[1] 
    98         theResult = mSaveTextToTempFile(me, theText, tempSrcHFSPath) 
    99         --------------------- 
    100          
    101         mDoShellCmd(me, "bbedit --wait --resume " & tempSrcPath) 
    102          
    103         theText = mGetTextFromFile(me, tempSrcHFSPath) 
    104          
    105         if theType = #script then 
    106           memref.scripttext = theText 
    107         else if theType = #text then 
    108           memref.html = theText 
    109         else if theType = #field then 
    110           memref.text = theText 
     96         
     97        if doLiveEdit then 
     98          --------------------- 
     99          -- create a temporary file from scripttext: 
     100          -- tempSrcPath = shell_cmd_list("mktemp -t temp_BBEdit_file.ls") 
     101          -- tempSrcPath = tempSrcPath[1] 
     102          tempSrcPath = "/tmp/temp_BBEdit_file.ls" 
     103          tempSrcHFSPath = mDoShellCmd(me, "osascript -e" && QUOTE & "return POSIX file \" & QUOTE & tempSrcPath & "\" & QUOTE & " as string" & QUOTE, 1) 
     104          tempSrcHFSPath = tempSrcHFSPath[1] 
     105          theResult = mSaveTextToTempFile(me, theText, tempSrcHFSPath) 
     106          --------------------- 
     107           
     108          mDoShellCmd(me, "bbedit --wait --resume " & tempSrcPath) 
     109           
     110          theText = mGetTextFromFile(me, tempSrcHFSPath) 
     111           
     112          if theType = #script then 
     113            memref.scripttext = theText 
     114          else if theType = #text then 
     115            memref.html = theText 
     116          else if theType = #field then 
     117            memref.text = theText 
     118          end if 
     119           
     120           
     121        else 
     122           
     123          theName = memref.name 
     124          if length(theName) < 1 then 
     125            theName = "member_" & memref.membernum & "_" & memref.castlibnum 
     126          end if 
     127          --------------------- 
     128          -- create a temporary file from scripttext: 
     129          tempSrcPath = "/tmp/" & theName & ".ls" 
     130          tempSrcHFSPath = mDoShellCmd(me, "osascript -e" && QUOTE & "return POSIX file \" & QUOTE & tempSrcPath & "\" & QUOTE & " as string" & QUOTE, 1) 
     131          tempSrcHFSPath = tempSrcHFSPath[1] 
     132          theResult = mSaveTextToTempFile(me, theText, tempSrcHFSPath) 
     133          --------------------- 
     134           
     135          mDoShellCmd(me, "bbedit " & tempSrcPath) 
     136           
     137           
    111138        end if 
    112139         
     
    128155         
    129156      end if 
     157    end repeat 
     158  end repeat 
     159   
     160end 
     161 
     162 
     163-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
     164 
     165on mReImport_text_Opened_In_BBedit me 
     166   
     167  if not(the platform contains "mac") then 
     168    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" 
     169    exit 
     170  end if 
     171   
     172  cl = the activecastlib 
     173  sel = the selection of castlib cl 
     174   
     175  repeat with sub in sel 
     176    repeat with mem = sub[1] to sub[2] 
     177       
     178      memref = member(mem,cl) 
     179       
     180       
     181      theName = memref.name 
     182      if length(theName) < 1 then 
     183        theName = "member_" & memref.membernum & "_" & memref.castlibnum 
     184      end if 
     185       
     186      delim = the last char of the moviepath 
     187      olddelim = the itemdelimiter 
     188      the itemdelimiter = delim 
     189      hd = item 1 of getosdirectory() 
     190       
     191      tempSrcPath = hd & delim & "tmp" & delim & theName & ".ls" 
     192      the itemdelimiter = olddelim 
     193       
     194      theText = mGetTextFromFile(me, tempSrcPath) 
     195       
     196      if length(theText) > 0 then 
     197         
     198        case memref.type of 
     199          #script: memref.scripttext = theText 
     200          #text: memref.html = theText 
     201          #field: memref.text = theText 
     202        end case 
     203         
     204      end if 
     205       
    130206    end repeat 
    131207  end repeat 
     
    541617        memref.filename = memref.filename 
    542618      else 
    543       if memref.type = #script then 
    544         aPath = mGetFilePathFromMemberComments(me, memref, isMac, CurrentOSXUserName) 
    545         if length(aPath) > 0 then 
    546           dertext = mGetTextFromFile(me, aPath) 
    547           if length(dertext) > 0 then 
    548             put "updating scripttext of member:" memref.name && "(" & memref & ")" 
    549             memref.scripttext = dertext 
     619        if memref.type = #script then 
     620          aPath = mGetFilePathFromMemberComments(me, memref, isMac, CurrentOSXUserName) 
     621          if length(aPath) > 0 then 
     622            dertext = mGetTextFromFile(me, aPath) 
     623            if length(dertext) > 0 then 
     624              put "updating scripttext of member:" memref.name && "(" & memref & ")" 
     625              memref.scripttext = dertext 
     626            end if 
    550627          end if 
    551628        end if 
    552       end if 
    553629      end if 
    554630    end repeat 
     
    913989        comm = memref.comments 
    914990        if comm.length then 
    915          
     991           
    916992          aPath = mGetFilePathFromMemberComments(me, memref, isMac, CurrentOSXUserName) 
    917993           
    918994          if length(aPath) > 0 then 
    919            
    920           fio = (xtra "fileio").new() 
    921           if objectP(fio) then 
    922             fio.openFile(aPath, 0) 
    923             if fio.status() = 0 then 
    924               vergText = fio.readFile() 
    925               fio.closeFile() 
    926               memscr = memref.scripttext 
    927               if vergText <> memscr then 
    928                  
    929                 isEqual = 0 
    930                 if mCheckForXtra(me, "Pregex") = 1 then 
     995             
     996            fio = (xtra "fileio").new() 
     997            if objectP(fio) then 
     998              fio.openFile(aPath, 0) 
     999              if fio.status() = 0 then 
     1000                vergText = fio.readFile() 
     1001                fio.closeFile() 
     1002                memscr = memref.scripttext 
     1003                if vergText <> memscr then 
    9311004                   
    932                   memscrLi = [memscr] 
    933                   pregex_replace(memscrLi, "\s", "ig", "") 
    934                   memscrLi = memscrLi[1] 
     1005                  isEqual = 0 
     1006                  if mCheckForXtra(me, "Pregex") = 1 then 
     1007                     
     1008                    memscrLi = [memscr] 
     1009                    pregex_replace(memscrLi, "\s", "ig", "") 
     1010                    memscrLi = memscrLi[1] 
     1011                     
     1012                    vergTextLi = [vergText] 
     1013                    pregex_replace(vergTextLi, "\s", "ig", "") 
     1014                    vergTextLi = vergTextLi[1] 
     1015                     
     1016                    isEqual = (memscrLi = vergTextLi) 
     1017                  end if 
    9351018                   
    936                   vergTextLi = [vergText] 
    937                   pregex_replace(vergTextLi, "\s", "ig", "") 
    938                   vergTextLi = vergTextLi[1] 
    939                    
    940                   isEqual = (memscrLi = vergTextLi) 
    941                 end if 
    942                  
    943                 if isEqual = 0 then 
    944                    
    945                   if length(bbdiffpath) < 1 then 
     1019                  if isEqual = 0 then 
    9461020                     
    947                      
    948                     if not(the platform contains "mac") then 
    949                       put "-------------------------------------------------------" 
    950                       put RETURN&"neuer = new(#field)"&RETURN&"neuer.text = "&memref&".scripttext"&RETURN&"neuer.copyToClipBoard()"&RETURN&"neuer.erase()"&RETURN 
    951                       put RETURN&"shell_cmd("&QUOTE&"PBPaste | BBedit ; BBedit "&memref.comments&QUOTE&")"&RETURN 
    952                     else 
     1021                    if length(bbdiffpath) < 1 then 
    9531022                       
    954                       if (mCheckForXtra(me, "Shell") + mCheckForXtra(me, "ff_shell")) = 0  then 
     1023                       
     1024                      if not(the platform contains "mac") then 
    9551025                        put "-------------------------------------------------------" 
    9561026                        put RETURN&"neuer = new(#field)"&RETURN&"neuer.text = "&memref&".scripttext"&RETURN&"neuer.copyToClipBoard()"&RETURN&"neuer.erase()"&RETURN 
    9571027                        put RETURN&"shell_cmd("&QUOTE&"PBPaste | BBedit ; BBedit "&memref.comments&QUOTE&")"&RETURN 
    958                          
    9591028                      else 
    9601029                         
    961                         neuer = new(#field) 
    962                         neuer.text = memscr 
    963                         neuer.copyToClipBoard() 
    964                         neuer.erase() 
    965                         mDoShellCmd(me, "PBPaste | BBedit ; BBedit "&memref.comments) 
     1030                        if (mCheckForXtra(me, "Shell") + mCheckForXtra(me, "ff_shell")) = 0  then 
     1031                          put "-------------------------------------------------------" 
     1032                          put RETURN&"neuer = new(#field)"&RETURN&"neuer.text = "&memref&".scripttext"&RETURN&"neuer.copyToClipBoard()"&RETURN&"neuer.erase()"&RETURN 
     1033                          put RETURN&"shell_cmd("&QUOTE&"PBPaste | BBedit ; BBedit "&memref.comments&QUOTE&")"&RETURN 
     1034                           
     1035                        else 
     1036                           
     1037                          neuer = new(#field) 
     1038                          neuer.text = memscr 
     1039                          neuer.copyToClipBoard() 
     1040                          neuer.erase() 
     1041                          mDoShellCmd(me, "PBPaste | BBedit ; BBedit "&memref.comments) 
     1042                           
     1043                        end if 
    9661044                         
    9671045                      end if 
    9681046                       
     1047                    else 
     1048                       
     1049                       
     1050                      tempSrcPath = mDoShellCmd(me, "mktemp -t temp_BBDiff_file1", 1) 
     1051                      tempSrcPath = tempSrcPath[1] 
     1052                      tempSrcHFSPath = mDoShellCmd(me, "osascript -e" && QUOTE & "return POSIX file \" & QUOTE & tempSrcPath & "\" & QUOTE & " as string" & QUOTE, 1) 
     1053                      tempSrcHFSPath = tempSrcHFSPath[1] 
     1054                       
     1055                      mSaveTextToTempFile(me, memref.scripttext, tempSrcHFSPath) 
     1056                       
     1057                      --                    comm = memref.comments 
     1058                      --                    if comm.length then 
     1059                      --                      if char 1 of comm = "~" then 
     1060                      --                        put shell_Cmd("echo -n $HOME") into char 1 of comm 
     1061                      --                      end if 
     1062                      --                    end if 
     1063                       
     1064                      mDoShellCmd(me, bbdiffpath & " --ignore-curly-quotes --ignore-spaces --wait --resume " &QUOTE& tempSrcPath &QUOTE&&QUOTE& comm &QUOTE) 
     1065                       
     1066                      memref.scripttext = mGetTextFromFile(me, tempSrcHFSPath) 
     1067                       
    9691068                    end if 
    970                      
    971                   else 
    972                      
    973                      
    974                     tempSrcPath = mDoShellCmd(me, "mktemp -t temp_BBDiff_file1", 1) 
    975                     tempSrcPath = tempSrcPath[1] 
    976                     tempSrcHFSPath = mDoShellCmd(me, "osascript -e" && QUOTE & "return POSIX file \" & QUOTE & tempSrcPath & "\" & QUOTE & " as string" & QUOTE, 1) 
    977                     tempSrcHFSPath = tempSrcHFSPath[1] 
    978                      
    979                     mSaveTextToTempFile(me, memref.scripttext, tempSrcHFSPath) 
    980                      
    981                     --                    comm = memref.comments 
    982                     --                    if comm.length then 
    983                     --                      if char 1 of comm = "~" then 
    984                     --                        put shell_Cmd("echo -n $HOME") into char 1 of comm 
    985                     --                      end if 
    986                     --                    end if 
    987                      
    988                     mDoShellCmd(me, bbdiffpath & " --ignore-curly-quotes --ignore-spaces --wait --resume " &QUOTE& tempSrcPath &QUOTE&&QUOTE& comm &QUOTE) 
    989                      
    990                     memref.scripttext = mGetTextFromFile(me, tempSrcHFSPath) 
    9911069                     
    9921070                  end if 
    9931071                   
     1072                   
    9941073                end if 
    995                  
    9961074                 
    9971075              end if 
    9981076               
    9991077            end if 
    1000              
    1001           end if 
    10021078          end if 
    10031079        end if 
Note: See TracChangeset for help on using the changeset viewer.