summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2021-09-07 01:44:21 +0900
committergit <svn-admin@ruby-lang.org>2021-09-07 01:59:05 +0900
commite8ad881336974d1719359d7545b6b9a0efe0dc79 (patch)
treedb0c88967c8b61170be4fc00f15e3737b837ef35
parent966ed206a626ef19a5e4deaf77a6ee2a28453026 (diff)
[ruby/reline] Trap TSTP to handle C-z
https://github.com/ruby/reline/commit/ebbd0076b8
-rw-r--r--lib/reline/line_editor.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index 8a23cc0dac..a2ad758081 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -170,6 +170,10 @@ class Reline::LineEditor
@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
@@ -211,6 +215,7 @@ class Reline::LineEditor
def finalize
Signal.trap('SIGINT', @old_trap)
+ Signal.trap('SIGTSTP', @old_tstp_trap)
end
def eof?