Skip to content

Commit

Permalink
Update readline to use reline
Browse files Browse the repository at this point in the history
  • Loading branch information
adfoster-r7 committed Jul 3, 2024
1 parent c5717d4 commit dc45461
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/rex/ui/text/input/readline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def reset_tab_completion(tab_complete_proc = nil)
# Retrieve the line buffer
#
def line_buffer
if defined? RbReadline
if defined? Reline
Reline.line_buffer
elsif defined? RbReadline
RbReadline.rl_line_buffer
else
::Readline.line_buffer
Expand Down Expand Up @@ -153,7 +155,21 @@ def readline_with_output(prompt, add_history=false)
=end
reset_sequence = ""

if defined? RbReadline
if defined? Reline
Reline.input = fd
Reline.output = output

line = RbReadline.readline(reset_sequence + prompt)

if add_history && line && !line.start_with?(' ')
# Don't add duplicate lines to history
if ::Readline::HISTORY.empty? || line.strip != ::Readline::HISTORY[-1]
RbReadline.add_history(line.strip)
end
end

line.try(:dup)
elsif defined? RbReadline
RbReadline.rl_instream = fd
RbReadline.rl_outstream = output

Expand Down

0 comments on commit dc45461

Please sign in to comment.