aboutsummaryrefslogtreecommitdiffstats
path: root/lib/reline/ansi.rb
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2019-05-13 00:22:27 +0900
committeraycabta <aycabta@gmail.com>2019-05-13 00:22:27 +0900
commit0f45bd0584f1550e153babc339ad7671e2424d20 (patch)
treeecabfd107eb49b00b3a2139762d4f44da958f354 /lib/reline/ansi.rb
parent11476e9902405b90b7493fed43f9fc2e6db9a32c (diff)
downloadruby-0f45bd0584f1550e153babc339ad7671e2424d20.tar.gz
Split namespace of env-dependent I/O classes
Diffstat (limited to 'lib/reline/ansi.rb')
-rw-r--r--lib/reline/ansi.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/reline/ansi.rb b/lib/reline/ansi.rb
index f34c4207e5..eb13c7f55b 100644
--- a/lib/reline/ansi.rb
+++ b/lib/reline/ansi.rb
@@ -1,13 +1,13 @@
-module Reline
- def getc
+class Reline::ANSI
+ def self.getc
c = nil
- until c
- return nil if @line_editor.finished?
+ loop do
result = select([$stdin], [], [], 0.1)
next if result.nil?
c = $stdin.read(1)
+ break
end
- c.ord
+ c&.ord
end
def self.get_screen_size
@@ -29,7 +29,7 @@ module Reline
end
end
m = res.match(/(?<row>\d+);(?<column>\d+)/)
- CursorPos.new(m[:column].to_i - 1, m[:row].to_i - 1)
+ Reline::CursorPos.new(m[:column].to_i - 1, m[:row].to_i - 1)
end
def self.move_cursor_column(x)
@@ -66,7 +66,7 @@ module Reline
print "\e[1;1H"
end
- def prep
+ def self.prep
int_handle = Signal.trap('INT', 'IGNORE')
otio = `stty -g`.chomp
setting = ' -echo -icrnl cbreak'
@@ -79,7 +79,7 @@ module Reline
otio
end
- def deprep(otio)
+ def self.deprep(otio)
int_handle = Signal.trap('INT', 'IGNORE')
`stty #{otio}`
Signal.trap('INT', int_handle)