1

Unity3d では、アプリケーションの設定で外部スクリプト エディターを設定できます。そこで、applescript を使用して独自のエディターを起動したいと考えています。このアップルスクリプトはこれまでのところうまく機能していますが、行番号にジャンプできませんでした。

Unity によると、「行番号は AppleEvent のパラメーターを介して送信する必要があります。typeChar および keyAEPosition ('kpos') である必要があります。このパラメーターを介して送信される構造は、次のレイアウトを持ちます。」

struct TheSelectionRange 
{
    short unused1; // 0 (not used)
    short lineNum; // line to select (<0 to specify range)
    long startRange; // start of selection range (if line < 0)
    long endRange; // end of selection range (if line < 0)
    long unused2; // 0 (not used)
    long theDate; // modification date/time
};

「lineNum には正しい行を入力する必要があります。他のフィールドには 0 と -1 以外は入力されません。」

では、なぜ私の入力からこれが何も表示されないのでしょうか? このアップルイベントをキャプチャするにはどうすればよいですか?

私のスクリプト:

on run input
    set element to item 1 of input
    if (element is in {{}, {""}, ""}) then
        return
    else
        tell application "System Events"
            set ProcessList to name of every process
            if "iTerm" is in ProcessList then
                set iterm_running to true
            else
                set iterm_running to false
            end if
            log iterm_running
        end tell
        tell application "iTerm"
            activate
            if (count terminal) < 1 then
                set term to (make new terminal)
            else
                set term to current terminal
            end if
            tell term
                set create_session to false
                try
                    do shell script ("/usr/local/bin/vim --servername UNITY --remote-send ''")
                    set create_session to false
                on error errorMessage number errorNumber
                    set create_session to true
                end try

                if iterm_running then
                    if create_session then
                        launch session "Default Session"
                        activate current session
                        tell current session
                            set name to "Unity"
                            write text "/usr/local/bin/vim --servername UNITY --remote-silent \"$(echo \"/Volumes/" & input & "\" | tr : /)\""
                        end tell
                    else
                        do shell script ("/usr/local/bin/vim --servername UNITY --remote-silent \"$(echo \"/Volumes/" & input & "\" | tr : /)\"")
                    end if
                else
                    activate current session
                    tell current session
                        set name to "Unity"
                        write text "/usr/local/bin/vim --servername UNITY --remote-silent \"$(echo \"/Volumes/" & input & "\" | tr : /)\""
                    end tell
                end if
            end tell
        end tell
    end if
    return input
end run
4

1 に答える 1

0

open イベントを処理すると、行番号を含むいくつかのパラメーターが表示されます。

on open (x,y)
  display dialog x
  display dialog y
  -- use x and y in your own script
end open
于 2013-07-08T15:52:10.933 に答える