mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/reline] Support dumb terminal
The "dumb" terminal is considered only on MSys tty now. However, the `TERM` feature has been used on many Unix-like systems for decades, not MSys specific. https://github.com/ruby/reline/commit/53fd51ab62
This commit is contained in:
parent
f229b36087
commit
59e8569cf9
2 changed files with 20 additions and 17 deletions
|
@ -601,24 +601,21 @@ module Reline
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'reline/general_io'
|
require 'reline/general_io'
|
||||||
if RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
io = Reline::GeneralIO
|
||||||
require 'reline/windows'
|
unless ENV['TERM'] == 'dumb'
|
||||||
if Reline::Windows.msys_tty?
|
case RbConfig::CONFIG['host_os']
|
||||||
Reline::IOGate = if ENV['TERM'] == 'dumb'
|
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
||||||
Reline::GeneralIO
|
require 'reline/windows'
|
||||||
else
|
tty = (io = Reline::Windows).msys_tty?
|
||||||
require 'reline/ansi'
|
|
||||||
Reline::ANSI
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
Reline::IOGate = Reline::Windows
|
tty = $stdout.tty?
|
||||||
end
|
|
||||||
else
|
|
||||||
Reline::IOGate = if $stdout.isatty
|
|
||||||
require 'reline/ansi'
|
|
||||||
Reline::ANSI
|
|
||||||
else
|
|
||||||
Reline::GeneralIO
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reline::IOGate = if tty
|
||||||
|
require 'reline/ansi'
|
||||||
|
Reline::ANSI
|
||||||
|
else
|
||||||
|
io
|
||||||
|
end
|
||||||
|
|
||||||
Reline::HISTORY = Reline::History.new(Reline.core.config)
|
Reline::HISTORY = Reline::History.new(Reline.core.config)
|
||||||
|
|
|
@ -397,6 +397,12 @@ class Reline::Test < Reline::TestCase
|
||||||
# TODO in Reline::Core
|
# TODO in Reline::Core
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_dumb_terminal
|
||||||
|
lib = File.expand_path("../../lib", __dir__)
|
||||||
|
out = IO.popen([{"TERM"=>"dumb"}, "ruby", "-I#{lib}", "-rreline", "-e", "p Reline::IOGate"], &:read)
|
||||||
|
assert_equal("Reline::GeneralIO", out.chomp)
|
||||||
|
end
|
||||||
|
|
||||||
def get_reline_encoding
|
def get_reline_encoding
|
||||||
if encoding = Reline::IOGate.encoding
|
if encoding = Reline::IOGate.encoding
|
||||||
encoding
|
encoding
|
||||||
|
|
Loading…
Reference in a new issue