2019-05-12 11:22:27 -04:00
|
|
|
require 'timeout'
|
2021-12-11 00:18:15 -05:00
|
|
|
require 'io/wait'
|
2019-05-12 11:22:27 -04:00
|
|
|
|
|
|
|
class Reline::GeneralIO
|
2021-04-19 23:00:08 -04:00
|
|
|
def self.reset(encoding: nil)
|
2020-11-08 07:56:27 -05:00
|
|
|
@@pasting = false
|
2021-04-19 23:00:08 -04:00
|
|
|
@@encoding = encoding
|
2020-11-08 07:56:27 -05:00
|
|
|
end
|
|
|
|
|
2020-01-12 08:24:17 -05:00
|
|
|
def self.encoding
|
2021-05-13 17:42:00 -04:00
|
|
|
if defined?(@@encoding)
|
2021-04-19 23:00:08 -04:00
|
|
|
@@encoding
|
|
|
|
elsif RUBY_PLATFORM =~ /mswin|mingw/
|
|
|
|
Encoding::UTF_8
|
|
|
|
else
|
|
|
|
Encoding::default_external
|
|
|
|
end
|
2020-01-12 08:24:17 -05:00
|
|
|
end
|
|
|
|
|
2020-01-31 12:59:46 -05:00
|
|
|
def self.win?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2021-04-05 03:03:53 -04:00
|
|
|
def self.set_default_key_bindings(_)
|
|
|
|
end
|
2019-05-31 11:34:38 -04:00
|
|
|
|
2019-05-12 11:22:27 -04:00
|
|
|
@@buf = []
|
2021-09-01 03:19:31 -04:00
|
|
|
@@input = STDIN
|
2019-05-12 11:22:27 -04:00
|
|
|
|
|
|
|
def self.input=(val)
|
|
|
|
@@input = val
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.getc
|
2019-05-24 10:38:40 -04:00
|
|
|
unless @@buf.empty?
|
|
|
|
return @@buf.shift
|
|
|
|
end
|
2019-05-12 11:22:27 -04:00
|
|
|
c = nil
|
|
|
|
loop do
|
2021-12-11 00:18:15 -05:00
|
|
|
result = @@input.wait_readable(0.1)
|
2019-05-12 11:22:27 -04:00
|
|
|
next if result.nil?
|
|
|
|
c = @@input.read(1)
|
|
|
|
break
|
|
|
|
end
|
|
|
|
c&.ord
|
|
|
|
end
|
|
|
|
|
2019-05-24 10:38:40 -04:00
|
|
|
def self.ungetc(c)
|
|
|
|
@@buf.unshift(c)
|
|
|
|
end
|
|
|
|
|
2019-05-12 11:22:27 -04:00
|
|
|
def self.get_screen_size
|
|
|
|
[1, 1]
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.cursor_pos
|
|
|
|
Reline::CursorPos.new(1, 1)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.move_cursor_column(val)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.move_cursor_up(val)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.move_cursor_down(val)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.erase_after_cursor
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.scroll_down(val)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.clear_screen
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.set_screen_size(rows, columns)
|
|
|
|
end
|
|
|
|
|
2019-08-29 02:21:00 -04:00
|
|
|
def self.set_winch_handler(&handler)
|
|
|
|
end
|
|
|
|
|
2020-11-08 07:56:27 -05:00
|
|
|
@@pasting = false
|
|
|
|
|
2020-10-19 19:39:12 -04:00
|
|
|
def self.in_pasting?
|
2020-11-08 07:56:27 -05:00
|
|
|
@@pasting
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.start_pasting
|
|
|
|
@@pasting = true
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.finish_pasting
|
|
|
|
@@pasting = false
|
2020-10-19 19:39:12 -04:00
|
|
|
end
|
|
|
|
|
2019-05-12 11:22:27 -04:00
|
|
|
def self.prep
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.deprep(otio)
|
|
|
|
end
|
|
|
|
end
|