summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStan Lo <[email protected]>2024-02-25 23:20:56 +0800
committergit <[email protected]>2024-02-25 15:21:00 +0000
commit898f30f8bd064c9803625c98a3e46bd3434ff1bb (patch)
tree023709237a0b4906e3da3e313297ea7fa0f411af /lib
parent3c4d0b13132f9ba3f07575f175d173b69f9bd6ef (diff)
[ruby/irb] Refactor IRB::Context#prompting
(https://github.com/ruby/irb/pull/889) https://github.com/ruby/irb/commit/7b323ee514
Diffstat (limited to 'lib')
-rw-r--r--lib/irb/context.rb4
-rw-r--r--lib/irb/input-method.rb16
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/irb/context.rb b/lib/irb/context.rb
index d2d0bed522..9647327037 100644
--- a/lib/irb/context.rb
+++ b/lib/irb/context.rb
@@ -479,9 +479,7 @@ module IRB
# StdioInputMethod or RelineInputMethod or ReadlineInputMethod, see #io
# for more information.
def prompting?
- verbose? || (STDIN.tty? && @io.kind_of?(StdioInputMethod) ||
- @io.kind_of?(RelineInputMethod) ||
- (defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)))
+ verbose? || @io.prompting?
end
# The return value of the last statement evaluated.
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index a483ec671b..c199830928 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -44,6 +44,10 @@ module IRB
false
end
+ def prompting?
+ false
+ end
+
# For debug message
def inspect
'Abstract InputMethod'
@@ -91,6 +95,10 @@ module IRB
true
end
+ def prompting?
+ STDIN.tty?
+ end
+
# Returns the current line number for #io.
#
# #line counts the number of times #gets is called.
@@ -220,6 +228,10 @@ module IRB
@eof
end
+ def prompting?
+ true
+ end
+
# For debug message
def inspect
readline_impl = (defined?(Reline) && Readline == Reline) ? 'Reline' : 'ext/readline'
@@ -467,6 +479,10 @@ module IRB
@eof
end
+ def prompting?
+ true
+ end
+
# For debug message
def inspect
config = Reline::Config.new