Skip to content

Commit

Permalink
Trap TSTP to handle C-z
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Sep 6, 2021
1 parent 1d7b603 commit ebbd007
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/reline/line_editor.rb
Expand Up @@ -170,6 +170,10 @@ def reset(prompt = '', encoding:)
@old_trap.call
end
}
@old_tstp_trap = Signal.trap(:TSTP) {
Reline::IOGate.ungetc("\C-z".ord)
@old_tstp_trap.call if @old_tstp_trap.respond_to?(:call)
}
Reline::IOGate.set_winch_handler do
@rest_height = (Reline::IOGate.get_screen_size.first - 1) - Reline::IOGate.cursor_pos.y
old_screen_size = @screen_size
Expand Down Expand Up @@ -211,6 +215,7 @@ def reset(prompt = '', encoding:)

def finalize
Signal.trap('SIGINT', @old_trap)
Signal.trap('SIGTSTP', @old_tstp_trap)
end

def eof?
Expand Down

0 comments on commit ebbd007

Please sign in to comment.