[ruby/reline] Rerender and enter raw mode again by SIGCONT

(https://github.com/ruby/reline/pull/727)

https://github.com/ruby/reline/commit/be45660c83
This commit is contained in:
tomoya ishida 2024-06-25 09:55:02 +09:00 коммит произвёл git
Родитель ae0c7faa79
Коммит 691d85d342
2 изменённых файлов: 27 добавлений и 0 удалений

Просмотреть файл

@ -347,6 +347,13 @@ class Reline::ANSI < Reline::IO
def set_winch_handler(&handler)
@old_winch_handler = Signal.trap('WINCH', &handler)
@old_cont_handler = Signal.trap('CONT') do
@input.raw!(intr: true) if @input.tty?
# Rerender the screen. Note that screen size might be changed while suspended.
handler.call
end
rescue ArgumentError
# Signal.trap may raise an ArgumentError if the platform doesn't support the signal.
end
def prep
@ -360,5 +367,6 @@ class Reline::ANSI < Reline::IO
# Disable bracketed paste
@output.write "\e[?2004l" if Reline.core.config.enable_bracketed_paste && both_tty?
Signal.trap('WINCH', @old_winch_handler) if @old_winch_handler
Signal.trap('CONT', @old_cont_handler) if @old_cont_handler
end
end

Просмотреть файл

@ -1840,6 +1840,25 @@ begin
EOC
end
def test_stop_continue
pidfile = Tempfile.create('pidfile')
rubyfile = Tempfile.create('rubyfile')
rubyfile.write <<~RUBY
File.write(#{pidfile.path.inspect}, Process.pid)
p Reline.readmultiline('>'){false}
RUBY
rubyfile.close
start_terminal(40, 50, ['bash'])
write "ruby -I#{@pwd}/lib -rreline #{rubyfile.path}\n"
write "abc\ndef\nhi"
pid = pidfile.tap(&:rewind).read.to_i
Process.kill(:STOP, pid) unless pid.zero?
write "fg\n"
write "\ebg"
close
assert_include result.join("\n"), ">abc\n>def\n>ghi\n"
end
def write_inputrc(content)
File.open(@inputrc_file, 'w') do |f|
f.write content