mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parent
85a337f986
commit
7fd6077d98
1 changed files with 16 additions and 7 deletions
|
@ -120,20 +120,29 @@ class Reline::ANSI
|
||||||
def self.prep
|
def self.prep
|
||||||
retrieve_keybuffer
|
retrieve_keybuffer
|
||||||
int_handle = Signal.trap('INT', 'IGNORE')
|
int_handle = Signal.trap('INT', 'IGNORE')
|
||||||
otio = `stty -g`.chomp
|
begin
|
||||||
setting = ' -echo -icrnl cbreak -ixoff -iexten'
|
otio = IO.popen(%w[stty -g], in: @@input, &:read).chomp
|
||||||
stty = `stty -a`
|
rescue ArgumentError
|
||||||
|
else
|
||||||
|
setting = %w'-echo -icrnl cbreak -ixoff -iexten'
|
||||||
|
stty = IO.popen(%w[stty -a], in: @@input, &:read)
|
||||||
if /-parenb\b/ =~ stty
|
if /-parenb\b/ =~ stty
|
||||||
setting << 'pass8'
|
setting << 'pass8'
|
||||||
end
|
end
|
||||||
`stty #{setting}`
|
system("stty", *setting, in: @@input)
|
||||||
|
end
|
||||||
Signal.trap('INT', int_handle)
|
Signal.trap('INT', int_handle)
|
||||||
otio
|
otio
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.deprep(otio)
|
def self.deprep(otio)
|
||||||
int_handle = Signal.trap('INT', 'IGNORE')
|
int_handle = Signal.trap('INT', 'IGNORE')
|
||||||
system("stty #{otio}", err: File::NULL)
|
if otio
|
||||||
|
begin
|
||||||
|
system("stty #{otio}", in: @@input, err: File::NULL)
|
||||||
|
rescue ArgumentError
|
||||||
|
end
|
||||||
|
end
|
||||||
Signal.trap('INT', int_handle)
|
Signal.trap('INT', int_handle)
|
||||||
Signal.trap('WINCH', @@old_winch_handler) if @@old_winch_handler
|
Signal.trap('WINCH', @@old_winch_handler) if @@old_winch_handler
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue