Revision: 6625
Updated Code
at June 4, 2008 06:50 by dbug13
Updated Code
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']
Revision: 6624
Updated Code
at June 3, 2008 15:36 by dbug13
Updated Code
SUPPORT = ENV['TM_SUPPORT_PATH'] # Retrieves the path of textmates ruby modules DIALOG = ENV['DIALOG'] # retrieves the tm_dialog command require SUPPORT + '/lib/escape' # 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']
Revision: 6623
Updated Code
at June 3, 2008 15:31 by dbug13
Updated Code
SUPPORT = ENV['TM_SUPPORT_PATH'] # Retrieves the path of textmates ruby modules DIALOG = ENV['DIALOG'] # retrieves the tm_dialog command require SUPPORT + '/lib/escape' # 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" } # transform an associative array into a plist (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']
Revision: 6622
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 3, 2008 15:30 by dbug13
Initial Code
SUPPORT = ENV['TM_SUPPORT_PATH'] # Retrieves the path of textmates ruby modules DIALOG = ENV['DIALOG'] # retrieves the tm_dialog command require SUPPORT + '/lib/escape' # 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" } # transform an associative array into a plist (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']
Initial URL
Initial Description
Initial Title
Use TextMate's tm_dialog command to create user defined menus
Initial Tags
textmate, ruby
Initial Language
Ruby