Changeset 791 for lang/ruby

Show
Ignore:
Timestamp:
10/28/07 20:31:21 (6 years ago)
Author:
cho45
Message:

lang/ruby/Amalgam/plugins/firefox.rb,
lang/ruby/Amalgam/AppController.rb:

高速化と、アイコンに NSImage/NSData わたしたときはそれをつかうように

Location:
lang/ruby/Amalgam
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/ruby/Amalgam/AppController.rb

    r789 r791  
    105105                when NilClass 
    106106                        @icon = NSWorkspace.sharedWorkspace.iconForFileType("unknown") 
     107                when NSData 
     108                        @icon = NSImage.alloc.initWithData(str) 
     109                when NSImage 
     110                        @icon = icon 
    107111                else 
    108112                        str = NSData.objc_send :dataWithBytes, icon.to_s, :length 
     
    166170        # Tableview 
    167171        def numberOfRowsInTableView(table) 
    168                 @now.length 
     172                @now.first(100).length 
    169173        end 
    170174 
     
    175179                                NSWorkspace.sharedWorkspace.iconForFileType('unknown') 
    176180                when :name 
    177                         "" 
     181                        "#{@now[row].name}\n\t#{@now[row].desc}" 
    178182                end 
    179183        end 
  • lang/ruby/Amalgam/plugins/firefox.rb

    r789 r791  
    44def history(text="") 
    55        require "net/telnet" 
    6         telnet = Net::Telnet.new("Host" => "localhost", "Port" => 4242, "Prompt" => /repl> \z/) {|c| puts c } 
     6        telnet = Net::Telnet.new("Host" => "localhost", "Port" => 4242, "Prompt" => /repl> \z/) 
    77        telnet.cmd("") 
    88        result = "" 
     
    3333end 
    3434 
    35 @candidates << Candidate.new("fx", "Firefox", :sh) do 
    36  
    37         c = [] 
    38         history.each do |m| 
    39                 c << Candidate.new(m, m, :sh) do 
     35Thread.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 
    4040                        system "open", "-a", "Firefox", m 
    4141                        @candidates.return 
    4242                end 
    4343        end 
    44         @candidates.into(c) 
     44        log :loaded_fx_history 
     45end 
     46 
     47 
     48@candidates << Candidate.new("fx", "Firefox History", :sh) do 
     49        @candidates.into(@fx_candidates || []) 
    4550        @input.stringValue = "" 
    4651        filtering ""