TextMate捆绑过帐代码
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TextMate捆绑过帐代码相关的知识,希望对你有一定的参考价值。
#!/usr/bin/env ruby -wKU # Copyright 2008 Hirotsugu Asari require "xmlrpc/client" CMD = [ ENV['TM_SUPPORT_PATH'] + '/bin/CocoaDialog.app/Contents/MacOS/CocoaDialog' ] def ask_for(item='') if item.to_s.empty? return [] end args = [ 'standard-inputbox','--title "Post Snippet to Snipplr"', "--informative-text 'Enter the new snippets #{item}'", '--string-output', '2>/dev/null' ] return %x{#{(CMD + args).join(" ")}}.split(" ") end if ENV['SNIPPLR_KEY'].nil? args = [ 'ok-msgbox', '--no-cancel', '--title "Snipplr"', '--text "Environment variable SNIPPLR_KEY missing."', '2>/dev/null' ] %x{ #{ (CMD + args).join(" ") } } exit end # Title user_response_for_title = ask_for('title') if user_response_for_title[0] == 'Cancel' exit end # Tags user_response_for_tags = ask_for('tags') if user_response_for_tags[0] == 'Cancel' exit end user_response_for_tags[1] += ' textmatebundle' # shameless self-promotion # Languages user_response_for_langs = nil while user_response_for_langs.nil? args = [ 'inputbox', '--title "Snipplr"', '--informative-text "Choose Language for this snippet"', '--button1 "OK"', '--button2 "Cancel"', '--button3 "Show Legal Languages"', '--string-output', '2>/dev/null' ] user_response_for_langs = %x{ #{ (CMD + args).join(" ") } }.split(" ") if user_response_for_langs[0] == 'Cancel' exit elsif user_response_for_langs[0] == 'Show Legal Languages' informative_text = '' begin known_langs = srv.call('languages.list',ENV['SNIPPLR_KEY']).invert known_langs.sort {|a,b| a[1] <=> b[1]}.each do |k,v| informative_text += "#{k} (#{v}) " end rescue informative_text << 'Failed to obtain known language list' end args = [ 'msgbox', '--title "Snipplr"', '--text "Currently known languages"', '--informative-text "' + informative_text + '"', '--debug', '--button1 "OK"','2>/dev/null' ] %x{ #{ (CMD + args).join(" ") } } user_response_for_langs = nil redo end end # finally ready to post begin srv_response = srv.call('snippet.post',ENV['SNIPPLR_KEY'], user_response_for_title[1], ARGF.to_a.to_s, user_response_for_tags[1], user_response_for_langs[1]) print "Successfully posted '#{user_response_for_title[1]}'" rescue args = [ 'ok-msgbox', '--no-cancel', '--title "Snipplr"', "--text 'Posting new snippet failed: #{$!}'" , '2>/dev/null' ] %x{#{(CMD + args).join(" ")}} end
以上是关于TextMate捆绑过帐代码的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Textmate 上为 Sencha 启用代码完成/代码感知