PageRenderTime 55ms CodeModel.GetById 52ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Commands/Run Simulator.tmCommand

http://github.com/osadchuk/Corona-SDK.tmbundle
Unknown | 79 lines | 70 code | 9 blank | 0 comment | 0 complexity | 094b97cea8468c1032238bba4451b18e MD5 | raw file
 1<?xml version="1.0" encoding="UTF-8"?>
 2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 3<plist version="1.0">
 4<dict>
 5	<key>beforeRunningCommand</key>
 6	<string>saveModifiedFiles</string>
 7	<key>command</key>
 8	<string>#!/bin/bash
 9
10if [[ ${#SKIN} &lt; 1 ]] ; then
11  SKIN="iPhone"
12fi
13
14if [[ ${#SDK_PATH} &gt; 0 ]] ; then
15  CORONA_SIM_PATH=$SDK_PATH"/Corona Terminal"
16else
17  CORONA_SIM_PATH="/Applications/CoronaSDK/Corona Terminal"
18fi
19
20if [[ ${#TM_PROJECT_DIRECTORY} &gt; 0 ]] ;  then
21  TARGET_DIR=$TM_PROJECT_DIRECTORY
22else
23  TARGET_DIR=$TM_DIRECTORY
24fi
25
26# In order for the simulator relaunch to work, "Enable access for assistive devices" must be selected in System Preferences &gt; Universal Access.
27
28osascript &lt;&lt;- APPLESCRIPT
29
30	on appIsRunning(appName)
31		tell application "System Events" to (name of processes) contains appName
32	end appIsRunning
33
34	on selectAppMenuItem(app_name, menu_name, menu_item)
35		 try
36		 -- bring the target application to the front
37			tell application app_name
38				 activate
39 			end tell
40			tell application "System Events"
41 				tell process app_name
42 					tell menu bar 1
43 						tell menu bar item menu_name
44 							tell menu menu_name
45 								click menu item menu_item
46 							end tell
47 						end tell
48 					end tell
49 				end tell
50 			end tell
51 			return true
52 			on error error_message
53 			return false
54 		end try
55	end selectAppMenuItem
56
57	if appIsRunning("Corona Simulator") then
58		selectAppMenuItem("Corona Simulator","File","Relaunch")
59	else
60		tell application "Terminal"
61		do script "'$CORONA_SIM_PATH' -project $TM_PROJECT_DIRECTORY -skin $SKIN"
62		end tell
63	end if
64
65APPLESCRIPT</string>
66	<key>input</key>
67	<string>none</string>
68	<key>keyEquivalent</key>
69	<string>@r</string>
70	<key>name</key>
71	<string>Run Simulator</string>
72	<key>output</key>
73	<string>discard</string>
74	<key>scope</key>
75	<string>source.lua</string>
76	<key>uuid</key>
77	<string>1831E774-8AF9-4EF0-BE93-11B077CC4DC2</string>
78</dict>
79</plist>