Skip to content

Commit 5bcade7

Browse files
gmcgibbonhsbt
authored andcommitted
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.).
1 parent 0700dd8 commit 5bcade7

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ irb(main):001:0> irb_info
1313
=>
1414
Ruby version: 3.0.0
1515
IRB version: irb 1.2.7 (2020-09-19)
16-
InputMethod: ReidlineInputMethod with Reline 0.1.9 and /home/aycabta/.inputrc
16+
InputMethod: RelineInputMethod with Reline 0.1.9 and /home/aycabta/.inputrc
1717
.irbrc path: /home/aycabta/.irbrc
1818
```
1919

lib/irb/context.rb

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Context
2222
#
2323
# The optional +input_method+ argument:
2424
#
25-
# +nil+:: uses stdin or Reidline or Readline
25+
# +nil+:: uses stdin or Reline or Readline
2626
# +String+:: uses a File
2727
# +other+:: uses this as InputMethod
2828
def initialize(irb, workspace = nil, input_method = nil)
@@ -48,8 +48,13 @@ def initialize(irb, workspace = nil, input_method = nil)
4848
end
4949
if IRB.conf.has_key?(:USE_MULTILINE)
5050
@use_multiline = IRB.conf[:USE_MULTILINE]
51-
elsif IRB.conf.has_key?(:USE_REIDLINE) # backward compatibility
52-
@use_multiline = IRB.conf[:USE_REIDLINE]
51+
elsif IRB.conf.has_key?(:USE_RELINE) # backward compatibility
52+
@use_multiline = IRB.conf[:USE_RELINE]
53+
elsif IRB.conf.has_key?(:USE_REIDLINE)
54+
warn <<~MSG.strip
55+
USE_REIDLINE is deprecated, please use USE_RELINE instead.
56+
MSG
57+
@use_multiline = IRB.conf[:USE_RELINE]
5358
else
5459
@use_multiline = nil
5560
end
@@ -83,14 +88,14 @@ def initialize(irb, workspace = nil, input_method = nil)
8388
when nil
8489
if STDIN.tty? && IRB.conf[:PROMPT_MODE] != :INF_RUBY && !use_singleline?
8590
# Both of multiline mode and singleline mode aren't specified.
86-
@io = ReidlineInputMethod.new
91+
@io = RelineInputMethod.new
8792
else
8893
@io = nil
8994
end
9095
when false
9196
@io = nil
9297
when true
93-
@io = ReidlineInputMethod.new
98+
@io = RelineInputMethod.new
9499
end
95100
unless @io
96101
case use_singleline?
@@ -160,7 +165,7 @@ def main
160165
# The current input method.
161166
#
162167
# Can be either StdioInputMethod, ReadlineInputMethod,
163-
# ReidlineInputMethod, FileInputMethod or other specified when the
168+
# RelineInputMethod, FileInputMethod or other specified when the
164169
# context is created. See ::new for more # information on +input_method+.
165170
attr_accessor :io
166171

@@ -326,9 +331,9 @@ def main
326331
# Alias for #use_singleline
327332
alias use_singleline? use_singleline
328333
# backward compatibility
329-
alias use_reidline use_multiline
334+
alias use_reline use_multiline
330335
# backward compatibility
331-
alias use_reidline? use_multiline
336+
alias use_reline? use_multiline
332337
# backward compatibility
333338
alias use_readline use_singleline
334339
# backward compatibility
@@ -346,7 +351,7 @@ def main
346351
# Returns whether messages are displayed or not.
347352
def verbose?
348353
if @verbose.nil?
349-
if @io.kind_of?(ReidlineInputMethod)
354+
if @io.kind_of?(RelineInputMethod)
350355
false
351356
elsif defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)
352357
false
@@ -361,11 +366,11 @@ def verbose?
361366
end
362367

363368
# Whether #verbose? is +true+, and +input_method+ is either
364-
# StdioInputMethod or ReidlineInputMethod or ReadlineInputMethod, see #io
369+
# StdioInputMethod or RelineInputMethod or ReadlineInputMethod, see #io
365370
# for more information.
366371
def prompting?
367372
verbose? || (STDIN.tty? && @io.kind_of?(StdioInputMethod) ||
368-
@io.kind_of?(ReidlineInputMethod) ||
373+
@io.kind_of?(RelineInputMethod) ||
369374
(defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)))
370375
end
371376

lib/irb/input-method.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def inspect
261261
end
262262
end
263263

264-
class ReidlineInputMethod < InputMethod
264+
class RelineInputMethod < InputMethod
265265
include Reline
266266

267267
# Creates a new input method object using Reline
@@ -470,4 +470,13 @@ def inspect
470470
str
471471
end
472472
end
473+
474+
class ReidlineInputMethod < RelineInputMethod
475+
def initialize
476+
warn <<~MSG.strip
477+
IRB::ReidlineInputMethod is deprecated, please use IRB::RelineInputMethod instead.
478+
MSG
479+
super
480+
end
481+
end
473482
end

0 commit comments

Comments
 (0)