# Encoding: UTF-8

[{beforeRunningCommand: "saveModifiedFiles",
  command: "ruby \"$TM_BUNDLE_SUPPORT/Tools/build_with_mtasc.rb\"",
  input: "none",
  keyEquivalent: "@r",
  name: "Build With MTASC",
  output: "discard",
  scope: "source.actionscript.2",
  uuid: "E0105691-3033-43C1-A4A2-4C2785446748"},
 {beforeRunningCommand: "saveModifiedFiles",
  command: 
   "# In order to use this command, you need this to install flashcommand:\n# http://www.markme.com/mesh/archives/004419.cfm\n#\n#\n# You can optionally set these shell variables in the project information:\n#\n# FLASH_FLA_PATH     \t/path/to/the/fla/file\n# FLASH_TEST_URL     \thttp://localhost/my_page_displaying_the_swf.php\n# FLASH_SWF_SAVE_PATH \t/path/where/copy/the/compiled/swf/file if successful\n#\n# If FLASH_FLA_PATH is not set, the selected .fla file in the project drawer will be used.\n# If FLASH_TEST_URL is not set, the resulting .swf is used directly\n#\n\n. \"$TM_SUPPORT_PATH/lib/webpreview.sh\"\nhtml_header \"Build in Flash\"\n\nrequire_cmd flashcommand\n\nSWF=\"/tmp/temp.swf\"\nFLASHCOMMAND=flashcommand\n\n# if a .fla file is selected, build it\n# if not, try to build $FLASH_FLA_PATH\n\nif [ \"${TM_SELECTED_FILE##*.}\" == \"fla\" ]\nthen\n\tFLA=\"$TM_SELECTED_FILE\"\nelif [ $FLASH_FLA_PATH ]\nthen\n\tFLA=\"$FLASH_FLA_PATH\"\nfi\n\nresult=`\"$FLASHCOMMAND\" -e -s \"$FLA\" -o \"$SWF\"`\n\n#flashcommand output is very dirty and windoze like. Let's format it!\n\"${TM_RUBY:-ruby}\" \"${TM_BUNDLE_SUPPORT}/formatBuildInFlashOutput.rb\" \"$result\"\n\nif [ \"$?\" == 0 ]\nthen\n\tif [ $FLASH_SWF_SAVE_PATH ]\n\tthen\n\t\tcp \"$SWF\" \"$FLASH_SWF_SAVE_PATH\"\n\tfi\n\n\tif [ $FLASH_TEST_URL ]\n\tthen\n\t\topen \"$FLASH_TEST_URL\"\n\telse\n\t\tif [ $FLASH_SWF_SAVE_PATH ]\n\t\tthen\n\t\t\topen \"$FLASH_SWF_SAVE_PATH\"\n\t\telse\n\t\t\topen \"$SWF\"\n\t\tfi\n\tfi\nfi",
  fileCaptureRegister: "2",
  input: "none",
  keyEquivalent: "@b",
  lineCaptureRegister: "3",
  name: "Build in Flash",
  output: "showAsHTML",
  scope: "source.actionscript.2",
  uuid: "2197A196-78E3-11D9-8177-000A95C5F126"},
 {beforeRunningCommand: "nop",
  command: 
   "#Check that flasm has been installed, if not warn the user.\nrequire_cmd \"flasm\" \"To view the disassembled bytecode for the selected .swf please install flasm in one of the locations below.<br><br>usr/local/bin is recommended.<br><br>Flasm can be found at <a href=\\\"http://www.nowrap.de/flasm.html\\\">http://www.nowrap.de/flasm.html</a>.\"\n\n#Check a swf is selected otherwise show tooltip.\nswfSelected=$( echo $TM_SELECTED_FILE | grep -i .swf )\nif [ \"$swfSelected\" == \"\" ]; then\n\techo \"Please select a swf file from the project drawer.\"\n\texit 206; \nfi\n\n#process the swf with flasm.\nflasm -d \"$TM_SELECTED_FILE\"",
  input: "none",
  keyEquivalent: "~",
  name: "Disassemble .SWF",
  output: "openAsNewDocument",
  scope: "source.actionscript",
  uuid: "022C9B78-88E9-11D9-9236-000A95C5F126"},
 {beforeRunningCommand: "nop",
  command: "\"$TM_BUNDLE_SUPPORT/Tools/asd.rb\"",
  dontFollowNewOutput: "1",
  fallbackInput: "word",
  input: "selection",
  keyEquivalent: "^h",
  name: "Find in Actionscript Dictionary",
  output: "discard",
  scope: "source.actionscript.2 ",
  uuid: "8B98F650-78F7-11D9-B2B4-000A95C5F126"},
 {beforeRunningCommand: "nop",
  command: 
   "cd \"$TM_PROJECT_DIRECTORY\"\ncp \"$TM_BUNDLE_SUPPORT/mtasc.yaml\" .\nmate mtasc.yaml",
  input: "none",
  name: "Install MTASC Support Files",
  output: "discard",
  scope: "source.actionscript.2",
  uuid: "FDF81E69-0EE5-4E32-A721-86FE17BF8A6F"},
 {beforeRunningCommand: "nop",
  command: 
   ". \"$TM_SUPPORT_PATH/lib/webpreview.sh\"\nhtml_header \"MTASC Help\" \"ActionScript\"\n\"$TM_SUPPORT_PATH/lib/markdown_to_help.rb\" \"$TM_BUNDLE_SUPPORT/help.markdown\"\nhtml_footer",
  input: "none",
  name: "MTASC Help",
  output: "showAsHTML",
  scope: "source.actionscript.2",
  uuid: "07095A35-FA36-4BA2-BED6-A369EA5F0A73"},
 {beforeRunningCommand: "nop",
  command: 
   "cat <<SNIPPET\nfunction ${TM_SELECTED_TEXT:-$TM_CURRENT_WORD}(\\${1:args}) {\n\t\\$0\n}\nSNIPPET",
  fallbackInput: "word",
  input: "selection",
  keyEquivalent: "$\n",
  name: "New Function",
  output: "insertAsSnippet",
  scope: "source.actionscript.2",
  uuid: "FEAF33F2-F8C2-463F-A76A-BA75D0645FC5"},
 {beforeRunningCommand: "saveModifiedFiles",
  command: 
   "# publishes the document which is open in flash\n\necho \"flash.getDocumentDOM().publish()\" > /tmp/test.jsfl;\nopen /tmp/test.jsfl;",
  input: "none",
  keyEquivalent: "@b",
  name: "Publish Movie",
  output: "discard",
  scope: "source.actionscript",
  uuid: "6EE297DB-83BF-11D9-AD5A-000A95C5F126"},
 {beforeRunningCommand: "nop",
  command: "\"$TM_BUNDLE_SUPPORT/Tools/functionsig.pl\"",
  fallbackInput: "word",
  input: "selection",
  keyEquivalent: "^H",
  name: "Show AS Function Signature",
  output: "showAsTooltip",
  scope: "source.actionscript.2",
  uuid: "7CDA9C8D-82C1-11D9-8357-000A95C5F126"},
 {beforeRunningCommand: "saveModifiedFiles",
  command: 
   "# assumes the .FLA file is already open\n\necho \"flash.getDocumentDOM().testMovie()\" > /tmp/test.jsfl;\nopen /tmp/test.jsfl;",
  input: "none",
  keyEquivalent: "@r",
  name: "Test Movie",
  output: "discard",
  scope: "source.actionscript.2",
  uuid: "BE332E85-83B1-11D9-AD5A-000A95C5F126"},
 {beforeRunningCommand: "saveActiveFile",
  command: 
   "#!/usr/bin/env ruby\n\nrequire 'open3'\nrequire ENV[\"TM_SUPPORT_PATH\"] + \"/lib/web_preview\"\nrequire ENV['TM_SUPPORT_PATH'] + \"/lib/exit_codes\"\n\nfilename = ENV['TM_FILEPATH']\n\ncmd = \"'\#{ENV['TM_BUNDLE_SUPPORT']}/bin/mtasc' '\#{filename}'\"\n\nstdin, stdout, stderr = Open3.popen3(cmd)\n\nwarnings = []\nerrors = []\nwhile err = stderr.gets\nif err[0, 10] == 'Warning : '\n  warnings.push(err.chomp)\nelse\n  m = /(.+):([0-9]+): characters ([0-9]+)-([0-9]+) : (.+)/.match(err)\n  if m != nil\n    if /^\\//.match(m[1])\n      real_path = m[1]\n    else\n      real_path = Dir.pwd + \"/\" + m[1]\n    end\n    a = \"txmt://open?url=file://\#{real_path}&line=\#{m[2]}&column=\#{m[3].to_i + 1}\"\n    err = \"<a href=\\\"\#{a}\\\">\#{File.basename(m[1])}, Line: \#{m[2]} Column: \#{m[3].to_i + 1} - \#{m[5]}</a>\"\n  end\n  errors.push(err.chomp)\nend\nend\nif errors.empty? && warnings.empty?\nputs \"Syntax Ok\"\nTextMate.exit_show_tool_tip\nelse\nhtml_header(\"Validating Syntax for \#{File.basename(filename)}\",\"Validate Syntax\")\nif !errors.empty?\n  puts \"<h2>Errors</h2>\"\n  puts errors\nend\nif !warnings.empty?\n  puts \"<h2>Warnings</h2>\"\n  puts warnings\nend\nhtml_footer\nTextMate.exit_show_html\nend",
  input: "none",
  keyEquivalent: "^V",
  name: "Validate Syntax",
  output: "discard",
  scope: "source.actionscript.2",
  uuid: "C8F898B5-87AD-443C-BBA1-9B611B6413A9"}]
