aboutsummaryrefslogtreecommitdiffstats
path: root/lib/reline/io.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/reline/io.rb')
-rw-r--r--lib/reline/io.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/reline/io.rb b/lib/reline/io.rb
new file mode 100644
index 0000000000..7fca0c338a
--- /dev/null
+++ b/lib/reline/io.rb
@@ -0,0 +1,45 @@
+
+module Reline
+ class IO
+ RESET_COLOR = "\e[0m"
+
+ def self.decide_io_gate
+ if ENV['TERM'] == 'dumb'
+ Reline::Dumb.new
+ else
+ require 'reline/io/ansi'
+
+ case RbConfig::CONFIG['host_os']
+ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
+ require 'reline/io/windows'
+ io = Reline::Windows.new
+ if io.msys_tty?
+ Reline::ANSI.new
+ else
+ io
+ end
+ else
+ if $stdout.tty?
+ Reline::ANSI.new
+ else
+ Reline::Dumb.new
+ end
+ end
+ end
+ end
+
+ def dumb?
+ false
+ end
+
+ def win?
+ false
+ end
+
+ def reset_color_sequence
+ self.class::RESET_COLOR
+ end
+ end
+end
+
+require 'reline/io/dumb'