[前][次][番号順一覧][スレッド一覧]

ruby-changes:67643

From: aycabta <ko1@a...>
Date: Tue, 7 Sep 2021 01:59:20 +0900 (JST)
Subject: [ruby-changes:67643] e8ad881336 (master): [ruby/reline] Trap TSTP to handle C-z

https://git.ruby-lang.org/ruby.git/commit/?id=e8ad881336

From e8ad881336974d1719359d7545b6b9a0efe0dc79 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Tue, 7 Sep 2021 01:44:21 +0900
Subject: [ruby/reline] Trap TSTP to handle C-z

https://github.com/ruby/reline/commit/ebbd0076b8
---
 lib/reline/line_editor.rb | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index 8a23cc0..a2ad758 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -170,6 +170,10 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L170
         @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 https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L215
 
   def finalize
     Signal.trap('SIGINT', @old_trap)
+    Signal.trap('SIGTSTP', @old_tstp_trap)
   end
 
   def eof?
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]