mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/reline] Simplify SIGWINCH handler to avoid aborting when resizing.
481add0537
This commit is contained in:
parent
2a3d0fbe17
commit
ef350b3a56
2 changed files with 44 additions and 37 deletions
|
@ -126,8 +126,8 @@ class Reline::ANSI
|
|||
unless @@buf.empty?
|
||||
return @@buf.shift
|
||||
end
|
||||
until c = @@input.raw(intr: true, &:getbyte)
|
||||
sleep 0.1
|
||||
until c = @@input.raw(intr: true) { select([@@input], [], [], 0.1) && @@input.getbyte }
|
||||
Reline.core.line_editor.resize
|
||||
end
|
||||
(c == 0x16 && @@input.raw(min: 0, tim: 0, &:getbyte)) || c
|
||||
rescue Errno::EIO
|
||||
|
|
|
@ -178,6 +178,14 @@ class Reline::LineEditor
|
|||
rescue ArgumentError
|
||||
end
|
||||
Reline::IOGate.set_winch_handler do
|
||||
@resized = true
|
||||
end
|
||||
@block_elem_width = Reline::Unicode.calculate_width('█')
|
||||
end
|
||||
|
||||
def resize
|
||||
return unless @resized
|
||||
@resized = false
|
||||
@rest_height = (Reline::IOGate.get_screen_size.first - 1) - Reline::IOGate.cursor_pos.y
|
||||
old_screen_size = @screen_size
|
||||
@screen_size = Reline::IOGate.get_screen_size
|
||||
|
@ -214,8 +222,6 @@ class Reline::LineEditor
|
|||
@rerender_all = true
|
||||
end
|
||||
end
|
||||
@block_elem_width = Reline::Unicode.calculate_width('█')
|
||||
end
|
||||
|
||||
def finalize
|
||||
Signal.trap('INT', @old_trap)
|
||||
|
@ -264,6 +270,7 @@ class Reline::LineEditor
|
|||
@auto_indent_proc = nil
|
||||
@dialogs = []
|
||||
@last_key = nil
|
||||
@resized = false
|
||||
reset_line
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue