/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. if [[ ${#SKIN} &lt; 1 ]] ; then
  10. SKIN="iPhone"
  11. fi
  12. if [[ ${#SDK_PATH} &gt; 0 ]] ; then
  13. CORONA_SIM_PATH=$SDK_PATH"/Corona Terminal"
  14. else
  15. CORONA_SIM_PATH="/Applications/CoronaSDK/Corona Terminal"
  16. fi
  17. if [[ ${#TM_PROJECT_DIRECTORY} &gt; 0 ]] ; then
  18. TARGET_DIR=$TM_PROJECT_DIRECTORY
  19. else
  20. TARGET_DIR=$TM_DIRECTORY
  21. fi
  22. # In order for the simulator relaunch to work, "Enable access for assistive devices" must be selected in System Preferences &gt; Universal Access.
  23. osascript &lt;&lt;- APPLESCRIPT
  24. on appIsRunning(appName)
  25. tell application "System Events" to (name of processes) contains appName
  26. end appIsRunning
  27. on selectAppMenuItem(app_name, menu_name, menu_item)
  28. try
  29. -- bring the target application to the front
  30. tell application app_name
  31. activate
  32. end tell
  33. tell application "System Events"
  34. tell process app_name
  35. tell menu bar 1
  36. tell menu bar item menu_name
  37. tell menu menu_name
  38. click menu item menu_item
  39. end tell
  40. end tell
  41. end tell
  42. end tell
  43. end tell
  44. return true
  45. on error error_message
  46. return false
  47. end try
  48. end selectAppMenuItem
  49. if appIsRunning("Corona Simulator") then
  50. selectAppMenuItem("Corona Simulator","File","Relaunch")
  51. else
  52. tell application "Terminal"
  53. do script "'$CORONA_SIM_PATH' -project $TM_PROJECT_DIRECTORY -skin $SKIN"
  54. end tell
  55. end if
  56. APPLESCRIPT</string>
  57. <key>input</key>
  58. <string>none</string>
  59. <key>keyEquivalent</key>
  60. <string>@r</string>
  61. <key>name</key>
  62. <string>Run Simulator</string>
  63. <key>output</key>
  64. <string>discard</string>
  65. <key>scope</key>
  66. <string>source.lua</string>
  67. <key>uuid</key>
  68. <string>1831E774-8AF9-4EF0-BE93-11B077CC4DC2</string>
  69. </dict>
  70. </plist>