类 IRB::ReadlineInputMethod
公共类方法
initialize_readline() 点击切换源代码
# File lib/irb/input-method.rb, line 165 def self.initialize_readline require "readline" rescue LoadError else include ::Readline end
new() 点击切换源代码
使用 Readline
创建一个新的输入方法对象
调用超类方法
IRB::StdioInputMethod::new
# File lib/irb/input-method.rb, line 175 def initialize self.class.initialize_readline if Readline.respond_to?(:encoding_system_needs) IRB.__send__(:set_encoding, Readline.encoding_system_needs.name, override: false) end super @eof = false @completor = RegexpCompletor.new if Readline.respond_to?("basic_word_break_characters=") Readline.basic_word_break_characters = BASIC_WORD_BREAK_CHARACTERS end Readline.completion_append_character = nil Readline.completion_proc = ->(target) { bind = IRB.conf[:MAIN_CONTEXT].workspace.binding @completor.completion_candidates('', target, '', bind: bind) } end
公共实例方法
completion_info() 点击切换源代码
# File lib/irb/input-method.rb, line 196 def completion_info 'RegexpCompletor' end
eof?() 点击切换源代码
是否已到达此输入方法的末尾,如果不再有数据可读,则返回 true
。
有关更多信息,请参见 IO#eof?
。
# File lib/irb/input-method.rb, line 219 def eof? @eof end
gets() 点击切换源代码
从此输入方法读取下一行。
有关更多信息,请参见 IO#gets
。
# File lib/irb/input-method.rb, line 203 def gets Readline.input = @stdin Readline.output = @stdout if l = readline(@prompt, false) HISTORY.push(l) if !l.empty? @line[@line_no += 1] = l + "\n" else @eof = true l end end
inspect() 点击切换源代码
用于调试消息
# File lib/irb/input-method.rb, line 224 def inspect readline_impl = (defined?(Reline) && Readline == Reline) ? 'Reline' : 'ext/readline' str = "ReadlineInputMethod with #{readline_impl} #{Readline::VERSION}" inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc') str += " and #{inputrc_path}" if File.exist?(inputrc_path) str end