2021-12-11 08:18:15 +03:00
|
|
|
require 'io/wait'
|
2019-05-12 18:22:27 +03:00
|
|
|
|
|
|
|
class Reline::GeneralIO
|
2024-05-29 01:54:39 +03:00
|
|
|
RESET_COLOR = '' # Do not send color reset sequence
|
|
|
|
|
2021-04-20 06:00:08 +03:00
|
|
|
def self.reset(encoding: nil)
|
2020-11-08 15:56:27 +03:00
|
|
|
@@pasting = false
|
2023-09-28 16:53:25 +03:00
|
|
|
if encoding
|
|
|
|
@@encoding = encoding
|
|
|
|
elsif defined?(@@encoding)
|
|
|
|
remove_class_variable(:@@encoding)
|
|
|
|
end
|
2020-11-08 15:56:27 +03:00
|
|
|
end
|
|
|
|
|
2020-01-12 16:24:17 +03:00
|
|
|
def self.encoding
|
2021-05-14 00:42:00 +03:00
|
|
|
if defined?(@@encoding)
|
2021-04-20 06:00:08 +03:00
|
|
|
@@encoding
|
|
|
|
elsif RUBY_PLATFORM =~ /mswin|mingw/
|
|
|
|
Encoding::UTF_8
|
|
|
|
else
|
|
|
|
Encoding::default_external
|
|
|
|
end
|
2020-01-12 16:24:17 +03:00
|
|
|
end
|
|
|
|
|
2020-01-31 20:59:46 +03:00
|
|
|
def self.win?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2021-04-05 10:03:53 +03:00
|
|
|
def self.set_default_key_bindings(_)
|
|
|
|
end
|
2019-05-31 18:34:38 +03:00
|
|
|
|
2019-05-12 18:22:27 +03:00
|
|
|
@@buf = []
|
2021-09-01 10:19:31 +03:00
|
|
|
@@input = STDIN
|
2019-05-12 18:22:27 +03:00
|
|
|
|
|
|
|
def self.input=(val)
|
|
|
|
@@input = val
|
|
|
|
end
|
|
|
|
|
2023-02-27 11:43:51 +03:00
|
|
|
def self.with_raw_input
|
|
|
|
yield
|
|
|
|
end
|
|
|
|
|
2023-08-20 13:40:42 +03:00
|
|
|
def self.getc(_timeout_second)
|
2019-05-24 17:38:40 +03:00
|
|
|
unless @@buf.empty?
|
|
|
|
return @@buf.shift
|
|
|
|
end
|
2019-05-12 18:22:27 +03:00
|
|
|
c = nil
|
|
|
|
loop do
|
2024-05-29 01:54:39 +03:00
|
|
|
Reline.core.line_editor.handle_signal
|
2021-12-11 08:18:15 +03:00
|
|
|
result = @@input.wait_readable(0.1)
|
2019-05-12 18:22:27 +03:00
|
|
|
next if result.nil?
|
|
|
|
c = @@input.read(1)
|
|
|
|
break
|
|
|
|
end
|
|
|
|
c&.ord
|
|
|
|
end
|
|
|
|
|
2019-05-24 17:38:40 +03:00
|
|
|
def self.ungetc(c)
|
|
|
|
@@buf.unshift(c)
|
|
|
|
end
|
|
|
|
|
2019-05-12 18:22:27 +03:00
|
|
|
def self.get_screen_size
|
2024-05-29 01:54:39 +03:00
|
|
|
[24, 80]
|
2019-05-12 18:22:27 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.cursor_pos
|
|
|
|
Reline::CursorPos.new(1, 1)
|
|
|
|
end
|
|
|
|
|
2022-09-02 08:25:51 +03:00
|
|
|
def self.hide_cursor
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.show_cursor
|
|
|
|
end
|
|
|
|
|
2019-05-12 18:22:27 +03:00
|
|
|
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 09:21:00 +03:00
|
|
|
def self.set_winch_handler(&handler)
|
|
|
|
end
|
|
|
|
|
2020-11-08 15:56:27 +03:00
|
|
|
@@pasting = false
|
|
|
|
|
2020-10-20 02:39:12 +03:00
|
|
|
def self.in_pasting?
|
2020-11-08 15:56:27 +03:00
|
|
|
@@pasting
|
|
|
|
end
|
|
|
|
|
2019-05-12 18:22:27 +03:00
|
|
|
def self.prep
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.deprep(otio)
|
|
|
|
end
|
|
|
|
end
|