mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Support SIGWINCH
This commit is contained in:
parent
682aaf6af5
commit
0f405541bf
2 changed files with 10 additions and 0 deletions
|
@ -106,6 +106,11 @@ class Reline::ANSI
|
|||
print "\e[1;1H"
|
||||
end
|
||||
|
||||
@@old_winch_handler = nil
|
||||
def self.set_winch_handler(&handler)
|
||||
@@old_winch_handler = Signal.trap('WINCH', &handler)
|
||||
end
|
||||
|
||||
def self.prep
|
||||
int_handle = Signal.trap('INT', 'IGNORE')
|
||||
otio = `stty -g`.chomp
|
||||
|
@ -123,5 +128,6 @@ class Reline::ANSI
|
|||
int_handle = Signal.trap('INT', 'IGNORE')
|
||||
`stty #{otio}`
|
||||
Signal.trap('INT', int_handle)
|
||||
Signal.trap('WINCH', @@old_winch_handler) if @@old_winch_handler
|
||||
end
|
||||
end
|
||||
|
|
|
@ -69,6 +69,10 @@ class Reline::LineEditor
|
|||
Reline::IOGate.move_cursor_column(0)
|
||||
@old_trap.call if @old_trap.respond_to?(:call) # can also be string, ex: "DEFAULT"
|
||||
}
|
||||
Reline::IOGate.set_winch_handler do
|
||||
@rest_height = (Reline::IOGate.get_screen_size.first - 1) - Reline::IOGate.cursor_pos.y
|
||||
@screen_size = Reline::IOGate.get_screen_size
|
||||
end
|
||||
end
|
||||
|
||||
def finalize
|
||||
|
|
Loading…
Reference in a new issue