Overview
Conducting a code reading of reline.
Preparation
- Clone reline
git@github.com:ruby/reline.git - Create a sample code
$LOAD_PATH.unshift(File.expand_path('lib', __dir__))
require "reline"
prompt = 'prompt> '
use_history = true
begin
while true
text = Reline.readmultiline(prompt, use_history) do |multiline_input|
# Accept the input until `end` is entered
multiline_input.split.last == "end"
end
puts 'You entered:'
puts text
end
# If you want to exit, type Ctrl-C
rescue Interrupt
puts '^C'
exit 0
end
- Insert
binding.irbat any desired point
Code Reading
Conduct code reading based on the sample code.
- Call of readline
- Processing of readline
- Omitted due to length
- Output
- ruby/reline/blob/master/lib/reline/line_editor.rb#L1323
- The input accumulated in the buffer is finally output here