Class: IRB::ReadlineInputMethod
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
StdioInputMethod ,
InputMethod
|
|
Instance Chain:
|
|
Inherits: |
IRB::StdioInputMethod
|
Defined in: | lib/irb/input-method.rb |
Constant Summary
InputMethod
- Inherited
Class Method Summary
- .initialize_readline
-
.new ⇒ ReadlineInputMethod
constructor
Creates a new input method object using Readline.
StdioInputMethod
- Inherited
.new | Creates a new input method object. |
Instance Attribute Summary
-
#eof? ⇒ Boolean
readonly
Whether the end of this input method has been reached, returns
true
if there is no more data to read. - #prompting? ⇒ Boolean readonly
HistorySavingAbility
- Included
StdioInputMethod
- Inherited
#eof? | Whether the end of this input method has been reached, returns |
#prompting?, | |
#readable_after_eof? | Whether this input method is still readable when there is no more data to read. |
InputMethod
- Inherited
#prompt | The irb prompt associated with this input method. |
#prompting?, | |
#readable_after_eof? | Whether this input method is still readable when there is no more data to read. |
#support_history_saving? |
Instance Method Summary
- #completion_info
-
#gets
Reads the next line from this input method.
-
#inspect
For debug message.
HistorySavingAbility
- Included
#load_history, #reset_history_counter, #save_history, | |
#ensure_history_file_writable | Returns boolean whether writing to |
StdioInputMethod
- Inherited
#encoding | The external encoding for standard input. |
#gets | Reads the next line from this input method. |
#inspect | For debug message. |
#line | Returns the current line number for |
InputMethod
- Inherited
Constructor Details
.new ⇒ ReadlineInputMethod
Creates a new input method object using Readline
# File 'lib/irb/input-method.rb', line 188
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
Class Method Details
.initialize_readline
[ GitHub ]# File 'lib/irb/input-method.rb', line 177
def initialize_readline require "readline" rescue LoadError else include ::Readline end
Instance Attribute Details
#eof? ⇒ Boolean
(readonly)
Whether the end of this input method has been reached, returns true
if there is no more data to read.
See IO#eof?
for more information.
# File 'lib/irb/input-method.rb', line 232
def eof? @eof end
#prompting? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/irb/input-method.rb', line 236
def prompting? true end
Instance Method Details
#completion_info
[ GitHub ]# File 'lib/irb/input-method.rb', line 209
def completion_info 'RegexpCompletor' end
#gets
Reads the next line from this input method.
See IO#gets
for more information.
# File 'lib/irb/input-method.rb', line 216
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
For debug message
# File 'lib/irb/input-method.rb', line 241
def inspect readline_impl = (defined?(Reline) && Readline == Reline) ? 'Reline' : 'ext/readline' str = "ReadlineInputMethod with #{readline_impl} #{Readline::VERSION}" inputrc_path = File. (ENV['INPUTRC'] || '~/.inputrc') str += " and #{inputrc_path}" if File.exist?(inputrc_path) str end