使用TextMate&ŧ039;的tmŧdialog命令创建用户定义的菜单
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用TextMate&ŧ039;的tmŧdialog命令创建用户定义的菜单相关的知识,希望对你有一定的参考价值。
SUPPORT = ENV['TM_SUPPORT_PATH'] # Retrieves the path of textmates ruby modules DIALOG = ENV['DIALOG'] # retrieves the tm_dialog command require SUPPORT + '/lib/escape' require SUPPORT + '/lib/osx/plist' # Set up your menu items # Create an array of associative arrays that will hold your menu items # # NOTE: the key names of the associative array are: # title: The menu Title # path: The value that is associated to the selected item # # When you select a menu item tm_dialog retuns both the title and path # of the selected menu item items = [] items << { "title" => "Macs", "path" => "Rule" } items << { "title" => "Windows", "path" => "Stinks" } # Create a container associative array to hold your menu items # # transform an associative array into a plist (Property List, which is just an XML file). to_plist appears # to be an extention that textmate loads up automatically plist = {'menuItems' => items}.to_plist # Run the tm_dialog command and load the result as a parsed property list. # NOTE: e_sh is provided by the escape module. res = OSX::PropertyList::load(`#{e_sh(DIALOG)} -up #{e_sh(plist)}`) # simply display the returned path of the selected menu item puts res['selectedMenuItem']['path']
以上是关于使用TextMate&ŧ039;的tmŧdialog命令创建用户定义的菜单的主要内容,如果未能解决你的问题,请参考以下文章