Kouhei Sutou
kous****@users*****
Thu May 11 11:23:23 JST 2006
Index: kazehakase/data/ext/ruby/kz/ruby-completion.rb diff -u kazehakase/data/ext/ruby/kz/ruby-completion.rb:1.1 kazehakase/data/ext/ruby/kz/ruby-completion.rb:1.2 --- kazehakase/data/ext/ruby/kz/ruby-completion.rb:1.1 Wed May 10 17:43:19 2006 +++ kazehakase/data/ext/ruby/kz/ruby-completion.rb Thu May 11 11:23:23 2006 @@ -24,6 +24,15 @@ module_function def complete(input, bind) + target = input.split(/[\s\"\'\`><=;|&\{\(]/).last + prefix = input[0...(input.rindex(target))] + candidates = collect_completion_candidates(target, bind) + candidates.compact.sort.collect do |message| + prefix + message + end + end + + def collect_completion_candidates(input, bind) case input when /^(\/[^\/]*\/)\.([^.]*)$/ # Regexp Index: kazehakase/data/ext/ruby/kz/ruby-dialog.rb diff -u kazehakase/data/ext/ruby/kz/ruby-dialog.rb:1.9 kazehakase/data/ext/ruby/kz/ruby-dialog.rb:1.10 --- kazehakase/data/ext/ruby/kz/ruby-dialog.rb:1.9 Thu May 11 11:01:59 2006 +++ kazehakase/data/ext/ruby/kz/ruby-dialog.rb Thu May 11 11:23:23 2006 @@ -159,15 +159,11 @@ end @entry.signal_connect("changed") do |widget, event| Kz.barrier do - update_input_exp_completion + update_input_entry_ruby_completion end end update_widget_font(@entry, nil, "monospace") - @ruby_exp_completion = Gtk::EntryCompletion.new - @ruby_exp_model = Gtk::ListStore.new(String) - @ruby_exp_completion.model = @ruby_exp_model - @ruby_exp_completion.text_column = 0 - @entry.completion = @ruby_exp_completion + setup_input_entry_ruby_completion @entry_last_text = nil @entry end @@ -178,10 +174,17 @@ @entry.position = -1 end - def update_input_exp_completion + def setup_input_entry_ruby_completion + @ruby_exp_completion = Gtk::EntryCompletion.new + @ruby_exp_model = Gtk::ListStore.new(String) + @ruby_exp_completion.model = @ruby_exp_model + @ruby_exp_completion.text_column = 0 + @entry.completion = @ruby_exp_completion + end + + def update_input_entry_ruby_completion return if****@entry*****? result = Kz::RubyCompletion.complete(@entry.text, @sandbox.binding) - result = result.compact.sort @ruby_exp_model.clear result.each do |item| iter = @ruby_exp_model.append