Skip to content

Commit

Permalink
Avoid using Reline as a module (#633)
Browse files Browse the repository at this point in the history
Using it as a module makes it harder to understand methods' source.
  • Loading branch information
st0012 authored Jul 9, 2023
1 parent 5e87f3b commit 652f413
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/irb/input-method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,6 @@ def inspect
end

class RelineInputMethod < InputMethod
include Reline

# Creates a new input method object using Reline
def initialize
IRB.__send__(:set_encoding, Reline.encoding_system_needs.name, override: false)
Expand Down Expand Up @@ -401,10 +399,10 @@ def auto_indent(&block)
mod_key = RUBY_PLATFORM.match?(/darwin/) ? "Option" : "Alt"
message = "Press #{mod_key}+d to read the full document"
contents = [message] + doc.accept(formatter).split("\n")
contents = contents.take(preferred_dialog_height) if respond_to?(:preferred_dialog_height)
contents = contents.take(Reline.preferred_dialog_height) if Reline.respond_to?(:preferred_dialog_height)

y = cursor_pos_to_render.y
DialogRenderInfo.new(pos: Reline::CursorPos.new(x, y), contents: contents, width: width, bg_color: '49')
Reline::DialogRenderInfo.new(pos: Reline::CursorPos.new(x, y), contents: contents, width: width, bg_color: '49')
}

# Reads the next line from this input method.
Expand All @@ -415,8 +413,8 @@ def gets
Reline.output = @stdout
Reline.prompt_proc = @prompt_proc
Reline.auto_indent_proc = @auto_indent_proc if @auto_indent_proc
if l = readmultiline(@prompt, false, &@check_termination_proc)
HISTORY.push(l) if !l.empty?
if l = Reline.readmultiline(@prompt, false, &@check_termination_proc)
Reline::HISTORY.push(l) if !l.empty?
@line[@line_no += 1] = l + "\n"
else
@eof = true
Expand Down

0 comments on commit 652f413

Please sign in to comment.