diff options
author | aycabta <aycabta@gmail.com> | 2019-05-18 03:12:53 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2019-05-18 12:48:27 +0900 |
commit | 16917cc3cb27277d04b9c35fb7fc10f72a9b6dfa (patch) | |
tree | 524745204c854b68070f9a22efb01adebc3aff4e /lib/reline.rb | |
parent | b165bedcbd41d791a85fc1ce90b57a0d0525f319 (diff) | |
download | ruby-16917cc3cb27277d04b9c35fb7fc10f72a9b6dfa.tar.gz |
Add Reline.test_mode to use with special I/O
Diffstat (limited to 'lib/reline.rb')
-rw-r--r-- | lib/reline.rb | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/reline.rb b/lib/reline.rb index 61b94d727a..a5acc52f03 100644 --- a/lib/reline.rb +++ b/lib/reline.rb @@ -180,12 +180,19 @@ module Reline @@line_editor&.delete_text(start, length) end + private_class_method def self.test_mode + remove_const('IOGate') if const_defined?('IOGate') + const_set('IOGate', Reline::GeneralIO) + end + def self.input=(val) raise TypeError unless val.respond_to?(:getc) or val.nil? if val.respond_to?(:getc) - Reline::GeneralIO.input = val - remove_const('IOGate') if const_defined?('IOGate') - const_set('IOGate', Reline::GeneralIO) + if defined?(Reline::ANSI) and IOGate == Reline::ANSI + Reline::ANSI.input = val + elsif IOGate == Reline::GeneralIO + Reline::GeneralIO.input = val + end end end @@ -193,6 +200,9 @@ module Reline def self.output=(val) raise TypeError unless val.respond_to?(:write) or val.nil? @@output = val + if defined?(Reline::ANSI) and IOGate == Reline::ANSI + Reline::ANSI.output = val + end end def self.vi_editing_mode |