lib/bond/readline.rb in bond-0.1.4 vs lib/bond/readline.rb in bond-0.2.0

- old
+ new

@@ -1,14 +1,13 @@ - module Bond - # This is the default readline plugin for Bond. A valid plugin must define methods setup() and line_buffer(). setup() - # should load the readline-like library and set the completion_proc. line_buffer() should give access to the full line of what - # the user has typed. + # This is the default readline plugin for Bond. A valid plugin must be a module that defines methods setup + # and line_buffer as described below. module Readline DefaultBreakCharacters = " \t\n\"\\'`><=;|&{(" - def setup + # Loads the readline-like library and sets the completion_proc to the given agent. + def setup(agent) require 'readline' begin require 'readline_line_buffer' rescue LoadError $stderr.puts "Failed to load readline_line_buffer extension. Falling back on RubyInline extension." @@ -35,12 +34,16 @@ ::Readline.completion_append_character = nil if ::Readline.respond_to?("basic_word_break_characters=") ::Readline.basic_word_break_characters = DefaultBreakCharacters end - ::Readline.completion_proc = self + ::Readline.completion_proc = agent + if (::Readline::VERSION rescue nil).to_s[/editline/i] + puts "Bond has detected EditLine and may not work with it. See the README's Limitations section." + end end + # Returns full line of what the user has typed. def line_buffer ::Readline.line_buffer end end end \ No newline at end of file