[ruby/reline] Reduce direct references to Reline::IOGate
(https://github.com/ruby/reline/pull/566) * Avoid referencing IOGate from IOGate classes The only time those classes being used is when themselves being the IOGate. So when referencing to IOGate, it's better to use `self` instead. * Avoid referencing to IOGate from LineEditor directly * Avoid referencing to IOGate from Core directly * Reference to Reline.core directly * Replace Reline::IOGate with Reline.core.io_gate
This commit is contained in:
parent
a642a94b68
commit
24d9e21f84
@ -83,8 +83,12 @@ module Reline
|
|||||||
@bracketed_paste_finished = false
|
@bracketed_paste_finished = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def io_gate
|
||||||
|
Reline::IOGate
|
||||||
|
end
|
||||||
|
|
||||||
def encoding
|
def encoding
|
||||||
Reline::IOGate.encoding
|
io_gate.encoding
|
||||||
end
|
end
|
||||||
|
|
||||||
def completion_append_character=(val)
|
def completion_append_character=(val)
|
||||||
@ -181,16 +185,16 @@ module Reline
|
|||||||
|
|
||||||
def input=(val)
|
def input=(val)
|
||||||
raise TypeError unless val.respond_to?(:getc) or val.nil?
|
raise TypeError unless val.respond_to?(:getc) or val.nil?
|
||||||
if val.respond_to?(:getc) && Reline::IOGate.respond_to?(:input=)
|
if val.respond_to?(:getc) && io_gate.respond_to?(:input=)
|
||||||
Reline::IOGate.input = val
|
io_gate.input = val
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def output=(val)
|
def output=(val)
|
||||||
raise TypeError unless val.respond_to?(:write) or val.nil?
|
raise TypeError unless val.respond_to?(:write) or val.nil?
|
||||||
@output = val
|
@output = val
|
||||||
if Reline::IOGate.respond_to?(:output=)
|
if io_gate.respond_to?(:output=)
|
||||||
Reline::IOGate.output = val
|
io_gate.output = val
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -213,7 +217,7 @@ module Reline
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_screen_size
|
def get_screen_size
|
||||||
Reline::IOGate.get_screen_size
|
io_gate.get_screen_size
|
||||||
end
|
end
|
||||||
|
|
||||||
Reline::DEFAULT_DIALOG_PROC_AUTOCOMPLETE = ->() {
|
Reline::DEFAULT_DIALOG_PROC_AUTOCOMPLETE = ->() {
|
||||||
@ -267,7 +271,7 @@ module Reline
|
|||||||
|
|
||||||
def readmultiline(prompt = '', add_hist = false, &confirm_multiline_termination)
|
def readmultiline(prompt = '', add_hist = false, &confirm_multiline_termination)
|
||||||
Reline.update_iogate
|
Reline.update_iogate
|
||||||
Reline::IOGate.with_raw_input do
|
io_gate.with_raw_input do
|
||||||
unless confirm_multiline_termination
|
unless confirm_multiline_termination
|
||||||
raise ArgumentError.new('#readmultiline needs block to confirm multiline termination')
|
raise ArgumentError.new('#readmultiline needs block to confirm multiline termination')
|
||||||
end
|
end
|
||||||
@ -300,7 +304,7 @@ module Reline
|
|||||||
|
|
||||||
private def inner_readline(prompt, add_hist, multiline, &confirm_multiline_termination)
|
private def inner_readline(prompt, add_hist, multiline, &confirm_multiline_termination)
|
||||||
if ENV['RELINE_STDERR_TTY']
|
if ENV['RELINE_STDERR_TTY']
|
||||||
if Reline::IOGate.win?
|
if io_gate.win?
|
||||||
$stderr = File.open(ENV['RELINE_STDERR_TTY'], 'a')
|
$stderr = File.open(ENV['RELINE_STDERR_TTY'], 'a')
|
||||||
else
|
else
|
||||||
$stderr.reopen(ENV['RELINE_STDERR_TTY'], 'w')
|
$stderr.reopen(ENV['RELINE_STDERR_TTY'], 'w')
|
||||||
@ -308,7 +312,7 @@ module Reline
|
|||||||
$stderr.sync = true
|
$stderr.sync = true
|
||||||
$stderr.puts "Reline is used by #{Process.pid}"
|
$stderr.puts "Reline is used by #{Process.pid}"
|
||||||
end
|
end
|
||||||
otio = Reline::IOGate.prep
|
otio = io_gate.prep
|
||||||
|
|
||||||
may_req_ambiguous_char_width
|
may_req_ambiguous_char_width
|
||||||
line_editor.reset(prompt, encoding: encoding)
|
line_editor.reset(prompt, encoding: encoding)
|
||||||
@ -335,7 +339,7 @@ module Reline
|
|||||||
unless config.test_mode
|
unless config.test_mode
|
||||||
config.read
|
config.read
|
||||||
config.reset_default_key_bindings
|
config.reset_default_key_bindings
|
||||||
Reline::IOGate.set_default_key_bindings(config)
|
io_gate.set_default_key_bindings(config)
|
||||||
end
|
end
|
||||||
|
|
||||||
line_editor.rerender
|
line_editor.rerender
|
||||||
@ -344,9 +348,9 @@ module Reline
|
|||||||
line_editor.set_signal_handlers
|
line_editor.set_signal_handlers
|
||||||
prev_pasting_state = false
|
prev_pasting_state = false
|
||||||
loop do
|
loop do
|
||||||
prev_pasting_state = Reline::IOGate.in_pasting?
|
prev_pasting_state = io_gate.in_pasting?
|
||||||
read_io(config.keyseq_timeout) { |inputs|
|
read_io(config.keyseq_timeout) { |inputs|
|
||||||
line_editor.set_pasting_state(Reline::IOGate.in_pasting?)
|
line_editor.set_pasting_state(io_gate.in_pasting?)
|
||||||
inputs.each { |c|
|
inputs.each { |c|
|
||||||
line_editor.input_key(c)
|
line_editor.input_key(c)
|
||||||
line_editor.rerender
|
line_editor.rerender
|
||||||
@ -356,29 +360,29 @@ module Reline
|
|||||||
@bracketed_paste_finished = false
|
@bracketed_paste_finished = false
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
if prev_pasting_state == true and not Reline::IOGate.in_pasting? and not line_editor.finished?
|
if prev_pasting_state == true and not io_gate.in_pasting? and not line_editor.finished?
|
||||||
line_editor.set_pasting_state(false)
|
line_editor.set_pasting_state(false)
|
||||||
prev_pasting_state = false
|
prev_pasting_state = false
|
||||||
line_editor.rerender_all
|
line_editor.rerender_all
|
||||||
end
|
end
|
||||||
break if line_editor.finished?
|
break if line_editor.finished?
|
||||||
end
|
end
|
||||||
Reline::IOGate.move_cursor_column(0)
|
io_gate.move_cursor_column(0)
|
||||||
rescue Errno::EIO
|
rescue Errno::EIO
|
||||||
# Maybe the I/O has been closed.
|
# Maybe the I/O has been closed.
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
line_editor.finalize
|
line_editor.finalize
|
||||||
Reline::IOGate.deprep(otio)
|
io_gate.deprep(otio)
|
||||||
raise e
|
raise e
|
||||||
rescue Exception
|
rescue Exception
|
||||||
# Including Interrupt
|
# Including Interrupt
|
||||||
line_editor.finalize
|
line_editor.finalize
|
||||||
Reline::IOGate.deprep(otio)
|
io_gate.deprep(otio)
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
|
|
||||||
line_editor.finalize
|
line_editor.finalize
|
||||||
Reline::IOGate.deprep(otio)
|
io_gate.deprep(otio)
|
||||||
end
|
end
|
||||||
|
|
||||||
# GNU Readline waits for "keyseq-timeout" milliseconds to see if the ESC
|
# GNU Readline waits for "keyseq-timeout" milliseconds to see if the ESC
|
||||||
@ -393,7 +397,7 @@ module Reline
|
|||||||
private def read_io(keyseq_timeout, &block)
|
private def read_io(keyseq_timeout, &block)
|
||||||
buffer = []
|
buffer = []
|
||||||
loop do
|
loop do
|
||||||
c = Reline::IOGate.getc
|
c = io_gate.getc
|
||||||
if c == -1
|
if c == -1
|
||||||
result = :unmatched
|
result = :unmatched
|
||||||
@bracketed_paste_finished = true
|
@bracketed_paste_finished = true
|
||||||
@ -433,7 +437,7 @@ module Reline
|
|||||||
begin
|
begin
|
||||||
succ_c = nil
|
succ_c = nil
|
||||||
Timeout.timeout(keyseq_timeout / 1000.0) {
|
Timeout.timeout(keyseq_timeout / 1000.0) {
|
||||||
succ_c = Reline::IOGate.getc
|
succ_c = io_gate.getc
|
||||||
}
|
}
|
||||||
rescue Timeout::Error # cancel matching only when first byte
|
rescue Timeout::Error # cancel matching only when first byte
|
||||||
block.([Reline::Key.new(c, c, false)])
|
block.([Reline::Key.new(c, c, false)])
|
||||||
@ -448,7 +452,7 @@ module Reline
|
|||||||
end
|
end
|
||||||
return :break
|
return :break
|
||||||
when :matching
|
when :matching
|
||||||
Reline::IOGate.ungetc(succ_c)
|
io_gate.ungetc(succ_c)
|
||||||
return :next
|
return :next
|
||||||
when :matched
|
when :matched
|
||||||
buffer << succ_c
|
buffer << succ_c
|
||||||
@ -465,7 +469,7 @@ module Reline
|
|||||||
begin
|
begin
|
||||||
escaped_c = nil
|
escaped_c = nil
|
||||||
Timeout.timeout(keyseq_timeout / 1000.0) {
|
Timeout.timeout(keyseq_timeout / 1000.0) {
|
||||||
escaped_c = Reline::IOGate.getc
|
escaped_c = io_gate.getc
|
||||||
}
|
}
|
||||||
rescue Timeout::Error # independent ESC
|
rescue Timeout::Error # independent ESC
|
||||||
block.([Reline::Key.new(c, c, false)])
|
block.([Reline::Key.new(c, c, false)])
|
||||||
@ -488,19 +492,19 @@ module Reline
|
|||||||
end
|
end
|
||||||
|
|
||||||
private def may_req_ambiguous_char_width
|
private def may_req_ambiguous_char_width
|
||||||
@ambiguous_width = 2 if Reline::IOGate == Reline::GeneralIO or !STDOUT.tty?
|
@ambiguous_width = 2 if io_gate == Reline::GeneralIO or !STDOUT.tty?
|
||||||
return if defined? @ambiguous_width
|
return if defined? @ambiguous_width
|
||||||
Reline::IOGate.move_cursor_column(0)
|
io_gate.move_cursor_column(0)
|
||||||
begin
|
begin
|
||||||
output.write "\u{25bd}"
|
output.write "\u{25bd}"
|
||||||
rescue Encoding::UndefinedConversionError
|
rescue Encoding::UndefinedConversionError
|
||||||
# LANG=C
|
# LANG=C
|
||||||
@ambiguous_width = 1
|
@ambiguous_width = 1
|
||||||
else
|
else
|
||||||
@ambiguous_width = Reline::IOGate.cursor_pos.x
|
@ambiguous_width = io_gate.cursor_pos.x
|
||||||
end
|
end
|
||||||
Reline::IOGate.move_cursor_column(0)
|
io_gate.move_cursor_column(0)
|
||||||
Reline::IOGate.erase_after_cursor
|
io_gate.erase_after_cursor
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -576,7 +580,7 @@ module Reline
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.ungetc(c)
|
def self.ungetc(c)
|
||||||
Reline::IOGate.ungetc(c)
|
core.io_gate.ungetc(c)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.line_editor
|
def self.line_editor
|
||||||
@ -588,7 +592,7 @@ module Reline
|
|||||||
|
|
||||||
# Need to change IOGate when `$stdout.tty?` change from false to true by `$stdout.reopen`
|
# Need to change IOGate when `$stdout.tty?` change from false to true by `$stdout.reopen`
|
||||||
# Example: rails/spring boot the application in non-tty, then run console in tty.
|
# Example: rails/spring boot the application in non-tty, then run console in tty.
|
||||||
if ENV['TERM'] != 'dumb' && Reline::IOGate == Reline::GeneralIO && $stdout.tty?
|
if ENV['TERM'] != 'dumb' && core.io_gate == Reline::GeneralIO && $stdout.tty?
|
||||||
require 'reline/ansi'
|
require 'reline/ansi'
|
||||||
remove_const(:IOGate)
|
remove_const(:IOGate)
|
||||||
const_set(:IOGate, Reline::ANSI)
|
const_set(:IOGate, Reline::ANSI)
|
||||||
|
@ -206,7 +206,7 @@ class Reline::ANSI
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.in_pasting?
|
def self.in_pasting?
|
||||||
@@in_bracketed_paste_mode or (not Reline::IOGate.empty_buffer?)
|
@@in_bracketed_paste_mode or (not empty_buffer?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.empty_buffer?
|
def self.empty_buffer?
|
||||||
|
@ -60,6 +60,10 @@ class Reline::LineEditor
|
|||||||
reset_variables(encoding: encoding)
|
reset_variables(encoding: encoding)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def io_gate
|
||||||
|
Reline::IOGate
|
||||||
|
end
|
||||||
|
|
||||||
def set_pasting_state(in_pasting)
|
def set_pasting_state(in_pasting)
|
||||||
@in_pasting = in_pasting
|
@in_pasting = in_pasting
|
||||||
end
|
end
|
||||||
|
@ -29,8 +29,8 @@ module Reline
|
|||||||
encoding = Encoding::UTF_8
|
encoding = Encoding::UTF_8
|
||||||
end
|
end
|
||||||
Reline::GeneralIO.reset(encoding: encoding) unless ansi
|
Reline::GeneralIO.reset(encoding: encoding) unless ansi
|
||||||
send(:core).config.instance_variable_set(:@test_mode, true)
|
core.config.instance_variable_set(:@test_mode, true)
|
||||||
send(:core).config.reset
|
core.config.reset
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_reset
|
def test_reset
|
||||||
|
@ -5,7 +5,7 @@ class Reline::ANSI::TestWithTerminfo < Reline::TestCase
|
|||||||
def setup
|
def setup
|
||||||
Reline.send(:test_mode, ansi: true)
|
Reline.send(:test_mode, ansi: true)
|
||||||
@config = Reline::Config.new
|
@config = Reline::Config.new
|
||||||
Reline::IOGate.set_default_key_bindings(@config, allow_terminfo: true)
|
Reline.core.io_gate.set_default_key_bindings(@config, allow_terminfo: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
|
@ -5,7 +5,7 @@ class Reline::ANSI::TestWithoutTerminfo < Reline::TestCase
|
|||||||
def setup
|
def setup
|
||||||
Reline.send(:test_mode, ansi: true)
|
Reline.send(:test_mode, ansi: true)
|
||||||
@config = Reline::Config.new
|
@config = Reline::Config.new
|
||||||
Reline::IOGate.set_default_key_bindings(@config, allow_terminfo: false)
|
Reline.core.io_gate.set_default_key_bindings(@config, allow_terminfo: false)
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
|
@ -85,7 +85,7 @@ class Reline::Config::Test < Reline::TestCase
|
|||||||
|
|
||||||
def test_encoding_is_ascii
|
def test_encoding_is_ascii
|
||||||
@config.reset
|
@config.reset
|
||||||
Reline::IOGate.reset(encoding: Encoding::US_ASCII)
|
Reline.core.io_gate.reset(encoding: Encoding::US_ASCII)
|
||||||
@config = Reline::Config.new
|
@config = Reline::Config.new
|
||||||
|
|
||||||
assert_equal true, @config.convert_meta
|
assert_equal true, @config.convert_meta
|
||||||
@ -93,7 +93,7 @@ class Reline::Config::Test < Reline::TestCase
|
|||||||
|
|
||||||
def test_encoding_is_not_ascii
|
def test_encoding_is_not_ascii
|
||||||
@config.reset
|
@config.reset
|
||||||
Reline::IOGate.reset(encoding: Encoding::UTF_8)
|
Reline.core.io_gate.reset(encoding: Encoding::UTF_8)
|
||||||
@config = Reline::Config.new
|
@config = Reline::Config.new
|
||||||
|
|
||||||
assert_equal nil, @config.convert_meta
|
assert_equal nil, @config.convert_meta
|
||||||
|
@ -297,7 +297,7 @@ class Reline::History::Test < Reline::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_default_internal_encoding
|
def get_default_internal_encoding
|
||||||
if encoding = Reline::IOGate.encoding
|
if encoding = Reline.core.encoding
|
||||||
encoding
|
encoding
|
||||||
elsif RUBY_PLATFORM =~ /mswin|mingw/
|
elsif RUBY_PLATFORM =~ /mswin|mingw/
|
||||||
Encoding.default_internal || Encoding::UTF_8
|
Encoding.default_internal || Encoding::UTF_8
|
||||||
|
@ -8,7 +8,7 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
|||||||
@config.autocompletion = false
|
@config.autocompletion = false
|
||||||
Reline::HISTORY.instance_variable_set(:@config, @config)
|
Reline::HISTORY.instance_variable_set(:@config, @config)
|
||||||
Reline::HISTORY.clear
|
Reline::HISTORY.clear
|
||||||
@encoding = Reline::IOGate.encoding
|
@encoding = Reline.core.encoding
|
||||||
@line_editor = Reline::LineEditor.new(@config, @encoding)
|
@line_editor = Reline::LineEditor.new(@config, @encoding)
|
||||||
@line_editor.reset(@prompt, encoding: @encoding)
|
@line_editor.reset(@prompt, encoding: @encoding)
|
||||||
end
|
end
|
||||||
@ -2167,7 +2167,7 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
|||||||
|
|
||||||
# Unicode emoji test
|
# Unicode emoji test
|
||||||
def test_ed_insert_for_include_zwj_emoji
|
def test_ed_insert_for_include_zwj_emoji
|
||||||
omit "This test is for UTF-8 but the locale is #{Reline::IOGate.encoding}" if Reline::IOGate.encoding != Encoding::UTF_8
|
omit "This test is for UTF-8 but the locale is #{Reline.core.encoding}" if Reline.core.encoding != Encoding::UTF_8
|
||||||
# U+1F468 U+200D U+1F469 U+200D U+1F467 U+200D U+1F466 is family: man, woman, girl, boy "👨👩👧👦"
|
# U+1F468 U+200D U+1F469 U+200D U+1F467 U+200D U+1F466 is family: man, woman, girl, boy "👨👩👧👦"
|
||||||
input_keys("\u{1F468}") # U+1F468 is man "👨"
|
input_keys("\u{1F468}") # U+1F468 is man "👨"
|
||||||
assert_line("\u{1F468}")
|
assert_line("\u{1F468}")
|
||||||
@ -2213,7 +2213,7 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_ed_insert_for_include_valiation_selector
|
def test_ed_insert_for_include_valiation_selector
|
||||||
omit "This test is for UTF-8 but the locale is #{Reline::IOGate.encoding}" if Reline::IOGate.encoding != Encoding::UTF_8
|
omit "This test is for UTF-8 but the locale is #{Reline.core.encoding}" if Reline.core.encoding != Encoding::UTF_8
|
||||||
# U+0030 U+FE00 is DIGIT ZERO + VARIATION SELECTOR-1 "0︀"
|
# U+0030 U+FE00 is DIGIT ZERO + VARIATION SELECTOR-1 "0︀"
|
||||||
input_keys("\u0030") # U+0030 is DIGIT ZERO
|
input_keys("\u0030") # U+0030 is DIGIT ZERO
|
||||||
assert_line("\u0030")
|
assert_line("\u0030")
|
||||||
|
@ -8,7 +8,7 @@ class Reline::KeyActor::ViInsert::Test < Reline::TestCase
|
|||||||
@config.read_lines(<<~LINES.split(/(?<=\n)/))
|
@config.read_lines(<<~LINES.split(/(?<=\n)/))
|
||||||
set editing-mode vi
|
set editing-mode vi
|
||||||
LINES
|
LINES
|
||||||
@encoding = Reline::IOGate.encoding
|
@encoding = Reline.core.encoding
|
||||||
@line_editor = Reline::LineEditor.new(@config, @encoding)
|
@line_editor = Reline::LineEditor.new(@config, @encoding)
|
||||||
@line_editor.reset(@prompt, encoding: @encoding)
|
@line_editor.reset(@prompt, encoding: @encoding)
|
||||||
end
|
end
|
||||||
|
@ -4,7 +4,7 @@ class Reline::MacroTest < Reline::TestCase
|
|||||||
def setup
|
def setup
|
||||||
Reline.send(:test_mode)
|
Reline.send(:test_mode)
|
||||||
@config = Reline::Config.new
|
@config = Reline::Config.new
|
||||||
@encoding = Reline::IOGate.encoding
|
@encoding = Reline.core.encoding
|
||||||
@line_editor = Reline::LineEditor.new(@config, @encoding)
|
@line_editor = Reline::LineEditor.new(@config, @encoding)
|
||||||
@line_editor.instance_variable_set(:@screen_size, [24, 80])
|
@line_editor.instance_variable_set(:@screen_size, [24, 80])
|
||||||
@output = @line_editor.output = File.open(IO::NULL, "w")
|
@output = @line_editor.output = File.open(IO::NULL, "w")
|
||||||
|
@ -285,7 +285,7 @@ class Reline::Test < Reline::TestCase
|
|||||||
input, to_write = IO.pipe
|
input, to_write = IO.pipe
|
||||||
to_read, output = IO.pipe
|
to_read, output = IO.pipe
|
||||||
unless Reline.__send__(:input=, input)
|
unless Reline.__send__(:input=, input)
|
||||||
omit "Setting to input is not effective on #{Reline::IOGate}"
|
omit "Setting to input is not effective on #{Reline.core.io_gate}"
|
||||||
end
|
end
|
||||||
Reline.output = output
|
Reline.output = output
|
||||||
|
|
||||||
@ -303,12 +303,12 @@ class Reline::Test < Reline::TestCase
|
|||||||
|
|
||||||
def test_vi_editing_mode
|
def test_vi_editing_mode
|
||||||
Reline.vi_editing_mode
|
Reline.vi_editing_mode
|
||||||
assert_equal(Reline::KeyActor::ViInsert, Reline.send(:core).config.editing_mode.class)
|
assert_equal(Reline::KeyActor::ViInsert, Reline.core.config.editing_mode.class)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_emacs_editing_mode
|
def test_emacs_editing_mode
|
||||||
Reline.emacs_editing_mode
|
Reline.emacs_editing_mode
|
||||||
assert_equal(Reline::KeyActor::Emacs, Reline.send(:core).config.editing_mode.class)
|
assert_equal(Reline::KeyActor::Emacs, Reline.core.config.editing_mode.class)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_add_dialog_proc
|
def test_add_dialog_proc
|
||||||
@ -374,12 +374,12 @@ class Reline::Test < Reline::TestCase
|
|||||||
|
|
||||||
def test_dumb_terminal
|
def test_dumb_terminal
|
||||||
lib = File.expand_path("../../lib", __dir__)
|
lib = File.expand_path("../../lib", __dir__)
|
||||||
out = IO.popen([{"TERM"=>"dumb"}, Reline.test_rubybin, "-I#{lib}", "-rreline", "-e", "p Reline::IOGate"], &:read)
|
out = IO.popen([{"TERM"=>"dumb"}, Reline.test_rubybin, "-I#{lib}", "-rreline", "-e", "p Reline.core.io_gate"], &:read)
|
||||||
assert_equal("Reline::GeneralIO", out.chomp)
|
assert_equal("Reline::GeneralIO", out.chomp)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_reline_encoding
|
def get_reline_encoding
|
||||||
if encoding = Reline::IOGate.encoding
|
if encoding = Reline.core.encoding
|
||||||
encoding
|
encoding
|
||||||
elsif RUBY_PLATFORM =~ /mswin|mingw/
|
elsif RUBY_PLATFORM =~ /mswin|mingw/
|
||||||
Encoding::UTF_8
|
Encoding::UTF_8
|
||||||
|
@ -6,7 +6,7 @@ class Reline::LineEditor::StringProcessingTest < Reline::TestCase
|
|||||||
@prompt = '> '
|
@prompt = '> '
|
||||||
@config = Reline::Config.new
|
@config = Reline::Config.new
|
||||||
Reline::HISTORY.instance_variable_set(:@config, @config)
|
Reline::HISTORY.instance_variable_set(:@config, @config)
|
||||||
@encoding = Reline::IOGate.encoding
|
@encoding = Reline.core.encoding
|
||||||
@line_editor = Reline::LineEditor.new(@config, @encoding)
|
@line_editor = Reline::LineEditor.new(@config, @encoding)
|
||||||
@line_editor.reset(@prompt, encoding: @encoding)
|
@line_editor.reset(@prompt, encoding: @encoding)
|
||||||
end
|
end
|
||||||
|
@ -3,14 +3,14 @@ require_relative 'helper'
|
|||||||
class Reline::WithinPipeTest < Reline::TestCase
|
class Reline::WithinPipeTest < Reline::TestCase
|
||||||
def setup
|
def setup
|
||||||
Reline.send(:test_mode)
|
Reline.send(:test_mode)
|
||||||
@encoding = Reline::IOGate.encoding
|
@encoding = Reline.core.encoding
|
||||||
@input_reader, @writer = IO.pipe(@encoding)
|
@input_reader, @writer = IO.pipe(@encoding)
|
||||||
Reline.input = @input_reader
|
Reline.input = @input_reader
|
||||||
@reader, @output_writer = IO.pipe(@encoding)
|
@reader, @output_writer = IO.pipe(@encoding)
|
||||||
@output = Reline.output = @output_writer
|
@output = Reline.output = @output_writer
|
||||||
@config = Reline.send(:core).config
|
@config = Reline.core.config
|
||||||
@config.keyseq_timeout *= 600 if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # for --jit-wait CI
|
@config.keyseq_timeout *= 600 if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # for --jit-wait CI
|
||||||
@line_editor = Reline.send(:core).line_editor
|
@line_editor = Reline.core.line_editor
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
|
@ -490,7 +490,7 @@ begin
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_enable_bracketed_paste
|
def test_enable_bracketed_paste
|
||||||
omit if Reline::IOGate.win?
|
omit if Reline.core.io_gate.win?
|
||||||
write_inputrc <<~LINES
|
write_inputrc <<~LINES
|
||||||
set enable-bracketed-paste on
|
set enable-bracketed-paste on
|
||||||
LINES
|
LINES
|
||||||
@ -877,7 +877,7 @@ begin
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_with_newline
|
def test_with_newline
|
||||||
omit if Reline::IOGate.win?
|
omit if Reline.core.io_gate.win?
|
||||||
cmd = %Q{ruby -e 'print(%Q{abc def \\e\\r})' | ruby -I#{@pwd}/lib -rreline -e 'p Reline.readline(%{> })'}
|
cmd = %Q{ruby -e 'print(%Q{abc def \\e\\r})' | ruby -I#{@pwd}/lib -rreline -e 'p Reline.readline(%{> })'}
|
||||||
start_terminal(40, 50, ['bash', '-c', cmd])
|
start_terminal(40, 50, ['bash', '-c', cmd])
|
||||||
sleep 1
|
sleep 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user