summaryrefslogtreecommitdiff
path: root/lib/reline/general_io.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/reline/general_io.rb')
-rw-r--r--lib/reline/general_io.rb35
1 files changed, 22 insertions, 13 deletions
diff --git a/lib/reline/general_io.rb b/lib/reline/general_io.rb
index 2f87d718c6..0ac1c6c56d 100644
--- a/lib/reline/general_io.rb
+++ b/lib/reline/general_io.rb
@@ -1,9 +1,15 @@
-require 'timeout'
+require 'io/wait'
class Reline::GeneralIO
+ RESET_COLOR = '' # Do not send color reset sequence
+
def self.reset(encoding: nil)
@@pasting = false
- @@encoding = encoding
+ if encoding
+ @@encoding = encoding
+ elsif defined?(@@encoding)
+ remove_class_variable(:@@encoding)
+ end
end
def self.encoding
@@ -24,18 +30,23 @@ class Reline::GeneralIO
end
@@buf = []
+ @@input = STDIN
def self.input=(val)
@@input = val
end
- def self.getc
+ def self.with_raw_input
+ yield
+ end
+
+ def self.getc(_timeout_second)
unless @@buf.empty?
return @@buf.shift
end
c = nil
loop do
- result = select([@@input], [], [], 0.1)
+ result = @@input.wait_readable(0.1)
next if result.nil?
c = @@input.read(1)
break
@@ -48,13 +59,19 @@ class Reline::GeneralIO
end
def self.get_screen_size
- [1, 1]
+ [24, 80]
end
def self.cursor_pos
Reline::CursorPos.new(1, 1)
end
+ def self.hide_cursor
+ end
+
+ def self.show_cursor
+ end
+
def self.move_cursor_column(val)
end
@@ -85,14 +102,6 @@ class Reline::GeneralIO
@@pasting
end
- def self.start_pasting
- @@pasting = true
- end
-
- def self.finish_pasting
- @@pasting = false
- end
-
def self.prep
end