Changeset 794
- Timestamp:
- 10/28/07 22:57:22 (6 years ago)
- Location:
- lang/ruby/Amalgam
- Files:
-
- 1 added
- 9 modified
-
Amalgam.xcodeproj/cho45.mode1 (modified) (17 diffs)
-
Amalgam.xcodeproj/cho45.pbxuser (modified) (2 diffs)
-
Amalgam.xcodeproj/project.pbxproj (modified) (4 diffs)
-
AppController.rb (modified) (10 diffs)
-
English.lproj/MainMenu.nib/info.nib (modified) (1 diff)
-
English.lproj/MainMenu.nib/keyedobjects.nib (modified) (previous)
-
plugin_base.rb (added)
-
plugins/applications.rb (modified) (1 diff)
-
plugins/firefox.rb (modified) (1 diff)
-
plugins/prefpanes.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/ruby/Amalgam/Amalgam.xcodeproj/cho45.mode1
r754 r794 257 257 <array> 258 258 <string>29B97314FDCFA39411CA2CEA</string> 259 <string>080E96DDFE201D6D7F000001</string> 259 260 <string>29B97317FDCFA39411CA2CEA</string> 260 261 <string>1C37FABC05509CD000000102</string> … … 263 264 <array> 264 265 <array> 265 <integer>4</integer> 266 <integer>3</integer> 266 <integer>1</integer> 267 267 <integer>0</integer> 268 268 </array> … … 369 369 <key>TableOfContents</key> 370 370 <array> 371 <string>745 815A30CD31BD2009F19BA</string>371 <string>745CBB1F0CD4C841005D7A02</string> 372 372 <string>1CE0B1FE06471DED0097A5F4</string> 373 <string>745 815A40CD31BD2009F19BA</string>373 <string>745CBB200CD4C841005D7A02</string> 374 374 <string>1CE0B20306471E060097A5F4</string> 375 375 <string>1CE0B20506471E060097A5F4</string> … … 505 505 <key>WindowOrderList</key> 506 506 <array> 507 <string>745CBB210CD4C841005D7A02</string> 507 508 <string>/Users/cho45/coderepos/lang/ruby/Amalgam/Amalgam.xcodeproj</string> 509 <string>1C0AD2B3069F1EA900FABCE6</string> 508 510 </array> 509 511 <key>WindowString</key> … … 512 514 <array> 513 515 <dict> 516 <key>FirstTimeWindowDisplayed</key> 517 <false/> 514 518 <key>Identifier</key> 515 519 <string>windowTool.build</string> 520 <key>IsVertical</key> 521 <true/> 516 522 <key>Layout</key> 517 523 <array> … … 525 531 <string>1CD0528F0623707200166675</string> 526 532 <key>PBXProjectModuleLabel</key> 527 <string><No Editor></string> 528 <key>PBXSplitModuleInNavigatorKey</key> 529 <dict> 530 <key>Split0</key> 531 <dict> 532 <key>PBXProjectModuleGUID</key> 533 <string>1CD052900623707200166675</string> 534 </dict> 535 <key>SplitCount</key> 536 <string>1</string> 537 </dict> 533 <string></string> 538 534 <key>StatusBarVisibility</key> 539 < integer>1</integer>535 <true/> 540 536 </dict> 541 537 <key>GeometryConfiguration</key> 542 538 <dict> 543 539 <key>Frame</key> 544 <string>{{0, 0}, {500, 21 5}}</string>540 <string>{{0, 0}, {500, 218}}</string> 545 541 <key>RubberWindowFrame</key> 546 <string> 192 257 500 500 0 0 1280 1002</string>542 <string>316 230 500 500 0 0 1280 778 </string> 547 543 </dict> 548 544 <key>Module</key> … … 552 548 </dict> 553 549 <dict> 554 <key>BecomeActive</key>555 <integer>1</integer>556 550 <key>ContentConfiguration</key> 557 551 <dict> … … 559 553 <string>XCMainBuildResultsModuleGUID</string> 560 554 <key>PBXProjectModuleLabel</key> 561 <string>Build</string> 555 <string>ビルド</string> 556 <key>XCBuildResultsTrigger_Collapse</key> 557 <integer>1021</integer> 558 <key>XCBuildResultsTrigger_Open</key> 559 <integer>1011</integer> 562 560 </dict> 563 561 <key>GeometryConfiguration</key> 564 562 <dict> 565 563 <key>Frame</key> 566 <string>{{0, 22 2}, {500, 236}}</string>564 <string>{{0, 223}, {500, 236}}</string> 567 565 <key>RubberWindowFrame</key> 568 <string> 192 257 500 500 0 0 1280 1002</string>566 <string>316 230 500 500 0 0 1280 778 </string> 569 567 </dict> 570 568 <key>Module</key> … … 575 573 </array> 576 574 <key>Proportion</key> 577 <string>45 8pt</string>575 <string>459pt</string> 578 576 </dict> 579 577 </array> … … 585 583 </array> 586 584 <key>StatusbarIsVisible</key> 587 < integer>1</integer>585 <true/> 588 586 <key>TableOfContents</key> 589 587 <array> 590 <string> 1C78EAA5065D492600B07095</string>591 <string> 1C78EAA6065D492600B07095</string>588 <string>745CBB210CD4C841005D7A02</string> 589 <string>745CBB220CD4C841005D7A02</string> 592 590 <string>1CD0528F0623707200166675</string> 593 591 <string>XCMainBuildResultsModuleGUID</string> … … 596 594 <string>xcode.toolbar.config.build</string> 597 595 <key>WindowString</key> 598 <string>192 257 500 500 0 0 1280 1002 </string> 596 <string>316 230 500 500 0 0 1280 778 </string> 597 <key>WindowToolGUID</key> 598 <string>745CBB210CD4C841005D7A02</string> 599 <key>WindowToolIsVisible</key> 600 <false/> 599 601 </dict> 600 602 <dict> … … 856 858 </dict> 857 859 <dict> 860 <key>FirstTimeWindowDisplayed</key> 861 <false/> 858 862 <key>Identifier</key> 859 863 <string>windowTool.run</string> 864 <key>IsVertical</key> 865 <true/> 860 866 <key>Layout</key> 861 867 <array> … … 871 877 <string>1CD0528B0623707200166675</string> 872 878 <key>PBXProjectModuleLabel</key> 873 <string> Run</string>879 <string>実行</string> 874 880 <key>Runner</key> 875 881 <dict> … … 886 892 <key>sizes</key> 887 893 <array> 888 <string>{{0, 0}, { 493, 167}}</string>889 <string>{{0, 17 6}, {493, 267}}</string>894 <string>{{0, 0}, {367, 168}}</string> 895 <string>{{0, 173}, {367, 270}}</string> 890 896 </array> 891 897 </dict> … … 902 908 <key>sizes</key> 903 909 <array> 904 <string>{{0, 0}, {40 5, 443}}</string>905 <string>{{41 4, 0}, {514, 443}}</string>910 <string>{{0, 0}, {406, 443}}</string> 911 <string>{{411, 0}, {517, 443}}</string> 906 912 </array> 907 913 </dict> … … 911 917 <dict> 912 918 <key>Frame</key> 913 <string>{{0, 0}, {4 60, 159}}</string>919 <string>{{0, 0}, {459, 159}}</string> 914 920 <key>RubberWindowFrame</key> 915 <string>316 696 459 200 0 0 1280 1002</string>921 <string>316 530 459 200 0 0 1280 778 </string> 916 922 </dict> 917 923 <key>Module</key> … … 932 938 </array> 933 939 <key>StatusbarIsVisible</key> 934 < integer>1</integer>940 <true/> 935 941 <key>TableOfContents</key> 936 942 <array> 937 943 <string>1C0AD2B3069F1EA900FABCE6</string> 938 <string> 1C0AD2B4069F1EA900FABCE6</string>944 <string>745CBB230CD4C841005D7A02</string> 939 945 <string>1CD0528B0623707200166675</string> 940 <string> 1C0AD2B5069F1EA900FABCE6</string>946 <string>745CBB240CD4C841005D7A02</string> 941 947 </array> 942 948 <key>ToolbarConfiguration</key> 943 949 <string>xcode.toolbar.config.run</string> 944 950 <key>WindowString</key> 945 <string>316 696 459 200 0 0 1280 1002</string>951 <string>316 530 459 200 0 0 1280 778 </string> 946 952 <key>WindowToolGUID</key> 947 953 <string>1C0AD2B3069F1EA900FABCE6</string> 948 954 <key>WindowToolIsVisible</key> 949 < integer>0</integer>955 <true/> 950 956 </dict> 951 957 <dict> -
lang/ruby/Amalgam/Amalgam.xcodeproj/cho45.pbxuser
r754 r794 36 36 ); 37 37 }; 38 PBXPerProjectTemplateStateSaveDate = 215 161437;39 PBXWorkspaceStateSaveDate = 215 161437;38 PBXPerProjectTemplateStateSaveDate = 215271155; 39 PBXWorkspaceStateSaveDate = 215271155; 40 40 }; 41 41 sourceControlManager = 74A87A1F0CD159CB00A3470F /* Source Control */; … … 62 62 debuggerPlugin = GDBDebugging; 63 63 disassemblyDisplayState = 0; 64 dylibVariantSuffix = ""; 64 65 enableDebugStr = 1; 65 66 environmentEntries = ( -
lang/ruby/Amalgam/Amalgam.xcodeproj/project.pbxproj
r754 r794 15 15 4DDCA70D0ACC9A6100E082CE /* RubyCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E8F5E24E03AEB6EC03A81C6F /* RubyCocoa.framework */; }; 16 16 745815A00CD31B04009F19BA /* plugins in Resources */ = {isa = PBXBuildFile; fileRef = 7458159C0CD31B04009F19BA /* plugins */; }; 17 745CBB1D0CD4C709005D7A02 /* plugin_base.rb in Resources */ = {isa = PBXBuildFile; fileRef = 745CBB1C0CD4C709005D7A02 /* plugin_base.rb */; }; 17 18 747D3D2F0CD26D5200284FB4 /* icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 747D3D2E0CD26D5200284FB4 /* icon.icns */; }; 18 19 74A87A220CD159D000A3470F /* AppController.rb in Resources */ = {isa = PBXBuildFile; fileRef = 74A87A210CD159D000A3470F /* AppController.rb */; }; … … 46 47 4DDCA7120ACC9A6100E082CE /* Amalgam.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Amalgam.app; sourceTree = BUILT_PRODUCTS_DIR; }; 47 48 7458159C0CD31B04009F19BA /* plugins */ = {isa = PBXFileReference; lastKnownFileType = folder; path = plugins; sourceTree = "<group>"; }; 49 745CBB1C0CD4C709005D7A02 /* plugin_base.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = plugin_base.rb; sourceTree = "<group>"; }; 48 50 747D3D2E0CD26D5200284FB4 /* icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = icon.icns; sourceTree = "<group>"; }; 49 51 74A87A210CD159D000A3470F /* AppController.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = AppController.rb; sourceTree = "<group>"; }; … … 68 70 isa = PBXGroup; 69 71 children = ( 72 745CBB1C0CD4C709005D7A02 /* plugin_base.rb */, 70 73 74A87A210CD159D000A3470F /* AppController.rb */, 71 74 ); … … 205 208 747D3D2F0CD26D5200284FB4 /* icon.icns in Resources */, 206 209 745815A00CD31B04009F19BA /* plugins in Resources */, 210 745CBB1D0CD4C709005D7A02 /* plugin_base.rb in Resources */, 207 211 ); 208 212 runOnlyForDeploymentPostprocessing = 0; -
lang/ruby/Amalgam/AppController.rb
r791 r794 125 125 end 126 126 127 require "singleton"128 127 require "yaml" 128 require "rubygems" 129 require "module/pluggable" 130 require "plugin_base" 129 131 class AmalgamConfig 130 include Singleton131 132 132 133 PATH = Pathname.new("#{ENV["HOME"]}/.amalgam") 134 135 pluggable :plugins, :base_class => AmalgamPlugin, 136 :search_path => (PATH + "plugins").to_s 137 pluggable :default_plugins, :base_class => AmalgamPlugin, 138 :search_path => (NSBundle.mainBundle.resourcePath + "/plugins").to_s 133 139 134 140 Default = { … … 136 142 }.freeze 137 143 138 139 def initialize144 def initialize(controller) 145 @controller = controller 140 146 begin 141 147 @config = Default.merge(YAML.load((PATH+"config.yaml").read)) … … 143 149 @config = Default 144 150 end 145 @default_plugins = Pathname.glob(NSBundle.mainBundle.resourcePath + "/plugins/**/*.rb") 151 plugins.init(controller) 152 default_plugins.init(controller) 146 153 end 147 154 … … 155 162 "" 156 163 end 157 158 def plugins159 @default_plugins + Pathname.glob(PATH + "plugins/**/*.rb")160 rescue161 @default_plugins162 end163 164 end 164 165 … … 167 168 ib_outlet :input 168 169 ib_outlet :results 170 171 attr_reader :candidates 172 173 def search_text 174 @input.stringValue 175 end 176 177 def search_text=(val) 178 @input.stringValue = val 179 end 169 180 170 181 # Tableview … … 205 216 def run_current_selection(*) 206 217 if @now[@results.selectedRow] 207 @now[@results.selectedRow].call 218 begin 219 @now[@results.selectedRow].call 220 rescue Exception => e 221 log e 222 alert("Error", e.inspect) 223 end 208 224 end 209 225 end … … 242 258 def awakeFromNib 243 259 @history = History.new 244 @config = AmalgamConfig.instance 260 log "Loading Config" 261 @config = AmalgamConfig.new(self) 245 262 246 263 rect = @view.frame … … 397 414 end 398 415 399 @candidates << Command.new("d", "Debug eval", :sh) do 400 log :d 416 @candidates << Command.new(".d", "Debug eval", :sh) do 401 417 _, code = @input.stringValue.split(/\s+/, 2) 402 418 … … 429 445 end 430 446 431 b = binding 432 @config.plugins.each do |f| 433 log "Plugin #{f} processing..." 434 begin 435 eval(f.read, b) 436 rescue Exception => e 437 log e 438 OSX.NSRunAlertPanel("Plugin #{f} Error", e.inspect, "OK", "", nil) 439 end 440 end 447 # b = binding 448 # @config.plugins.each do |f| 449 # log "Plugin #{f} processing..." 450 # begin 451 # eval(f.read, b) 452 # rescue Exception => e 453 # log e 454 # OSX.NSRunAlertPanel("Plugin #{f} Error", e.inspect, "OK", "", nil) 455 # end 456 # end 457 log @config.default_plugins 458 @config.default_plugins.candidates.each do |k,v| 459 @candidates.concat v 460 end 461 # @config.plugins.candidates.each do |k,v| 462 # log k 463 # @candidates.concat v 464 # end 441 465 442 466 @candidates.replace @candidates.sort_by {|c| c.name } … … 446 470 end 447 471 448 def search_applications_recursive(dir) 449 ret = [] 450 Pathname.glob("#{dir}/*") do |f| 451 next unless f.directory? 452 if f.extname == ".app" 453 ret << f 454 #set_status "Found.. #{f.basename}" 455 else 456 ret.concat search_applications_recursive(f) 457 end 458 end 459 ret 460 end 461 462 end 463 464 472 473 end 474 475 -
lang/ruby/Amalgam/English.lproj/MainMenu.nib/info.nib
r747 r794 8 8 <dict> 9 9 <key>196</key> 10 <string> 350 466358 235 0 0 1280 778 </string>10 <string>461 410 358 235 0 0 1280 778 </string> 11 11 </dict> 12 12 <key>IBFramework Version</key> -
lang/ruby/Amalgam/plugins/applications.rb
r783 r794 1 1 #!/usr/bin/env ruby 2 2 3 applications = [] 4 applications.concat search_applications_recursive("/Applications") 5 applications.concat search_applications_recursive("/Developer/Applications") 6 applications.concat search_applications_recursive("/System/Library/CoreServices") 3 class Applications < AmalgamPlugin 7 4 8 @candidates.concat applications.map {|f| 9 Candidate.new(f.basename(".app").to_s, f.realpath, f.realpath) do |c| 10 log [:open_a, c, f] 11 system("open", "-a", f) 5 def candidates 6 applications = [] 7 applications.concat search_applications_recursive("/Applications") 8 applications.concat search_applications_recursive("/Developer/Applications") 9 applications.concat search_applications_recursive("/System/Library/CoreServices") 10 11 applications.map {|f| 12 Candidate.new(f.basename(".app").to_s, f.realpath, f.realpath) do |c| 13 log [:open_a, c, f] 14 system("open", "-a", f) 15 end 16 } 12 17 end 13 }14 18 19 private 20 def search_applications_recursive(dir) 21 ret = [] 22 Pathname.glob("#{dir}/*") do |f| 23 next unless f.directory? 24 if f.extname == ".app" 25 ret << f 26 #set_status "Found.. #{f.basename}" 27 else 28 ret.concat search_applications_recursive(f) 29 end 30 end 31 ret 32 end 33 34 end 35 36 -
lang/ruby/Amalgam/plugins/firefox.rb
r791 r794 2 2 # 3 3 4 def history(text="") 5 require "net/telnet" 6 telnet = Net::Telnet.new("Host" => "localhost", "Port" => 4242, "Prompt" => /repl> \z/) 7 telnet.cmd("") 8 result = "" 9 telnet.cmd(<<-EOF) { |c| result << c } 10 (function () { try { 11 var searchString = ""; 12 var searchParam = ""; 13 var previousResult = null; 14 //var history = Cc["@mozilla.org/browser/global-history;2"].getService(Ci.nsIBrowserHistory); 15 var history = Cc["@mozilla.org/browser/global-history;2"].getService(Ci.nsIAutoCompleteSearch); 16 //.createInstance(Ci.nsIAutoCompleteSearch); 17 var results; 18 history.startSearch(searchString, searchParam, previousResult, { 19 onSearchResult: function (search, result) { 20 results = []; 21 // alert([search, result]); 22 // alert([result.matchCount, result.searchResult, result.getValueAt(0)]); 23 for (var i = 0; i < result.matchCount; i++) { 24 results.push(result.getValueAt(i)); 4 class Firefox < AmalgamPlugin 5 6 def history(text="") 7 require "net/telnet" 8 telnet = Net::Telnet.new("Host" => "localhost", "Port" => 4242, "Prompt" => /repl> \z/) 9 telnet.cmd("") 10 result = "" 11 telnet.cmd(<<-EOF) { |c| result << c } 12 (function () { try { 13 var searchString = ""; 14 var searchParam = ""; 15 var previousResult = null; 16 //var history = Cc["@mozilla.org/browser/global-history;2"].getService(Ci.nsIBrowserHistory); 17 var history = Cc["@mozilla.org/browser/global-history;2"].getService(Ci.nsIAutoCompleteSearch); 18 //.createInstance(Ci.nsIAutoCompleteSearch); 19 var results; 20 history.startSearch(searchString, searchParam, previousResult, { 21 onSearchResult: function (search, result) { 22 results = []; 23 // alert([search, result]); 24 // alert([result.matchCount, result.searchResult, result.getValueAt(0)]); 25 for (var i = 0; i < result.matchCount; i++) { 26 results.push(result.getValueAt(i)); 27 } 25 28 } 26 } 27 }); 28 return results.toSource(); 29 } catch (e) { alert(e) } })(); 30 EOF 31 telnet.cmd("") { |c| result << c } 32 eval(result.gsub(/repl> /, "")) 33 end 29 }); 30 return results.toSource(); 31 } catch (e) { alert(e) } })(); 32 EOF 33 telnet.cmd("") { |c| result << c } 34 eval(result.gsub(/repl> /, "")) 35 end 34 36 35 Thread.start do 36 Thread.abort_on_exception = true 37 icon = NSWorkspace.sharedWorkspace.iconForFileType('unknown') 38 @fx_candidates = history.map do |m| 39 Candidate.new(m, m, icon) do 40 system "open", "-a", "Firefox", m 41 @candidates.return 37 def init(c) 38 super 39 Thread.start do 40 Thread.abort_on_exception = true 41 icon = NSWorkspace.sharedWorkspace.iconForFileType('html') 42 @candidates = history.map do |m| 43 Candidate.new(m, m, icon) do 44 system "open", "-a", "Firefox", m 45 @candidates.return 46 end 47 end 48 log :loaded_fx_history 42 49 end 43 50 end 44 log :loaded_fx_history45 end46 51 47 48 @candidates << Candidate.new("fx", "Firefox History", :sh) do 49 @candidates.into(@fx_candidates || []) 50 @input.stringValue = "" 51 filtering "" 52 def candidates 53 [ 54 Candidate.new("fx", "Firefox History", "/Applications/Firefox.app") do 55 amalgam.candidates.into(@candidates || []) 56 amalgam.search_text = "" 57 amalgam.filtering "" 58 end 59 ] 60 end 52 61 end 53 62 -
lang/ruby/Amalgam/plugins/prefpanes.rb
r783 r794 1 1 2 @candidates.concat Pathname.glob("/System/Library/PreferencePanes/*.prefPane").map {|f| 3 Candidate.new(f.basename.to_s, f.basename(".prefPane"), f.realpath) do 4 system("open", f) 2 class Prefpanes < AmalgamPlugin 3 def candidates 4 Pathname.glob("/System/Library/PreferencePanes/*.prefPane").map {|f| 5 Candidate.new(f.basename.to_s, f.basename(".prefPane"), f.realpath) do 6 system("open", f) 7 end 8 } 5 9 end 6 } 10 end 7 11 8 12
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)