[ruby/irb] Rename IDB::ReidlineInputMethod to IRB::RelineInputMethod

Deprecates IDB::ReidlineInputMethod and USE_REIDLINE in favor of
IRB::RelineInputMethod and USE_RELINE. The Input method uses Reline to
read input from the console, so it can be named directly after the
Reline library like other inputs methods are (Readline, Stdio, etc.).

https://github.com/ruby/irb/commit/5bcade7130
This commit is contained in:
Gannon McGibbon 2022-10-04 15:28:45 -05:00 committed by Hiroshi SHIBATA
parent 48c261a040
commit 19e4a4c624
2 changed files with 26 additions and 12 deletions

View File

@ -22,7 +22,7 @@ module IRB
# #
# The optional +input_method+ argument: # The optional +input_method+ argument:
# #
# +nil+:: uses stdin or Reidline or Readline # +nil+:: uses stdin or Reline or Readline
# +String+:: uses a File # +String+:: uses a File
# +other+:: uses this as InputMethod # +other+:: uses this as InputMethod
def initialize(irb, workspace = nil, input_method = nil) def initialize(irb, workspace = nil, input_method = nil)
@ -48,8 +48,13 @@ module IRB
end end
if IRB.conf.has_key?(:USE_MULTILINE) if IRB.conf.has_key?(:USE_MULTILINE)
@use_multiline = IRB.conf[:USE_MULTILINE] @use_multiline = IRB.conf[:USE_MULTILINE]
elsif IRB.conf.has_key?(:USE_REIDLINE) # backward compatibility elsif IRB.conf.has_key?(:USE_RELINE) # backward compatibility
@use_multiline = IRB.conf[:USE_REIDLINE] @use_multiline = IRB.conf[:USE_RELINE]
elsif IRB.conf.has_key?(:USE_REIDLINE)
warn <<~MSG.strip
USE_REIDLINE is deprecated, please use USE_RELINE instead.
MSG
@use_multiline = IRB.conf[:USE_RELINE]
else else
@use_multiline = nil @use_multiline = nil
end end
@ -83,14 +88,14 @@ module IRB
when nil when nil
if STDIN.tty? && IRB.conf[:PROMPT_MODE] != :INF_RUBY && !use_singleline? if STDIN.tty? && IRB.conf[:PROMPT_MODE] != :INF_RUBY && !use_singleline?
# Both of multiline mode and singleline mode aren't specified. # Both of multiline mode and singleline mode aren't specified.
@io = ReidlineInputMethod.new @io = RelineInputMethod.new
else else
@io = nil @io = nil
end end
when false when false
@io = nil @io = nil
when true when true
@io = ReidlineInputMethod.new @io = RelineInputMethod.new
end end
unless @io unless @io
case use_singleline? case use_singleline?
@ -160,7 +165,7 @@ module IRB
# The current input method. # The current input method.
# #
# Can be either StdioInputMethod, ReadlineInputMethod, # Can be either StdioInputMethod, ReadlineInputMethod,
# ReidlineInputMethod, FileInputMethod or other specified when the # RelineInputMethod, FileInputMethod or other specified when the
# context is created. See ::new for more # information on +input_method+. # context is created. See ::new for more # information on +input_method+.
attr_accessor :io attr_accessor :io
@ -326,9 +331,9 @@ module IRB
# Alias for #use_singleline # Alias for #use_singleline
alias use_singleline? use_singleline alias use_singleline? use_singleline
# backward compatibility # backward compatibility
alias use_reidline use_multiline alias use_reline use_multiline
# backward compatibility # backward compatibility
alias use_reidline? use_multiline alias use_reline? use_multiline
# backward compatibility # backward compatibility
alias use_readline use_singleline alias use_readline use_singleline
# backward compatibility # backward compatibility
@ -346,7 +351,7 @@ module IRB
# Returns whether messages are displayed or not. # Returns whether messages are displayed or not.
def verbose? def verbose?
if @verbose.nil? if @verbose.nil?
if @io.kind_of?(ReidlineInputMethod) if @io.kind_of?(RelineInputMethod)
false false
elsif defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod) elsif defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)
false false
@ -361,11 +366,11 @@ module IRB
end end
# Whether #verbose? is +true+, and +input_method+ is either # Whether #verbose? is +true+, and +input_method+ is either
# StdioInputMethod or ReidlineInputMethod or ReadlineInputMethod, see #io # StdioInputMethod or RelineInputMethod or ReadlineInputMethod, see #io
# for more information. # for more information.
def prompting? def prompting?
verbose? || (STDIN.tty? && @io.kind_of?(StdioInputMethod) || verbose? || (STDIN.tty? && @io.kind_of?(StdioInputMethod) ||
@io.kind_of?(ReidlineInputMethod) || @io.kind_of?(RelineInputMethod) ||
(defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod))) (defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)))
end end

View File

@ -261,7 +261,7 @@ module IRB
end end
end end
class ReidlineInputMethod < InputMethod class RelineInputMethod < InputMethod
include Reline include Reline
# Creates a new input method object using Reline # Creates a new input method object using Reline
@ -470,4 +470,13 @@ module IRB
str str
end end
end end
class ReidlineInputMethod < RelineInputMethod
def initialize
warn <<~MSG.strip
IRB::ReidlineInputMethod is deprecated, please use IRB::RelineInputMethod instead.
MSG
super
end
end
end end